com.tensegrity.generic.persistence
Class XMLWriter

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

Deprecated. use XMLStreamWriter instead.

public class XMLWriter
extends java.lang.Object
implements Writer

Writes an AttributeList to a XML-file, which can contain AttributeLists, AttributeSets and Attributes. Additionally Constraints may be assigned to all these types, which will be stored in the document, too.

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 must be parseable by the 
  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 during 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 during 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: XMLWriter.java,v 1.25 2006/01/26 17:08:03 MichaelKegel Exp $
Author:
MichaelKegel, BurkhardWick

Constructor Summary
XMLWriter(java.io.OutputStream outStream)
          Deprecated. use XMLStreamWriter instead.
XMLWriter(java.io.OutputStream outStream, boolean omitXMLHeader)
          Deprecated. use XMLStreamWriter instead.
 
Method Summary
protected  boolean isAttribute(Attribute attribute)
          Deprecated. Checks whether the given Attribute is not of type AttributeSet and not of type AttributeList.
protected  boolean isAttributeList(Attribute attribute)
          Deprecated. Checks whether the given Attribute is an instance of class AttributeList.
protected  boolean isAttributeSet(Attribute attribute)
          Deprecated. Checks whether the given Attribute is of type AttributeSet.
protected  boolean isComment(Attribute attribute)
          Deprecated. Checks if the given Attribute contains a comment.
 void setOutput(java.io.OutputStream outStream)
          Deprecated. Sets the OutputStream to be used for this instance.
protected  void storeConstraint(Constraint constraint, org.w3c.dom.Element element, org.w3c.dom.Document doc)
          Deprecated. Stores the given constraint as a child of element element in the document.
protected  void storeToAttributes(org.w3c.dom.Element element, java.lang.Object object)
          Deprecated. Stores the attributes (classname, ...) of the object as attributes of the given Element.
protected  boolean storeToDocument(AttributeCollection collection, org.w3c.dom.Element element, org.w3c.dom.Document document)
          Deprecated. Stores the give collection under the node given by element.
protected  java.lang.String stripPackageName(java.lang.String className)
          Deprecated. Returns the given String without the possibly extant package-extension.
 void write(AttributeList attributeList)
          Deprecated. 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

XMLWriter

public XMLWriter(java.io.OutputStream outStream)
Deprecated. use XMLStreamWriter instead.

Creates a new XMLWriter based on the given OutputStream.

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

XMLWriter

public XMLWriter(java.io.OutputStream outStream,
                 boolean omitXMLHeader)
Deprecated. use XMLStreamWriter instead.

Creates a new XMLWriter 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

setOutput

public void setOutput(java.io.OutputStream outStream)
Deprecated. 
Sets the OutputStream to be used for this instance.

Parameters:
outStream - the OutputStream that method write() will use.

write

public void write(AttributeList attributeList)
           throws WriteException
Deprecated. 
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

storeToDocument

protected boolean storeToDocument(AttributeCollection collection,
                                  org.w3c.dom.Element element,
                                  org.w3c.dom.Document document)
Deprecated. 
Stores the give collection under the node given by element. It differentiates between AttributeSets, AttributeLists, single Attributes and comments.

Parameters:
collection - the collection to store.
element - the node under which the collection is to be stored.
document - the document to which the element belongs.
Returns:
true, if storing was successful

storeConstraint

protected void storeConstraint(Constraint constraint,
                               org.w3c.dom.Element element,
                               org.w3c.dom.Document doc)
Deprecated. 
Stores the given constraint as a child of element element in the document.

Parameters:
constraint - the attribute-constraint to be stored.
element - the "father"-element to which the constraint will belong.
doc - document holding the given element.

isAttributeSet

protected boolean isAttributeSet(Attribute attribute)
Deprecated. 
Checks whether the given Attribute is of type AttributeSet.

Parameters:
attribute - the Attribute to check.
Returns:
true, if the given Attribute is of type AttributeSet

isAttributeList

protected boolean isAttributeList(Attribute attribute)
Deprecated. 
Checks whether the given Attribute is an instance of class AttributeList.

Parameters:
attribute - the Attribute to check.
Returns:
true, if the given Attribute is of type AttributeList.

isAttribute

protected boolean isAttribute(Attribute attribute)
Deprecated. 
Checks whether the given Attribute is not of type AttributeSet and not of type AttributeList.

Parameters:
attribute - the Attribute to check.
Returns:
true, if the given Attribute is not of type AttributeSet and not of type AttributeList.

isComment

protected boolean isComment(Attribute attribute)
Deprecated. 
Checks if the given Attribute contains a comment.

Parameters:
attribute - the Attribute to check.
Returns:
boolean true, if the Attribute contains a comment.

stripPackageName

protected java.lang.String stripPackageName(java.lang.String className)
Deprecated. 
Returns the given String without the possibly extant package-extension.

Example:

 stripPackageName("com.tensegrity.generic.persistence.XMLWriter") 
 returns "XMLWriter"
 

Parameters:
className - the classname to be shortened.
Returns:
the classname without the package extension.

storeToAttributes

protected void storeToAttributes(org.w3c.dom.Element element,
                                 java.lang.Object object)
Deprecated. 
Stores the attributes (classname, ...) of the object as attributes of the given Element.

Parameters:
element - the element that will store the object-attributes.
object - the object to store the attributes for.


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