com.gridsystems.innergrid.kernel.genericutils
Class ApiUtils

java.lang.Object
  extended by com.gridsystems.innergrid.kernel.genericutils.ApiUtils

public final class ApiUtils
extends java.lang.Object

Class that contains some functionality used inside the api methods.


Field Summary
static int MAX_NAME_LENGTH
          Maximum allowed name size.
static char SEPARATOR
          General separator character.
static java.lang.String VALID_CHARACTERS
          List of valid Characters.
 
Method Summary
static java.lang.String checkEmptyName(java.lang.String name)
          Checks if the specified name is empty or null, throwing an exception if it is.
static java.lang.String checkEmptyName(java.lang.String name, java.lang.String caption)
          Checks if the specified name is empty or null, throwing an exception if it is.
static java.lang.String checkEmptyParam(java.lang.String param, java.lang.String name)
          Checks if the specified String parameter is empty or null, throwing an exception if it is.
static void checkName(java.lang.String name)
          Checks that the name is valid.
static void checkName(java.lang.String name, java.lang.String caption)
          Checks that the name is valid.
static void checkNullParam(java.lang.Object param, java.lang.String paramName)
          Throws an exception if the specified parameter value is null.
static java.lang.String hygienize(java.lang.String s)
          It cleans 'dirty' strings, substituting dangerous characters.
static com.gridsystems.innergrid.kernel.KernelException processException(java.lang.Exception e)
          Converts any exception into a KernelException.
static void setThreadName(java.lang.String text)
          Sets the current thread name, adding the specific suffix and a timestamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_NAME_LENGTH

public static final int MAX_NAME_LENGTH
Maximum allowed name size.

See Also:
Constant Field Values

VALID_CHARACTERS

public static final java.lang.String VALID_CHARACTERS
List of valid Characters.

See Also:
Constant Field Values

SEPARATOR

public static final char SEPARATOR
General separator character.

See Also:
Constant Field Values
Method Detail

processException

public static com.gridsystems.innergrid.kernel.KernelException processException(java.lang.Exception e)
Converts any exception into a KernelException.

Parameters:
e - exception to manage and convert into a KernelException
Returns:
a KernelException with all the relevant information

checkName

public static void checkName(java.lang.String name)
                      throws IllegalValueException
Checks that the name is valid. Checks that the name is valid. A valid name must be not null, have a length between 1 and MAX_NAME_LENGTH - 1 and all of its characters must be in the set [a-zA-Z0-9_]. This overloaded method performs a call to checkName(String, String) with parameters name and "name".

Parameters:
name - The name to check
Throws:
IllegalValueException - if the name is not valid.

checkName

public static void checkName(java.lang.String name,
                             java.lang.String caption)
                      throws IllegalValueException
Checks that the name is valid. Checks that the name is valid. A valid name must be not null, have a length between 1 and MAX_NAME_LENGTH - 1 and all of its characters must be in the set [a-zA-Z0-9_].

Parameters:
name - The name to check
caption - an id to provide the user of a hint of which is the meaning of the value in name, if it is not valid. If this parameter is null, it is changed by "name".
Throws:
IllegalValueException - if the name is not valid: - If is null then throws NullParameterException - If exceeds the length then throws StringTooLongException - If contains invalid character then throws InvalidCharacterException

checkEmptyName

public static java.lang.String checkEmptyName(java.lang.String name)
                                       throws NullParameterException
Checks if the specified name is empty or null, throwing an exception if it is. This overloaded method performs a call to checkEmptyName(String, String) with parameters name and "name".

Parameters:
name - The object name to check
Returns:
The trimmed object name
Throws:
NullParameterException - if the specified name is null or empty.

checkEmptyName

public static java.lang.String checkEmptyName(java.lang.String name,
                                              java.lang.String caption)
                                       throws NullParameterException
Checks if the specified name is empty or null, throwing an exception if it is.

Parameters:
name - The object name to check
caption - an id to provide the user of a hint of which is the meaning of the value in name, if it is not valid. If this parameter is null, it is changed by "name".
Returns:
The trimmed object name
Throws:
NullParameterException - if the specified name is null or empty.

checkEmptyParam

public static java.lang.String checkEmptyParam(java.lang.String param,
                                               java.lang.String name)
                                        throws NullParameterException
Checks if the specified String parameter is empty or null, throwing an exception if it is.

Parameters:
param - The parameter
name - The parameter name
Returns:
The trimmed parameter
Throws:
NullParameterException - if the specified parameter is null or empty.

setThreadName

public static void setThreadName(java.lang.String text)
Sets the current thread name, adding the specific suffix and a timestamp.

If a null suffix is passed, it removes the additional text, leaving the original thread name.

Parameters:
text - Suffix to add to the thread name

hygienize

public static java.lang.String hygienize(java.lang.String s)
It cleans 'dirty' strings, substituting dangerous characters. This is used to avoid problems when the client interface is on an internet navigator

Parameters:
s - String to be hygienized. If null, it is replaced by the empty String "".
Returns:
the hygienized string

checkNullParam

public static void checkNullParam(java.lang.Object param,
                                  java.lang.String paramName)
                           throws NullParameterException
Throws an exception if the specified parameter value is null.

Parameters:
param - the parameter value
paramName - the parameter name
Throws:
NullParameterException - if param is null


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.