org.ocltf.translation
Class TranslationUtils

java.lang.Object
  extended byorg.ocltf.translation.TranslationUtils

public class TranslationUtils
extends java.lang.Object

Contains translation utilities.

Author:
Chad Brandon

Constructor Summary
TranslationUtils()
          TranslationUtils instances should NOT be constructed in standard programming.
 
Method Summary
static boolean containsPattern(java.lang.String string, java.lang.String pattern)
          Returns true if the specified pattern with braces around it, like so --> "{pattern}" exists in the string.
static java.lang.String deleteWhitespace(java.lang.Object object)
          Calls the object's toString method and deletes any whitespace from the value.
static java.lang.Object getProperty(java.lang.Object bean, java.lang.String property)
          Just retriieves properties from a bean, but gives a more informational error when the property can't be retrieved, it also cleans the resulting property from any excess white space
static java.lang.String getPropertyAsString(java.lang.Object bean, java.lang.String property)
          Just retriieves properties from a bean, but gives a more informational error when the property can't be retrieved, it also cleans the resulting property from any excess white space
static java.lang.String getStartingProperty(java.lang.String property)
          Retrieves the "starting" property name from one that is nested, for example, will return '' from the string --> ...
static boolean isManyConnectingAssociationEnd(ElementFacade element, java.lang.String name)
          Returns true if the passed in name is a connecting end and its multiplicity is many.
static java.lang.String removeExtraWhitespace(java.lang.String string)
          Removes any extra whitepace --> does not remove the spaces between the words.
static java.lang.String replaceFirstPattern(java.lang.String string, java.lang.String pattern, java.lang.String replaceWith)
          Searches for and replaces the specified pattern with braces around it, like so --> "{pattern}" the first time it occurs in the string
static java.lang.String replacePattern(java.lang.String string, java.lang.String pattern, java.lang.String replaceWith)
          Searches for and replaces the specified pattern with braces around it, like so --> "{pattern}" every time it occurs in the string.
static java.lang.String trimToEmpty(java.lang.Object object)
          Calls the object's toString method and trims the value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TranslationUtils

public TranslationUtils()

TranslationUtils instances should NOT be constructed in standard programming. Instead, the class should be used as TranslationUtils.replacePattern(" some pattern ");.

This constructor is public to permit tools that require a JavaBean instance to operate.

Method Detail

replacePattern

public static java.lang.String replacePattern(java.lang.String string,
                                              java.lang.String pattern,
                                              java.lang.String replaceWith)
Searches for and replaces the specified pattern with braces around it, like so --> "{pattern}" every time it occurs in the string.

Parameters:
string - the string to to perform replacement on.
pattern - the pattern to find
replaceWith - the pattern to place the existing one with.
Returns:
String the string will all replacements

replaceFirstPattern

public static java.lang.String replaceFirstPattern(java.lang.String string,
                                                   java.lang.String pattern,
                                                   java.lang.String replaceWith)
Searches for and replaces the specified pattern with braces around it, like so --> "{pattern}" the first time it occurs in the string

Parameters:
string - the string to to perform replacement on.
pattern - the pattern to find
replaceWith - the pattern to place the existing one with.
Returns:
String the string will all replacements

containsPattern

public static boolean containsPattern(java.lang.String string,
                                      java.lang.String pattern)
Returns true if the specified pattern with braces around it, like so --> "{pattern}" exists in the string.

Parameters:
string - the string to to perform replacement on.
pattern - the pattern to find
Returns:
boolean true if the string contains the pattern, false otherwise

trimToEmpty

public static java.lang.String trimToEmpty(java.lang.Object object)
Calls the object's toString method and trims the value. Returns and empty string if null is given.

Parameters:
object - the object to use.
Returns:
String

deleteWhitespace

public static java.lang.String deleteWhitespace(java.lang.Object object)
Calls the object's toString method and deletes any whitespace from the value. Returns and empty string if null is given.

Parameters:
object - the object to deleteWhite space from.
Returns:
String

getStartingProperty

public static java.lang.String getStartingProperty(java.lang.String property)
Retrieves the "starting" property name from one that is nested, for example, will return '' from the string --> ... If the property isn't nested, then just return the name that is passed in.

Parameters:
property - the property.
Returns:
String

removeExtraWhitespace

public static java.lang.String removeExtraWhitespace(java.lang.String string)
Removes any extra whitepace --> does not remove the spaces between the words. Only removes tabs and newline characters. This is to allow everything to be on one line while keeping the spaces between words.

Parameters:
string -
Returns:
String the string with the removed extra spaces.

getProperty

public static java.lang.Object getProperty(java.lang.Object bean,
                                           java.lang.String property)
Just retriieves properties from a bean, but gives a more informational error when the property can't be retrieved, it also cleans the resulting property from any excess white space

Parameters:
bean - the bean from which to retrieve the property
property - the property name
Returns:
Object the value of the property

getPropertyAsString

public static java.lang.String getPropertyAsString(java.lang.Object bean,
                                                   java.lang.String property)
Just retriieves properties from a bean, but gives a more informational error when the property can't be retrieved, it also cleans the resulting property from any excess white space

Parameters:
bean - the bean from which to retrieve the property
property - the property name
Returns:
Object the value of the property

isManyConnectingAssociationEnd

public static boolean isManyConnectingAssociationEnd(ElementFacade element,
                                                     java.lang.String name)
Returns true if the passed in name is a connecting end and its multiplicity is many.

Parameters:
element - the ElementFacade to check.
name - the name of the association.
Returns:
boolean true/false


Copyright © 2003-2004 Chad Brandon. All Rights Reserved.