|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.xoe.core.content.Stash
The class Stash
represents a virtual filesystem implemented
as a DOM tree of content elements. The filesystem may be read in from or
flushed out to disk. Reading from disk is done in a lazy fashion as the
DOM tree is expanded.
Constructor Summary | |
Stash()
|
Method Summary | |
static ContentElement |
addAlias(String name,
ContentElement content)
Adds an alias to content using the name name . |
static boolean |
contains(String uri)
Returns true if a ContentElement exists in the
Stash for uri . |
static boolean |
contains(URL url)
Returns true if a ContentElement exists in the
Stash for url . |
static URL |
createUniqueFilename(URL baseURL,
String filename,
String suffix)
A convenience method which returns an unused Stash URL based on the criteria passed in. |
static ContentElement |
fetch(String uri)
Returns the ContentElement from the Stash referred to by
uri . |
static ContentElement |
fetch(URL url)
Returns the ContentElement from the Stash referred to by
url . |
static ContentElement |
findFirstNode(String query)
Returns the first content element in the node list returned by evaluating query using the root Stash directory
as the context. |
static ContentElement |
findFirstNode(org.xoe.core.xpath.XPath query)
Returns the first content element in the node list returned by evaluating query using the root Stash directory
as the context. |
static org.w3c.dom.NodeList |
findNodes(String query)
Returns the list of nodes satisfying the location path query
using the root Stash directory as the context. |
static org.w3c.dom.NodeList |
findNodes(org.xoe.core.xpath.XPath query)
Returns the list of nodes satisfying the location path query
using the root Stash directory as the context. |
static ContentElementFactory |
getFactory()
Returns the factory to use for creating a new Stash content element. |
static String |
getPackageArchiveURI(String pkgURI)
Returns the installed location of the package, known as the package archive, for pkgURI . |
static String |
getPackageWorkspaceURI(String username,
String pkgName)
Returns the package workspace URI for the username and package name passed in. |
static String |
getPath()
Returns the directory on the filesystem that corresponds to the Stash. |
static URL |
getPkgArchiveRoot()
Returns the URL of the read-only directory where packages are installed. |
static String |
getUserWorkspaceURI(String username)
Returns the workspace URI for the user designated by username . |
static URL |
getWorkingDirectory(Class c)
Returns the workspace URL for the package that loaded c . |
static URL |
getWorkingDirectory(ClassLoader cl)
Returns the workspace URL for the package that is associated with
cl . |
static URL |
getWorkingDirectory(Object o)
Returns the workspace URL for the package that installed o . |
static URL |
getWorkingDirectory(XoePackage pkg)
Returns the URL of the package workspace for pkg . |
static String |
getXML()
Returns the XML representation of the Stash document. |
static ContentElement |
put(ContentElement content)
Adds a ContentElement to the Stash. |
static void |
putAlias(String name,
String uri)
Adds an alias to the content element referred to by uri using
the name name . |
static StashDirectory |
putDirectory(String dirName)
Adds the directory hierarchy to the Stash specified by
dirName . |
static ContentElement |
remove(String uri)
Removes the content element referred to by uri . |
static ContentElement |
remove(URL url)
Removes the content element referred to by url . |
static void |
removeAlias(String name)
Removes the alias specified by name . |
static void |
setPath(String path)
Assigns the directory to use for the Stash where default files will be loaded from. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Stash()
Method Detail |
public static ContentElementFactory getFactory()
public static URL getPkgArchiveRoot()
public static URL getWorkingDirectory(XoePackage pkg)
pkg
.pkg
- the xoe package in questionpkg
.public static URL getWorkingDirectory(Object o)
o
.o
- the object in questiono
.public static URL getWorkingDirectory(Class c)
c
.c
- the class in questionc
.public static URL getWorkingDirectory(ClassLoader cl)
cl
.cl
- the class loadeder in question
cl
.public static String getUserWorkspaceURI(String username)
username
.username
- the user in questionpublic static String getPackageArchiveURI(String pkgURI)
pkgURI
.pkgURI
- the package URIpublic static String getPackageWorkspaceURI(String username, String pkgName)
username
- the user namepkgName
- the package namepublic static void setPath(String path) throws StashException
path
- directory to use for the Stash default dataStashException
- if the Stash has already been initialized; or if
path
is: null, not a valid file path
on disk, or exists but isn't a directory on diskpublic static String getPath()
public static boolean contains(URL url) throws IOException
true
if a ContentElement
exists in the
Stash for url
.url
- the URL to look for in the Stashtrue
if content is found;
false
if no content is foundIOException
- if an I/O error occurspublic static boolean contains(String uri) throws IOException
true
if a ContentElement
exists in the
Stash for uri
.uri
- the URI string to look for in the Stashtrue
if content is found;
false
if no content is foundIOException
- if an I/O error occurspublic static ContentElement fetch(URL url) throws StashException
ContentElement
from the Stash referred to by
url
.url
- the URL of the desired contentnull
if not found.StashException
- if url
is null
or
doesn't use the Stash protocol.public static ContentElement fetch(String uri) throws StashException
ContentElement
from the Stash referred to by
uri
.uri
- the URI string of the desired contentnull
if not found.StashException
- if uri
is null
or
doesn't use the Stash protocol.public static ContentElement put(ContentElement content) throws IOException, StashException
ContentElement
to the Stash. Only elements whose
URL begins with stash:/ can be added. Any existing element at the
same URL is removed and returned. content
- the content to place in the Stashnull
if no content previously existed at that locationIOException
- if an I/O exception occursStashException
- if the content's URL refers to a file on disk
that has spaces in it's name.public static StashDirectory putDirectory(String dirName) throws IOException
dirName
. Walks each level of the path and adds the
directories if necessary.dirName
- the path to add to the StashIOException
- if an I/O error occurspublic static void putAlias(String name, String uri) throws IOException, StashException
uri
using
the name name
. Throws a StashException if uri
doesn't refer to valid Stash content.name
- the name to use for the aliasuri
- the URI string the alias should point toIOException
- if an I/O error occursStashException
- if uri
doesn't refer to valid Stash
content.public static ContentElement addAlias(String name, ContentElement content) throws IOException
content
using the name name
.
.name
- the name to use for the aliascontent
- the element to which the alias refersIOException
- if an I/O error occurspublic static ContentElement remove(URL url) throws StashException
url
.url
- the URL of the content element to removeStashException
- if url
is null
or
doesn't use the Stash protocol.public static ContentElement remove(String uri) throws StashException
uri
.uri
- the URI string of the content element to removeStashException
- if uri
is null
or
doesn't use the Stash protocol.public static void removeAlias(String name) throws StashException
name
.name
- the name of the alias to removeStashException
- if name
is null
or
doesn't use the Stash protocol.public static ContentElement findFirstNode(String query)
query
using the root Stash directory
as the context.query
- the string representing the location path to evaluatequery
public static ContentElement findFirstNode(org.xoe.core.xpath.XPath query)
query
using the root Stash directory
as the context.query
- the compiled XPath
representing the location
path to evaluatequery
public static org.w3c.dom.NodeList findNodes(String query)
query
using the root Stash directory as the context.query
- the string representing the location path to evaluatepublic static org.w3c.dom.NodeList findNodes(org.xoe.core.xpath.XPath query)
query
using the root Stash directory as the context.query
- the compiled XPath
representing the location
path to evaluatepublic static URL createUniqueFilename(URL baseURL, String filename, String suffix) throws IOException
baseURL
- the Stash directory to look infilename
- the initial filename to trysuffix
- the file suffix to use for the URL returnedIOException
- if an I/O error occurspublic static String getXML()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |