helma.scripting.rhino.extensions
Class XmlObject

java.lang.Object
  extended by 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:

Constructor Summary
XmlObject(RhinoCore core)
          Creates a new XmlObject object.
 
Method Summary
 java.lang.Object get(java.lang.String url)
          Retrieves an XML document from a given URL and transforms it into a HopObject
 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
 java.lang.Object getFromString(java.lang.String str)
          Transforms a XML literal into a HopObject
 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
 java.lang.Object read(java.lang.String file)
          Reads an XML document from a file and creates a HopObject out of it
 java.lang.Object read(java.lang.String file, INode node)
          Reads an XML document from a file and reads it into the HopObject argument
 java.lang.Object readFromString(java.lang.String str)
          Reads an XML document from an XML literal and creates a HopObject out of it
 java.lang.Object readFromString(java.lang.String str, INode node)
          Reads an XML document from an XML literal and creates a HopObject out of it
 boolean write(INode node, java.lang.String file)
          Writes a HopObject to an XML file
 boolean write(INode node, java.lang.String file, boolean dbmode)
          Writes a HopObject to an XML file, optionally using shallow/db mode
 java.lang.String writeToString(INode node)
          Transforms a HopObject to XML and returns the result as string
 java.lang.String writeToString(INode node, boolean dbmode)
          Transforms a HopObject to XML and returns the result as string, optionally using shallow/db mode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 encode
file - 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 encode
file - the file to write to
dbmode - 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 encode
dbmode - 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 name
node - 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 string
node - 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 parsed
conversionRules - 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 literal
conversionRules - a file name pointing to the conversion rules
Returns:
a HopObject obtained from parsing the XML
See Also:


Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.