net.xoetrope.data
Class XDataSource

java.lang.Object
  extended by net.xoetrope.data.XDataSource
Direct Known Subclasses:
XOptionalDataSource, XPojoDataSource

public class XDataSource
extends java.lang.Object

Loads a model from a reader

Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt $Revision: 2.11 $


Field Summary
protected  XProject currentProject
          The current XProject
 
Constructor Summary
XDataSource(XProject project)
          Create a new data source
 
Method Summary
 void loadTable(XmlElement source, XModel model)
          Recursively load the model data
 void outputModel(java.lang.String filename, XModel model)
          Iterate the XModels and outputs the Elements and their attributes.
static void outputModel(java.io.Writer w, XModel model)
          Iterates the XModels and outputs the Elements and their attributes.
static void outputModel(XmlElement parentEle, XModel model)
          Recursive method which builds up the XML Document based on the XModel.
 void read(java.io.Reader r)
          Read a model from the Reader
 void read(XmlElement ele)
          Read an file pointed to by an element in the XML description of the data sources
protected  void readDataSource(java.lang.String fileName, XmlElement source)
          Read the data source file.
static void setUseValueAsId(boolean state)
          Set the model to use the value as the ID for a node if the ID is not specified
 void write(java.io.Writer w)
          Outputs the datasource as XML
 void write(java.io.Writer w, XModel model)
          Outputs the datasource as XML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentProject

protected XProject currentProject
The current XProject

Constructor Detail

XDataSource

public XDataSource(XProject project)
Create a new data source

Parameters:
project - the owner project
Method Detail

read

public void read(java.io.Reader r)
Read a model from the Reader

Parameters:
r - the Reader

read

public void read(XmlElement ele)
Read an file pointed to by an element in the XML description of the data sources

Parameters:
ele - the individual data source description

readDataSource

protected void readDataSource(java.lang.String fileName,
                              XmlElement source)
Read the data source file.

Parameters:
fileName - the nam eof the file to open
source - the XML element describing the source

loadTable

public void loadTable(XmlElement source,
                      XModel model)
Recursively load the model data

Parameters:
source - the source element
model - the model for the source element

write

public void write(java.io.Writer w)
Outputs the datasource as XML

Parameters:
w - The Writer of the file.

write

public void write(java.io.Writer w,
                  XModel model)
Outputs the datasource as XML

Parameters:
model - the model node to write
w - The Writer of the file.

outputModel

public static void outputModel(java.io.Writer w,
                               XModel model)
Iterates the XModels and outputs the Elements and their attributes.

Parameters:
w - the output writer
model - the model to write

outputModel

public static void outputModel(XmlElement parentEle,
                               XModel model)
Recursive method which builds up the XML Document based on the XModel.

Parameters:
parentEle - the current parent element
model - the current model being processed

outputModel

public void outputModel(java.lang.String filename,
                        XModel model)
Iterate the XModels and outputs the Elements and their attributes.

Parameters:
filename - the file to write
model - the model to write

setUseValueAsId

public static void setUseValueAsId(boolean state)
Set the model to use the value as the ID for a node if the ID is not specified

Parameters:
state - true to use the value when an ID is not specified