com.xefer.rebel
Class XBELDocument

java.lang.Object
  |
  +--com.xefer.rebel.XBELElement
        |
        +--com.xefer.rebel.XBELDocument

class XBELDocument
extends XBELElement

Encapsulates the XBEL document


Field Summary
(package private)  Document document
          The underlying XML Document that this class is managing
 
Fields inherited from class com.xefer.rebel.XBELElement
element
 
Constructor Summary
XBELDocument(Document document)
          constructor
XBELDocument(Element element)
          constructor
XBELDocument(String filename)
          constructor
 
Method Summary
protected  void closeStream(InputStream stream)
          silently closes the stream and absorbs and logs exceptions
protected  void closeStream(OutputStream stream)
          silently closes the stream and absorbs and logs exceptions
 void delete()
          delete Not allowed to delete the XBEL document itself
 void deleteElement(XBELElement resource)
          deletes the element from the document
 XBELElement getElement(String path)
          getElement retrieves the location at the given URL or throws a ResourceException if not element can be located.
 XBELElement getElement(String path, boolean generate)
          getElement retrieves the element at the given URL path, generating a new resource if the generate flag is true.
 String getLocationUrl(StringBuffer url)
          Returns the resource Location URL based on the current url and the resource type
 boolean isLocatable()
          Returns true if this XBELElement is directly locatable through a URL.
protected  FileInputStream openStream(File file)
          Open the file and and return an input stream
 void postElement(XBELElement resource, XBELElement entity)
          postElement
 void putElement(XBELElement resource, XBELElement entity)
          put updates the resource element with the entity element
 void write(ServletContext context, String filename)
          Write the given XML Document to the given file location
 
Methods inherited from class com.xefer.rebel.XBELElement
addChild, addChildDirect, getId, getType, post, put, replaceChild, replaceSelf, setId, write
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

document

Document document
The underlying XML Document that this class is managing
Constructor Detail

XBELDocument

public XBELDocument(Document document)
constructor
Parameters:
document - Document the document that this class encapsulates

XBELDocument

public XBELDocument(Element element)
constructor
Parameters:
element - Element the document element of the resource

XBELDocument

public XBELDocument(String filename)
             throws ResourceException
constructor
Parameters:
filename - String the file to be parsed
Method Detail

closeStream

protected void closeStream(InputStream stream)
silently closes the stream and absorbs and logs exceptions
Parameters:
stream - InputStream to be closed

closeStream

protected void closeStream(OutputStream stream)
silently closes the stream and absorbs and logs exceptions
Parameters:
stream - OutputputStream to be closed

delete

public void delete()
            throws ResourceException
delete Not allowed to delete the XBEL document itself
Overrides:
delete in class XBELElement
Following copied from class: com.xefer.rebel.XBELElement
Returns:
void

deleteElement

public void deleteElement(XBELElement resource)
                   throws ResourceException
deletes the element from the document
Parameters:
resource - XBELElement to be deleted

getElement

public XBELElement getElement(String path)
                       throws ResourceException
getElement retrieves the location at the given URL or throws a ResourceException if not element can be located.
Parameters:
path - String representing the resources path.
Returns:
XBELElement at the given path

getElement

public XBELElement getElement(String path,
                              boolean generate)
                       throws ResourceException
getElement retrieves the element at the given URL path, generating a new resource if the generate flag is true. For URL paths that end in a "/", the generated element will be an XBELFolder (or XBELDocument if its the root), if the URL does not end in a "/" the generated element will be a XBELBookmark
Parameters:
path - String of the path to the resource
Returns:
XBELElement generated or null if not generated and no resource found

getLocationUrl

public String getLocationUrl(StringBuffer url)
Returns the resource Location URL based on the current url and the resource type
Overrides:
getLocationUrl in class XBELElement
Parameters:
url - StringBuffer the URL location of the parent resource

isLocatable

public boolean isLocatable()
Returns true if this XBELElement is directly locatable through a URL. For bookmark elements this is true.
Overrides:
isLocatable in class XBELElement

openStream

protected FileInputStream openStream(File file)
                              throws ResourceException
Open the file and and return an input stream
Parameters:
file - File to be opened

postElement

public void postElement(XBELElement resource,
                        XBELElement entity)
                 throws ResourceException
postElement

putElement

public void putElement(XBELElement resource,
                       XBELElement entity)
                throws ResourceException
put updates the resource element with the entity element
Parameters:
resource - XBELElement to be updated
entity - XBELElement to be stored as the updated resource

write

public void write(ServletContext context,
                  String filename)
           throws ResourceException
Write the given XML Document to the given file location