Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ssaglobal.generator.helper
Class StringHelper

    java.lang.Object
      com.ssaglobal.generator.helper.StringHelper

    public class StringHelper

extends java.lang.Object

Helper class that wraps a string and exposes methods to manipulate it. It was developed to support the StringTemplate engine, since StringTemplate doesn't provide any way to do operations like uppercase and lowercase.

The transform operations (uppercase, lowercase, capitalize, uncapitalize, and name) are exposed as getters so that StringTemplate sees them as properties. They all return instances of StringHelper so that they can be chained together. For example, writing $property.name.capitalize$ in a StringTemplate template will take the value of property, transform it to a name, and capitalize the result of the name transformation.

The getInstance method converts an EObject to a database of HashMaps, ArrayLists, and StringHelpers allowing StringTemplate to access all properties of the EObject (and the objects it points to) as instances of StringHelper.

Constructor Summary
`StringHelper(java.lang.String string)` Constructor

Method Summary
`static java.lang.String` | `capitalize(java.lang.String s)` Capitalize a string (force the first character to uppercase)
`StringHelper` | `getCapitalized()` Force the first character to uppercase
`static java.lang.Object` | `getInstance(GeneratorLog log, org.eclipse.emf.ecore.EObject object, GeneratorControlArea controlData)` Return a HashMap representing `object`.
`StringHelper` | `getLowercase()` Convert the entire string to lowercase
`StringHelper` | `getName()` Transform the value to a valid name (remove embedded spaces, tranform any other invalid characters to underscores, and insert a leading underscore if the first character is a digit).
`StringHelper` | `getUncapitalized()` Force the first character to lowercase
`StringHelper` | `getUppercase()` Convert the entire string to uppercase
`static java.lang.String` | `toName(java.lang.String s)` Convert a string to a valid name remove embedded spaces convert any other invalid characters to underscores insert a leading underscore if the remaining string begins with a digit
`java.lang.String` | `toString()` Return the string value
`static java.lang.String` | `unCapitalize(java.lang.String s)` Un-capitalize a string (force the first character to lowercase)

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### StringHelper

    public StringHelper(java.lang.String string)

  Constructor

  Parameters:
    `string` -

Method Detail

### getUppercase

    public StringHelper getUppercase()

  Convert the entire string to uppercase

  Returns:
    new instance of StringHelper with uppercase string

### getLowercase

    public StringHelper getLowercase()

  Convert the entire string to lowercase

  Returns:
    new instance of StringHelper with lowercase string

### getCapitalized

    public StringHelper getCapitalized()

  Force the first character to uppercase

  Returns:
    new instance of StringHelper with capitalized string

### getUncapitalized

    public StringHelper getUncapitalized()

  Force the first character to lowercase

  Returns:
    new instance of StringHelper with unCapitalized string

### getName

    public StringHelper getName()

  Transform the value to a valid name (remove embedded spaces, tranform any other invalid characters to underscores, and insert a leading underscore if the first character is a digit).

  Returns:
    new StringHelper instance with valid name based on string

### toString

    public java.lang.String toString()

  Return the string value

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    String value

### getInstance

    public static java.lang.Object getInstance(GeneratorLog log,
                                               org.eclipse.emf.ecore.EObject object,
                                               GeneratorControlArea controlData)

  Return a HashMap representing `object`. EObject properties of `object` are represented as a nested HashMap and List properties are represented as a nested ArrayList. All other properties are converted to strings (using String.valueOf()) and wrapped in a StringHelper.

  Parameters:
    `log` -
    `object` -
    `controlData` -
  Returns:
    HashMap representing object

### capitalize

    public static java.lang.String capitalize(java.lang.String s)

  Capitalize a string (force the first character to uppercase)

  Parameters:
    `s` -
  Returns:
    capitalized string s

### unCapitalize

    public static java.lang.String unCapitalize(java.lang.String s)

  Un-capitalize a string (force the first character to lowercase)

  Parameters:
    `s` -
  Returns:
    un-capitalized string s

### toName

    public static java.lang.String toName(java.lang.String s)

  Convert a string to a valid name
  1. remove embedded spaces
  2. convert any other invalid characters to underscores
  3. insert a leading underscore if the remaining string begins with a digit

  Parameters:
    `s` -
  Returns:
    valid name for s

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD