## org.exist.xmldb
Class LocalXMLResource

    java.lang.Object
      org.exist.xmldb.AbstractEXistResource
          org.exist.xmldb.LocalXMLResource

All Implemented Interfaces:
  EXistResource, Resource, XMLResource

public class LocalXMLResource
extends AbstractEXistResource
implements XMLResource

Local implementation of XMLResource.

Field Summary

Fields inherited from interface org.xmldb.api.modules.XMLResource
`RESOURCE_TYPE`

Constructor Summary
`LocalXMLResource(User user, BrokerPool pool, LocalCollection parent, NodeProxy p)`
`LocalXMLResource(User user, BrokerPool pool, LocalCollection parent, XmldbURI did)`

Method Summary
`java.lang.Object` `getContent()` Retrieves the content from the resource.
`org.w3c.dom.Node` `getContentAsDOM()` Returns the content of the `Resource` as a DOM Node.
`void` `getContentAsSAX(org.xml.sax.ContentHandler handler)` Allows you to use a `ContentHandler` to parse the XML data from the database for use in an application.
`int` `getContentLength()`
`java.util.Date` `getCreationTime()`
`org.w3c.dom.DocumentType` `getDocType()`
`java.lang.String` `getDocumentId()` Returns the unique id for the parent document to this `Resource` or null if the `Resource` does not have a parent document.
`java.lang.String` `getId()` Returns the unique id for this `Resource` or null if the `Resource` is anonymous.
`java.util.Date` `getLastModificationTime()`
`NodeProxy` `getNode()`
`Collection` `getParentCollection()` Returns the `Collection` instance that this resource is associated with.
`Permission` `getPermissions()`
`java.lang.String` `getResourceType()` Returns the resource type for this Resource.
`boolean` `getSAXFeature(java.lang.String arg0)` Returns current setting of a SAX feature that will be used when this `XMLResource` is used to produce SAX events (through the getContentAsSAX() method)
`void` `setContent(java.lang.Object obj)` Sets the content for this resource.
`void` `setContentAsDOM(org.w3c.dom.Node root)` Sets the content of the `Resource` using a DOM Node as the source.
`org.xml.sax.ContentHandler` `setContentAsSAX()` Sets the content of the `Resource` using a SAX `ContentHandler`.
`void` `setDocType(org.w3c.dom.DocumentType doctype)`
`void` `setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)`
`void` `setSAXFeature(java.lang.String arg0, boolean arg1)` Sets a SAX feature that will be used when this `XMLResource` is used to produce SAX events (through the getContentAsSAX() method)

Methods inherited from class org.exist.xmldb.AbstractEXistResource
`getMimeType, setMimeType`

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

Constructor Detail

### LocalXMLResource

    public LocalXMLResource(User user,
                            BrokerPool pool,
                            LocalCollection parent,
                            XmldbURI did)
                     throws XMLDBException

### LocalXMLResource

    public LocalXMLResource(User user,
                            BrokerPool pool,
                            LocalCollection parent,
                            NodeProxy p)
                     throws XMLDBException

Method Detail

### getContent

    public java.lang.Object getContent()
                                throws XMLDBException

  Description copied from interface: `Resource`
  Retrieves the content from the resource. The type of the content varies depending what type of resource is being used.

  Specified by:
    `getContent` in interface `Resource`
  Returns:
    the content of the resource.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### getContentAsDOM

    public org.w3c.dom.Node getContentAsDOM()
                                     throws XMLDBException

  Description copied from interface: `XMLResource`
  Returns the content of the `Resource` as a DOM Node.

  Specified by:
    `getContentAsDOM` in interface `XMLResource`
  Returns:
    The XML content as a DOM `Node`
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### getContentAsSAX

    public void getContentAsSAX(org.xml.sax.ContentHandler handler)
                         throws XMLDBException

  Description copied from interface: `XMLResource`
  Allows you to use a `ContentHandler` to parse the XML data from the database for use in an application.

  Specified by:
    `getContentAsSAX` in interface `XMLResource`
  Parameters:
    `handler` - the SAX `ContentHandler` to use to handle the `Resource` content.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.
    `ErrorCodes.INVALID_RESOURCE` if the `ContentHandler` provided is null.

### getDocumentId

    public java.lang.String getDocumentId()
                                   throws XMLDBException

  Description copied from interface: `XMLResource`
  Returns the unique id for the parent document to this `Resource` or null if the `Resource` does not have a parent document. `getDocumentId()` is typically used with `Resource` instances retrieved using a query. It enables accessing the parent document of the `Resource` even if the `Resource` is a child node of the document. If the `Resource` was not obtained through a query then `getId()` and `getDocumentId()` will return the same id.

  Specified by:
    `getDocumentId` in interface `XMLResource`
  Returns:
    the id for the parent document of this `Resource` or null if there is no parent document for this `Resource`.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### getId

    public java.lang.String getId()
                           throws XMLDBException

  Description copied from interface: `Resource`
  Returns the unique id for this `Resource` or null if the `Resource` is anonymous. The `Resource` will be anonymous if it is obtained as the result of a query.

  Specified by:
    `getId` in interface `Resource`
  Returns:
    the id for the Resource or null if no id exists.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### getParentCollection

    public Collection getParentCollection()
                                   throws XMLDBException

  Description copied from interface: `Resource`
  Returns the `Collection` instance that this resource is associated with. All resources must exist within the context of a `collection`.

  Specified by:
    `getParentCollection` in interface `Resource`
  Returns:
    the collection associated with the resource.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### getResourceType

    public java.lang.String getResourceType()
                                     throws XMLDBException

  Description copied from interface: `Resource`
  Returns the resource type for this Resource.

  XML:DB defined resource types are:

  XMLResource - all XML data stored in the database
  BinaryResource - Binary blob data stored in the database

  Specified by:
    `getResourceType` in interface `Resource`
  Returns:
    the resource type for the Resource.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### getCreationTime

    public java.util.Date getCreationTime()
                                   throws XMLDBException

  Specified by:
    `getCreationTime` in interface `EXistResource`
  Specified by:
    `getCreationTime` in class `AbstractEXistResource`
  Throws:
    `XMLDBException`

