org.openxri.store.impl.n
Class NullStore

java.lang.Object
  extended by org.openxri.config.impl.AbstractComponent
      extended by org.openxri.store.impl.n.NullStore
All Implemented Interfaces:
java.io.Serializable, Component, Store, StoreAttributable, StoreBackupable, StoreBetterLookup, StoreEditable, StoreLookup, StoreStatistics

public class NullStore
extends AbstractComponent
implements Store, StoreLookup, StoreBetterLookup, StoreEditable, StoreAttributable, StoreStatistics, StoreBackupable

A store that implements all the store interfaces, but does not actually store or retrieve anything.

Author:
=peacekeeper
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openxri.store.StoreAttributable
StoreAttributable.Selector
 
Field Summary
 
Fields inherited from class org.openxri.config.impl.AbstractComponent
properties
 
Constructor Summary
NullStore(java.util.Properties properties)
           
 
Method Summary
 void backupStore(java.io.OutputStream stream)
          Backups all store contents into a stream.
 Authority createAuthority(XRD xrd)
          Creates an authority without associating it with a subsegment.
 SubSegment createRootSubSegment(java.lang.String name, XRD xrd)
          Creates a root subsegment (entry-point namespace to the server).
 void deleteAuthority(Authority authority)
          Deletes an authority and any subsegments registered underneath it.
 void deleteRootSubSegment(java.lang.String name)
          Deletes the root subsegment (namespace) associated with an authority.
 SubSegment findRootSubSegment(java.lang.String namespace)
          Finds a root subsegment with a given name.
 SubSegment findSubSegment(Authority authority, java.lang.String name)
          Finds a subsegment with a given authority and name.
 java.util.Map<java.lang.String,java.lang.String> getAuthorityAttributes(Authority authority)
          Gets attributes from an authority.
 SubSegment[] getAuthorityChildSubSegments(Authority authority)
          Gets all subsegments that have this authority as parent.
 java.lang.Long getAuthorityCount()
           
 java.lang.String getAuthorityIndex(Authority authority)
          Gets the index of the authority.
 java.lang.String[] getAuthorityQxris(Authority authority)
          Gets all full XRIs that lead to this authority.
 java.lang.String[] getAuthorityQxris(Authority authority, boolean reassignable, boolean persistent)
          Gets all full XRIs that lead to this authority.
 SubSegment[] getAuthoritySubSegments(Authority authority)
          Gets all subsegments that lead to this authority.
 java.util.Map<java.lang.String,java.lang.String> getStoreAttributes()
          Gets attributes from the store.
 java.util.Map<java.lang.String,java.lang.String> getSubSegmentAttributes(SubSegment subSegment)
          Gets attributes from a subsegment.
 Authority getSubSegmentAuthority(SubSegment subSegment)
          Returns the authority of this subsegment.
 java.lang.Long getSubSegmentCount()
           
 java.lang.String getSubSegmentIndex(SubSegment subSegment)
          Gets the index of the subsegment.
 Authority getSubSegmentParentAuthority(SubSegment subSegment)
          Returns the authority of this subsegment.
 SubSegment[] getSynonymSubSegments(Authority parent, Authority authority)
          Gets all subsegments with a given parent authority and authority.
 void init()
          A server component is constructed by the ComponentRegistry by passing a Properties object to its constructor and then calling this init() method.
 Authority[] listAuthorities()
          Returns all authorities.
 Authority[] listAuthoritiesByAttributes(StoreAttributable.Selector selector)
          Returns all authorities whose attributes satisfy certain conditions.
 Authority[] listAuthoritiesByAttributeValue(java.lang.String key, java.lang.String value)
          Returns all authorities with a certain attribute key/value pair.
 Authority[] listAuthoritiesByIndex(java.lang.String indx)
          Returns all authorities with a certain index.
 SubSegment[] listRootSubSegments()
          Lists all of the root subsegments (namespaces) on the server.
 SubSegment[] listSubSegments()
          Returns all subsegments.
 SubSegment[] listSubSegmentsByAttributes(StoreAttributable.Selector selector)
          Returns all subsegments whose attributes satisfy certain conditions.
 SubSegment[] listSubSegmentsByAttributeValue(java.lang.String key, java.lang.String value)
          Returns all subsegments whose attributes satisfy certain conditions.
 SubSegment[] listSubSegmentsByIndex(java.lang.String indx)
          Returns all subsegments with a certain index.
 Authority localLookup(XRIAuthority authorityPath)
          This method iterates through all subsegments of the given authority path and returns its final authority.
 SubSegment registerSubsegment(Authority parent, java.lang.String name, Authority authority)
          Registers a new subsegment using an already existing authority.
 SubSegment registerSubsegment(Authority parent, java.lang.String name, XRD xrd)
          Registers a subsegment with a new authority.
 void releaseSubSegment(SubSegment subSegment)
          Releases the descriptor information associated with a registered subsegment.
 void restoreStore(java.io.InputStream stream)
          Restores all store contents from a stream.
 void setAuthorityAttributes(Authority authority, java.util.Map<java.lang.String,java.lang.String> attributes)
          Associates attributes with an authority.
 void setAuthorityIndex(Authority authority, java.lang.String indx)
          Associates an index with an authority.
 void setStoreAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
          Associates attributes with the store.
 void setSubSegmentAttributes(SubSegment subSegment, java.util.Map<java.lang.String,java.lang.String> attributes)
          Associates attributes with a subsegment.
 void setSubSegmentIndex(SubSegment subSegment, java.lang.String indx)
          Associates an index with a subsegment.
 void setXrd(Authority authority, XRD xrd)
          Sets the XRD of an authority.
 
