org.semanticweb.HermiT
Class Prefixes

java.lang.Object
  extended by org.semanticweb.HermiT.Prefixes
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Prefixes.ImmutablePrefixes

public class Prefixes
extends java.lang.Object
implements java.io.Serializable

This class is responsible for abbreviating IRIs. The resulting IRIs can be either
1) <uri> or
2) prefix-name:local-name where prefix-name can be empty.
Forms 1 and 2 are dependent upon a set of prefix declarations that associates prefix names with prefix IRIs. A IRI abbreviated using form 2 that uses an unregistered prefix is invalid---expanding it will result in an exception. Neither prefixes nor local names may contain colon characters. The grammar used for various parts of the IRIs is as follows:
PN_CHARS_BASE ::= [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
PN_CHARS ::= PN_CHARS_BASE | '_' | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
PN_LOCAL ::= ( PN_CHARS_BASE | '_' | [0-9] ) ( ( PN_CHARS | '.' )* PN_CHARS )?
PN_PREFIX ::= PN_CHARS_BASE ( ( PN_CHARS | '.' )* PN_CHARS )?

See Also:
Serialized Form

Nested Class Summary
static class Prefixes.ImmutablePrefixes
           
 
Field Summary
protected  java.util.regex.Pattern m_prefixIRIMatchingPattern
           
protected  java.util.Map<java.lang.String,java.lang.String> m_prefixIRIsByPrefixName
           
protected  java.util.Map<java.lang.String,java.lang.String> m_prefixNamesByPrefixIRI
           
protected static java.lang.String PN_CHARS
           
protected static java.lang.String PN_CHARS_BASE
           
protected static java.util.regex.Pattern s_localNameChecker
           
static java.util.Map<java.lang.String,java.lang.String> s_semanticWebPrefixes
           
static Prefixes STANDARD_PREFIXES
           
 
Constructor Summary
Prefixes()
           
 
Method Summary
 java.lang.String abbreviateIRI(java.lang.String iri)
           
 boolean addPrefixes(Prefixes prefixes)
          Registers all the prefixes from the supplied object.
protected  void buildPrefixIRIMatchingPattern()
           
 boolean canBeExpanded(java.lang.String iri)
          Checks whether the given IRI can be expanded
 boolean declareDefaultPrefix(java.lang.String defaultPrefixIRI)
           
 boolean declareInternalPrefixes(java.util.Collection<java.lang.String> individualIRIs, java.util.Collection<java.lang.String> anonIndividualIRIs)
          Registers HermiT's internal prefixes with this object.
 boolean declarePrefix(java.lang.String prefixName, java.lang.String prefixIRI)
           
protected  boolean declarePrefixRaw(java.lang.String prefixName, java.lang.String prefixIRI)
           
 boolean declareSemanticWebPrefixes()
          Registers the well-known Semantic Web prefixes.
 java.lang.String expandAbbreviatedIRI(java.lang.String abbreviation)
          Expands a full IRI from the abbreviated one, which is of one of the following forms: 'prefix:name', where 'prefix' is a registered prefix name (can be empty), or '<iri>', where 'iri' is an IRI.
 java.lang.String getPrefixIRI(java.lang.String prefixName)
           
 java.util.Map<java.lang.String,java.lang.String> getPrefixIRIsByPrefixName()
           
 java.lang.String getPrefixName(java.lang.String prefixIRI)
           
static boolean isInternalIRI(java.lang.String iri)
          Determines whether the supplied IRI is used internally by HermiT.
static boolean isValidLocalName(java.lang.String localName)
          Determines whether the supplied string is a valid local name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PN_CHARS_BASE

protected static final java.lang.String PN_CHARS_BASE
See Also:
Constant Field Values

PN_CHARS

protected static final java.lang.String PN_CHARS
See Also:
Constant Field Values

s_localNameChecker

protected static final java.util.regex.Pattern s_localNameChecker

s_semanticWebPrefixes

public static final java.util.Map<java.lang.String,java.lang.String> s_semanticWebPrefixes

STANDARD_PREFIXES

public static final Prefixes STANDARD_PREFIXES

m_prefixIRIsByPrefixName

protected final java.util.Map<java.lang.String,java.lang.String> m_prefixIRIsByPrefixName

m_prefixNamesByPrefixIRI

protected final java.util.Map<java.lang.String,java.lang.String> m_prefixNamesByPrefixIRI

m_prefixIRIMatchingPattern

protected java.util.regex.Pattern m_prefixIRIMatchingPattern
Constructor Detail

Prefixes

public Prefixes()
Method Detail

buildPrefixIRIMatchingPattern

protected void buildPrefixIRIMatchingPattern()

abbreviateIRI

public java.lang.String abbreviateIRI(java.lang.String iri)

expandAbbreviatedIRI

public java.lang.String expandAbbreviatedIRI(java.lang.String abbreviation)
Expands a full IRI from the abbreviated one, which is of one of the following forms: 'prefix:name', where 'prefix' is a registered prefix name (can be empty), or '<iri>', where 'iri' is an IRI.


canBeExpanded

public boolean canBeExpanded(java.lang.String iri)
Checks whether the given IRI can be expanded


declarePrefix

public boolean declarePrefix(java.lang.String prefixName,
                             java.lang.String prefixIRI)

declarePrefixRaw

protected boolean declarePrefixRaw(java.lang.String prefixName,
                                   java.lang.String prefixIRI)

declareDefaultPrefix

public boolean declareDefaultPrefix(java.lang.String defaultPrefixIRI)

getPrefixIRIsByPrefixName

public java.util.Map<java.lang.String,java.lang.String> getPrefixIRIsByPrefixName()

getPrefixIRI

public java.lang.String getPrefixIRI(java.lang.String prefixName)

getPrefixName

public java.lang.String getPrefixName(java.lang.String prefixIRI)

declareInternalPrefixes

public boolean declareInternalPrefixes(java.util.Collection<java.lang.String> individualIRIs,
                                       java.util.Collection<java.lang.String> anonIndividualIRIs)
Registers HermiT's internal prefixes with this object.

Parameters:
individualIRIs - the collection of IRIs used in individuals (used for registering nominal prefix names)
Returns:
'true' if this object already contained one of the internal prefix names

declareSemanticWebPrefixes

public boolean declareSemanticWebPrefixes()
Registers the well-known Semantic Web prefixes.

Returns:
'true' if this object already contained one of the well-known prefixes

addPrefixes

public boolean addPrefixes(Prefixes prefixes)
Registers all the prefixes from the supplied object.

Parameters:
prefixes - the object from which the prefixes are taken
Returns:
'true' if this object already contained one of the prefixes from the supplied object

isInternalIRI

public static boolean isInternalIRI(java.lang.String iri)
Determines whether the supplied IRI is used internally by HermiT.


isValidLocalName

public static boolean isValidLocalName(java.lang.String localName)
Determines whether the supplied string is a valid local name.