|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.fatwire.cs.core.uri.AbstractAssembler
public abstract class AbstractAssembler
Base implementation of an Assembler. This class implements all the methods of the Assembler interface, but calls out to abstract methods in order to get relevant components for URI assembly and disassembly. This class also provides a number of utility methods that can be helpful in assembly and disassembly. The QueryAssembler
class is the primary implementation and is most likely the first place to start in developing a custom assembler.
Assembler
, QueryAssembler
Nested Class Summary | |
---|---|
protected static class |
AbstractAssembler.AssemblyContext This class is a wrapper over the Definition object. |
protected static class |
AbstractAssembler.DisassemblyContext This class is a wrapper over the incoming URI that contains an accessor to arbitrary context parameters that extending classes can specify. |
Field Summary | |
---|---|
protected static java.lang.String |
PAGENAME This string corresponds to the required variable for the Content Server app type, pagename. |
Constructor Summary | |
---|---|
protected |
AbstractAssembler() Constructor. |
Method Summary | |
---|---|
java.net.URI |
assemble(Definition def) Constructs a URI from the Definition provided. |
protected java.lang.String |
decode(java.lang.String string) URLDecodes a string using the encoding specified by this class. |
protected java.lang.String |
decode(java.lang.String string, java.lang.String encoding) URLDecodes a string using the encoding specified. |
Definition |
disassemble(java.net.URI uri, Definition.ContainerType ct) Constructs a Definition from the URI provided, using the container type specified. |
protected java.lang.String |
encode(java.lang.String string) URLEncodes a string using the encoding specified by this class. |
protected abstract Definition.AppType |
getAppType(AbstractAssembler.DisassemblyContext ctx) Return the AppType for the URI specified. |
protected AbstractAssembler.AssemblyContext |
getAssemblyContext(Definition def) Returns an assembly context object given the input definition. |
protected abstract java.lang.String |
getAuthority(AbstractAssembler.AssemblyContext ctx) Returns the authority (host and port) for the assembly context specified. |
protected abstract java.lang.String |
getAuthority(AbstractAssembler.DisassemblyContext ctx) Returns the authority (host:port etc) for the URI specified |
protected AbstractAssembler.DisassemblyContext |
getDisassemblyContext(java.net.URI uri) |
protected abstract java.lang.String |
getFragment(AbstractAssembler.AssemblyContext ctx) Get the fragment corresponding to this assembly context. |
protected abstract java.lang.String |
getFragment(AbstractAssembler.DisassemblyContext ctx) Returns the fragment for the uri specified |
protected org.apache.commons.logging.Log |
getLog() Return a Log object that is appropriate for use with this component. |
protected abstract java.lang.String |
getPath(AbstractAssembler.AssemblyContext ctx) Returns the path for the assembly context specified. |
protected java.lang.String |
getProperty(java.lang.String name, java.lang.String dephault) Get the property value of a specified property. |
protected abstract java.lang.String |
getQuery(AbstractAssembler.AssemblyContext ctx) This method returns the query string for the URI given the assembly context specified. |
protected abstract java.util.Map |
getQuery(AbstractAssembler.DisassemblyContext ctx) Returns a map of query name/value pairs for the URI specified. |
protected abstract Definition.SatelliteContext |
getSatelliteContext(AbstractAssembler.DisassemblyContext ctx) Return the Satellite Context for this Definition |
protected abstract java.lang.String |
getScheme(AbstractAssembler.AssemblyContext ctx) Returns the scheme (protocol) for the assembly context specified. |
protected abstract java.lang.String |
getScheme(AbstractAssembler.DisassemblyContext ctx) Return the scheme (http, https, etc.) for the URI specified |
protected abstract boolean |
getSessionEncode(AbstractAssembler.DisassemblyContext ctx) Get the session encode flag for this Definition. |
protected java.util.Map<java.lang.String,java.lang.String[]> |
parseQueryString(java.lang.String qry) Parse a query string and put the parameters into a map. |
void |
setProperties(java.util.Properties props) Sets the properties into the assembler. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String PAGENAME
Constructor Detail |
---|
protected AbstractAssembler()
UTF-8 is the recommended URLEncoding:
Method Detail |
---|
protected final org.apache.commons.logging.Log getLog()
public final void setProperties(java.util.Properties props)
Assembler
, and they contain information about the url path for each app type. Some containers may not permit the use of a url base, in which case the property value supplied will be null.
Property values do not need to be unique.
This method must be called by all Assemblers before any other Assembler methods are called.
setProperties
in interface Assembler
props
- The propertiesprotected final java.lang.String getProperty(java.lang.String name, java.lang.String dephault)
name
- property namedephault
- default property value or nullpublic java.net.URI assemble(Definition def) throws java.net.URISyntaxException
The components do not need to be encoded as this method will encode all values that require encoding.
The corresponding methods are called in the following order:
and the AssemblyContext object is not modified by this method. It is the same object in all of these methods. Most subclasses will not need to override this method, and should instead override the getter methods specified above instead.assemble
in interface Assembler
def
-java.net.URISyntaxException
AbstractAssembler.encode(String)
, AbstractAssembler.decode(String)
protected abstract java.lang.String getScheme(AbstractAssembler.AssemblyContext ctx)
ctx
- Assembly context objectprotected abstract java.lang.String getAuthority(AbstractAssembler.AssemblyContext ctx)
ctx
- Assembly context objectprotected abstract java.lang.String getPath(AbstractAssembler.AssemblyContext ctx)
AbstractAssembler.assemble(com.fatwire.cs.core.uri.Definition)
.ctx
- Assembly context objectprotected abstract java.lang.String getQuery(AbstractAssembler.AssemblyContext ctx)
result.append('&').append(encode(key)).append('=').append(encode(value));
ctx
- Assembly context objectEncode provides a helpful method for quoting illegal characters in the query string.
protected abstract java.lang.String getFragment(AbstractAssembler.AssemblyContext ctx)
AbstractAssembler.assemble(com.fatwire.cs.core.uri.Definition)
.ctx
- Assembly context objectprotected AbstractAssembler.AssemblyContext getAssemblyContext(Definition def)
def
- input definitionAbstractAssembler.AssemblyContext
public Definition disassemble(java.net.URI uri, Definition.ContainerType ct) throws java.net.URISyntaxException
AbstractAssembler.DisassemblyContext
object as the argument. If through the decoding process, a method determines that the URI provided does not correspond to the current assembler, the assembler should set the ownership to foreign. This will prevent any further processing (and it is more efficient than throwing an exception).
Methods are called in the following order:
AbstractAssembler.getDisassemblyContext(URI)
AbstractAssembler.getQuery(DisassemblyContext)
AbstractAssembler.getAppType(DisassemblyContext)
AbstractAssembler.getSatelliteContext(DisassemblyContext)
AbstractAssembler.getSessionEncode(DisassemblyContext)
AbstractAssembler.getScheme(DisassemblyContext)
AbstractAssembler.getAuthority(DisassemblyContext)
AbstractAssembler.getFragment(DisassemblyContext)
Overriding classes may either override this method or one or more of the corresponding getter methods (overriding the getter methods is recommended for most situations).
Users overriding this method should note that the assemble() method created a uri such that the five components were encoded using UTF-8 if required. Therefore, to disassemble a URI, components should not be retrieved using the getRaw*
methods, because that will return a component that has not been decoded.
disassemble
in interface Assembler
uri
-ct
- the container type to be set in the returned Definitionjava.net.URISyntaxException
Definition
, Definition.ContainerType
protected abstract boolean getSessionEncode(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract Definition.SatelliteContext getSatelliteContext(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract java.lang.String getScheme(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract java.lang.String getAuthority(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract java.lang.String getFragment(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected abstract Definition.AppType getAppType(AbstractAssembler.DisassemblyContext ctx)
ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.protected AbstractAssembler.DisassemblyContext getDisassemblyContext(java.net.URI uri)
protected abstract java.util.Map getQuery(AbstractAssembler.DisassemblyContext ctx)
String
/String[]
pairs, not String
/String
pairs.ctx
- DisassemblyContext object containing the URI, context parameters, and a flag inidicating whether or not this assembler is capable of disassembling this URI.String
/String[]
name/value pairs for the URi being specified, or null if the ownership is foreign.protected final java.lang.String encode(java.lang.String string)
string
-java.lang.IllegalStateException
- if UTF-8 encoding is not supported and the platform's default encoding is not supported.protected final java.lang.String decode(java.lang.String string)
string
- encoded stringjava.lang.IllegalStateException
- if UTF-8 encoding is not supported and the platform's default encoding is not supported.java.lang.IllegalArgumentException
- if the string is not well-formed for decoding.protected final java.lang.String decode(java.lang.String string, java.lang.String encoding)
string
- encoded stringencoding
- the encoding to use to decode the string. If null is specified, the decoding specified by this class shall be used.java.lang.IllegalStateException
- if the encoding specified is not supported, or if UTF-8 encoding is not supported and the platform's default encoding is not supported.java.lang.IllegalArgumentException
- if the string is not well-formed for decoding.protected final java.util.Map<java.lang.String,java.lang.String[]> parseQueryString(java.lang.String qry)
Note that the map returned contains a String[]
as the value, not a single String
value This provides support for query strings with multiple values for a given parameter name.
qry
-String
/String[]
pairs.java.lang.IllegalArgumentException
- if there are mistakes in the string that make it impossible to parse.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.