com.simonstl.fragment
Class Element

java.lang.Object
  |
  +--com.simonstl.fragment.DocComponent
        |
        +--com.simonstl.fragment.Element

public class Element
extends DocComponent

The Element class stores information about elements (and perhaps someday attributes) in a format that supports namespaces, allows the preservation of prefix information, and supports matching on namespace URIs and localNames.

I may eventually add more support for attributes, and also for wildcard matching on nsURI and/or localName.

Version 0.11 fixed a bug in addComponent() that kept attribute rules from functioning.

Version 0.10 adds improved printing support.

Version 0.09 supports the cleanDuplicate() method to avoid shallow copying issues.

Version 0.08 allows Elements to store parent and child information for the recording phase.

Version 0.07 adds additional support for attributes through the attColl AttributeCollection, replacing the AttributesImpl I'd used before. It's more overhead, but it gives me much finer-grained control over attributes.

Version 0.06 extends DocComponent rather than trying to handle all cases itself.

Version 0.05 adds support for beforeInside and afterInside attributes, allowing rules to add content inside of the element they create.

Version 0.04 changed support for skipping, allowing for the chars element to operate when character output is desired. It also now calls the startChars() and endChars() methods of FragmentFilter to give these characters their own place in the stack. Finally, it now supports before and after content.

Version 0.03 added properties for content and attributes. It also added the eventElement() method, which allows Element objects to write out their own SAX events. This should make it easier to manage configuration in the future.

version 0.02 added the getKey() method, so that Elements could define their own keys. This should permit future versions to support more complex matching than just nsURI>localName. (Making that work will involve revisions to matchElement (String match) as well.)

Version:
0.09 4 July 2001
Author:
Simon St.Laurent

Fields inherited from class com.simonstl.fragment.DocComponent
after, before, content, localName, nsURI, parentElement, prefix, type
 
Constructor Summary
protected Element()
           
  Element(Element oldElement)
           
  Element(java.lang.String _nsURI, java.lang.String _localName)
           
  Element(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix)
           
  Element(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix, org.xml.sax.Attributes _atts)
           
  Element(java.lang.String _nsURI, java.lang.String _localName, java.lang.String _prefix, java.lang.String _content)
           
 
Method Summary
 void addAtt(Attribute newAtt)
           
 void addContent(DocComponent newComponent)
          Adds content to this component.
 DocComponent cleanDuplicate()
          Returns a clean copy of the component and its contents.
 void clearContent()
          Clears the content for this component.
 void eventComponent(FragmentFilter handler)
          Describes the content for this component as a series of SAX events.
 java.lang.String getAfterInside()
           
 org.xml.sax.Attributes getAtts()
           
 java.lang.String getBeforeInside()
           
 java.lang.String getContent()
          Returns the content for this component.
 java.lang.String getKey()
          Returns a key which can be used as a unique identifier for this component.
 boolean matchComponent(DocComponent compare)
           
 boolean matchComponent(java.lang.String match)
          Takes a string representing a component description and returns true or false to indicate whether or not it matches this component.
 void print()
          Prints a representation of the component to STDOUT
 void processComponentContent(FragmentRules rules)
          Supports processing of content, if any.
 void setAfterInside(java.lang.String newAfterInside)
           
 void setAtts(org.xml.sax.Attributes newAtts)
           
 void setBeforeInside(java.lang.String newBeforeInside)
           
 void setContent(java.lang.String _content)
          Sets the content for this component.
 java.lang.String toString()
          Returns a representation of the component as a String.
 
Methods inherited from class com.simonstl.fragment.DocComponent
getAfter, getBefore, getLocalName, getNsURI, getParentElement, getPrefix, getType, matchAll, matchComponent, matchElement, matchSingleton, setAfter, setBefore, setLocalName, setNsURI, setParentElement, setPrefix, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Element

public Element(java.lang.String _nsURI,
               java.lang.String _localName)

Element

public Element(java.lang.String _nsURI,
               java.lang.String _localName,
               java.lang.String _prefix)

Element

public Element(java.lang.String _nsURI,
               java.lang.String _localName,
               java.lang.String _prefix,
               org.xml.sax.Attributes _atts)

Element

public Element(java.lang.String _nsURI,
               java.lang.String _localName,
               java.lang.String _prefix,
               java.lang.String _content)

Element

protected Element()

Element

public Element(Element oldElement)
Method Detail

cleanDuplicate

public DocComponent cleanDuplicate()
Description copied from class: DocComponent
Returns a clean copy of the component and its contents.
Overrides:
cleanDuplicate in class DocComponent

matchComponent

public boolean matchComponent(DocComponent compare)

matchComponent

public boolean matchComponent(java.lang.String match)
Description copied from class: DocComponent
Takes a string representing a component description and returns true or false to indicate whether or not it matches this component.
Overrides:
matchComponent in class DocComponent

getKey

public java.lang.String getKey()
Description copied from class: DocComponent
Returns a key which can be used as a unique identifier for this component.
Overrides:
getKey in class DocComponent

setAtts

public void setAtts(org.xml.sax.Attributes newAtts)

addAtt

public void addAtt(Attribute newAtt)

getAtts

public org.xml.sax.Attributes getAtts()

setBeforeInside

public void setBeforeInside(java.lang.String newBeforeInside)

getBeforeInside

public java.lang.String getBeforeInside()

setAfterInside

public void setAfterInside(java.lang.String newAfterInside)

getAfterInside

public java.lang.String getAfterInside()

setContent

public void setContent(java.lang.String _content)
Sets the content for this component. Need to override DocComponent. Use only with simple types
Overrides:
setContent in class DocComponent

getContent

public java.lang.String getContent()
Returns the content for this component. Need to override DocComponent.
Overrides:
getContent in class DocComponent

clearContent

public void clearContent()
Clears the content for this component.
Overrides:
clearContent in class DocComponent

addContent

public void addContent(DocComponent newComponent)
Adds content to this component. Need to override DocComponent.
Overrides:
addContent in class DocComponent

eventComponent

public void eventComponent(FragmentFilter handler)
                    throws org.xml.sax.SAXException
Description copied from class: DocComponent
Describes the content for this component as a series of SAX events. Note that FragmentFilter supports some events (startChars and endChars) which are extensions to the existing SAX models and which serve to keep the stacks under control.
Overrides:
eventComponent in class DocComponent

processComponentContent

public void processComponentContent(FragmentRules rules)
Description copied from class: DocComponent
Supports processing of content, if any. By default, does nothing. (Element overrides, Attribute will.)
Overrides:
processComponentContent in class DocComponent

print

public void print()
Description copied from class: DocComponent
Prints a representation of the component to STDOUT
Overrides:
print in class DocComponent

toString

public java.lang.String toString()
Description copied from class: DocComponent
Returns a representation of the component as a String.
Overrides:
toString in class DocComponent