Framework Professional Edition Package


com.prosyst.util.xml
Class TagClass

java.lang.Object
  extended by com.prosyst.util.xml.TagClass

public class TagClass
extends java.lang.Object

Class corresponding to one XML tag, containing its tag name, attributes, content string and tree of the sub tags.

Author:
Ivan Dimitrov

Field Summary
protected  boolean fInline
           
 
Constructor Summary
TagClass()
          Creates an empty tag node
TagClass(int line, java.lang.String name)
          Creates tag node with specified name
TagClass(int line, java.lang.String name, java.lang.String contentStr)
          Creates tag node with specified name and content string
TagClass(java.lang.String name)
          Creates tag node with specified name
TagClass(java.lang.String name, java.lang.String contentStr)
          Creates tag node with specified name and content string
 
Method Summary
 void addTag(TagClass aTag)
          Adds a child tag to this one
protected  void appendContent(com.prosyst.util.string.CharBuffer toAppend)
          Appends the 'toAppend' CharBuffer content to the content buffer
protected  void appendContent(java.lang.String toAppend)
          Appends the 'toAppend' string to the content buffer
 java.lang.String getAttribute(java.lang.String attrName)
          Returns an attribute value for an attribute with a given name (attrName)
 java.lang.String getAttributes()
          Returns string with all attribute names and values of the tag, as is in the XML content.
 java.lang.String getContent()
          Returns content string of the tag
 java.lang.String getContent(int aPos, java.lang.String aName)
          Returns the content of a child tag with index position equals to aPos but only if its name is equal to aName.
protected  com.prosyst.util.string.CharBuffer getContentBuffer()
          Returns the internal content buffer
 int getLine()
          Returns the line in the XML file where the tags begin.
 java.lang.String getName()
          Returns name of the tag
 TagClass getTagAt(int aPos)
          Returns sub tag of this one at a given position
protected  void setInline()
           
protected  void setLine(int aLine)
          Sets the tag line number (the line in the XML file where the current tag starts)
protected  void setName(java.lang.String aName)
          Sets the name of the tag
 int size()
          Returns children tags count
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fInline

protected boolean fInline
Constructor Detail

TagClass

public TagClass()
Creates an empty tag node


TagClass

public TagClass(java.lang.String name)
Creates tag node with specified name

Parameters:
name - tag name

TagClass

public TagClass(int line,
                java.lang.String name)
Creates tag node with specified name

Parameters:
line - the line in the XML file where the tags begin.
name - tag name

TagClass

public TagClass(java.lang.String name,
                java.lang.String contentStr)
Creates tag node with specified name and content string

Parameters:
name - tag name
contentStr - content string of the tag

TagClass

public TagClass(int line,
                java.lang.String name,
                java.lang.String contentStr)
Creates tag node with specified name and content string

Parameters:
line - the line in the XML file where the tags begin.
name - tag name
contentStr - content string of the tag
Method Detail

appendContent

protected void appendContent(com.prosyst.util.string.CharBuffer toAppend)
Appends the 'toAppend' CharBuffer content to the content buffer

Parameters:
toAppend - CharBuffer content to append

appendContent

protected void appendContent(java.lang.String toAppend)
Appends the 'toAppend' string to the content buffer

Parameters:
toAppend - string to append

getContent

public java.lang.String getContent()
Returns content string of the tag

Returns:
tag content note: The content that is to be returned will be trimmed first

getContent

public java.lang.String getContent(int aPos,
                                   java.lang.String aName)
Returns the content of a child tag with index position equals to aPos but only if its name is equal to aName. Otherwise the method throws an exception

Parameters:
aPos - index of the tag in its parent list
aName - the name of the tag
Returns:
tag content
Throws:
java.lang.NullPointerException - if there is no tag on the given position
java.lang.IllegalArgumentException - if the name of the tag on the given position does not match the requested name

getContentBuffer

protected com.prosyst.util.string.CharBuffer getContentBuffer()
Returns the internal content buffer

Returns:
internal content buffer as CharBuffer

getName

public java.lang.String getName()
Returns name of the tag

Returns:
tag name

setName

protected void setName(java.lang.String aName)
Sets the name of the tag

Parameters:
aName - name of the tag

getAttributes

public java.lang.String getAttributes()
Returns string with all attribute names and values of the tag, as is in the XML content.

Returns:
tag name and its attributes

getAttribute

public java.lang.String getAttribute(java.lang.String attrName)
Returns an attribute value for an attribute with a given name (attrName)

Parameters:
attrName - the name of attribute
Returns:
Attribute value for attribute with name given by attrName or null if there is no such an attribute
Throws:
java.lang.NullPointerException - if attrName is null

addTag

public void addTag(TagClass aTag)
Adds a child tag to this one

Parameters:
aTag - a tag to be added as a child tag

getTagAt

public TagClass getTagAt(int aPos)
Returns sub tag of this one at a given position

Parameters:
aPos - position of the searched tag
Returns:
a child tag at a given position in the child-tags set or null if there is no such a tag

size

public int size()
Returns children tags count

Returns:
sub tags count

getLine

public int getLine()
Returns the line in the XML file where the tags begin.

Returns:
Returns the line.

setLine

protected void setLine(int aLine)
Sets the tag line number (the line in the XML file where the current tag starts)

Parameters:
aLine - current tag line number

setInline

protected void setInline()

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved