QJCC homepage

biz.chitec.quarterback.gjsa
Class Obj2StrParser

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.Obj2StrParser

public final class Obj2StrParser
extends java.lang.Object

Parser to make a String-based representation out of an object. Obj2StrParser has been developed in the context of transferring data between a server and a client in the predecessor architecture of the GJSA. Since then, it has been evolved into a general Object-to-String parser.

Obj2StrParser can be extended through ClassParser objects, which can be loaded into the parser at runtime. After loading the parser for a specific class, it can be parsed in any context, especially as part of another object (which can be either parsed by the builtin parser parts or by other external class parsers. By default, Obj2StrParser parses Numbers, Strings, boolean values, Lists and Maps.

Obj2StrParser can be roughly compared to Object.toString(), though it is much superior. Its counterpart is Str2ObjParser, which can recreate a Java object from a String representation.

Due to its history and current usage, Obj2StrParser has several special conversion methods for ServerRequest- and ServerReply-objects.

Obj2StrParser has only instance methods and is not instancizable (private constructor).

Version:
$Id: a77ec9c2e5356e624b6185d55819a28a96155492 $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000-2003, cantamen/Dirk Hillbrecht 2003-2005. Distributed under the terms of the GNU LGPL.

Field Summary
private static java.util.List classparsers
           
(package private) static java.text.DecimalFormatSymbols dfs
           
static java.text.DecimalFormat doubleformatter
          Description of the Field
(package private) static java.text.FieldPosition dummyfieldposition
           
private static java.lang.String legacynonencodechars
           
private static Logger mess
           
protected static java.util.Map nspreq
          Parameters that must not be logged, e.g. passwords.
 
Constructor Summary
private Obj2StrParser()
          Constructor for the Obj2StrParser object
 
Method Summary
static void addClassParser(ClassParser cp)
          Adds a feature to the ClassParser attribute of the Obj2StrParser class
static void addNoShowParameters(int request, int[] params)
          Adds a feature to the NoShowParameters attribute of the Obj2StrParser class
static java.lang.String formatDouble(double d)
          Description of the Method
static java.lang.String parseEnvelopeAsReply(ServerEnvelope se, boolean alwaysparse)
          parse a ServerEnvelope object including leading signs
static java.lang.String parseEnvelopeAsRequest(ServerEnvelope se, boolean alwaysparse)
          parse a ServerEnvelope object including leading signs
private static java.lang.String parseIterator(java.util.Iterator it)
          Parses through an iterator
static java.lang.String parseList(java.util.List l)
          Parse the contents of a List
static java.lang.String parseMap(java.util.Map m)
          Parse the contents of a Map
private static java.lang.String parseMapsLegacy(java.util.Map m)
          Legacy transformation method to transfer Maps in old style if possible
static java.lang.String parseMapStringKey(java.util.Map m)
          Parse map with String-only keys
static java.lang.String parseObject(java.lang.Object o)
          parses any object.
static java.lang.String parseProperties(java.util.Properties p)
          Parse the contents of a Properties including any ancestor/default values
static java.lang.String parseReply(ServerEnvelope se)
          Description of the Method
static java.lang.String parseReply(ServerEnvelope se, boolean alwaysparse)
          parses the ServerReply part of a ServerEnvelope object
static java.lang.String parseReply(ServerReply rep)
          parses a ServerReply object directly
static java.lang.String parseReply(ServerReply rep, boolean alwaysparse)
          parses a ServerReply object directly
static java.lang.String parseReplyList(java.util.List reqv, boolean alwaysparse)
          parse a vector af replies (separate output with semicolons).
static java.lang.String parseRequest(ServerEnvelope se)
          Description of the Method
static java.lang.String parseRequest(ServerEnvelope se, boolean alwaysparse)
          Description of the Method
static java.lang.String parseRequest(ServerRequest req, boolean alwaysparse)
          parse a ServerRequest object directly
static java.lang.String parseRequestList(java.util.List reqv, boolean alwaysparse)
          parse a vector af requests (separate output with semicolons).
static java.lang.String parseResourceBundle(java.util.ResourceBundle rb)
          Parse a ResourceBundle
static java.lang.String parseSet(java.util.Set s)
          Parse the contents of a Set
static void setLogger(Logger m)
          Sets the logger attribute of the Obj2StrParser class
private static char toHex(int nibble)
          Convert a nibble to a hex character
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mess

private static Logger mess

classparsers

private static java.util.List classparsers

nspreq

protected static java.util.Map nspreq
Parameters that must not be logged, e.g. passwords.


legacynonencodechars

private static java.lang.String legacynonencodechars

dfs

static java.text.DecimalFormatSymbols dfs

doubleformatter

public static java.text.DecimalFormat doubleformatter
Description of the Field


dummyfieldposition

static java.text.FieldPosition dummyfieldposition
Constructor Detail

Obj2StrParser

private Obj2StrParser()
Constructor for the Obj2StrParser object

Method Detail

setLogger

public static void setLogger(Logger m)
Sets the logger attribute of the Obj2StrParser class

Parameters:
m - The new logger value

addClassParser

public static void addClassParser(ClassParser cp)
Adds a feature to the ClassParser attribute of the Obj2StrParser class

Parameters:
cp - The feature to be added to the ClassParser attribute

addNoShowParameters

public static void addNoShowParameters(int request,
                                       int[] params)
Adds a feature to the NoShowParameters attribute of the Obj2StrParser class

Parameters:
request - The feature to be added to the NoShowParameters attribute
params - The feature to be added to the NoShowParameters attribute

formatDouble

public static java.lang.String formatDouble(double d)
Description of the Method

Parameters:
d - Description of the Parameter
Returns:
Description of the Return Value

toHex

private static char toHex(int nibble)
Convert a nibble to a hex character

Parameters:
nibble - the nibble to convert.
Returns:
Description of the Return Value

parseObject

public static java.lang.String parseObject(java.lang.Object o)
parses any object. The parsers works recursively in the case an objects contains further objects (e.g. Map). To handle this case, any parsing code may call parseObject() recursively for contained objects.

Parameters:
o - Description of the Parameter
Returns:
Description of the Return Value

parseIterator

private static java.lang.String parseIterator(java.util.Iterator it)
Parses through an iterator

Parameters:
it - Iterator, not yet evaluated in any way
Returns:
String with all the contents

parseList

public static java.lang.String parseList(java.util.List l)
Parse the contents of a List

Parameters:
l - The List to be parsed
Returns:
String containing all parsed elements

parseSet

public static java.lang.String parseSet(java.util.Set s)
Parse the contents of a Set

Parameters:
s - The Set to be parsed
Returns:
String containing all parsed elements

parseProperties

public static java.lang.String parseProperties(java.util.Properties p)
Parse the contents of a Properties including any ancestor/default values

Parameters:
p - The Properties bundle to be parsed
Returns:
String containing all parsed elements

parseMap

public static java.lang.String parseMap(java.util.Map m)
Parse the contents of a Map

Parameters:
m - The Map to be parsed
Returns:
String containing all parsed elements

parseMapStringKey

public static java.lang.String parseMapStringKey(java.util.Map m)
Parse map with String-only keys


parseMapsLegacy

private static java.lang.String parseMapsLegacy(java.util.Map m)
Legacy transformation method to transfer Maps in old style if possible


parseResourceBundle

public static java.lang.String parseResourceBundle(java.util.ResourceBundle rb)
Parse a ResourceBundle


parseEnvelopeAsReply

public static java.lang.String parseEnvelopeAsReply(ServerEnvelope se,
                                                    boolean alwaysparse)
parse a ServerEnvelope object including leading signs

Parameters:
se - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

parseEnvelopeAsRequest

public static java.lang.String parseEnvelopeAsRequest(ServerEnvelope se,
                                                      boolean alwaysparse)
parse a ServerEnvelope object including leading signs

Parameters:
se - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

parseReply

public static java.lang.String parseReply(ServerReply rep,
                                          boolean alwaysparse)
parses a ServerReply object directly

Parameters:
rep - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

parseReply

public static java.lang.String parseReply(ServerReply rep)
parses a ServerReply object directly

Parameters:
rep - Description of the Parameter
Returns:
Description of the Return Value

parseReplyList

public static java.lang.String parseReplyList(java.util.List reqv,
                                              boolean alwaysparse)
parse a vector af replies (separate output with semicolons).

Parameters:
reqv - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

parseReply

public static java.lang.String parseReply(ServerEnvelope se,
                                          boolean alwaysparse)
parses the ServerReply part of a ServerEnvelope object

Parameters:
se - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

parseReply

public static java.lang.String parseReply(ServerEnvelope se)
Description of the Method

Parameters:
se - Description of the Parameter
Returns:
Description of the Return Value

parseRequest

public static java.lang.String parseRequest(ServerEnvelope se,
                                            boolean alwaysparse)
Description of the Method

Parameters:
se - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

parseRequest

public static java.lang.String parseRequest(ServerEnvelope se)
Description of the Method

Parameters:
se - Description of the Parameter
Returns:
Description of the Return Value

parseRequest

public static java.lang.String parseRequest(ServerRequest req,
                                            boolean alwaysparse)
parse a ServerRequest object directly

Parameters:
req - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

parseRequestList

public static java.lang.String parseRequestList(java.util.List reqv,
                                                boolean alwaysparse)
parse a vector af requests (separate output with semicolons).

Parameters:
reqv - Description of the Parameter
alwaysparse - Description of the Parameter
Returns:
Description of the Return Value

QJCC homepage