Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.2 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javolution.xml
Class XMLReferenceResolver

    java.lang.Object
      javolution.xml.XMLReferenceResolver

All Implemented Interfaces:
  Reusable

    public class XMLReferenceResolver

extends java.lang.Object
implements Reusable

This class represents a resolver for XML cross references during the marshalling/unmarshalling process.

Instances of this class may only be shared by `XMLObjectReader`/ `XMLObjectWriter` running sequentially (for cross references spawning multiple documents).

Version:
  4.0, September 4, 2006
Author:
  Jean-Marie Dautelle

Constructor Summary
`XMLReferenceResolver()` Default constructor.

Method Summary
`void` | `createReference(java.lang.Object obj, XMLFormat.InputElement xml)` Creates a reference for the specified object (the identifier being specified by the input XML element).
`java.lang.Object` | `readReference(XMLFormat.InputElement xml)` Reads the object referenced by the specified xml input element if any.
`void` | `reset()` Resets the internal state of this object to its default values.
`void` | `setIdentifierAttribute(java.lang.String name)` Sets the name of the identifier attribute (by default`"id"`).
`void` | `setIdentifierAttribute(java.lang.String localName, java.lang.String uri)` Sets the local name and namespace URI of the identifier attribute.
`void` | `setReferenceAttribute(java.lang.String name)` Sets the name of the reference attribute (by default`"ref"`).
`void` | `setReferenceAttribute(java.lang.String localName, java.lang.String uri)` Sets the local name and namespace URI of the identifier attribute.
`boolean` | `writeReference(java.lang.Object obj, XMLFormat.OutputElement xml)` Writes a reference to the specified object into the specified XML element.

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

Constructor Detail

### XMLReferenceResolver

    public XMLReferenceResolver()

  Default constructor.

Method Detail

### setIdentifierAttribute

    public void setIdentifierAttribute(java.lang.String name)

  Sets the name of the identifier attribute (by default`"id"`). If the name is `null` then the identifier attribute is never read/written (which may prevent unmarshalling).

  Parameters:
    `name` - the name of the attribute or `null`.

### setIdentifierAttribute

    public void setIdentifierAttribute(java.lang.String localName,
                                       java.lang.String uri)

  Sets the local name and namespace URI of the identifier attribute.

  Parameters:
    `localName` - the local name of the attribute or `null`.
    `uri` - the URI of the attribute or `null` if the attribute has no namespace URI.

### setReferenceAttribute

    public void setReferenceAttribute(java.lang.String name)

  Sets the name of the reference attribute (by default`"ref"`). If the name is `null` then the reference attribute is never read/written (which may prevent unmarshalling).

  Parameters:
    `name` - the name of the attribute or `null`.

### setReferenceAttribute

    public void setReferenceAttribute(java.lang.String localName,
                                      java.lang.String uri)

  Sets the local name and namespace URI of the identifier attribute.

  Parameters:
    `localName` - the local name of the attribute or `null`.
    `uri` - the URI of the attribute or `null` if the attribute has no namespace URI.

### writeReference

    public boolean writeReference(java.lang.Object obj,
                                  XMLFormat.OutputElement xml)
                           throws XMLStreamException

  Writes a reference to the specified object into the specified XML element. The default implementation writes the reference into the reference attribute and for the first occurences an identifier (counter starting at 1) is written into the identifier attribute.

  Parameters:
    `obj` - the object for which the reference is written.
    `xml` - the output XML element.
  Returns:
    `true` if a reference is written; `false` if a new identifier is written.
  Throws:
    `XMLStreamException`

### readReference

    public java.lang.Object readReference(XMLFormat.InputElement xml)
                                   throws XMLStreamException

  Reads the object referenced by the specified xml input element if any. The default implementation reads the reference attribute to retrieve the object.

  Parameters:
    `xml` - the input XML element.
  Returns:
    the referenced object or `null` if the specified XML input does not have a reference attribute.
  Throws:
    `XMLStreamException`

### createReference

    public void createReference(java.lang.Object obj,
                                XMLFormat.InputElement xml)
                         throws XMLStreamException

  Creates a reference for the specified object (the identifier being specified by the input XML element). The default implementation reads the identifier attribute (if any) and associates it to the specified object.

  Parameters:
    `obj` - the object being referenced.
    `xml` - the input XML element holding the reference identifier.
  Throws:
    `XMLStreamException`

### reset

    public void reset()

  Description copied from interface: `Reusable`
  Resets the internal state of this object to its default values.

  Specified by:
    `reset` in interface `Reusable`

Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.2 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 - 2007 Javolution.