com.tensegrity.generic.persistence
Class XMLStreamReader

java.lang.Object
  extended bycom.tensegrity.generic.persistence.XMLStreamReader
All Implemented Interfaces:
Reader

public class XMLStreamReader
extends java.lang.Object
implements Reader

Class XMLStreamReader loads an XML file, parses its contents and creates a runtime AttributeList instance containing Attribute or AttributeSet objects or both. Constraint objects may be assigned to all these objects in the list.

The following seven basic types are explicitly converted by class XMLStreamReader.

  1. String
  2. Double
  3. Float
  4. Integer
  5. Long
  6. Boolean
  7. Color
If a type is encountered that is not within this list, an Attribute with a value of type String is created.

Structure of XML-file:

 
- LIST:

  <list name=NAME>
      (LIST | SET | ATTRIBUTE)*
      (constraint)+
  </list>
 
      NAME: Name of list (in a set this has to be unique)

  
- SET:

  <set name=NAME>
      (SET | ATTRIBUTE)*
  </set>
 
       NAME: String name of this set (in a set this has to be unique)

  
- ATTRIBUTE:

  <attribute name=NAME type=TYPE value=VALUE>
      (CONSTRAINT)+
  </attribute>
 
       NAME: String name of this attribute (in a set this has to be unique)
       TYPE: Full classname of the value of this attribute
      VALUE: Initial value of the instance of this valueobject 
 
 
- CONSTRAINT:

  <constraint>
      <![cdata[(EXPR)]]>
  </constraint>
 
  (Instead of the cdata-Part a text node is allowed, too:
   <constraint>value==0</constraint>
   But concerning the special characters (">", ...) it should not be used.)


- EXPR:

  String expression that can be parsed by a ConstraintParser.
 

Structure of AttributeList:

 
- LIST:

  AttributeList, containing attributes of following types:
      (LIST-ATTRIBUTE | SET-ATTRIBUTE | ATTRIBUTE)*
      May contain a valid constraint of any type.

  
- LIST-ATTRIBUTE:

  Attribute with name and value. In a set the name has to be unique.
  The name will be stored as name of the list. 
  The value is of type AttributeList.
  Must not contain a Constraint, as this is ignored when writing to XML.
  Instead the Constraint should be assigned to the AttributeList directly.
  The list itself may contain the following attributes:
  (LIST-ATTRIBUTE | SET-ATTRIBUTE | ATTRIBUTE)*

  
- SET-ATTRIBUTE:

  Attribute with name and value. In a set the name has to be unique.
  The name will be stored as name of the set. 
  The value is of type AttributeSet.
  Must not contain a Constraint, as this is ignored when writing to XML.
  Instead the Constraint should be assigned to the AttributeSet directly.
  The set itself may contain the following attributes:
  (SET-ATTRIBUTE | ATTRIBUTE)*

  
- ATTRIBUTE:

  Any Attribute with a name and value. In a set the name has to be unique.
  The value may be of any type that can be recreated/stored by 
  parseToObject() (or storeToString() of XMLWriter).
 
 

Version:
$Id: XMLStreamReader.java,v 1.18 2005/11/14 16:53:47 KevinCVS Exp $
Author:
MichaelKegel, BurkhardWick, Stepan Rutz

Constructor Summary
XMLStreamReader(java.io.InputStream inStream)
          Constructor specifying the InputStream to use.
 
Method Summary
 AttributeList read()
          This method reads the information available in the data source and returns them in form of an AttributeList.
 void setInput(java.io.InputStream inStream)
          Sets the input stream for a second use for this class instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStreamReader

public XMLStreamReader(java.io.InputStream inStream)
Constructor specifying the InputStream to use.

Parameters:
inStream - the InputStream to use.
Method Detail

setInput

public void setInput(java.io.InputStream inStream)
Sets the input stream for a second use for this class instance.

Parameters:
inStream - the InputStream that method read() will use.

read

public AttributeList read()
                   throws ReadException
Description copied from interface: Reader
This method reads the information available in the data source and returns them in form of an AttributeList.

Specified by:
read in interface Reader
Returns:
AttributeList with the read information.
Throws:
ReadException - is thrown whenever an error occurs while reading the information
See Also:
Reader.read()


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.