pl.bristleback.server.bristle.token
Class JsonTokenizerEngine
java.lang.Object
pl.bristleback.server.bristle.token.JsonTokenizerEngine
- All Implemented Interfaces:
- TokenizerEngine
public class JsonTokenizerEngine
- extends java.lang.Object
- implements TokenizerEngine
This class allows adding raw and complex objects to Token.
Lists and arrays will be changed into JSONArray objects, maps will be changed into JSONObject objects.
Complex custom objects will be changed into JSONObject using reflection.
deepSearch parameter specifies whether reflection searching should be recursive
in case when another complex object is found inside already processed object.
In other words, if object A contains object B and
deepSearch parameter is set to true, it tell us that object B should be also added to token.
Moreover, parameter names can be complex, like parent.nestedObject.
In that case, inside token, there will be JSONObject object created with name parent.
That object will contain nestedObject parameter.
This is a default implementation of TokenizerEngine interface,
used when custom object tokenizer is not set in Tokenize annotation.
Currently, this implementation works only for JSONToken objects,
because of big differences in functionality in various Token implementations.
Created on: 2010-12-16 14:29:14
- Author:
- Wojciech Niemiec
|
Method Summary |
java.lang.String |
getLastParameter(java.lang.String[] parameters)
|
org.jwebsocket.token.Token |
tokenize(org.jwebsocket.token.Token token,
boolean deepSearch,
java.lang.String[] parameterNames,
java.lang.Object[] values)
Adds raw and complex objects to token. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JsonTokenizerEngine
public JsonTokenizerEngine()
tokenize
public org.jwebsocket.token.Token tokenize(org.jwebsocket.token.Token token,
boolean deepSearch,
java.lang.String[] parameterNames,
java.lang.Object[] values)
- Adds raw and complex objects to token. Method accepts only
JSONToken implementation of token.
- Specified by:
tokenize in interface TokenizerEngine
- Parameters:
token - a token to fill.deepSearch - if set to true, reflection searching of complex objects will be recursive.parameterNames - keys of token entries. Can be complex names, with dots as separators,
like object.nestedObject.moreNestedObject.values - values of token entries. Can be raw or complex objects, maps, lists and arrays.
- Returns:
- token given as parameter with filled parameters.
getLastParameter
public java.lang.String getLastParameter(java.lang.String[] parameters)
Copyright © 2011. All Rights Reserved.