com.fatwire.cs.core.uri
Class AssemblerEngine

java.lang.Object
  extended by com.fatwire.cs.core.uri.AssemblerEngine

public final class AssemblerEngine
extends java.lang.Object

This class is a utility that manages the invocation of the Assembler interface.

Multiple assemblers can be registered, with a priority, and then used together to encode and decod URIs for applications. For example, unless otherwise specified, the AssemblerEngine.assemble(com.fatwire.cs.core.uri.Definition, java.lang.String) method will always construct URIs using the top-ranked assembler.

A user may request that a specific assembler be used to generate a URI. If the specified assembler has been registered, then the URI will be constructed using it.

This class also manages the sequential invocation of the AssemblerEngine.disassemble(java.net.URI, com.fatwire.cs.core.uri.Definition.ContainerType) method. Each registered assembler will return null if it is unable to identify the input URI as its own. Once the highest-ranked assembler successfully disassembles the input URI, the method returns.

This class also handles configuration and registration of assemblers. It is thread-safe.

Since:
26-Oct-2004 1:58:54 PM

Method Summary
 java.net.URI assemble(Definition definition, java.lang.String assembler)
          This method assembles the Definition into a URI using the assembler specified.
 Definition disassemble(java.net.URI uri, Definition.ContainerType type)
          This method attempts to disassemble a URI using all registered assemblers until a match is found.
static java.lang.String getAssemblerClassnamePropName(int i)
          Get the classname property name for the URI Assembler given the rank index specified
static java.lang.String getAssemblerShortFormPropName(int i)
          Get the shortform property name for the URI Assembler given the rank index specified
static AssemblerEngine newInstance(java.util.Properties registrationProps, java.util.Properties assemblerProps)
          Construct an AssemblerEngine given the properties specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static AssemblerEngine newInstance(java.util.Properties registrationProps,
                                          java.util.Properties assemblerProps)
Construct an AssemblerEngine given the properties specified. The properties contain information regarding: in properties with names corresponding to the following:

Parameters:
registrationProps - properties containing information about currently registered assemblers
assemblerProps - properties containing information that will be passed to all registered assemblers. These are the properties defined in Assembler.setProperties(Properties).
Returns:
fully constructed and populated AssemblerEngine.

getAssemblerClassnamePropName

public static java.lang.String getAssemblerClassnamePropName(int i)
Get the classname property name for the URI Assembler given the rank index specified

Parameters:
i - rank
Returns:
classname property name for the URI Assembler

getAssemblerShortFormPropName

public static java.lang.String getAssemblerShortFormPropName(int i)
Get the shortform property name for the URI Assembler given the rank index specified

Parameters:
i - rank
Returns:
shortform property name for the URI Assembler

assemble

public java.net.URI assemble(Definition definition,
                             java.lang.String assembler)
                      throws java.net.URISyntaxException
This method assembles the Definition into a URI using the assembler specified. If no assembler (i.e. null) is specified, the default assembler is used

Parameters:
definition - Definition
assembler - Assembler shortform name
Returns:
URI
Throws:
java.net.URISyntaxException - on error

disassemble

public Definition disassemble(java.net.URI uri,
                              Definition.ContainerType type)
                       throws java.net.URISyntaxException
This method attempts to disassemble a URI using all registered assemblers until a match is found.

Parameters:
uri - URI to decode
type - ContainerType that this is being decoded in
Returns:
Definition or null if no assembler claims ownership
Throws:
java.net.URISyntaxException - if an assembler chokes on the URI to disassemble.