public class XMLElement
extends java.lang.Object
implements java.io.Serializable
Note that NanoXML is not 100% XML 1.0 compliant:
<!ENTITY...>.
You can opt to use a SAX compatible API, by including both nanoxml.jar
and nanoxml-sax.jar in your classpath and setting the property
org.xml.sax.parser to nanoxml.sax.SAXParser
$Revision: 1.3 $
$Date: 2005/11/19 09:15:30 $
XMLParseException,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
NANOXML_MAJOR_VERSION
Major version of NanoXML.
|
static int |
NANOXML_MINOR_VERSION
Minor version of NanoXML.
|
| Modifier | Constructor and Description |
|---|---|
|
XMLElement()
Creates a new XML element.
|
|
XMLElement(boolean skipLeadingWhitespace)
Creates a new XML element.
|
|
XMLElement(java.util.Properties conversionTable)
Creates a new XML element.
|
|
XMLElement(java.util.Properties conversionTable,
boolean skipLeadingWhitespace)
Creates a new XML element.
|
|
XMLElement(java.util.Properties conversionTable,
boolean skipLeadingWhitespace,
boolean ignoreCase)
Creates a new XML element.
|
protected |
XMLElement(java.util.Properties conversionTable,
boolean skipLeadingWhitespace,
boolean fillBasicConversionTable,
boolean ignoreCase)
Creates a new XML element.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(XMLElement child)
Adds a subobject.
|
void |
addProperty(java.lang.String key,
double value)
Adds a property.
|
void |
addProperty(java.lang.String key,
int value)
Adds a property.
|
void |
addProperty(java.lang.String key,
java.lang.Object value)
Adds a property.
|
int |
countChildren()
Returns the number of subobjects of the object.
|
protected XMLElement |
createAnotherElement()
Creates a new XML element.
|
protected java.lang.String |
decodeString(java.lang.String s,
int lineNr)
Converts &...; sequences to "normal" chars.
|
java.util.Enumeration |
enumerateChildren()
Enumerates the subobjects of the object.
|
java.util.Enumeration |
enumeratePropertyNames()
Enumerates the attribute names.
|
java.util.Vector |
getChildren()
Returns the subobjects of the object.
|
java.lang.String |
getContents()
Returns the #PCDATA content of the object.
|
int |
getIntProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
Returns a property by looking up a key in a hashtable.
|
int |
getLineNr()
Returns the line nr on which the element is found.
|
java.lang.String |
getProperty(java.lang.String key)
Returns a property of the object.
|
double |
getProperty(java.lang.String key,
double defaultValue)
Returns a floating point property of the object.
|
java.lang.Object |
getProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
Returns a property by looking up a key in the hashtable valueSet If
the property doesn't exist, the value corresponding to defaultValue
is returned.
|
int |
getProperty(java.lang.String key,
int defaultValue)
Returns an integer property of the object.
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
Returns a property of the object.
|
boolean |
getProperty(java.lang.String key,
java.lang.String trueValue,
java.lang.String falseValue,
boolean defaultValue)
Returns a boolean property of the object.
|
double |
getSpecialDoubleProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
Returns a property by looking up a key in the hashtable valueSet .
|
int |
getSpecialIntProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
Returns a property by looking up a key in the hashtable valueSet .
|
java.lang.String |
getStringProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
Returns a property by looking up a key in the hashtable valueSet .
|
java.lang.String |
getTagName()
Returns the class (i.e.
|
int |
parseCharArray(char[] input,
int offset,
int end)
Parses an XML definition starting at offset .
|
int |
parseCharArray(char[] input,
int offset,
int end,
int startingLineNr)
Parses an XML definition starting at offset .
|
void |
parseFromReader(java.io.Reader reader)
Reads an XML definition from a java.io.Reader and parses it.
|
void |
parseFromReader(java.io.Reader reader,
int startingLineNr)
Reads an XML definition from a java.io.Reader and parses it.
|
void |
parseString(java.lang.String string)
Parses an XML definition.
|
int |
parseString(java.lang.String string,
int offset)
Parses an XML definition starting at offset .
|
int |
parseString(java.lang.String string,
int offset,
int end)
Parses an XML definition starting at offset .
|
int |
parseString(java.lang.String string,
int offset,
int end,
int startingLineNr)
Parses an XML definition starting at offset .
|
void |
removeChild(java.lang.String key)
Removes an attribute.
|
void |
removeChild(XMLElement child)
Removes a child object.
|
protected void |
scanChildren(char[] input,
int contentOffset,
int contentSize,
int contentLineNr)
!!! Searches the content for child objects.
|
void |
setContent(java.lang.String content)
Changes the content string.
|
void |
setTagName(java.lang.String tagName)
Changes the tag name.
|
protected int |
skipBogusTag(char[] input,
int offset,
int end,
int[] lineNr)
Skips a tag that don't contain any useful data: <?...?>, <!...>
and comments.
|
java.lang.String |
toString()
Writes the XML element to a string.
|
void |
write(java.io.Writer writer)
Writes the XML element to a writer.
|
void |
write(java.io.Writer writer,
int indent)
Writes the XML element to a writer.
|
protected void |
writeEncoded(java.io.PrintWriter out,
java.lang.String str)
Writes a string encoded to a writer.
|
public static final int NANOXML_MAJOR_VERSION
public static final int NANOXML_MINOR_VERSION
public XMLElement()
& < >
' "falsetruepublic XMLElement(java.util.Properties conversionTable)
& < >
' "falsetrueconversionTable - Description of ParameterXMLElement(),
XMLElement(boolean),
XMLElement(java.util.Properties,boolean)public XMLElement(boolean skipLeadingWhitespace)
& < >
' "trueskipLeadingWhitespace - Description of ParameterXMLElement(),
XMLElement(java.util.Properties),
XMLElement(java.util.Properties,boolean)public XMLElement(java.util.Properties conversionTable,
boolean skipLeadingWhitespace)
& < >
' "trueconversionTable - Description of ParameterskipLeadingWhitespace - Description of ParameterXMLElement(),
XMLElement(boolean),
XMLElement(java.util.Properties)public XMLElement(java.util.Properties conversionTable,
boolean skipLeadingWhitespace,
boolean ignoreCase)
& < >
' " (depending on
fillBasicConversionTable )This constructor should only be called from XMLElement itself to create child elements.
conversionTable - Description of ParameterskipLeadingWhitespace - Description of ParameterignoreCase - Description of ParameterXMLElement(),
XMLElement(boolean),
XMLElement(java.util.Properties),
XMLElement(java.util.Properties,boolean)protected XMLElement(java.util.Properties conversionTable,
boolean skipLeadingWhitespace,
boolean fillBasicConversionTable,
boolean ignoreCase)
& < >
' " (depending on
fillBasicConversionTable )This constructor should only be called from XMLElement itself to create child elements.
conversionTable - Description of ParameterskipLeadingWhitespace - Description of ParameterfillBasicConversionTable - Description of ParameterignoreCase - Description of ParameterXMLElement(),
XMLElement(boolean),
XMLElement(java.util.Properties),
XMLElement(java.util.Properties,boolean)public void setContent(java.lang.String content)
content - The new content string.public void setTagName(java.lang.String tagName)
tagName - The new tag name.public java.util.Vector getChildren()
public java.lang.String getContents()
null is returned.public int getLineNr()
public int getIntProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
key - Description of ParametervalueSet - Description of ParameterdefaultValue - Description of Parameterpublic java.lang.String getProperty(java.lang.String key)
null.key - Description of Parameterpublic java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue)
key - Description of ParameterdefaultValue - Description of Parameterpublic int getProperty(java.lang.String key,
int defaultValue)
key - Description of ParameterdefaultValue - Description of Parameterpublic double getProperty(java.lang.String key,
double defaultValue)
key - Description of ParameterdefaultValue - Description of Parameterpublic boolean getProperty(java.lang.String key,
java.lang.String trueValue,
java.lang.String falseValue,
boolean defaultValue)
key - Description of ParametertrueValue - Description of ParameterfalseValue - Description of ParameterdefaultValue - Description of Parameterpublic java.lang.Object getProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
key - Description of ParametervalueSet - Description of ParameterdefaultValue - Description of Parameterpublic java.lang.String getStringProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
key - Description of ParametervalueSet - Description of ParameterdefaultValue - Description of Parameterpublic int getSpecialIntProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
key - Description of ParametervalueSet - Description of ParameterdefaultValue - Description of Parameterpublic double getSpecialDoubleProperty(java.lang.String key,
java.util.Hashtable valueSet,
java.lang.String defaultValue)
key - Description of ParametervalueSet - Description of ParameterdefaultValue - Description of Parameterpublic java.lang.String getTagName()
public void addChild(XMLElement child)
child - The feature to be added to the Child attributepublic void addProperty(java.lang.String key,
java.lang.Object value)
key - The feature to be added to the Property attributevalue - The feature to be added to the Property attributepublic void addProperty(java.lang.String key,
int value)
key - The feature to be added to the Property attributevalue - The feature to be added to the Property attributepublic void addProperty(java.lang.String key,
double value)
key - The feature to be added to the Property attributevalue - The feature to be added to the Property attributepublic int countChildren()
public java.util.Enumeration enumeratePropertyNames()
public java.util.Enumeration enumerateChildren()
public void parseFromReader(java.io.Reader reader)
throws java.io.IOException,
XMLParseException
reader - Description of Parameterjava.io.IOException - Description of ExceptionXMLParseException - Description of Exceptionpublic void parseFromReader(java.io.Reader reader,
int startingLineNr)
throws java.io.IOException,
XMLParseException
reader - Description of ParameterstartingLineNr - Description of Parameterjava.io.IOException - Description of ExceptionXMLParseException - Description of Exceptionpublic void parseString(java.lang.String string)
throws XMLParseException
string - Description of ParameterXMLParseException - Description of Exceptionpublic int parseString(java.lang.String string,
int offset)
throws XMLParseException
string - Description of Parameteroffset - Description of ParameterXMLParseException - Description of Exceptionpublic int parseString(java.lang.String string,
int offset,
int end)
throws XMLParseException
string - Description of Parameteroffset - Description of Parameterend - Description of ParameterXMLParseException - Description of Exceptionpublic int parseString(java.lang.String string,
int offset,
int end,
int startingLineNr)
throws XMLParseException
string - Description of Parameteroffset - Description of Parameterend - Description of ParameterstartingLineNr - Description of ParameterXMLParseException - Description of Exceptionpublic int parseCharArray(char[] input,
int offset,
int end)
throws XMLParseException
input - Description of Parameteroffset - Description of Parameterend - Description of ParameterXMLParseException - Description of Exceptionpublic int parseCharArray(char[] input,
int offset,
int end,
int startingLineNr)
throws XMLParseException
input - Description of Parameteroffset - Description of Parameterend - Description of ParameterstartingLineNr - Description of ParameterXMLParseException - Description of Exceptionpublic void removeChild(XMLElement child)
child - Description of Parameterpublic void removeChild(java.lang.String key)
key - Description of Parameterpublic java.lang.String toString()
toString in class java.lang.Objectpublic void write(java.io.Writer writer)
writer - Description of Parameterpublic void write(java.io.Writer writer,
int indent)
writer - Description of Parameterindent - Description of Parameterprotected void scanChildren(char[] input,
int contentOffset,
int contentSize,
int contentLineNr)
throws XMLParseException
null.input - Description of ParametercontentOffset - Description of ParametercontentSize - Description of ParametercontentLineNr - Description of ParameterXMLParseException - Description of ExceptionparseCharArray(char[], int, int, int[])protected XMLElement createAnotherElement()
protected int skipBogusTag(char[] input,
int offset,
int end,
int[] lineNr)
input - Description of Parameteroffset - Description of Parameterend - Description of ParameterlineNr - Description of Parameterprotected java.lang.String decodeString(java.lang.String s,
int lineNr)
s - Description of ParameterlineNr - Description of Parameterprotected void writeEncoded(java.io.PrintWriter out,
java.lang.String str)
out - Description of Parameterstr - Description of Parameter