net.sf.json.util
Class JavaIdentifierTransformer

java.lang.Object
  extended by net.sf.json.util.JavaIdentifierTransformer

public abstract class JavaIdentifierTransformer
extends Object

Transforms a string into a valid Java identifier.
There are five predefined strategies:

Author:
Andres Almiray

Field Summary
static JavaIdentifierTransformer CAMEL_CASE
          CamelCase transformer 'camel case' => 'camelCase'
static JavaIdentifierTransformer NOOP
          Noop transformer '@invalid' => '@invalid'
static JavaIdentifierTransformer STRICT
          Strict transformer '@invalid' => JSONException
static JavaIdentifierTransformer UNDERSCORE
          Underscore transformer 'under score' => 'under_score'
static JavaIdentifierTransformer WHITESPACE
          Whitespace transformer 'white space' => 'whitespace'
 
Constructor Summary
JavaIdentifierTransformer()
           
 
Method Summary
protected  String shaveOffNonJavaIdentifierStartChars(String str)
          Removes all non JavaIdentifier chars from the start of the string.
abstract  String transformToJavaIdentifier(String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CAMEL_CASE

public static final JavaIdentifierTransformer CAMEL_CASE
CamelCase transformer 'camel case' => 'camelCase'


NOOP

public static final JavaIdentifierTransformer NOOP
Noop transformer '@invalid' => '@invalid'


STRICT

public static final JavaIdentifierTransformer STRICT
Strict transformer '@invalid' => JSONException


UNDERSCORE

public static final JavaIdentifierTransformer UNDERSCORE
Underscore transformer 'under score' => 'under_score'


WHITESPACE

public static final JavaIdentifierTransformer WHITESPACE
Whitespace transformer 'white space' => 'whitespace'

Constructor Detail

JavaIdentifierTransformer

public JavaIdentifierTransformer()
Method Detail

transformToJavaIdentifier

public abstract String transformToJavaIdentifier(String str)

shaveOffNonJavaIdentifierStartChars

protected final String shaveOffNonJavaIdentifierStartChars(String str)
Removes all non JavaIdentifier chars from the start of the string.

Throws:
JSONException - if the resulting string has zero length.