info.sswap.http.representation
Class Prefixes

java.lang.Object
  extended by info.sswap.http.representation.Prefixes

public class Prefixes
extends java.lang.Object

Represents the map of prefixes and provides methods for expanding prefixed QNames into URIs

Author:
Blazej Bulka

Field Summary
private  java.util.Map<java.lang.String,java.lang.String> prefixes
          The map of prefixes.
 
Constructor Summary
Prefixes()
           
Prefixes(java.util.Map<java.lang.String,java.lang.String> prefixes)
          Creates a new Prefixes object.
 
Method Summary
private  void addPredefinedPrefixes()
          Adds predefined prefixes to the map of prefixes.
 java.lang.String expandPotentialQName(java.lang.String qName)
          Assumes that the argument is a QName and attempts to expand it to the absolute URI.
private static java.lang.String getLocalName(java.lang.String parameter)
          Extracts the local part (i.e., the part after the prefix and the colon) from the argument.
private static java.lang.String getPotentialPrefix(java.lang.String parameter)
          Extracts a potential prefix from the argument.
 java.util.Map<java.lang.String,java.lang.String> getPrefixMap()
           
private static boolean hasPotentialPrefix(java.lang.String parameter)
          Checks whether the argument has (potentially) a prefix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prefixes

private java.util.Map<java.lang.String,java.lang.String> prefixes
The map of prefixes. The keys are the prefix names, and the values are the URIs for the corresponding namespace.

Constructor Detail

Prefixes

public Prefixes()

Prefixes

public Prefixes(java.util.Map<java.lang.String,java.lang.String> prefixes)
Creates a new Prefixes object.

Parameters:
prefixes - the map with prefixes (the keys are prefix names, and the values are the URIs for the corresponding namespace).
Method Detail

getPrefixMap

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

addPredefinedPrefixes

private void addPredefinedPrefixes()
Adds predefined prefixes to the map of prefixes. This ensures that standard prefixes (like "rdf", "rdfs", "owl", "xsd" and "sswap") are always accessible.


expandPotentialQName

public java.lang.String expandPotentialQName(java.lang.String qName)
Assumes that the argument is a QName and attempts to expand it to the absolute URI. If the argument is not a QName or if it uses an unknown namespace prefix, this method returns the arguments without any modifications

Parameters:
qName - the potential QName to be expanded to the absolute URI
Returns:
the expanded absoluteURI or the argument passed to this method

hasPotentialPrefix

private static boolean hasPotentialPrefix(java.lang.String parameter)
Checks whether the argument has (potentially) a prefix. The method checks for the first colon in the URI, and if there is one, it assumes that there is a potential prefix.

Parameters:
parameter - the argument to be checked whether it contains a potential prefix
Returns:
true if the argument can potentially have a prefix, false otherwise

getPotentialPrefix

private static java.lang.String getPotentialPrefix(java.lang.String parameter)
                                            throws java.lang.IllegalArgumentException
Extracts a potential prefix from the argument. The method assumes that everything up to the first colon is a potential prefix. If the argument does not have a colon (i.e., cannot have a potential prefix, as indicated by hasPotentialPrefix() method returning false), this method throws an IllegalArgumentException

Parameters:
parameter - the string from which the potential prefix should be extracted
Returns:
the potential prefix
Throws:
java.lang.IllegalArgumentException - if the argument cannot contain a prefix

getLocalName

private static java.lang.String getLocalName(java.lang.String parameter)
Extracts the local part (i.e., the part after the prefix and the colon) from the argument. The method assumes that everything up to the first colon is a potential prefix, and everything after the first colon is the local part. If the argument does not have a colon (i.e., cannot have a prefix, as indicated by hasPotentialPrefix() method returning false), this method throws an IllegalArgumentException.

Parameters:
parameter - the string from which the local part should be extracted.
Returns:
the potential local part
Throws:
java.lang.IllegalArgumentException - if the argument cannot contain a prefix


Copyright (c) 2010, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.