org.formaria.data
Class DataSource

java.lang.Object
  extended by org.formaria.data.DataSource
Direct Known Subclasses:
OptionalDataSource, PojoDataSource, PojoDataSourceEx

public class DataSource
extends java.lang.Object

Loads a model from a reader

Copyright (c) Formaria Ltd., 2008
License: see license.txt $Revision: 2.11 $


Field Summary
protected  Project currentProject
          The current Project
 
Constructor Summary
DataSource(Project project)
          Create a new data source
 
Method Summary
 void loadTable(XmlElement source, DataModel model)
          Recursively load the model data
 void outputModel(java.lang.String filename, DataModel model)
          Iterate the Models and outputs the Elements and their attributes.
static void outputModel(java.io.Writer w, DataModel model)
          Iterates the Models and outputs the Elements and their attributes.
static void outputModel(XmlElement parentEle, DataModel model)
          Recursive method which builds up the XML Document based on the DataModel.
 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, DataModel 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 Project currentProject
The current Project

Constructor Detail

DataSource

public DataSource(Project 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,
                      DataModel 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,
                  DataModel 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,
                               DataModel model)
Iterates the Models and outputs the Elements and their attributes.

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

outputModel

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

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

outputModel

public void outputModel(java.lang.String filename,
                        DataModel model)
Iterate the Models 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