Methods inherited from class org.openxri.config.impl.AbstractComponent
getProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openxri.config.Component
getProperties
 

Constructor Detail

NullStore

public NullStore(java.util.Properties properties)
Method Detail

init

public void init()
Description copied from interface: Component
A server component is constructed by the ComponentRegistry by passing a Properties object to its constructor and then calling this init() method.

Specified by:
init in interface Component

createRootSubSegment

public SubSegment createRootSubSegment(java.lang.String name,
                                       XRD xrd)
                                throws StoreException
Description copied from interface: Store
Creates a root subsegment (entry-point namespace to the server).

Specified by:
createRootSubSegment in interface Store
Parameters:
name - The name of the new root subsegment.
xrd - The XRD of the authority associated with the root subsegment.
Throws:
StoreException

deleteAuthority

public void deleteAuthority(Authority authority)
                     throws StoreException
Description copied from interface: Store
Deletes an authority and any subsegments registered underneath it. It does not delete any authorities registered for those subsegments.

Specified by:
deleteAuthority in interface Store
Parameters:
authority - The authority to delete
Throws:
StoreException

deleteRootSubSegment

public void deleteRootSubSegment(java.lang.String name)
                          throws StoreException
Description copied from interface: Store
Deletes the root subsegment (namespace) associated with an authority. Does not delete the authority itself.

Specified by:
deleteRootSubSegment in interface Store
Parameters:
name - The root subsegment (namespace) to delete.
Throws:
StoreException

listRootSubSegments

public SubSegment[] listRootSubSegments()
                                 throws StoreException
Description copied from interface: Store
Lists all of the root subsegments (namespaces) on the server.

Specified by:
listRootSubSegments in interface Store
Throws:
StoreException

registerSubsegment

public SubSegment registerSubsegment(Authority parent,
                                     java.lang.String name,
                                     Authority authority)
                              throws StoreException
Description copied from interface: Store
Registers a new subsegment using an already existing authority.

Specified by:
registerSubsegment in interface Store
Parameters:
parent - The authority id to register under.
name - The name of the subsegment to register.
authority - The existing authority for the subsegment.
Throws:
StoreException

registerSubsegment

public SubSegment registerSubsegment(Authority parent,
                                     java.lang.String name,
                                     XRD xrd)
                              throws StoreException
Description copied from interface: Store
Registers a subsegment with a new authority.

Specified by:
registerSubsegment in interface Store
Parameters:
parent - The authority to register under.
name - The name of the subsegment to register.
xrd - An initial XRD that will be run through the default create pipeline and then associated with the new authority.
Throws:
StoreException

releaseSubSegment

public void releaseSubSegment(SubSegment subSegment)
                       throws StoreException
Description copied from interface: Store
Releases the descriptor information associated with a registered subsegment.

Specified by:
releaseSubSegment in interface Store
Parameters:
subSegment - The subsegment to release.
Throws:
StoreException

findRootSubSegment

public SubSegment findRootSubSegment(java.lang.String namespace)
                              throws StoreException
Description copied from interface: StoreLookup
Finds a root subsegment with a given name.

