Class XmlObject

java.lang.Object
helma.scripting.rhino.extensions.XmlObject

public class XmlObject extends Object
This class provides methods for converting HopObjects to XML and back.
See Also:
  • invalid input: '<http://helma.org/development/rfc/xmlconversion/>'
  • Constructor Details

    • XmlObject

      public XmlObject(RhinoCore core)
      Creates a new XmlObject object.
      Parameters:
      core - ...
  • Method Details

    • write

      public boolean write(INode node, String file) throws IOException
      Writes a HopObject to an XML file
      Parameters:
      node - the HopObject to encode
      file - the file to write to
      Returns:
      true
      Throws:
      IOException - if something went wrong along the way
    • write

      public boolean write(INode node, String file, boolean dbmode) throws 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:
      IOException - if something went wrong along the way
    • writeToString

      public String writeToString(INode node) throws 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:
      IOException - if something went wrong along the way
    • writeToString

      public String writeToString(INode node, boolean dbmode) throws 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:
      IOException - if something went wrong
    • read

      public Object read(String file) throws RuntimeException
      Reads an XML document from a file and creates a HopObject out of it
      Parameters:
      file - the file name
      Returns:
      the HopObject
      Throws:
      RuntimeException - ...
    • read

      public Object read(String file, INode node) throws 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:
      RuntimeException
    • readFromString

      public Object readFromString(String str) throws 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:
      RuntimeException - ...
    • readFromString

      public Object readFromString(String str, INode node) throws 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:
      RuntimeException - ...
    • get

      public Object get(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 Object get(String url, 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:
      • invalid input: '<http://helma.org/development/rfc/xmlconversion/>'
    • getFromString

      public Object getFromString(String str)
      Transforms a XML literal into a HopObject
      Parameters:
      str - an XML literal
      Returns:
      a HopObject obtained from parsing the XML
    • getFromString

      public Object getFromString(String str, 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:
      • invalid input: '<http://helma.org/development/rfc/xmlconversion/>'