|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.binaryfantasy.murq.Murq
public final class Murq
The face of the Murq persistance library.
Murq is threadsafe as long as there is only one Murq instance per
ISource destination. If two instances
of Murq are created based on the same
ISource instance, or two
ISource instances pointing to the same
repository, behavior will be nondeterministic.
| Constructor Summary | |
|---|---|
Murq(ISource source)
Constructs a new instance using the specified source. |
|
Murq(ISource source,
String password)
Constructs a new instance using the specified source. |
|
| Method Summary | |
|---|---|
void |
add(ISource src)
Adds all content from the specified unencrypted src to
this instance. |
void |
add(ISource src,
String password)
Adds all content from the specified src to this instance. |
void |
addContentListener(IContentListener listener)
Adds a listener to be notified of ContentEvents. |
void |
addContentListener(IContentListener listener,
Executor executor)
Adds a listener to be notified of ContentEvents. |
void |
addLink(String linkName,
String contentId)
Provides a simple name link to the specified contentId. |
void |
close()
Closes this Murq instance and releases resources. |
protected void |
finalize()
|
Set<IContent> |
find(MurqQuery query)
Performs a search of all content and returns a Set of
matching content, or an empty Set if no matches are
found. |
Set<IContent> |
find(String queryStr)
Performs a search of all default content and returns a Set of matching content, or an empty
Set if no matches are found. |
Set<IContent> |
find(String queryStr,
Locale locale)
Performs a search of all content relevant to the provided locale and returns a Set of matching
content, or an empty Set if no matches are found. |
Set<IContent> |
find(String queryStr,
Locale locale,
String[] orderBy)
Performs a search of all content relevant to the provided locale and returns a Set of matching
content, or an empty Set if no matches are found. |
Set<IContent> |
findAll(String queryStr,
String[] orderBy)
Performs a search of the current contents using the Lucene search engine and returns a Set of ALL matching content
objects - regardless of locale, or an empty Set if no
matches are found. |
IContent |
findRandom(MurqQuery query)
Returns a single, random IContent
from the results returned from the specified query, or
null if no matches are found. |
IContent |
get(String contentId)
Returns the default content associated with the specified contentId, or null if no content is
found. |
IContent |
get(String contentId,
Locale locale)
Returns the content associated with the specified contentId
and relevant to the locale, or null if no
content is found. |
Set<IContent> |
getAll(String contentId,
String[] orderBy)
Returns a Set of ALL content - regardless of
locale - matching the specified contentId, or an empty
Set if none are found. |
Set<IContent> |
getAllByClass(Class contentClass,
String[] orderBy)
Returns a Set of ALL content that is
assignment-compatible with the contentClass and relevant
to the locale, or an empty Set if none
are found. |
Set<IContent> |
getByClass(Class contentClass)
Returns a Set of all default content that is
assignment-compatible with the contentClass, or an empty
Set if none are found. |
Set<IContent> |
getByClass(Class contentClass,
Locale locale,
String[] orderBy)
Returns a Set of content that is assignment-compatible
with the contentClass and relevant to the
locale, or an empty Set if none are
found. |
Set<IContent> |
getByClass(Class contentClass,
String[] orderBy)
Returns a Set of all default content that is
assignment-compatible with the contentClass, or an empty
Set if none are found. |
String |
getId()
Returns the unique id belonging to the ISource that backs the
Murq facade. |
Set<String> |
getLinkNames()
Returns all current link names. |
Set<Locale> |
getLocales(IContent content)
Returns all Locales that the specified
content is available in. |
Set<Locale> |
getLocales(String contentId)
Returns all Locales that the specified
contentId is available in. |
ISource |
getSource()
Returns the ISource being used for
persistance. |
boolean |
isOpen()
Returns true if this Murq instance is
open. |
boolean |
isUpdating()
Returns true if there are
ContentEvents being processed. |
void |
put(IContent content)
Persists the specified content. |
void |
put(IContent content,
boolean force)
Persists the specified content, ignoring any possible
concurrent modification issues if force is
true. |
int |
read(String contentId,
Locale locale,
OutputStream out)
Reads binary data relevant to the locale and associated
with the contentId, writing it to the specified
out. |
int |
read(String contentId,
OutputStream out)
Reads the default binary data associated with the contentId
and writes it to the specified out. |
boolean |
remove(IContent content)
Removes the specified content. |
boolean |
remove(String contentId,
Locale locale)
Removes the specified content. |
boolean |
removeAll(String contentId)
Removes all content, in all locales, associated with the specified contentId. |
void |
removeContentListener(IContentListener listener)
Removes a listener from being notified of ContentEvents. |
void |
removeLink(String linkName)
Removes a simple name link. |
void |
removeLinks(String contentId)
Removes all links associated with the contentId. |
IContent |
resolveLink(String linkName,
Locale locale)
Returns the IContent relevant to
the locale targeted by the specified
linkName, or null if none exists. |
String |
resolveLinkId(String linkName)
Returns the contentId relevant to the specified linkName,
or null if none exists. |
IContent |
resovleLink(String linkName)
Returns the default IContent
target of the specified linkName, or null
if none exists. |
String |
toString()
|
int |
write(IBinaryContent content,
InputStream in)
Persists the specified binary data from the in along with
the metadata describing it in the content. |
int |
write(IBinaryContent content,
InputStream in,
boolean force)
Persists the specified binary data from the in along with
the metadata describing it in the content, ignoring any
possible concurrent modification issues if force is
true. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Murq(ISource source)
source.
source - the initialized ISource
persistance to be used.
public Murq(ISource source,
String password)
source.
source - the initialized ISource
persistance to be used.password - if encrypted, null otherwise.| Method Detail |
|---|
public String getId()
ISource that backs the
Murq facade.
ISource that backs the
Murq facade.public ISource getSource()
ISource being used for
persistance.
NOTE: This method is intended for internal use only. Accessing and
manipulating the ISource outside
of Murq will result in nondeterministic behavior.
ISource being used for
persistance.public boolean isOpen()
true if this Murq instance is
open.
true if this Murq instance is
open.public void close()
Murq instance and releases resources.
Attempts to use this instance after closing will result in a
IllegalStateException.
Multiple calls to close have no effect.
public void addContentListener(IContentListener listener)
ContentEvents.
listener - the object to be notified of
ContentEvents.
IllegalArgumentException - if listener is null.
public void addContentListener(IContentListener listener,
Executor executor)
ContentEvents.
listener - the object to be notified of
ContentEvents.executor - the executor to use in firing events to this listener, or
null to use default.
IllegalArgumentException - if listener is null.public void removeContentListener(IContentListener listener)
ContentEvents.
listener - the object to no longer be notified of
ContentEvents.
IllegalArgumentException - if listener is null.public IContent findRandom(MurqQuery query)
IContent
from the results returned from the specified query, or
null if no matches are found.
query - defines the search, from which the random result will be
selected.
IContent
from the results returned from the specified query,
or null if no matches are found.public Set<IContent> find(MurqQuery query)
Set of
matching content, or an empty Set if no matches are
found.
query - defines the search terms.
Set if no
matches are found.
IllegalArgumentException - if the query is null.
IllegalStateException - if this Murq instance is closed.public Set<IContent> find(String queryStr)
Set of matching content, or an empty
Set if no matches are found.
queryStr - a query string using Lucene query syntax.
Set if no
matches are found.
IllegalArgumentException - if the queryStr is null or if
it cannot be parsed.
IllegalStateException - if this Murq instance is closed.
public Set<IContent> find(String queryStr,
Locale locale)
locale and returns a Set of matching
content, or an empty Set if no matches are found.
queryStr - a query string using Lucene query syntax.locale - the locale releveant to the content to be found.
Set if no
matches are found.
IllegalArgumentException - if the queryStr is null or if
it cannot be parsed.
IllegalStateException - if this Murq instance is closed.
public Set<IContent> find(String queryStr,
Locale locale,
String[] orderBy)
locale and returns a Set of matching
content, or an empty Set if no matches are found.
queryStr - a query string using Lucene query syntax.orderBy - property names in order of precedence to order results by.locale - the locale releveant to the content to be found.
Set if no
matches are found.
IllegalArgumentException - if the queryStr is null or if
it cannot be parsed.
IllegalStateException - if this Murq instance is closed.
public Set<IContent> findAll(String queryStr,
String[] orderBy)
Set of ALL matching content
objects - regardless of locale, or an empty Set if no
matches are found.
queryStr - the query to be executed.orderBy - property names in order of precedence to order results by.
Set
if no matches are found.
IllegalStateException - if this Murq instance is closed.
IllegalArgumentException - if query is null.public Set<IContent> getByClass(Class contentClass)
Set of all default content that is
assignment-compatible with the contentClass, or an empty
Set if none are found.
contentClass - the assignment-compatible Class of the content
to be found.
Set of all default content that is
assignment-compatible with the contentClass, or
an empty Set if none are found.
IllegalArgumentException - if contentClass is null.
IllegalStateException - if this Murq instance is closed.
public Set<IContent> getByClass(Class contentClass,
String[] orderBy)
Set of all default content that is
assignment-compatible with the contentClass, or an empty
Set if none are found.
contentClass - the assignment-compatible Class of the content
to be found.orderBy - property names in order of precedence to order results by.
Set of all default content that is
assignment-compatible with the contentClass, or
an empty Set if none are found.
IllegalArgumentException - if contentClass is null.
IllegalStateException - if this Murq instance is closed.public Set<Locale> getLocales(IContent content)
Locales that the specified
content is available in.
content - the IContent to check for available
Locales.
Locales that the specified
content is available in.public Set<Locale> getLocales(String contentId)
Locales that the specified
contentId is available in.
contentId - the unique content identifier to check for available
Locales.
Locales that the specified
contentId is available in.
public Set<IContent> getByClass(Class contentClass,
Locale locale,
String[] orderBy)
Set of content that is assignment-compatible
with the contentClass and relevant to the
locale, or an empty Set if none are
found.
contentClass - the assignment-compatible Class of the content
to be found.locale - the locale releveant to the content to be found.orderBy - property names in order of precedence to order results by.
Set of all default content that is
assignment-compatible with the contentClass, or
an empty Set if none are found.
IllegalArgumentException - if contentClass is null.
IllegalStateException - if this Murq instance is closed.
public Set<IContent> getAllByClass(Class contentClass,
String[] orderBy)
Set of ALL content that is
assignment-compatible with the contentClass and relevant
to the locale, or an empty Set if none
are found.
contentClass - the assignment-compatible Class of the content
to be found.orderBy - property names in order of precedence to order results by.
contentClass, or an empty Set
if none are found.
IllegalArgumentException - if contentClass is null.
IllegalStateException - if this Murq instance is closed.public IContent get(String contentId)
contentId, or null if no content is
found.
contentId - id associated with the content to be returned.
contentId, or null if no content
is found.
IllegalArgumentException - if contentId is null.
IllegalStateException - if this Murq instance is closed.
public IContent get(String contentId,
Locale locale)
contentId
and relevant to the locale, or null if no
content is found.
contentId - id associated with the content to be returned.locale - the locale relevant to the content to be returned.
contentId
and relevant to the locale, or null
if no content is found.
IllegalArgumentException - if contentId is null.
IllegalStateException - if this Murq instance is closed.
public Set<IContent> getAll(String contentId,
String[] orderBy)
Set of ALL content - regardless of
locale - matching the specified contentId, or an empty
Set if none are found.
contentId - the id of the content to be found.orderBy - property names in order or precedence to order results by.
Set of all content - regardless of locale -
matching the specified contentId, or an empty
Set if none are found.
IllegalArgumentException - if contentClass is null.
IllegalStateException - if this Murq instance is closed.
public int read(String contentId,
OutputStream out)
contentId
and writes it to the specified out.
contentId - the identifier associated with the binary data to be read.out - destination of the read binary data.
IllegalArgumentException - if contentClass is null.
IllegalStateException - if this Murq instance is closed.
public int read(String contentId,
Locale locale,
OutputStream out)
locale and associated
with the contentId, writing it to the specified
out.
contentId - the identifier associated with the binary data to be read.locale - the locale relevant to the data to be returned.out - destination of the read binary data.
IllegalArgumentException - if contentClass is null.
IllegalStateException - if this Murq instance is closed.public void put(IContent content)
content. This is the same as
put(IContent, boolean) with a false force
argument.
content - the content to be persisted.
IllegalArgument - if content is null.
ConcurrentModificationException - if content already exists and is an older
version than the one currently persisted.
IllegalStateException - if this Murq instance is closed.put(IContent, boolean)
public void put(IContent content,
boolean force)
content, ignoring any possible
concurrent modification issues if force is
true.
Content is considered to be new if
IContent.getContentId() returns
null. In this case, a unique id will be set, both in the
persisted copy and the content passed in. New content
also has it's creationDate set.
All content, new or updated, has it's lastModified date
updated.
content - the content to be persisted.force - set to true to ignore concurent modification
checks.
IllegalArgument - if content is null.
ConcurrentModificationException - if force is false and
content already exists and is an older
version than the one already persisted.
IllegalStateException - if this Murq instance is closed.
public int write(IBinaryContent content,
InputStream in)
in along with
the metadata describing it in the content. The same as
calling write(IBinaryContent, InputStream, boolean) with a
false force argument.
content - the metadata content describing the binary data.in - binary data to read and persist.
IllegalArgument - if content is null.
ConcurrentModificationException - if content already exists and is an older
version than the one currently persisted.
IllegalStateException - if this Murq instance is closed.write(IBinaryContent, InputStream, boolean)
public int write(IBinaryContent content,
InputStream in,
boolean force)
in along with
the metadata describing it in the content, ignoring any
possible concurrent modification issues if force is
true.
content - the metadata content describing the binary data.in - binary data to read and persist.force - set to true to ignore concurent modification
checks.
IllegalArgument - if content is null.
ConcurrentModificationException - if force is false and
content already exists and is an older
version than the one already persisted.
IllegalStateException - if this Murq instance is closed.public boolean removeAll(String contentId)
contentId.
contentId - id associated with the content to be removed.
true if successful, false
otherwise.
IllegalArgumentException - if contentId is null.
IllegalStateException - if this Murq instance is closed.public boolean remove(IContent content)
content.
content - the content to be removed.
true if successful, false
otherwise.
IllegalArgumentException - if content is null.
IllegalStateException - if this Murq instance is closed.
public boolean remove(String contentId,
Locale locale)
content.
contentId - the id associated with the content to be removed.locale - the locale relevant to the content to be removed.
true if successful, false
otherwise.
IllegalArgumentException - if contentId is null.
IllegalStateException - if this Murq instance is closed.
public void addLink(String linkName,
String contentId)
contentId.
linkName - name of the link.contentId - id to be the target of the link.
IllegalArgumentException - if linkName or contentId is
null.
IllegalStateException - if this Murq instance is closed.public void removeLink(String linkName)
linkName - name of the link to remove.
IllegalArgumentException - if linkName is null.
IllegalStateException - if this Murq instance is closed.public void removeLinks(String contentId)
contentId.
contentId - the contentId for which all associated links should be
removed.
IllegalArgumentException - if contentId is null.
IllegalStateException - if this Murq instance is closed.public IContent resovleLink(String linkName)
IContent
target of the specified linkName, or null
if none exists.
linkName - name of the link to resolve.
linkName, or
null if none exists.
IllegalArgumentException - if linkName is null.
IllegalStateException - if this Murq instance is closed.
public IContent resolveLink(String linkName,
Locale locale)
IContent relevant to
the locale targeted by the specified
linkName, or null if none exists.
linkName - name of the link to resolve.locale - the locale relevant to content.
linkName, or null if none exists.
IllegalArgumentException - if linkName is null.
IllegalStateException - if this Murq instance is closed.public String resolveLinkId(String linkName)
linkName,
or null if none exists.
linkName - name of the link to resolve.
linkName,
or null if none exists.
IllegalArgumentException - if linkName is null.
IllegalStateException - if this Murq instance is closed.public Set<String> getLinkNames()
IllegalStateException - if this Murq instance is closed.public void add(ISource src)
src to
this instance.
Warning: In the case of conflicting link names, the added link names will overwrite the existing links.
src - source of content to be added.
IllegalArgumentException - if src is null.
IllegalStateException - if this Murq instance is closed.
public void add(ISource src,
String password)
src to this instance.
Warning: In the case of conflicting link names, the added link names will overwrite the existing links.
src - source of content to be added.password - password required to access the src, or
null if unencrypted.
IllegalArgumentException - if src is null.
IllegalStateException - if this Murq instance is closed.public boolean isUpdating()
true if there are
ContentEvents being processed.
true if there are
ContentEvents being
processed.public String toString()
toString in class Object
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||