org.apache.ws.jaxme.js

Class Util

public class Util extends Object

Various static utility methods.

Author: Jochen Wiedmann

Method Summary
static StringasJavaIdentifier(String pIdentifier)

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

static voidcheckJavaIdentifier(String pName)

Returns whether the given name is a valid Java identifier.

static JavaSourcenewJavaSource(JavaSourceFactory pFactory, Class pClass)
Converts the given class into an instance of {@link JavaSource}.

Method Detail

asJavaIdentifier

public static String asJavaIdentifier(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 {@link Character#isJavaIdentifierStart(char)}. If that method returns false, replaces the character with an underscore ('_').
  2. For any following character, invokes {@link Character#isJavaIdentifierPart(char)}. If that method returns false, replaces the character with an underscore ('_').

Parameters: pIdentifier The identifier being mapped

Throws: IllegalArgumentException The parameter pIdentifier cannot be converted into a Java identifier, because it is null or empty.

checkJavaIdentifier

public static void checkJavaIdentifier(String pName)

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

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

newJavaSource

public static JavaSource newJavaSource(JavaSourceFactory pFactory, Class pClass)
Converts the given class into an instance of {@link JavaSource}.