Package helma.scripting.rhino.extensions
Class XmlObject
- java.lang.Object
-
- helma.scripting.rhino.extensions.XmlObject
-
public class XmlObject extends java.lang.Object
This class provides methods for converting HopObjects to XML and back.- See Also:
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.String url)
Retrieves an XML document from a given URL and transforms it into a HopObjectjava.lang.Object
get(java.lang.String url, java.lang.String conversionRules)
Retrieves an XML document from a given URL and transforms it into a HopObjectjava.lang.Object
getFromString(java.lang.String str)
Transforms a XML literal into a HopObjectjava.lang.Object
getFromString(java.lang.String str, java.lang.String conversionRules)
Transforms a XML literal into a HopObject according to the rules specified in the file defined by conversionRulesjava.lang.Object
read(java.lang.String file)
Reads an XML document from a file and creates a HopObject out of itjava.lang.Object
read(java.lang.String file, INode node)
Reads an XML document from a file and reads it into the HopObject argumentjava.lang.Object
readFromString(java.lang.String str)
Reads an XML document from an XML literal and creates a HopObject out of itjava.lang.Object
readFromString(java.lang.String str, INode node)
Reads an XML document from an XML literal and creates a HopObject out of itboolean
write(INode node, java.lang.String file)
Writes a HopObject to an XML fileboolean
write(INode node, java.lang.String file, boolean dbmode)
Writes a HopObject to an XML file, optionally using shallow/db modejava.lang.String
writeToString(INode node)
Transforms a HopObject to XML and returns the result as stringjava.lang.String
writeToString(INode node, boolean dbmode)
Transforms a HopObject to XML and returns the result as string, optionally using shallow/db mode
-
-
-
Constructor Detail
-
XmlObject
public XmlObject(RhinoCore core)
Creates a new XmlObject object.- Parameters:
core
- ...
-
-
Method Detail
-
write
public boolean write(INode node, java.lang.String file) throws java.io.IOException
Writes a HopObject to an XML file- Parameters:
node
- the HopObject to encodefile
- the file to write to- Returns:
- true
- Throws:
java.io.IOException
- if something went wrong along the way
-
write
public boolean write(INode node, java.lang.String file, boolean dbmode) throws java.io.IOException
Writes a HopObject to an XML file, optionally using shallow/db mode- Parameters:
node
- the HopObject to encodefile
- the file to write todbmode
- whether to write a shallow copy- Returns:
- true
- Throws:
java.io.IOException
- if something went wrong along the way
-
writeToString
public java.lang.String writeToString(INode node) throws java.io.IOException
Transforms a HopObject to XML and returns the result as string- Parameters:
node
- the HopObject to encode- Returns:
- the XML representing the HopObject
- Throws:
java.io.IOException
- if something went wrong along the way
-
writeToString
public java.lang.String writeToString(INode node, boolean dbmode) throws java.io.IOException
Transforms a HopObject to XML and returns the result as string, optionally using shallow/db mode- Parameters:
node
- the HopObject to encodedbmode
- whether to write a shallow copy- Returns:
- the XML representing the HopObject
- Throws:
java.io.IOException
- if something went wrong
-
read
public java.lang.Object read(java.lang.String file) throws java.lang.RuntimeException
Reads an XML document from a file and creates a HopObject out of it- Parameters:
file
- the file name- Returns:
- the HopObject
- Throws:
java.lang.RuntimeException
- ...
-
read
public java.lang.Object read(java.lang.String file, INode node) throws java.lang.RuntimeException
Reads an XML document from a file and reads it into the HopObject argument- Parameters:
file
- the file namenode
- the HopObject to use for conversion- Returns:
- the HopObject
- Throws:
java.lang.RuntimeException
-
readFromString
public java.lang.Object readFromString(java.lang.String str) throws java.lang.RuntimeException
Reads an XML document from an XML literal and creates a HopObject out of it- Parameters:
str
- the XML string- Returns:
- the HopObject
- Throws:
java.lang.RuntimeException
- ...
-
readFromString
public java.lang.Object readFromString(java.lang.String str, INode node) throws java.lang.RuntimeException
Reads an XML document from an XML literal and creates a HopObject out of it- Parameters:
str
- the XML stringnode
- the HopObject to use for conversion- Returns:
- ...
- Throws:
java.lang.RuntimeException
- ...
-
get
public java.lang.Object get(java.lang.String url)
Retrieves an XML document from a given URL and transforms it into a HopObject- Parameters:
url
- the URL containing the XML to be parsed- Returns:
- a HopObject obtained from parsing the XML
-
get
public java.lang.Object get(java.lang.String url, java.lang.String conversionRules)
Retrieves an XML document from a given URL and transforms it into a HopObject- Parameters:
url
- the URL containing the XML to be parsedconversionRules
- a file name pointing to the conversion rules- Returns:
- a HopObject obtained from parsing the XML
- See Also:
-
getFromString
public java.lang.Object getFromString(java.lang.String str)
Transforms a XML literal into a HopObject- Parameters:
str
- an XML literal- Returns:
- a HopObject obtained from parsing the XML
-
getFromString
public java.lang.Object getFromString(java.lang.String str, java.lang.String conversionRules)
Transforms a XML literal into a HopObject according to the rules specified in the file defined by conversionRules- Parameters:
str
- an XML literalconversionRules
- a file name pointing to the conversion rules- Returns:
- a HopObject obtained from parsing the XML
- See Also:
-
-