## net.sf.saxon.xqj
Class StandardObjectConverter

    java.lang.Object
      net.sf.saxon.xqj.StandardObjectConverter

All Implemented Interfaces:
  ObjectConverter

    public class StandardObjectConverter

extends java.lang.Object
implements ObjectConverter

This class provides all the conversion methods used to convert data between XDM values and Java values in the XQJ API. At one time the XQJ specification defined such a class, and it has been retained in the Saxon implementation.

This handler implements the mappings defined in the XQJ specification. In addition, it defines the following mappings, which are applied after those defined in XQJ:

For fromObject:

- If the supplied object is an instance of javax.xml.transform.Source, a document node is constructed from the source and the resulting node is returned as the Item
- If the supplied object is an instance of javax.xml.stream.XMLStreamReader, a document node is constructed from the XMLStreamReader and the resulting node is returned as the Item
- If the supplied object is

Constructor Summary
`StandardObjectConverter(SaxonXQDataFactory factory)` Create an instance of the class

Method Summary
`Item` `convertToItem(java.lang.Object value)` Convert a Java object to a Saxon Item
`Item` `convertToItem(java.lang.Object value, javax.xml.xquery.XQItemType type)` Convert a Java object to an Item, when a required type has been specified.
`java.lang.Object` `toObject(javax.xml.xquery.XQItemAccessor xqItemAccessor)` Convert an Item to a Java object

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### StandardObjectConverter

    public StandardObjectConverter(SaxonXQDataFactory factory)

  Create an instance of the class

  Parameters:
    `factory` - the factory object

Method Detail

### toObject

    public java.lang.Object toObject(javax.xml.xquery.XQItemAccessor xqItemAccessor)
                              throws javax.xml.xquery.XQException

  Description copied from interface: `ObjectConverter`
  Convert an Item to a Java object

  Specified by:
    `toObject` in interface `ObjectConverter`
  Parameters:
    `xqItemAccessor` - the XQJ object representing the item to be converted
  Returns:
    the Java object that results from the conversion
  Throws:
    `javax.xml.xquery.XQException`

### convertToItem

    public Item convertToItem(java.lang.Object value)
                       throws javax.xml.xquery.XQException

  Convert a Java object to a Saxon Item

  Specified by:
    `convertToItem` in interface `ObjectConverter`
  Parameters:
    `value` - the Java object
  Returns:
    the corresponding Item
  Throws:
    `javax.xml.xquery.XQException`

### convertToItem

    public Item convertToItem(java.lang.Object value,
                              javax.xml.xquery.XQItemType type)
                       throws javax.xml.xquery.XQException

  Convert a Java object to an Item, when a required type has been specified. Note that Saxon only calls this method when none of the standard conversions defined in the XQJ specification is able to handle the object.

  Specified by:
    `convertToItem` in interface `ObjectConverter`
  Parameters:
    `value` - the supplied Java object
    `type` - the required XPath data type
  Returns:
    the Item that results from the conversion
  Throws:
    `javax.xml.xquery.XQException` - if the Java object cannot be converted to an XQItem

Copyright (c) Saxonica Limited. All rights reserved.