Specified by:
findRootSubSegment in interface StoreLookup
Parameters:
namespace - The namespace (root subsegment) to look for.
Returns:
The found root subsegment, or null if it could not be found.
Throws:
StoreException

findSubSegment

public SubSegment findSubSegment(Authority authority,
                                 java.lang.String name)
                          throws StoreException
Description copied from interface: StoreLookup
Finds a subsegment with a given authority and name.

Specified by:
findSubSegment in interface StoreLookup
Parameters:
authority - The authority to look for.
name - The subsegment name to look for.
Returns:
The found subsegment, or null if it could not be found.
Throws:
StoreException

getSubSegmentAuthority

public Authority getSubSegmentAuthority(SubSegment subSegment)
                                 throws StoreException
Description copied from interface: StoreLookup
Returns the authority of this subsegment.

Specified by:
getSubSegmentAuthority in interface StoreLookup
Parameters:
subSegment - subsegment
Returns:
The authority for this subsegment; null if this store has no authority for the subsegment
Throws:
StoreException

getSubSegmentParentAuthority

public Authority getSubSegmentParentAuthority(SubSegment subSegment)
                                       throws StoreException
Description copied from interface: StoreLookup
Returns the authority of this subsegment.

Specified by:
getSubSegmentParentAuthority in interface StoreLookup
Parameters:
subSegment - subsegment
Returns:
The authority for this subsegment; null if this store has no authority for the subsegment
Throws:
StoreException

getAuthorityQxris

public java.lang.String[] getAuthorityQxris(Authority authority)
                                     throws StoreException
Description copied from interface: StoreBetterLookup
Gets all full XRIs that lead to this authority. If it is a root authority, this is just the namespace, otherwise it's the namespace of the root authority plus names of subsegments. Usually just one result, unless there are aliases in the subsegment chain.

Specified by:
getAuthorityQxris in interface StoreBetterLookup
Parameters:
authority - Authority for which all full names should be found
Returns:
An array of QXRIs.
Throws:
StoreException

getAuthorityQxris

public java.lang.String[] getAuthorityQxris(Authority authority,
                                            boolean reassignable,
                                            boolean persistent)
                                     throws StoreException
Description copied from interface: StoreBetterLookup
Gets all full XRIs that lead to this authority. If it is a root authority, this is just the namespace, otherwise it's the namespace of the root authority plus names of subsegments. Usually just one result, unless there are aliases in the subsegment chain. The reassignable and persistent parameters can be used to only read i-names or i-numbers from the store.

Specified by:
getAuthorityQxris in interface StoreBetterLookup
Parameters:
authority - Authority for which all full names should be found
reassignable - Whether to consider reassignable subsegments when constructing XRIs.
persistent - Whether to consider persistent subsegments when constructing XRIs.
Returns:
An array of QXRIs.
Throws:
StoreException

listAuthorities

public Authority[] listAuthorities()
                            throws StoreException
Description copied from interface: StoreBetterLookup
Returns all authorities.

Specified by:
listAuthorities in interface StoreBetterLookup
Returns:
A list of authorities
Throws:
StoreException

getAuthoritySubSegments

public SubSegment[] getAuthoritySubSegments(Authority authority)
                                     throws StoreException
Description copied from interface: StoreBetterLookup
Gets all subsegments that lead to this authority.

Specified by:
getAuthoritySubSegments in interface StoreBetterLookup
Parameters:
authority - authority for which subsegments should be found
Returns:
An array of subsegments.
Throws:
StoreException

getAuthorityChildSubSegments

public SubSegment[] getAuthorityChildSubSegments(Authority authority)
                                          throws StoreException
Description copied from interface: StoreBetterLookup
Gets all subsegments that have this authority as parent.

Specified by:
getAuthorityChildSubSegments in interface StoreBetterLookup
Parameters:
authority - authority for which child subsegments should be found
Returns:
An array of subsegments.
Throws:
StoreException

getSynonymSubSegments

public SubSegment[] getSynonymSubSegments(Authority parent,
                                          Authority authority)
                                   throws StoreException
Description copied from interface: StoreBetterLookup
Gets all subsegments with a given parent authority and authority. All returned subsegments have the same parent authority and authority, and are therefore local synonyms.

Specified by:
getSynonymSubSegments in interface StoreBetterLookup
Parameters:
parent - authority for which child subsegments should be found
authority - authority for which subsegments should be found
Returns:
An array of subsegments.
Throws:
StoreException