### getLastModificationTime

    public java.util.Date getLastModificationTime()
                                           throws XMLDBException

  Specified by:
    `getLastModificationTime` in interface `EXistResource`
  Specified by:
    `getLastModificationTime` in class `AbstractEXistResource`
  Throws:
    `XMLDBException`

### getContentLength

    public int getContentLength()
                         throws XMLDBException

  Specified by:
    `getContentLength` in interface `EXistResource`
  Throws:
    `XMLDBException`

### setContent

    public void setContent(java.lang.Object obj)
                    throws XMLDBException

  Sets the content for this resource. If value is of type File, it is directly passed to the parser when Collection.storeResource is called. Otherwise the method tries to convert the value to String. Passing a File object should be preferred if the document is large. The file's content will not be loaded into memory but directly passed to a SAX parser.

  Specified by:
    `setContent` in interface `Resource`
  Parameters:
    `obj` - the content value to set for the resource.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### setContentAsDOM

    public void setContentAsDOM(org.w3c.dom.Node root)
                         throws XMLDBException

  Description copied from interface: `XMLResource`
  Sets the content of the `Resource` using a DOM Node as the source.

  Specified by:
    `setContentAsDOM` in interface `XMLResource`
  Parameters:
    `root` - The new content value
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.
    `ErrorCodes.INVALID_RESOURCE` if the content value provided is null.
    `ErrorCodes.WRONG_CONTENT_TYPE` if the content provided in not a valid DOM `Node`.

### setContentAsSAX

    public org.xml.sax.ContentHandler setContentAsSAX()
                                               throws XMLDBException

  Description copied from interface: `XMLResource`
  Sets the content of the `Resource` using a SAX `ContentHandler`.

  Specified by:
    `setContentAsSAX` in interface `XMLResource`
  Returns:
    a SAX `ContentHandler` that can be used to add content into the `Resource`.
  Throws:
    `XMLDBException` - with expected error codes.
    `ErrorCodes.VENDOR_ERROR` for any vendor specific errors that occur.

### getSAXFeature

    public boolean getSAXFeature(java.lang.String arg0)
                          throws org.xml.sax.SAXNotRecognizedException,
                                 org.xml.sax.SAXNotSupportedException

  Description copied from interface: `XMLResource`
  Returns current setting of a SAX feature that will be used when this `XMLResource` is used to produce SAX events (through the getContentAsSAX() method)

  Specified by:
    `getSAXFeature` in interface `XMLResource`
  Parameters:
    `arg0` - Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.
  Returns:
    whether the feature is set
  Throws:
    `org.xml.sax.SAXNotRecognizedException`
    `org.xml.sax.SAXNotSupportedException`

### setSAXFeature

    public void setSAXFeature(java.lang.String arg0,
                              boolean arg1)
                       throws org.xml.sax.SAXNotRecognizedException,
                              org.xml.sax.SAXNotSupportedException

  Description copied from interface: `XMLResource`
  Sets a SAX feature that will be used when this `XMLResource` is used to produce SAX events (through the getContentAsSAX() method)

  Specified by:
    `setSAXFeature` in interface `XMLResource`
  Parameters:
    `arg0` - Feature name. Standard SAX feature names are documented at http://sax.sourceforge.net/.
    `arg1` - Set or unset feature
  Throws:
    `org.xml.sax.SAXNotRecognizedException`
    `org.xml.sax.SAXNotSupportedException`

### getPermissions

    public Permission getPermissions()
                              throws XMLDBException

  Specified by:
    `getPermissions` in interface `EXistResource`
  Specified by:
    `getPermissions` in class `AbstractEXistResource`
  Throws:
    `XMLDBException`

### setLexicalHandler

    public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)

  Specified by:
    `setLexicalHandler` in interface `EXistResource`
  Overrides:
    `setLexicalHandler` in class `AbstractEXistResource`

### getNode

    public NodeProxy getNode()
                      throws XMLDBException

  Throws:
    `XMLDBException`

### getDocType

    public org.w3c.dom.DocumentType getDocType()
                                        throws XMLDBException

  Specified by:
    `getDocType` in interface `EXistResource`
  Overrides:
    `getDocType` in class `AbstractEXistResource`
  Throws:
    `XMLDBException`

### setDocType

    public void setDocType(org.w3c.dom.DocumentType doctype)
                    throws XMLDBException

  Specified by:
    `setDocType` in interface `EXistResource`
  Overrides:
    `setDocType` in class `AbstractEXistResource`
  Throws:
    `XMLDBException`

Copyright (C) Wolfgang Meier. All rights reserved.