Package org.xmldb.api.base
Interface Resource
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Subinterfaces:
BinaryResource,XMLResource
public interface Resource extends java.lang.AutoCloseableResourceis a container for data stored within the database. Raw resources are not particulary useful. It is necessary to have a resource implementation that provides handling for a specific content type before anything useful can be done.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Releases all resources consumed by theResource.java.lang.ObjectgetContent()Retrieves the content from the resource.voidgetContentAsStream(java.io.OutputStream stream)Retrieves the content from the resource.java.time.InstantgetCreationTime()Returns the time of creation of the resource.java.lang.StringgetId()Returns the unique id for thisResourceor null if theResourceis anonymous.java.time.InstantgetLastModificationTime()Returns the time of last modification of the resource.CollectiongetParentCollection()Returns theCollectioninstance that this resource is associated with.ResourceTypegetResourceType()Returns the resource type for this Resource.booleanisClosed()Returns whenever the current resource has been closed or not.voidsetContent(java.lang.Object value)Sets the content for this resource.
-
-
-
Method Detail
-
getResourceType
ResourceType getResourceType()
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- Returns:
- the resource type for the Resource.
-
getParentCollection
Collection getParentCollection() throws XMLDBException
Returns theCollectioninstance that this resource is associated with. All resources must exist within the context of acollection.- Returns:
- the collection associated with the resource.
- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getId
java.lang.String getId() throws XMLDBExceptionReturns the unique id for thisResourceor null if theResourceis anonymous. TheResourcewill be anonymous if it is obtained as the result of a query.- Returns:
- the id for the Resource or null if no id exists.
- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getContent
java.lang.Object getContent() throws XMLDBExceptionRetrieves the content from the resource. The type of the content varies depending what type of resource is being used.- Returns:
- the content of the resource.
- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getContentAsStream
void getContentAsStream(java.io.OutputStream stream) throws XMLDBExceptionRetrieves the content from the resource. The type of the content varies depending what type of resource is being used.- Parameters:
stream- the output stream to write the resource content to- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
setContent
void setContent(java.lang.Object value) throws XMLDBExceptionSets the content for this resource. The type of content that can be set depends on the type of resource being used.- Parameters:
value- the content value to set for the resource.- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
isClosed
boolean isClosed()
Returns whenever the current resource has been closed or not.- Returns:
truewhen the resource has been closed,falseotherwise.
-
close
void close() throws XMLDBExceptionReleases all resources consumed by theResource. Theclosemethod must always be called when use of aResourceis complete. It is not safe to use aResourceafter theclosemethod has been called.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getCreationTime
java.time.Instant getCreationTime() throws XMLDBExceptionReturns the time of creation of the resource.- Returns:
- the creation date of the current resource
- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
getLastModificationTime
java.time.Instant getLastModificationTime() throws XMLDBExceptionReturns the time of last modification of the resource.- Returns:
- the last modification date of the current resource
- Throws:
XMLDBException- with expected error codes.ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.
-
-