|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fatwire.gst.foundation.url.LightweightAbstractAssembler
public abstract class LightweightAbstractAssembler
Lightweight abstract assembler that handles property management, provides a
logger, handles encoding and decoding and query string processing. Much
lighter in weight than com.fatwire.cs.core.uri.AbstractAssembler
.
Field Summary | |
---|---|
protected static org.apache.commons.logging.Log |
LOG
Logger for use by sub-classes. |
Fields inherited from interface com.fatwire.cs.core.uri.Assembler |
---|
LOG_NAME, PROP_PATH_PREFIX, PROP_URIBASE_BLOB_SERVER, PROP_URIBASE_CACHE_SERVER, PROP_URIBASE_CATALOG_MANAGER, PROP_URIBASE_CONTENT_SERVER, PROP_URIBASE_COOKIE_SERVER, PROP_URIBASE_DISPATCH_MANAGER, PROP_URIBASE_PAGE_DISPATCH_SERVER, PROP_URIBASE_SATELLITE_SERVER, PROP_URIBASE_SEED_DISPATCH_SERVER, PROP_URIBASE_SYNC_SEED_DISPATCH_SERVER, PROP_URIBASE_TREE_MANAGER |
Constructor Summary | |
---|---|
protected |
LightweightAbstractAssembler()
Constructor. |
Method Summary | |
---|---|
protected String |
constructQueryString(Map<String,String[]> parameters)
Given an input map of name-value pairs, construct a query string. |
protected static URI |
constructURI(String scheme,
String authority,
String path,
String quotedQueryString,
String fragment)
The multi-arg java.net.URI constructors quote illegal
characters. |
protected String |
decode(String string)
URLDecodes a string using the encoding specified by this class. |
protected String |
decode(String string,
String encoding)
URLDecodes a string using the encoding specified. |
protected String |
encode(String string)
URLEncodes a string using the encoding specified by this class. |
protected String[] |
excludeFromPackedargs(String[] origPackedargsStrings,
Collection<String> toExclude)
Given an array of query-string-like packed arguments, eliminate the specified parameters and return the packedargs parameter with the values stripped. |
protected String |
getProperty(String name,
String dephault)
Convenience method to get a property value set into the assembler from the configuration files. |
protected Map<String,String[]> |
parseQueryString(String qry)
Parse a query string and put the parameters into a map. |
void |
setProperties(Properties props)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.fatwire.cs.core.uri.Assembler |
---|
assemble, disassemble |
Field Detail |
---|
protected static final org.apache.commons.logging.Log LOG
Constructor Detail |
---|
protected LightweightAbstractAssembler()
Method Detail |
---|
public void setProperties(Properties props)
setProperties
in interface com.fatwire.cs.core.uri.Assembler
protected String getProperty(String name, String dephault)
name
- name of property to importdephault
- default value of property - returned if the property
value is not specified
protected final String encode(String string)
string
- the string to encode
IllegalStateException
- if UTF-8 encoding is not supported and the
platform's default encoding is not supported.protected final String decode(String string)
string
- encoded string
IllegalStateException
- if UTF-8 encoding is not supported and the
platform's default encoding is not supported.
IllegalArgumentException
- if the string is not well-formed for
decoding.protected final String decode(String string, 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.
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.
IllegalArgumentException
- if the string is not well-formed for
decoding.protected static final URI constructURI(String scheme, String authority, String path, String quotedQueryString, String fragment) throws URISyntaxException
java.net.URI
constructors quote illegal
characters. However, this class requires that the query string already be
properly URLEncoded. As a result, we can't use the multi-arg URI
constructor because all of our % symbols and the + symbol will end up
getting double-encoded. So, we need to construct a full URL ourselves so
we can use the single-arg URI constructor, because it does not quote
anything.
There are multiple variants of combinations of these parameters to create
a valid URL. Consult the URI specificaiton for what is allowed and what
is not. The URI constructor will throw a URISyntaxException if required
components are missing for a given combination.
scheme
- the URI scheme (protocol)authority
- the URI authority (host:port)path
- the path for the URI (servlet context path, servlet name,
pathinfo)quotedQueryString
- the query string, with illegal characters
already quoted.fragment
- the fragment (anchor)
URISyntaxException
- if there is a problem with what is passed inprotected final Map<String,String[]> parseQueryString(String qry)
String[]
as the
value, not a single String
value This provides support
for query strings with multiple values for a given parameter name.
This decoding method is smart enough to be able to interpret the
_charset_
URL parameter that is often used by IE.
qry
-
String
/String[]
pairs.
IllegalArgumentException
- if there are mistakes in the string that
make it impossible to parse.protected final String constructQueryString(Map<String,String[]> parameters)
parameters
- parameters to encode and place in the query string
encode(String)
protected final String[] excludeFromPackedargs(String[] origPackedargsStrings, Collection<String> toExclude)
origPackedargsStrings
- array of query string-like packed args.toExclude
- list of args to remove from the packed args.
toExclude
parameters are removed.
If all params end up getting removed, the packedargs string ends
up being null. The array returned is never null though.
IllegalArgumentException
- if the input args or the input list are
null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |