|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mulgara.jena.shared.impl.PrefixMappingImpl
public class PrefixMappingImpl
An implementation of PrefixMapping. The mappings are stored in a pair of hash tables, one per direction. The test for a legal prefix is left to xerces's XMLChar.isValidNCName() predicate.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.mulgara.jena.shared.PrefixMapping |
|---|
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException |
| Field Summary | |
|---|---|
protected boolean |
locked
|
protected Map<String,String> |
prefixToURI
|
protected Map<String,String> |
URItoPrefix
|
| Fields inherited from interface org.mulgara.jena.shared.PrefixMapping |
|---|
Extended, Standard |
| Constructor Summary | |
|---|---|
PrefixMappingImpl()
|
|
| Method Summary | |
|---|---|
protected void |
checkUnlocked()
|
protected boolean |
equals(PrefixMappingImpl other)
|
protected boolean |
equalsByMap(PrefixMapping other)
|
String |
expandPrefix(String prefixed)
Expand a prefixed URI. |
protected String |
get(String prefix)
|
Map<String,String> |
getNsPrefixMap()
Return a copy of the internal mapping from names to URI strings. |
String |
getNsPrefixURI(String prefix)
Get the URI bound to a specific prefix, null if there isn't one. |
String |
getNsURIPrefix(String uri)
Answer the prefix for the given URI, or null if there isn't one. |
static boolean |
isNiceURI(String uri)
|
PrefixMapping |
lock()
Lock the PrefixMapping so that changes can no longer be made to it. |
static boolean |
notNameChar(char ch)
answer true iff this is not a legal NCName character, ie, is a possible split-point start. |
String |
qnameFor(String uri)
Answer the qname for uri which uses a prefix from this
mapping, or null if there isn't one. |
protected void |
regenerateReverseMapping()
|
PrefixMapping |
removeNsPrefix(String prefix)
Remove any existing maplet with the given prefix name and answer this mapping. |
protected boolean |
sameAs(PrefixMappingImpl other)
|
boolean |
samePrefixMappingAs(PrefixMapping other)
Answer true iff this prefix-mappings are equal, that is, map the same prefixes to the same URIs; same as this.getNsPrefixMap().equals( other.getNsPrefixMap() ) except that it may avoid unnecessary Map creations. |
protected void |
set(String prefix,
String uri)
|
PrefixMapping |
setNsPrefix(String prefix,
String uri)
Specify the prefix name for a URI prefix string. |
PrefixMapping |
setNsPrefixes(Map<String,String> other)
Add the bindings in the prefixToURI to our own. |
PrefixMapping |
setNsPrefixes(PrefixMapping other)
Add the bindings of other to our own. |
String |
shortForm(String uri)
Compress the URI using the prefix mapping. |
String |
toString()
Answer a readable (we hope) representation of this prefix mapping. |
PrefixMapping |
withDefaultMappings(PrefixMapping other)
Answer this PrefixMapping after updating it with the (p, u)
mappings in other where neither p nor
u appear in this mapping. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Map<String,String> prefixToURI
protected Map<String,String> URItoPrefix
protected boolean locked
| Constructor Detail |
|---|
public PrefixMappingImpl()
| Method Detail |
|---|
protected void set(String prefix,
String uri)
protected String get(String prefix)
public PrefixMapping lock()
PrefixMapping
lock in interface PrefixMapping
public PrefixMapping setNsPrefix(String prefix,
String uri)
PrefixMappingA prefix name must be a valid NCName, or the empty string. The empty string is reserved to mean "the default namespace".
Need not check the RFC2396 validity of the URI. Bad URIs are either silently ignored or behave as if they were good. The earlier restriction that the URI should end with a non-NCName character has been removed.
setNsPrefix in interface PrefixMappingprefix - the string to be used for the prefix.uri - the URI prefix to be named
public PrefixMapping removeNsPrefix(String prefix)
PrefixMappingThe reverse URI-to-prefix mapping is updated, but if there are multiple prefixes for the removed URI it is unspecified which of them will be chosen.
removeNsPrefix in interface PrefixMappingprefix - the prefix string to remove
protected void regenerateReverseMapping()
protected void checkUnlocked()
public static boolean isNiceURI(String uri)
public PrefixMapping setNsPrefixes(PrefixMapping other)
setNsPrefixes in interface PrefixMappingother - the PrefixMapping whose bindings we are to add to this.
public PrefixMapping withDefaultMappings(PrefixMapping other)
(p, u)
mappings in other where neither p nor
u appear in this mapping.
withDefaultMappings in interface PrefixMappingpublic PrefixMapping setNsPrefixes(Map<String,String> other)
setNsPrefixes in interface PrefixMappingother - the Map whose bindings we are to add to this.
public String getNsPrefixURI(String prefix)
PrefixMapping
getNsPrefixURI in interface PrefixMappingprefix - the prefix name to be looked up
public Map<String,String> getNsPrefixMap()
PrefixMapping
getNsPrefixMap in interface PrefixMappingpublic String getNsURIPrefix(String uri)
PrefixMapping
getNsURIPrefix in interface PrefixMappinguri - the uri whose prefix is to be found
public String expandPrefix(String prefixed)
expandPrefix in interface PrefixMappingprefixed - a QName or URI
public String toString()
toString in class Objectpublic String qnameFor(String uri)
uri which uses a prefix from this
mapping, or null if there isn't one.
Relies on splitNamespace to carve uri into namespace and
localname components; this ensures that the localname is legal and we just
have to (reverse-)lookup the namespace in the prefix table.
qnameFor in interface PrefixMappingPrefixMapping.qnameFor(java.lang.String)public String shortForm(String uri)
shortForm in interface PrefixMappinguri - the URI string to try and prefix-compress
public boolean samePrefixMappingAs(PrefixMapping other)
PrefixMappingthis.getNsPrefixMap().equals( other.getNsPrefixMap() )except that it may avoid unnecessary Map creations.
samePrefixMappingAs in interface PrefixMappingprotected boolean equals(PrefixMappingImpl other)
protected boolean sameAs(PrefixMappingImpl other)
protected final boolean equalsByMap(PrefixMapping other)
public static boolean notNameChar(char ch)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||