org.priha.path
Class PathFactory

java.lang.Object
  extended by org.priha.path.PathFactory

public class PathFactory
extends java.lang.Object

Gets Paths from a local storage.

If you possibly can, you should use PathFactory to get yourself a Path object. This factory class stores the Paths in a WeakHashMap, and is always guaranteed to give you a good Path object. In most cases, this is a lot faster than calling the regular Path.Path(String) constructor, since path parsing can take quite a bit of time.


Constructor Summary
PathFactory()
           
 
Method Summary
static java.lang.String getMappedPath(NamespaceMapper ns, Path path)
           
static Path getPath(NamespaceMapper ns, java.lang.String path)
          Turns a String to a Path.
static Path getPath(java.lang.String property)
          Turns a FQN-representation of a Path into a real Path.
static void reset()
          This method clears up the PathFactory cache maps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathFactory

public PathFactory()
Method Detail

reset

public static void reset()
This method clears up the PathFactory cache maps. It is mandatory that this method is called every time when you change namespace mappings, otherwise the results of getPath() might no longer be correct.


getPath

public static Path getPath(NamespaceMapper ns,
                           java.lang.String path)
                    throws javax.jcr.NamespaceException,
                           javax.jcr.RepositoryException
Turns a String to a Path.

Parameters:
path - A String representing the Path
Returns:
A valid Path object.
Throws:
javax.jcr.RepositoryException - If there is a problem parsing the Path
javax.jcr.NamespaceException - If the Path contains a prefix which could not be parsed.

getMappedPath

public static java.lang.String getMappedPath(NamespaceMapper ns,
                                             Path path)
                                      throws javax.jcr.NamespaceException,
                                             javax.jcr.RepositoryException
Throws:
javax.jcr.NamespaceException
javax.jcr.RepositoryException

getPath

public static Path getPath(java.lang.String property)
                    throws javax.jcr.NamespaceException,
                           javax.jcr.RepositoryException
Turns a FQN-representation of a Path into a real Path.

Parameters:
property -
Returns:
Throws:
javax.jcr.NamespaceException
javax.jcr.RepositoryException