public class Context extends Object implements ReadContext, Cloneable
Modifier and Type | Field and Description |
---|---|
protected Map<String,Set<String>> |
allMap |
protected com.hp.hpl.jena.shared.PrefixMapping |
allPrefixes |
protected String |
base |
protected boolean |
completedMappingTable |
static Pattern |
labelPattern |
protected int |
nameCount |
protected Map<String,String> |
nameToURI |
static com.hp.hpl.jena.rdf.model.Resource[] |
PROP_TYPES_TO_SHORTEN |
static com.hp.hpl.jena.rdf.model.Resource[] |
RES_TYPES_TO_SHORTEN |
protected boolean |
sortProperties |
protected Map<String,String> |
uriToName |
protected Map<String,ContextPropertyInfo> |
uriToProp |
Constructor and Description |
---|
Context()
Construct an empty context
|
Context(com.hp.hpl.jena.rdf.model.Model ontology)
Construct a context, initialized from an ontology.
|
Context(String base)
Construct a context with a defined base URI
|
Modifier and Type | Method and Description |
---|---|
void |
checkShortnames()
Check to see if there are any shortnames that map to multiple
URIs.
|
Context |
clone()
Clone this context, so that JSON rendering using the clone does
not affect this context.
|
protected void |
completeContext()
URIs that have no preferred shortname are given their alternative
shortname as their preferred shortname.
|
protected void |
createPropertyRecord(String name,
com.hp.hpl.jena.rdf.model.Resource res) |
ContextPropertyInfo |
findProperty(com.hp.hpl.jena.rdf.model.Property p)
Find the info record for a property.
|
ContextPropertyInfo |
findProperty(com.hp.hpl.jena.rdf.model.Property p,
String name)
Find the info record for a property.
|
String |
forceShorten(String uri) |
String |
getBase()
Return the base URI assumed during serialization
|
protected String |
getLocalName(String uri) |
String |
getNameForURI(String uri)
Lookup the shortened form for a URI, can apply to non-properties (e.g.
|
ContextPropertyInfo |
getPropertyByName(String name)
Lookup the definition of a property based on its mapped name
|
ContextPropertyInfo |
getPropertyByURI(String uri)
Lookup the definition of a property based on its URI
|
String |
getURIfromName(String name)
Lookup the URI for a shortened name.
|
protected boolean |
isNameFree(String name)
Test if a name is not already in use
|
boolean |
isSortProperties() |
protected void |
loadAnnotations(Set<String> notThese,
Set<String> seen,
com.hp.hpl.jena.rdf.model.ResIterator ri,
boolean isProperty,
com.hp.hpl.jena.shared.PrefixMapping prefixes) |
void |
loadVocabularyAnnotations(Set<String> seen,
com.hp.hpl.jena.rdf.model.Model m) |
void |
loadVocabularyAnnotations(Set<String> notThese,
com.hp.hpl.jena.rdf.model.Model m,
com.hp.hpl.jena.shared.PrefixMapping prefixes)
Scan the given vocabulary file to find shortname and property type
annotations.
|
protected boolean |
nameUpdateOK(String name,
String uri) |
Set<String> |
preferredNames()
The set of all mapped names
|
protected void |
recordAltName(String uri,
com.hp.hpl.jena.shared.PrefixMapping pm) |
protected void |
recordAltName(String name,
String uri)
Record an alternative named to use to to shorted a URI.
|
void |
recordPreferredName(String name,
String uri)
Record the preferred name to use to shorten a URI.
|
protected void |
recordShortname(String name,
String uri)
Record all preferred shortname => uri mappings that we find (even ones that
the older code discards) so that we can detect clashes later.
|
void |
setBase(String base)
Set the base URI
|
void |
setProperty(String uri,
ContextPropertyInfo prop) |
void |
setSorted(boolean sorted)
Set flag to indicate if properties should be sorted in the encoding
|
String |
toString() |
protected String base
protected Map<String,ContextPropertyInfo> uriToProp
protected int nameCount
protected boolean sortProperties
protected boolean completedMappingTable
protected final com.hp.hpl.jena.shared.PrefixMapping allPrefixes
public static com.hp.hpl.jena.rdf.model.Resource[] RES_TYPES_TO_SHORTEN
public static com.hp.hpl.jena.rdf.model.Resource[] PROP_TYPES_TO_SHORTEN
public static Pattern labelPattern
public Context()
public Context(com.hp.hpl.jena.rdf.model.Model ontology)
ontology
- ontology model used for naming, and annotation to control serializationspublic Context(String base)
base
- URI used for relative referencingpublic Context clone()
public void loadVocabularyAnnotations(Set<String> seen, com.hp.hpl.jena.rdf.model.Model m)
public void loadVocabularyAnnotations(Set<String> notThese, com.hp.hpl.jena.rdf.model.Model m, com.hp.hpl.jena.shared.PrefixMapping prefixes)
notThese
. Update
notThese with any new URIs once we're done.protected void loadAnnotations(Set<String> notThese, Set<String> seen, com.hp.hpl.jena.rdf.model.ResIterator ri, boolean isProperty, com.hp.hpl.jena.shared.PrefixMapping prefixes)
protected void createPropertyRecord(String name, com.hp.hpl.jena.rdf.model.Resource res)
protected void recordAltName(String name, String uri)
protected void recordAltName(String uri, com.hp.hpl.jena.shared.PrefixMapping pm)
public void recordPreferredName(String name, String uri)
protected void recordShortname(String name, String uri)
protected void completeContext()
public void checkShortnames()
public String getBase()
getBase
in interface ReadContext
public void setBase(String base)
public void setSorted(boolean sorted)
public boolean isSortProperties()
isSortProperties
in interface ReadContext
public ContextPropertyInfo getPropertyByURI(String uri)
public ContextPropertyInfo getPropertyByName(String name)
getPropertyByName
in interface ReadContext
public String getNameForURI(String uri)
getNameForURI
in interface ReadContext
public String forceShorten(String uri)
forceShorten
in interface ReadContext
public String getURIfromName(String name)
getURIfromName
in interface ReadContext
public ContextPropertyInfo findProperty(com.hp.hpl.jena.rdf.model.Property p)
findProperty
in interface ReadContext
public ContextPropertyInfo findProperty(com.hp.hpl.jena.rdf.model.Property p, String name)
protected boolean isNameFree(String name)
public void setProperty(String uri, ContextPropertyInfo prop)
Copyright © 2014. All Rights Reserved.