listSubSegments

public SubSegment[] listSubSegments()
                             throws StoreException
Description copied from interface: StoreBetterLookup
Returns all subsegments.

Specified by:
listSubSegments in interface StoreBetterLookup
Returns:
A list of subsegments
Throws:
StoreException

getAuthorityCount

public java.lang.Long getAuthorityCount()
                                 throws StoreException
Specified by:
getAuthorityCount in interface StoreStatistics
Returns:
The number of authorities in the store
Throws:
StoreException

getSubSegmentCount

public java.lang.Long getSubSegmentCount()
                                  throws StoreException
Specified by:
getSubSegmentCount in interface StoreStatistics
Returns:
The number of subsegments in the store
Throws:
StoreException

localLookup

public Authority localLookup(XRIAuthority authorityPath)
                      throws StoreException
Description copied from interface: StoreLookup
This method iterates through all subsegments of the given authority path and returns its final authority. This only works if all subsegments are part of this store and if the whole authority path is in one of its root namespaces.

Specified by:
localLookup in interface StoreLookup
Parameters:
authorityPath - The XRI authority path to resolve
Returns:
The matching authority or null
Throws:
StoreException

backupStore

public void backupStore(java.io.OutputStream stream)
                 throws StoreException
Description copied from interface: StoreBackupable
Backups all store contents into a stream.

Specified by:
backupStore in interface StoreBackupable
Parameters:
stream - Stream to write all data into.
Throws:
StoreException

restoreStore

public void restoreStore(java.io.InputStream stream)
                  throws StoreException
Description copied from interface: StoreBackupable
Restores all store contents from a stream.

Specified by:
restoreStore in interface StoreBackupable
Parameters:
stream - Stream to read all data from.
Throws:
StoreException

createAuthority

public Authority createAuthority(XRD xrd)
                          throws StoreException
Description copied from interface: Store
Creates an authority without associating it with a subsegment. You probably want to use registerSubsegment() instead, which creates both and authority and an associated subsegment.

Specified by:
createAuthority in interface Store
Parameters:
xrd - An initial XRD that will be run through the default create pipeline and then associated with the new authority.
Throws:
StoreException

setXrd

public void setXrd(Authority authority,
                   XRD xrd)
            throws StoreException
Description copied from interface: StoreEditable
Sets the XRD of an authority.

Specified by:
setXrd in interface StoreEditable
Parameters:
authority - The authority.
xrd - The XRD to set for the authority.
Throws:
StoreException

getAuthorityAttributes

public java.util.Map<java.lang.String,java.lang.String> getAuthorityAttributes(Authority authority)
                                                                        throws StoreException
Description copied from interface: StoreAttributable
Gets attributes from an authority.

Specified by:
getAuthorityAttributes in interface StoreAttributable
Parameters:
authority - The authority.
Returns:
The attributes, or null.
Throws:
StoreException

getStoreAttributes

public java.util.Map<java.lang.String,java.lang.String> getStoreAttributes()
                                                                    throws StoreException
Description copied from interface: StoreAttributable
Gets attributes from the store.

Specified by:
getStoreAttributes in interface StoreAttributable
Returns:
The attributes, or null.
Throws:
StoreException

getSubSegmentAttributes

public java.util.Map<java.lang.String,java.lang.String> getSubSegmentAttributes(SubSegment subSegment)
                                                                         throws StoreException
Description copied from interface: StoreAttributable
Gets attributes from a subsegment.

Specified by:
getSubSegmentAttributes in interface StoreAttributable
Parameters:
subSegment - The subsegment.
Returns:
The attributes, or null.
Throws:
StoreException

listAuthoritiesByAttributes

public Authority[] listAuthoritiesByAttributes(StoreAttributable.Selector selector)
                                        throws StoreException
Description copied from interface: StoreAttributable
Returns all authorities whose attributes satisfy certain conditions.

Specified by:
listAuthoritiesByAttributes in interface StoreAttributable
Parameters:
selector - An object that can select authorities based on their attributes.
Returns:
An array of authorities.
Throws:
StoreException

listSubSegmentsByAttributes

public SubSegment[] listSubSegmentsByAttributes(StoreAttributable.Selector selector)
                                         throws StoreException
Description copied from interface: StoreAttributable
Returns all subsegments whose attributes satisfy certain conditions.

