org.optimizationservices.oscommon.representationparser
Class OSgLReader

java.lang.Object
  extended by org.optimizationservices.oscommon.representationparser.OSgLReader
Direct Known Subclasses:
OSaLReader, OSbLReader, OSeLReader, OSfLReader, OSiLReader, OSoLReader, OSParameterReader, OSpLReader, OSqLReader, OSRegistryReader, OSRepositoryReader, OSrLReader, OSsLReader, OSuLReader

public class OSgLReader
extends java.lang.Object

The OSgLReader class is a general and generic reader class for all the other OSxL reader classes to extend, which mostly parse an OSxL instance into a DOM tree and provide a set of "get" methods that can be used to retrieve different pieces of information of the OSxL instance.

Since:
OS 1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin

Field Summary
 org.w3c.dom.Document m_document
          m_document holds the W3C DOM type document to create XML elements and attributes.
 
Constructor Summary
OSgLReader()
          Constructor.
OSgLReader(boolean validate)
          constructor
 
Method Summary
 org.w3c.dom.Document getDocument()
          get document
 org.w3c.dom.Element getRootElement()
           
 boolean isValidate()
           
static void main(java.lang.String[] argv)
          main for test purposes.
 boolean readFile(java.lang.String fileName)
          Read the xml file that contains the OSxL instance.
 boolean readString(java.lang.String osxlString)
          Read the xml string that contains the OSxL instance.
 void setDocument(org.w3c.dom.Document document)
          set document
 void setRootElement(org.w3c.dom.Element rootElement)
          Set root element
 void setValidate(boolean xsdValidate)
           
 boolean writeToFile(java.lang.String fileName)
          Write the xml file from the internally constructed DOM tree structure that contains the OSxL instance to a file.
 java.lang.String writeToSring()
          Write the xml file from the internally constructed DOM tree structure that contains the OSxL instance to a string to be returned.
 boolean writeToStandardOutput()
          Write the xml file from the internally constructed DOM tree structure that contains the OSxL instance to the standard output (e.g.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_document

public org.w3c.dom.Document m_document
m_document holds the W3C DOM type document to create XML elements and attributes. It is the parent of the root element, e.g. the <OSiL> element in OSiL. It is used to create all the nodes in the DOM tree.

Constructor Detail

OSgLReader

public OSgLReader()
Constructor.


OSgLReader

public OSgLReader(boolean validate)
constructor

Parameters:
validate - holds whether the OSgLReader should be validating against the schema or not.
Method Detail

setDocument

public void setDocument(org.w3c.dom.Document document)
set document

Parameters:
document - holds the W3C DOM type document to create XML elements and attributes. It is the parent of the root element, e.g. the <OSiL> element in OSiL. It is used to create all the nodes in the DOM tree.

getDocument

public org.w3c.dom.Document getDocument()
get document

Returns:
the document which holds the W3C DOM type document to create XML elements and attributes. It is the parent of the root element, e.g. the <OSiL> element in OSiL. It is used to create all the nodes in the DOM tree.

setRootElement

public void setRootElement(org.w3c.dom.Element rootElement)
Set root element

Parameters:
rootElement - holds the root element to be set.

getRootElement

public org.w3c.dom.Element getRootElement()
Returns:
the root element.

isValidate

public boolean isValidate()
Returns:
whether the parser should be validating against the schema or not.

setValidate

public void setValidate(boolean xsdValidate)
Parameters:
xsdValidate - holds whether the parser should be validating against the schema or not.

readFile

public boolean readFile(java.lang.String fileName)
Read the xml file that contains the OSxL instance.

Parameters:
fileName - holds the xml filename that contains the OSxL instance
Returns:
whether the file is read successfully without any error.

readString

public boolean readString(java.lang.String osxlString)
Read the xml string that contains the OSxL instance.

Parameters:
osxlString - holds the xml string that contains the OSxL instance
Returns:
whether the string is read successfully without any error.

writeToFile

public boolean writeToFile(java.lang.String fileName)
Write the xml file from the internally constructed DOM tree structure that contains the OSxL instance to a file.

Parameters:
fileName - holds the xml filename to write out the file to.
Returns:
whether the file is written successfully without any error.

writeToStandardOutput

public boolean writeToStandardOutput()
Write the xml file from the internally constructed DOM tree structure that contains the OSxL instance to the standard output (e.g. screen).

Returns:
whether the output is written successfully without any error.

writeToSring

public java.lang.String writeToSring()
Write the xml file from the internally constructed DOM tree structure that contains the OSxL instance to a string to be returned.

Returns:
a string that contains the OSxL optimization instance. If error is encountered in writing the string, null is returned.

main

public static void main(java.lang.String[] argv)
main for test purposes.

Parameters:
argv - command line arguments.