|
|||||||||
| Home >> All >> ru >> gammalabs >> ice >> utils >> [ http overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
ru.gammalabs.ice.utils.http
Class DefaultRequestProcessor

java.lang.Objectru.gammalabs.ice.utils.http.DefaultRequestProcessor
- All Implemented Interfaces:
- java.lang.Cloneable, RequestProcessor
- public class DefaultRequestProcessor
- extends java.lang.Object
- implements RequestProcessor
- extends java.lang.Object
Default implementation of RequestProcessor for use with HTTP GET/POST request strings.
- Version:
- $Revision: 1.1 $
| Field Summary | |
protected java.util.Map |
cache
Parsed objects cache. |
(package private) java.lang.String |
FINE_GRAIN_SEPARATOR
Separator between complex property values (like different array values). |
(package private) java.lang.String |
NAME_VALUE_SEPARATOR
Separator between object property name and value. |
(package private) java.lang.String |
OBJECT_PROPERTIES_SEPARATOR
Separator between object identifier and serialized object data. |
(package private) java.lang.String |
OBJECTS_SEPARATOR
Separator between two objects in request string. |
(package private) java.lang.String |
PROPERTIES_SEPARATOR
Separator between two serialized properties. |
protected java.lang.String |
request
Request string. |
(package private) java.lang.String |
SCRIBBLE_METHOD_PREFIX
|
(package private) java.lang.String |
UNSCRIBBLE_METHOD_PREFIX
|
protected java.util.Map |
values
String values map. |
| Constructor Summary | |
DefaultRequestProcessor()
Creates new RequestProcessor instance. |
|
| Method Summary | |
private void |
assembleRequestString()
Assembles stored request string from current values Map. |
void |
clear()
Clear all request data that is currently stored in the RequestProcessor. |
java.lang.Object |
clone()
This method may be called to create a new copy of the Object. |
java.lang.Object |
decode(java.lang.String s,
java.lang.String id,
java.lang.Object object)
Fills individual object from part of request string, corresponding to this object values. |
java.lang.Object[] |
decode(java.lang.String s,
java.lang.String id,
java.lang.Object[] object)
Fills individual object array from part of request string, corresponding to this objects array values. |
java.lang.String |
encode(java.lang.String id,
java.lang.Object object)
Encodes any supported Object descendant into id=value string. |
java.lang.String |
encode(java.lang.String id,
java.lang.Object[] object)
Encodes individual objects array to be stored in request string. |
java.lang.Object |
get(java.lang.String id,
java.lang.Object object)
Returns object stored in the RequestProcessor with specified identifier. |
java.lang.Object[] |
get(java.lang.String id,
java.lang.Object[] object)
Returns objects array stored in the RequestProcessor with specified identifier. |
java.lang.String |
getRequestString()
Returns request string containing currenly stored objects in serialized form. |
private boolean |
isRequestable(java.lang.Class c)
Replacement for instanceof for situations where we cannot use it. |
void |
put(java.lang.String id,
java.lang.Object object)
Puts object into RequestProcessor internal storage. |
void |
put(java.lang.String id,
java.lang.Object[] object)
Puts array of objects into RequestProcessor internal storage. |
void |
remove(java.lang.String id)
Removes specified object from the RequestProcessor internal storage. |
java.lang.String |
scribbleboolean(boolean b)
Method for encoding boolean value. |
java.lang.String |
scribbleBoolean(java.lang.Boolean b)
Method for encoding Boolean value. |
java.lang.String |
scribbleClass(java.lang.Class c)
Method for encoding Class value. |
java.lang.String |
scribbleDate(java.util.Date d)
Method for encoding Date value. |
java.lang.String |
scribbleint(int i)
Method for encoding int value. |
java.lang.String |
scribbleInteger(java.lang.Integer i)
Method for decoding Integer value. |
java.lang.String |
scribbleLocale(java.util.Locale l)
Method for encoding Locale value. |
java.lang.String |
scribblelong(long l)
Method for encoding long value. |
java.lang.String |
scribbleLong(java.lang.Long l)
Method for encoding Long value. |
java.lang.String |
scribbleObject(java.lang.Object o)
Method for encoding Object value. |
java.lang.String |
scribbleObject(java.lang.Object[] o)
|
java.lang.String |
scribbleRequestable(Requestable r)
Method for encoding Requestable value. |
java.lang.String |
scribbleString(java.lang.String s)
Method for encoding String value. |
void |
setRequestString(java.lang.String s)
Passes request string containing serialized objects data. |
private void |
splitRequestString()
Splits passed request string into internal data structures. |
boolean |
unscribbleboolean(java.lang.String s)
Method for decoding encoded boolean value. |
java.lang.Boolean |
unscribbleBoolean(java.lang.String s)
Method for decoding encoded Boolean value. |
java.lang.Class |
unscribbleClass(java.lang.String s)
Method for decoding encoded Class value. |
java.util.Date |
unscribbleDate(java.lang.String s)
Method for decoding encoded Date value. |
int |
unscribbleint(java.lang.String s)
Method for decoding encoded int value. |
java.lang.Integer |
unscribbleInteger(java.lang.String s)
Method for decoding encoded Integer value. |
java.util.Locale |
unscribbleLocale(java.lang.String s)
Method for decoding encoded Locale value. |
long |
unscribblelong(java.lang.String s)
Method for decoding encoded long value. |
java.lang.Long |
unscribbleLong(java.lang.String s)
Method for decoding encoded Long value. |
java.lang.Object |
unscribbleObject(java.lang.String s,
java.lang.Object o)
Method for decoding string containing any Object descendand encoded value. |
java.lang.Object[] |
unscribbleObject(java.lang.String s,
java.lang.Object[] o)
|
Requestable |
unscribbleRequestable(java.lang.String s,
Requestable r)
Method for decoding string containing encoded Requestable object value. |
java.lang.String |
unscribbleString(java.lang.String s)
Method for decoding encoded String value. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
OBJECTS_SEPARATOR
final java.lang.String OBJECTS_SEPARATOR
- Separator between two objects in request string.
- See Also:
- Constant Field Values
OBJECT_PROPERTIES_SEPARATOR
final java.lang.String OBJECT_PROPERTIES_SEPARATOR
- Separator between object identifier and serialized object data.
- See Also:
- Constant Field Values
NAME_VALUE_SEPARATOR
final java.lang.String NAME_VALUE_SEPARATOR
- Separator between object property name and value.
- See Also:
- Constant Field Values
PROPERTIES_SEPARATOR
final java.lang.String PROPERTIES_SEPARATOR
- Separator between two serialized properties.
- See Also:
- Constant Field Values
FINE_GRAIN_SEPARATOR
final java.lang.String FINE_GRAIN_SEPARATOR
- Separator between complex property values (like different array values).
- See Also:
- Constant Field Values
SCRIBBLE_METHOD_PREFIX
final java.lang.String SCRIBBLE_METHOD_PREFIX
- See Also:
- Constant Field Values
UNSCRIBBLE_METHOD_PREFIX
final java.lang.String UNSCRIBBLE_METHOD_PREFIX
- See Also:
- Constant Field Values
request
protected java.lang.String request
- Request string.
cache
protected java.util.Map cache
- Parsed objects cache. Key is object identifier
String, value isObject.
values
protected java.util.Map values
- String values map. Key is object identifier
String, value is serialized propertiesString.
| Constructor Detail |
DefaultRequestProcessor
public DefaultRequestProcessor()
- Creates new
RequestProcessorinstance.
| Method Detail |
clear
public void clear()
- Description copied from interface:
RequestProcessor - Clear all request data that is currently stored in the
RequestProcessor.- Specified by:
clearin interfaceRequestProcessor
remove
public void remove(java.lang.String id)
- Description copied from interface:
RequestProcessor - Removes specified object from the
RequestProcessorinternal storage.- Specified by:
removein interfaceRequestProcessor
put
public void put(java.lang.String id, java.lang.Object object)
- Description copied from interface:
RequestProcessor - Puts object into
RequestProcessorinternal storage.- Specified by:
putin interfaceRequestProcessor
put
public void put(java.lang.String id, java.lang.Object[] object)
- Description copied from interface:
RequestProcessor - Puts array of objects into
RequestProcessorinternal storage.- Specified by:
putin interfaceRequestProcessor
get
public java.lang.Object get(java.lang.String id, java.lang.Object object)
- Description copied from interface:
RequestProcessor - Returns object stored in the
RequestProcessorwith specified identifier.- Specified by:
getin interfaceRequestProcessor
get
public java.lang.Object[] get(java.lang.String id, java.lang.Object[] object)
- Description copied from interface:
RequestProcessor - Returns objects array stored in the
RequestProcessorwith specified identifier.- Specified by:
getin interfaceRequestProcessor
setRequestString
public void setRequestString(java.lang.String s)
- Description copied from interface:
RequestProcessor - Passes request string containing serialized objects data. All previously stored objects are eliminated
by this call.
- Specified by:
setRequestStringin interfaceRequestProcessor
getRequestString
public java.lang.String getRequestString()
- Description copied from interface:
RequestProcessor - Returns request string containing currenly stored objects in serialized form.
- Specified by:
getRequestStringin interfaceRequestProcessor
clone
public java.lang.Object clone()
- Description copied from class:
java.lang.Object - This method may be called to create a new copy of the
Object. The typical behavior is as follows:
o == o.clone()is falseo.getClass() == o.clone().getClass()is trueo.equals(o)is true
However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>
Object.equals(Object)55 .If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.
Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override this method as follows (it should never fail):
public Object clone() { try { super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } }
encode
public java.lang.String encode(java.lang.String id, java.lang.Object object)
- Encodes any supported
Objectdescendant into id=value string. In case passed object implementsRequestablespecialencodemethod for compaund objects is called. Otherwise we lookupencode<passed object class name>method and use it to encode passed value into string.- Specified by:
encodein interfaceRequestProcessor
decode
public java.lang.Object decode(java.lang.String s, java.lang.String id, java.lang.Object object)
- Description copied from interface:
RequestProcessor - Fills individual object from part of request string, corresponding to this object values.
- Specified by:
decodein interfaceRequestProcessor
encode
public java.lang.String encode(java.lang.String id, java.lang.Object[] object)
- Description copied from interface:
RequestProcessor - Encodes individual objects array to be stored in request string.
- Specified by:
encodein interfaceRequestProcessor
decode
public java.lang.Object[] decode(java.lang.String s, java.lang.String id, java.lang.Object[] object)
- Description copied from interface:
RequestProcessor - Fills individual object array from part of request string, corresponding to this objects array values.
- Specified by:
decodein interfaceRequestProcessor
scribbleRequestable
public java.lang.String scribbleRequestable(Requestable r)
- Method for encoding
Requestablevalue.
unscribbleRequestable
public Requestable unscribbleRequestable(java.lang.String s, Requestable r)
- Method for decoding string containing encoded
Requestableobject value. Note: Unlike otherunscribble...methods takes initializedRequestableobject as the second parameter. This is done because otherwise we had to pass type information with every encoded request which adds overhead and potentially insecure. Passed object is filled with decoded values. Also decoded object is returned.
scribbleObject
public java.lang.String scribbleObject(java.lang.Object o)
- Method for encoding
Objectvalue. In general it will take anyObjectdescendant and find appropriate method to encode it. For objects implementingRequestableinterfacescribbleRequestablealways will be called instead.
unscribbleObject
public java.lang.Object unscribbleObject(java.lang.String s, java.lang.Object o)
- Method for decoding string containing any
Objectdescendand encoded value. Note: Unlike otherunscribble...methods takes initialized object as the second parameter. This is done because otherwise we had to pass type information with every encoded request which adds overhead and potentially insecure. Passed object is not modified except it implementsRequestableinterface. Decoded object is returned.
scribbleObject
public java.lang.String scribbleObject(java.lang.Object[] o)
unscribbleObject
public java.lang.Object[] unscribbleObject(java.lang.String s, java.lang.Object[] o)
scribbleString
public java.lang.String scribbleString(java.lang.String s)
- Method for encoding
Stringvalue.
unscribbleString
public java.lang.String unscribbleString(java.lang.String s)
- Method for decoding encoded
Stringvalue.
scribbleint
public java.lang.String scribbleint(int i)
- Method for encoding
intvalue.
unscribbleint
public int unscribbleint(java.lang.String s)
- Method for decoding encoded
intvalue.
scribbleInteger
public java.lang.String scribbleInteger(java.lang.Integer i)
- Method for decoding
Integervalue.
unscribbleInteger
public java.lang.Integer unscribbleInteger(java.lang.String s)
- Method for decoding encoded
Integervalue.
scribblelong
public java.lang.String scribblelong(long l)
- Method for encoding
longvalue.
unscribblelong
public long unscribblelong(java.lang.String s)
- Method for decoding encoded
longvalue.
scribbleLong
public java.lang.String scribbleLong(java.lang.Long l)
- Method for encoding
Longvalue.
unscribbleLong
public java.lang.Long unscribbleLong(java.lang.String s)
- Method for decoding encoded
Longvalue.
scribbleClass
public java.lang.String scribbleClass(java.lang.Class c)
- Method for encoding
Classvalue.
unscribbleClass
public java.lang.Class unscribbleClass(java.lang.String s)
- Method for decoding encoded
Classvalue.
scribbleDate
public java.lang.String scribbleDate(java.util.Date d)
- Method for encoding
Datevalue.
unscribbleDate
public java.util.Date unscribbleDate(java.lang.String s)
- Method for decoding encoded
Datevalue.
scribbleBoolean
public java.lang.String scribbleBoolean(java.lang.Boolean b)
- Method for encoding
Booleanvalue.
unscribbleBoolean
public java.lang.Boolean unscribbleBoolean(java.lang.String s)
- Method for decoding encoded
Booleanvalue.
scribbleboolean
public java.lang.String scribbleboolean(boolean b)
- Method for encoding
booleanvalue.
unscribbleboolean
public boolean unscribbleboolean(java.lang.String s)
- Method for decoding encoded
booleanvalue.
scribbleLocale
public java.lang.String scribbleLocale(java.util.Locale l)
- Method for encoding
Localevalue.
unscribbleLocale
public java.util.Locale unscribbleLocale(java.lang.String s)
- Method for decoding encoded
Localevalue.
assembleRequestString
private void assembleRequestString()
- Assembles stored request string from current
valuesMap.
splitRequestString
private void splitRequestString()
- Splits passed request string into internal data structures.
isRequestable
private boolean isRequestable(java.lang.Class c)
- Replacement for
instanceoffor situations where we cannot use it. Checks if passed class or one of it ancestors implementRequestableinterface.
|
|||||||||
| Home >> All >> ru >> gammalabs >> ice >> utils >> [ http overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
ru.gammalabs.ice.utils.http.DefaultRequestProcessor