Specified by:
listSubSegmentsByAttributes in interface StoreAttributable
Parameters:
selector - An object that can select authorities based on their attributes.
Returns:
An array of subsegments.
Throws:
StoreException

listAuthoritiesByAttributeValue

public Authority[] listAuthoritiesByAttributeValue(java.lang.String key,
                                                   java.lang.String value)
                                            throws StoreException
Description copied from interface: StoreAttributable
Returns all authorities with a certain attribute key/value pair.

Specified by:
listAuthoritiesByAttributeValue in interface StoreAttributable
Parameters:
key - An attribute key.
value - An attribute value.
Returns:
An array of authorities.
Throws:
StoreException

listSubSegmentsByAttributeValue

public SubSegment[] listSubSegmentsByAttributeValue(java.lang.String key,
                                                    java.lang.String value)
                                             throws StoreException
Description copied from interface: StoreAttributable
Returns all subsegments whose attributes satisfy certain conditions.

Specified by:
listSubSegmentsByAttributeValue in interface StoreAttributable
Parameters:
key - An attribute key.
value - An attribute value.
Returns:
An array of subsegments.
Throws:
StoreException

listAuthoritiesByIndex

public Authority[] listAuthoritiesByIndex(java.lang.String indx)
                                   throws StoreException
Description copied from interface: StoreAttributable
Returns all authorities with a certain index.

Specified by:
listAuthoritiesByIndex in interface StoreAttributable
Parameters:
indx - The index to look for.
Returns:
An array of authorities.
Throws:
StoreException

listSubSegmentsByIndex

public SubSegment[] listSubSegmentsByIndex(java.lang.String indx)
                                    throws StoreException
Description copied from interface: StoreAttributable
Returns all subsegments with a certain index.

Specified by:
listSubSegmentsByIndex in interface StoreAttributable
Parameters:
indx - The index to look for.
Returns:
An array of subsegments.
Throws:
StoreException

setAuthorityAttributes

public void setAuthorityAttributes(Authority authority,
                                   java.util.Map<java.lang.String,java.lang.String> attributes)
                            throws StoreException
Description copied from interface: StoreAttributable
Associates attributes with an authority.

Specified by:
setAuthorityAttributes in interface StoreAttributable
Parameters:
authority - The authority.
attributes - The attributes.
Throws:
StoreException

setStoreAttributes

public void setStoreAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
                        throws StoreException
Description copied from interface: StoreAttributable
Associates attributes with the store.

Specified by:
setStoreAttributes in interface StoreAttributable
Parameters:
attributes - The attributes.
Throws:
StoreException

setSubSegmentAttributes

public void setSubSegmentAttributes(SubSegment subSegment,
                                    java.util.Map<java.lang.String,java.lang.String> attributes)
                             throws StoreException
Description copied from interface: StoreAttributable
Associates attributes with a subsegment.

Specified by:
setSubSegmentAttributes in interface StoreAttributable
Parameters:
subSegment - The subsegment.
attributes - The attributes.
Throws:
StoreException

getAuthorityIndex

public java.lang.String getAuthorityIndex(Authority authority)
                                   throws StoreException
Description copied from interface: StoreAttributable
Gets the index of the authority.

Specified by:
getAuthorityIndex in interface StoreAttributable
Throws:
StoreException

getSubSegmentIndex

public java.lang.String getSubSegmentIndex(SubSegment subSegment)
                                    throws StoreException
Description copied from interface: StoreAttributable
Gets the index of the subsegment.

Specified by:
getSubSegmentIndex in interface StoreAttributable
Parameters:
subSegment - The subsegment.
Throws:
StoreException

setAuthorityIndex

public void setAuthorityIndex(Authority authority,
                              java.lang.String indx)
                       throws StoreException
Description copied from interface: StoreAttributable
Associates an index with an authority.

Specified by:
setAuthorityIndex in interface StoreAttributable
Parameters:
authority - The authority.
indx - The index for the authority.
Throws:
StoreException

setSubSegmentIndex

public void setSubSegmentIndex(SubSegment subSegment,
                               java.lang.String indx)
                        throws StoreException
Description copied from interface: StoreAttributable
Associates an index with a subsegment.

Specified by:
setSubSegmentIndex in interface StoreAttributable
Parameters:
subSegment - The subsegment.
indx - The index for the subsegment.
Throws:
StoreException


Copyright © 2005-2012. All Rights Reserved.