Class ReferenceManager
public class ReferenceManager extends Object
The reference manager is a singleton class which is responsible for deriving reference URI's into references at runtime.
Raw reference factories (which are capable of actually creating fully qualified reference objects) are added with the addFactory() method. The most common method of doing so is to implement the PrefixedRootFactory as either a full class, or an anonymous inner class, providing the roots available in the current environment and the code for constructing a reference from them.
RootTranslators (which rely on other factories) are used to describe that a particular reference style (generally a high level reference like "jr://media/" or "jr://images/") should be translated to another available reference in this environment like "jr://file/". Root Translators do not directly derive references, but rather translate them to what the reference should look like in the current circumstances.
- Author:
- ctsims
-
Method Summary
Modifier and Type Method Description static ReferenceManager__()Deprecated.use instance() insteadvoidaddReferenceFactory(ReferenceFactory factory)Adds a factory for deriving reference URI's into referencesvoidaddRootTranslator(RootTranslator translator)Adds a new Translator to the current environment.voidaddSessionRootTranslator(RootTranslator translator)Adds a root translator that is maintained over the course of a session.voidclearSession()Wipes out all of the translators being maintained in the current session (IE: Any translators added via "addSessionRootTranslator".ReferencederiveReference(String uri)Derives a global reference from a URI in the current environment.ReferencederiveReference(String uri, String context)Derives a reference from a URI in the current environment.ReferencederiveReference(String uri, Reference context)Derives a reference from a URI in the current environment.ReferenceDeriveReference(String uri)Deprecated.use deriveReference insteadReferenceDeriveReference(String uri, String context)Deprecated.use deriveReference insteadReferenceDeriveReference(String uri, Reference context)Deprecated.use deriveReference insteadReferenceFactory[]getFactories()static ReferenceManagerinstance()static booleanisRelative(String URI)booleanremoveReferenceFactory(ReferenceFactory factory)voidreset()
-
Method Details
-
reset
public void reset() -
instance
- Returns:
- Singleton accessor to the global ReferenceManager.
-
__
Deprecated.use instance() instead- See Also:
instance
-
getFactories
- Returns:
- The available reference factories
-
addRootTranslator
Adds a new Translator to the current environment. -
addReferenceFactory
Adds a factory for deriving reference URI's into references- Parameters:
factory- A raw ReferenceFactory capable of creating a reference.
-
removeReferenceFactory
-
deriveReference
Derives a global reference from a URI in the current environment.- Parameters:
uri- The URI representing a global reference.- Returns:
- A reference which is identified by the provided URI.
- Throws:
InvalidReferenceException- If the current reference could not be derived by the current environment
-
deriveReference
Derives a reference from a URI in the current environment.- Parameters:
uri- The URI representing a reference.context- A reference which provides context for any relative reference accessors.- Returns:
- A reference which is identified by the provided URI.
- Throws:
InvalidReferenceException- If the current reference could not be derived by the current environment
-
deriveReference
Derives a reference from a URI in the current environment.- Parameters:
uri- The URI representing a reference.context- A reference URI which provides context for any relative reference accessors.- Returns:
- A reference which is identified by the provided URI.
- Throws:
InvalidReferenceException- If the current reference could not be derived by the current environment, or if the context URI is not valid in the current environment.
-
addSessionRootTranslator
Adds a root translator that is maintained over the course of a session. It will be globally available until the session is cleared using the "clearSession" method.- Parameters:
translator- A Root Translator that will be added to the current session
-
clearSession
public void clearSession()Wipes out all of the translators being maintained in the current session (IE: Any translators added via "addSessionRootTranslator". Used to manage a temporary set of translations for a limited amount of time. -
isRelative
- Returns:
- Whether the provided URI describes a relative reference.
-
DeriveReference
Deprecated.use deriveReference instead- Throws:
InvalidReferenceException
-
DeriveReference
@Deprecated public Reference DeriveReference(String uri, Reference context) throws InvalidReferenceExceptionDeprecated.use deriveReference instead- Throws:
InvalidReferenceException
-
DeriveReference
@Deprecated public Reference DeriveReference(String uri, String context) throws InvalidReferenceExceptionDeprecated.use deriveReference instead- Throws:
InvalidReferenceException
-