|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.modeshape.graph.property.basic.GraphNamespaceRegistry
@NotThreadSafe public class GraphNamespaceRegistry
A NamespaceRegistry
implementation that stores the namespaces in a Graph as individual nodes for each namespace, under
a parent supplied by the constructor.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.modeshape.graph.property.NamespaceRegistry |
---|
NamespaceRegistry.Namespace |
Field Summary | |
---|---|
static Name |
DEFAULT_GENERATED_PROPERTY_NAME
|
static Name |
DEFAULT_URI_PROPERTY_NAME
|
static String |
GENERATED_PREFIX
|
protected static Pattern |
GENERATED_PREFIX_PATTERN
|
Constructor Summary | |
---|---|
GraphNamespaceRegistry(Graph store,
Path parentOfNamespaceNodes,
Name uriPropertyName,
Name generatedPropertyName,
Property... additionalProperties)
|
Method Summary | |
---|---|
protected Map<String,String> |
doRegister(Map<String,String> newUrisByPrefix)
|
protected boolean |
doUnregister(String uri)
|
protected String |
generatePrefix(Set<String> existingGeneratedPrefixes)
|
String |
getDefaultNamespaceUri()
Return the namespace URI that is currently mapped to the empty prefix, or null if there is no current default namespace. |
String |
getNamespaceForPrefix(String prefix)
Get the namespace URI for the supplied prefix. |
Set<NamespaceRegistry.Namespace> |
getNamespaces()
Obtain a snapshot of all of the namespaces registered at the time this method is called. |
Path |
getParentOfNamespaceNodes()
|
protected String |
getPrefixFor(Path path)
|
protected String |
getPrefixFor(String name,
int counter)
|
String |
getPrefixForNamespaceUri(String namespaceUri,
boolean generateIfMissing)
Return the prefix used for the supplied namespace URI. |
Set<String> |
getRegisteredNamespaceUris()
Obtain the set of namespaces that are registered. |
protected void |
initializeCacheFromStore(NamespaceRegistry cache)
|
protected boolean |
isGeneratedPrefix(String prefix)
|
boolean |
isRegisteredNamespaceUri(String namespaceUri)
Return whether there is a registered prefix for the supplied namespace URI. |
protected String |
readPrefixFor(String namespaceUri,
boolean generateIfMissing)
|
protected String |
readUriFor(String prefix)
|
void |
refresh()
Refresh the namespaces from the persistent store, and update the embedded cache. |
void |
register(Iterable<NamespaceRegistry.Namespace> namespaces)
|
void |
register(Map<String,String> namespaceUrisByPrefix)
Register a set of namespaces. |
String |
register(String prefix,
String namespaceUri)
Register a new namespace using the supplied prefix, returning the namespace URI previously registered under that prefix. |
String |
toString()
|
boolean |
unregister(String namespaceUri)
Unregister the namespace with the supplied URI. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Name DEFAULT_URI_PROPERTY_NAME
public static final Name DEFAULT_GENERATED_PROPERTY_NAME
public static final String GENERATED_PREFIX
protected static final Pattern GENERATED_PREFIX_PATTERN
Constructor Detail |
---|
public GraphNamespaceRegistry(Graph store, Path parentOfNamespaceNodes, Name uriPropertyName, Name generatedPropertyName, Property... additionalProperties)
Method Detail |
---|
public Path getParentOfNamespaceNodes()
public String getNamespaceForPrefix(String prefix)
getNamespaceForPrefix
in interface NamespaceRegistry
prefix
- the namespace prefix
public String getPrefixForNamespaceUri(String namespaceUri, boolean generateIfMissing)
getPrefixForNamespaceUri
in interface NamespaceRegistry
namespaceUri
- the namespace URIgenerateIfMissing
- true if the namespace URI has not already been registered and the method should auto-register the
namespace with a generated prefix, or false if the method should never auto-register the namespace
null
if the namespace has not been registered
and generateIfMissing
is false
NamespaceRegistry.isRegisteredNamespaceUri(String)
public boolean isRegisteredNamespaceUri(String namespaceUri)
isRegisteredNamespaceUri
in interface NamespaceRegistry
namespaceUri
- the namespace URI
public String getDefaultNamespaceUri()
getDefaultNamespaceUri
in interface NamespaceRegistry
public void register(Iterable<NamespaceRegistry.Namespace> namespaces)
register
in interface NamespaceRegistry
NamespaceRegistry.register(java.lang.Iterable)
public void register(Map<String,String> namespaceUrisByPrefix)
namespaceUrisByPrefix
- the map of new namespace URIs by their prefixpublic String register(String prefix, String namespaceUri)
register
in interface NamespaceRegistry
prefix
- the prefix for the namespace, or null if a namesapce prefix should be generated automaticallynamespaceUri
- the namespace URI
public boolean unregister(String namespaceUri)
unregister
in interface NamespaceRegistry
namespaceUri
- the namespace URI
NamespaceRegistry.unregister(java.lang.String)
public Set<String> getRegisteredNamespaceUris()
getRegisteredNamespaceUris
in interface NamespaceRegistry
public Set<NamespaceRegistry.Namespace> getNamespaces()
namespaces
registered at the time this method is called. The resulting
set is immutable, and will not reflect changes made to the registry.
getNamespaces
in interface NamespaceRegistry
NamespaceRegistry.Namespace
objects reflecting a snapshot of the registry; never nullNamespaceRegistry.getNamespaces()
public void refresh()
public String toString()
toString
in class Object
Object.toString()
protected void initializeCacheFromStore(NamespaceRegistry cache)
protected String readUriFor(String prefix)
protected String getPrefixFor(Path path)
protected String getPrefixFor(String name, int counter)
protected boolean isGeneratedPrefix(String prefix)
protected String generatePrefix(Set<String> existingGeneratedPrefixes)
protected String readPrefixFor(String namespaceUri, boolean generateIfMissing)
protected Map<String,String> doRegister(Map<String,String> newUrisByPrefix)
protected boolean doUnregister(String uri)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |