com.tensegrity.generic.persistence
Class XMLStreamWriter

java.lang.Object
  extended bycom.tensegrity.generic.persistence.XMLStreamWriter
All Implemented Interfaces:
Writer

public class XMLStreamWriter
extends java.lang.Object
implements Writer

Class XMLStreamWriter writes an AttributeList object to an XML file. This list may contain AttributeList, AttributeSet and Attributes instances. All Constraint objects that have been assigned to the objects will be stored in the XML file as well.

XML File Structure:

 
- 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: XMLStreamWriter.java,v 1.19 2006/01/26 17:08:03 MichaelKegel Exp $
Author:
MichaelKegel, BurkhardWick, Stepan Rutz

Constructor Summary
XMLStreamWriter(java.io.OutputStream outStream)
          Creates a new XMLStreamWriter based on the given OutputStream.
XMLStreamWriter(java.io.OutputStream outStream, boolean omitXMLHeader)
          Creates a new XMLStreamWriter based on the given OutputStream.
 
Method Summary
 void write(AttributeList attributeList)
          This method writes the information given by an AttributeList to a data storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStreamWriter

public XMLStreamWriter(java.io.OutputStream outStream)
Creates a new XMLStreamWriter based on the given OutputStream.

Parameters:
outStream - the OutputStream that should be used to write out the document.

XMLStreamWriter

public XMLStreamWriter(java.io.OutputStream outStream,
                       boolean omitXMLHeader)
Creates a new XMLStreamWriter based on the given OutputStream. The omitXMLHeader flag indicates whether to leave out the xml declaration header.

Parameters:
outStream - the OutputStream that should be used to write out the document.
omitXMLHeader - a switch to omit the xml header of the document.
Method Detail

write

public void write(AttributeList attributeList)
           throws WriteException
Description copied from interface: Writer
This method writes the information given by an AttributeList to a data storage.

Specified by:
write in interface Writer
Parameters:
attributeList - list holding the information to write.
Throws:
WriteException - is thrown whenever an error occurs while writing out the information stored in the AttributeList.
See Also:
AttributeList


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