S-PLUS Connect/Java v1.0

com.insightful.gdevice
Class XMLElement

java.lang.Object
  extended bycom.insightful.gdevice.XMLElement

public class XMLElement
extends Object

XMLElement is a representation of an XML object. The object is able to parse XML code.

Note that NanoXML is not 100% XML 1.0 compliant:

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

This class is part of NanoXML.
Copyright (C) 2000 Marc De Scheemaecker, All Rights Reserved.

Version:
1.5
See Also:
XMLParseException

Field Summary
static int NANOXML_MAJOR_VERSION
          Major version of NanoXML.
static int NANOXML_MINOR_VERSION
          Minor version of NanoXML.
 
Constructor Summary
XMLElement()
          Creates a new XML element.
XMLElement(boolean skipLeadingWhitespace)
          Creates a new XML element.
XMLElement(Properties conversionTable)
          Creates a new XML element.
XMLElement(Properties conversionTable, boolean skipLeadingWhitespace)
          Creates a new XML element.
 
Method Summary
 int countChildren()
          Returns the number of subobjects of the object.
 Enumeration enumerateChildren()
          Enumerates the subobjects of the object.
 Enumeration enumeratePropertyNames()
          Enumerates the attribute names.
 Vector getChildren()
          Returns the subobjects of the object.
 String getContents()
          Returns the #PCDATA content of the object.
 int getIntProperty(String key, Hashtable valueSet, 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.
 String getProperty(String key)
          Returns a property of the object.
 double getProperty(String key, double defaultValue)
          Returns a floating point property of the object.
 Object getProperty(String key, Hashtable valueSet, String defaultValue)
          Returns a property by looking up a key in the hashtable valueSet.
 int getProperty(String key, int defaultValue)
          Returns an integer property of the object.
 String getProperty(String key, String defaultValue)
          Returns a property of the object.
 boolean getProperty(String key, String trueValue, String falseValue, boolean defaultValue)
          Returns a boolean property of the object.
 double getSpecialDoubleProperty(String key, Hashtable valueSet, String defaultValue)
          Returns a property by looking up a key in the hashtable valueSet.
 int getSpecialIntProperty(String key, Hashtable valueSet, String defaultValue)
          Returns a property by looking up a key in the hashtable valueSet.
 String getStringProperty(String key, Hashtable valueSet, String defaultValue)
          Returns a property by looking up a key in the hashtable valueSet.
 String getTagName()
          Returns the class (i.e. the name indicated in the tag) of the object.
 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(Reader reader)
          Reads an XML definition from a java.io.Reader and parses it.
 void parseFromReader(Reader reader, int startingLineNr)
          Reads an XML definition from a java.io.Reader and parses it.
 void parseString(String string)
          Parses an XML definition.
 int parseString(String string, int offset)
          Parses an XML definition starting at offset.
 int parseString(String string, int offset, int end)
          Parses an XML definition starting at offset.
 int parseString(String string, int offset, int end, int startingLineNr)
          Parses an XML definition starting at offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NANOXML_MAJOR_VERSION

public static final int NANOXML_MAJOR_VERSION
Major version of NanoXML.

See Also:
Constant Field Values

NANOXML_MINOR_VERSION

public static final int NANOXML_MINOR_VERSION
Minor version of NanoXML.

See Also:
Constant Field Values
Constructor Detail

XMLElement

public XMLElement()
Creates a new XML element. The following settings are used:
Conversion table
Minimal XML conversions: & < > ' "
Skip whitespace in contents
false

See Also:
XMLElement(java.util.Properties), XMLElement(boolean), XMLElement(java.util.Properties,boolean)

XMLElement

public XMLElement(Properties conversionTable)
Creates a new XML element. The following settings are used:
Conversion table
conversionTable combined with the minimal XML conversions: & < > ' "
Skip whitespace in contents
false

See Also:
XMLElement(), XMLElement(boolean), XMLElement(java.util.Properties,boolean)

XMLElement

public XMLElement(boolean skipLeadingWhitespace)
Creates a new XML element. The following settings are used:
Conversion table
Minimal XML conversions: & < > ' "
Skip whitespace in contents
skipLeadingWhitespace

See Also:
XMLElement(), XMLElement(java.util.Properties), XMLElement(java.util.Properties,boolean)

XMLElement

public XMLElement(Properties conversionTable,
                  boolean skipLeadingWhitespace)
Creates a new XML element. The following settings are used:
Conversion table
conversionTable combined with the minimal XML conversions: & < > ' "
Skip whitespace in contents
skipLeadingWhitespace

See Also:
XMLElement(), XMLElement(boolean), XMLElement(java.util.Properties)
Method Detail

countChildren

public int countChildren()
Returns the number of subobjects of the object.


enumeratePropertyNames

public Enumeration enumeratePropertyNames()
Enumerates the attribute names.


enumerateChildren

public Enumeration enumerateChildren()
Enumerates the subobjects of the object.


getChildren

public Vector getChildren()
Returns the subobjects of the object.


getContents

public String getContents()
Returns the #PCDATA content of the object. If there is no such content, null is returned.


getLineNr

public int getLineNr()
Returns the line nr on which the element is found.


getIntProperty

public int getIntProperty(String key,
                          Hashtable valueSet,
                          String defaultValue)
Returns a property by looking up a key in a hashtable. The property has to be specified in capital letters. If the property doesn't exist, the value corresponding to defaultValue is returned.


getProperty

public String getProperty(String key)
Returns a property of the object. The property has to be specified in capital letters. If there is no such property, this method returns null.


getProperty

public String getProperty(String key,
                          String defaultValue)
Returns a property of the object. The property has to be specified in capital letters. If the property doesn't exist, defaultValue is returned.


getProperty

public int getProperty(String key,
                       int defaultValue)
Returns an integer property of the object. The property has to be specified in capital letters. If the property doesn't exist, defaultValue is returned.


getProperty

public double getProperty(String key,
                          double defaultValue)
Returns a floating point property of the object. The property has to be specified in capital letters. If the property doesn't exist, defaultValue is returned.


getProperty

public boolean getProperty(String key,
                           String trueValue,
                           String falseValue,
                           boolean defaultValue)
Returns a boolean property of the object. If the property is missing, defaultValue is returned.


getProperty

public Object getProperty(String key,
                          Hashtable valueSet,
                          String defaultValue)
Returns a property by looking up a key in the hashtable valueSet. The property has to be specified in capital letters. If the property doesn't exist, the value corresponding to defaultValue is returned.


getStringProperty

public String getStringProperty(String key,
                                Hashtable valueSet,
                                String defaultValue)
Returns a property by looking up a key in the hashtable valueSet. The property has to be specified in capital letters. If the property doesn't exist, the value corresponding to defaultValue is returned.


getSpecialIntProperty

public int getSpecialIntProperty(String key,
                                 Hashtable valueSet,
                                 String defaultValue)
Returns a property by looking up a key in the hashtable valueSet. The property has to be specified in capital letters. If the value is not defined in the hashtable, the value is considered to be an integer. If the property doesn't exist, the value corresponding to defaultValue is returned.


getSpecialDoubleProperty

public double getSpecialDoubleProperty(String key,
                                       Hashtable valueSet,
                                       String defaultValue)
Returns a property by looking up a key in the hashtable valueSet. The property has to be specified in capital letters. If the value is not defined in the hashtable, the value is considered to be a floating point number. If the property doesn't exist, the value corresponding to defaultValue is returned.


getTagName

public String getTagName()
Returns the class (i.e. the name indicated in the tag) of the object.


parseFromReader

public void parseFromReader(Reader reader)
                     throws IOException,
                            XMLParseException
Reads an XML definition from a java.io.Reader and parses it.

Throws:
IOException - if an error occured while reading the input
XMLParseException - if an error occured while parsing the read data

parseFromReader

public void parseFromReader(Reader reader,
                            int startingLineNr)
                     throws IOException,
                            XMLParseException
Reads an XML definition from a java.io.Reader and parses it.

Throws:
IOException - if an error occured while reading the input
XMLParseException - if an error occured while parsing the read data

parseString

public void parseString(String string)
                 throws XMLParseException
Parses an XML definition.

Throws:
XMLParseException - if an error occured while parsing the string

parseString

public int parseString(String string,
                       int offset)
                throws XMLParseException
Parses an XML definition starting at offset.

Returns:
the offset of the string following the XML data
Throws:
XMLParseException - if an error occured while parsing the string

parseString

public int parseString(String string,
                       int offset,
                       int end)
                throws XMLParseException
Parses an XML definition starting at offset.

Returns:
the offset of the string following the XML data (<= end)
Throws:
XMLParseException - if an error occured while parsing the string

parseString

public int parseString(String string,
                       int offset,
                       int end,
                       int startingLineNr)
                throws XMLParseException
Parses an XML definition starting at offset.

Returns:
the offset of the string following the XML data (<= end)
Throws:
XMLParseException - if an error occured while parsing the string

parseCharArray

public int parseCharArray(char[] input,
                          int offset,
                          int end)
                   throws XMLParseException
Parses an XML definition starting at offset.

Returns:
the offset of the array following the XML data (<= end)
Throws:
XMLParseException - if an error occured while parsing the array

parseCharArray

public int parseCharArray(char[] input,
                          int offset,
                          int end,
                          int startingLineNr)
                   throws XMLParseException
Parses an XML definition starting at offset.

Returns:
the offset of the array following the XML data (<= end)
Throws:
XMLParseException - if an error occured while parsing the array

S-PLUS Connect/Java v1.0

Copyright © 2000, 2002 Insightful Corporation
Warning: Classes not documented in the S-PLUS Programmer's Guide may change in future releases.