com.tensegrity.generic.attribute
Class XMLVisitor

java.lang.Object
  extended bycom.tensegrity.generic.attribute.XMLVisitor
All Implemented Interfaces:
AttributeCollectionVisitor

public class XMLVisitor
extends java.lang.Object
implements AttributeCollectionVisitor

This class implements a visitor for AttributeSets. It traverses an AttributeSet and generates a xml representation that is written to a sepecified PrintStream.

Version:
$Id: XMLVisitor.java,v 1.19 2006/01/26 17:15:08 MichaelKegel Exp $
Author:
S. Rutz

Constructor Summary
XMLVisitor(java.io.PrintStream pout)
          Constructor specifying a PrintStream to write the xml- output to.
 
Method Summary
 boolean acceptFilter(Attribute attribute, int level, java.lang.String path)
          This method allows fine grained control of what subtrees in the hierarchy are visited by means of the return value of this method.
 void beginVisit()
          This method is invoked before the traversal of an AttributeCollection hierarchy actually begins.
 void endVisit()
          This method is invoked after an AtributeCollection traversal has ended.
 void enterAttribute(Attribute attribute, int level, java.lang.String path)
          This method is invoked during traversal of an AtributeCollection hierarchy each time an attribute is encountered and entered.
 void enterAttributeCollection(AttributeCollection set, int level, java.lang.String path)
          This method is invoked during traversal of an AtributeCollection hierarchy each time a nested AtributeCollection is encountered and entered.
 void leaveAttribute(Attribute attribute, int level, java.lang.String path)
          This method is invoked during traversal of an AtributeCollection hierarchy each time after an attribute was visited.
 void leaveAttributeCollection(AttributeCollection set, int level, java.lang.String path)
          This method is invoked during traversal of an AtributeCollection hierarchy each time after an AtributeCollection was visited.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLVisitor

public XMLVisitor(java.io.PrintStream pout)
Constructor specifying a PrintStream to write the xml- output to.

Parameters:
pout - the stream to write the xml-output to.
Method Detail

beginVisit

public void beginVisit()
Description copied from interface: AttributeCollectionVisitor
This method is invoked before the traversal of an AttributeCollection hierarchy actually begins. Initialization can be done here.

Specified by:
beginVisit in interface AttributeCollectionVisitor

endVisit

public void endVisit()
Description copied from interface: AttributeCollectionVisitor
This method is invoked after an AtributeCollection traversal has ended. Cleanup work can be done here.

Specified by:
endVisit in interface AttributeCollectionVisitor

enterAttribute

public void enterAttribute(Attribute attribute,
                           int level,
                           java.lang.String path)
Description copied from interface: AttributeCollectionVisitor
This method is invoked during traversal of an AtributeCollection hierarchy each time an attribute is encountered and entered. This method is invoked before nested AtributeCollection instances are visited.

Specified by:
enterAttribute in interface AttributeCollectionVisitor
Parameters:
attribute - the current Attribute of the traversal.
level - the nesting level of the traversal.
path - the current path of the traversal so far, excluding the current attribute. The full path to the current attribute thus is path + AttributeCollection.SEPARATOR + attribute.getName();

leaveAttribute

public void leaveAttribute(Attribute attribute,
                           int level,
                           java.lang.String path)
Description copied from interface: AttributeCollectionVisitor
This method is invoked during traversal of an AtributeCollection hierarchy each time after an attribute was visited. This method is invoked after a nested AtributeCollection has been visited.

Specified by:
leaveAttribute in interface AttributeCollectionVisitor
Parameters:
attribute - the current Attribute of the traversal
level - the nesting level of the traversal
path - the current path of the traversal so far, excluding the current attribute. The full path to the current attribute thus is path + AttributeCollection.SEPARATOR + attribute.getName();

enterAttributeCollection

public void enterAttributeCollection(AttributeCollection set,
                                     int level,
                                     java.lang.String path)
Description copied from interface: AttributeCollectionVisitor
This method is invoked during traversal of an AtributeCollection hierarchy each time a nested AtributeCollection is encountered and entered. This method is invoked before nested attributes are visited.

Specified by:
enterAttributeCollection in interface AttributeCollectionVisitor
Parameters:
set - the current AtributeCollection of the traversal.
level - the nesting level of the traversal.
path - the current path of the traversal so far.

leaveAttributeCollection

public void leaveAttributeCollection(AttributeCollection set,
                                     int level,
                                     java.lang.String path)
Description copied from interface: AttributeCollectionVisitor
This method is invoked during traversal of an AtributeCollection hierarchy each time after an AtributeCollection was visited. This method is invoked after nested attributes were visited.

Specified by:
leaveAttributeCollection in interface AttributeCollectionVisitor
Parameters:
set - the current AtributeCollection of the traversal.
level - the nesting level of the traversal.
path - the current path of the traversal so far.

acceptFilter

public boolean acceptFilter(Attribute attribute,
                            int level,
                            java.lang.String path)
Description copied from interface: AttributeCollectionVisitor
This method allows fine grained control of what subtrees in the hierarchy are visited by means of the return value of this method. If this method returns false for a particular Attribute then the Attribute and all potentially nested AtributeCollection objects are excluded from the traversal. If no filter should be used, then this method is implemented with just one statement returning true. Then the visiting process behaves like no filter is set at all. This method is a convenience method to limit and cutoff the search depending on a certain attribute's name or value, the nesting of the search so far or on the contents of the current access-path.

Specified by:
acceptFilter in interface AttributeCollectionVisitor
Parameters:
attribute - the current Attribute of the traversal
level - the nesting level of the traversal.
path - the current path of the traversal so far, excluding the current Attribute.
Returns:
false if to exclude this attribute and nested AtributeCollection objects from the traversal. true if the traversal shall continue as is. The full path to the current Attribute thus is path + AttributeCollection.SEPARATOR + attribute.getName();


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