net.sf.jaxme.js
Class Util

java.lang.Object
  extended bynet.sf.jaxme.js.Util

public class Util
extends java.lang.Object

Various static utility methods.

Author:
Jochen Wiedmann

Constructor Summary
Util()
           
 
Method Summary
static java.lang.String asJavaIdentifier(java.lang.String pIdentifier)
          Takes as input an arbitrary String and maps it to a String, which is a valid Java identifier.
static void checkJavaIdentifier(java.lang.String pName)
          Returns whether the given name is a valid Java identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

checkJavaIdentifier

public static void checkJavaIdentifier(java.lang.String pName)

Returns whether the given name is a valid Java identifier. Works by using Character.isJavaIdentifierStart(char) and Character.isJavaIdentifierPart(char).

Throws:
java.lang.IllegalArgumentException - The name is not valid. An explanation why is given in the detail message.

asJavaIdentifier

public static java.lang.String asJavaIdentifier(java.lang.String pIdentifier)

Takes as input an arbitrary String and maps it to a String, which is a valid Java identifier. Mapping works as follows:

  1. For the first character, invokes Character.isJavaIdentifierStart(char). If that method returns false, replaces the character with an underscore ('_').
  2. For any following character, invokes Character.isJavaIdentifierPart(char). If that method returns false, replaces the character with an underscore ('_').

Parameters:
pIdentifier - The identifier being mapped
Throws:
java.lang.IllegalArgumentException - The parameter pIdentifier cannot be converted into a Java identifier, because it is null or empty.