de.uni_paderborn.tools.util
Class TextUtil

java.lang.Object
  extended byde.uni_paderborn.tools.util.TextUtil

public final class TextUtil
extends java.lang.Object

A class that contains some text-based utilities for fujaba.

Version:
$Revision: 1.11 $
Author:
$Author: fklar $

Method Summary
static java.lang.String getNameWithoutPackage(java.lang.String className)
          Get the nameWithoutPackage attribute of the TextUtil class
static java.lang.String getPackageWithoutName(java.lang.String className)
          Get the packageWithoutName attribute of the TextUtil class
static boolean isJavaIdentifier(java.lang.String string)
          Calls the Character.isJavaIdentifierPart(char) method for each char in string.
static boolean isJavaIdentifier(java.lang.String string, boolean considerStartLetter)
          Calls the Character.isJavaIdentifierPart(char) method for each char in string.
static boolean isJavaKeyword(java.lang.String str)
          This method returns true if the provided String represents one of the Java keywords as defined in the language specification.
static boolean isJavaKeyword(java.lang.String str, boolean literalsIncluded)
          This method returns true if the provided String represents one of the Java keywords as defined in the language specification.
static boolean isJavaKeyword(java.lang.String str, boolean literalsIncluded, boolean trim)
          This method returns true if the provided String represents one of the Java keywords as defined in the language specification.
static boolean isJavaSuitable(java.lang.String string)
          Calls the Character.isJavaIdentifierPart(char) method for each char in string.
static boolean isJavaSuitable(java.lang.String string, boolean considerStartLetter)
          Calls the Character.isJavaIdentifierPart(char) method for each char in string.
static java.lang.String makeFujabaSuitable(java.lang.String s)
          Turns a String, that represents a parameter or return type, to the right value so that a comparison of this String with the list of parameters e. g. in a method declaration will return true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isJavaKeyword

public static boolean isJavaKeyword(java.lang.String str)
This method returns true if the provided String represents one of the Java keywords as defined in the language specification. It returns true as well, if the String represents a Java literal, which are "true", "false" and "null". If the String itself is null, false is returned. When the String is compared, it has to match cases. All Keywords and literals are lower-case-words.
This method returns the same as isJavaKeyword(str, true, true).

Note:
Beginning spaces and spaces at the end will be ignored because of invoking the trim()-method on this String.

Parameters:
str - The String to be possibly a Java keyword.
Returns:
true, if the provided String represents a Java keyword or Java literal, false otherwise.

isJavaKeyword

public static boolean isJavaKeyword(java.lang.String str,
                                    boolean literalsIncluded)
This method returns true if the provided String represents one of the Java keywords as defined in the language specification. By setting the boolean value literalsIncluded to true, it returns true as well, if the String represents a Java literal, which are "true", "false" and "null". If the String itself is null, false is returned. When the String is compared, it has to match cases. All Keywords and literals are lower-case-words.
This method returns the same as isJavaKeyword(str, true, true).

Note:
Beginning spaces and spaces at the end will be ignored because of invoking the trim()-method on this String.

Parameters:
str - The String to be possibly a Java keyword.
literalsIncluded - If true, the test will be extended to the Java literals "false", "true" and "null".
Returns:
true, if the provided String represents a Java keyword or, depending on the boolean parameter, represents a Java literal, false otherwise.

isJavaKeyword

public static boolean isJavaKeyword(java.lang.String str,
                                    boolean literalsIncluded,
                                    boolean trim)
This method returns true if the provided String represents one of the Java keywords as defined in the language specification. By setting the boolean value literalsIncluded to true, it returns true as well, if the String represents a Java literal, which are "true", "false" and "null". If the String itself is null, false is returned. When the String is compared, it has to match cases. All Keywords and literals are lower-case-words.

Parameters:
str - The String to be possibly a Java keyword.
literalsIncluded - If true, the test will be extended to the Java literals "false", "true" and "null".
trim - Indicates if the trim()-method should be invoked on the String before testing.
Returns:
true, if the provided String represents a Java keyword or, depending on the boolean parameter, represents a Java literal, false otherwise.

isJavaIdentifier

public static boolean isJavaIdentifier(java.lang.String string)
Calls the Character.isJavaIdentifierPart(char) method for each char in string. Calls also Character.isJavaIdentifierStart(char) for the first char. Returns true if the method written above returns true for each char, false otherwise. If string is null, it returns false. If string.length()==0 it returns true.

Parameters:
string - No description provided
Returns:
The javaIdentifier value

isJavaSuitable

public static boolean isJavaSuitable(java.lang.String string)
Calls the Character.isJavaIdentifierPart(char) method for each char in string. Calls also Character.isJavaIdentifierStart(char) for the first char. Returns true if the method written above returns true for each char, false otherwise. If string is null, it returns false. If string.length()==0 it returns true.

Parameters:
string - No description provided
Returns:
The javaSuitable value

isJavaIdentifier

public static boolean isJavaIdentifier(java.lang.String string,
                                       boolean considerStartLetter)
Calls the Character.isJavaIdentifierPart(char) method for each char in string. Calls also Character.isJavaIdentifierStart(char) for the first char if considerStartLetter is true. Returns true if the method written above returns true for each char, false otherwise. If string is null, it returns false. If string.length()==0 it returns true.

Parameters:
string - No description provided
considerStartLetter - No description provided
Returns:
The javaIdentifier value

isJavaSuitable

public static boolean isJavaSuitable(java.lang.String string,
                                     boolean considerStartLetter)
Calls the Character.isJavaIdentifierPart(char) method for each char in string. Calls also Character.isJavaIdentifierStart(char) for the first char if considerStartLetter is true. Returns true if the method written above returns true for each char, false otherwise. If string is null, it returns false. If string.length()==0 it returns true.

Parameters:
string - No description provided
considerStartLetter - No description provided
Returns:
The javaSuitable value

makeFujabaSuitable

public static java.lang.String makeFujabaSuitable(java.lang.String s)
Turns a String, that represents a parameter or return type, to the right value so that a comparison of this String with the list of parameters e. g. in a method declaration will return true. This method turn the following String to to following modified Strings:

String Modified String boolean Boolean boolean[] BooleanArray byte Byte byte[] ByteArray char Character char[] CharacterArray double Double double[] DoubleArray float Float float[] FloatArray int Integer int[] IntegerArray long LongInteger long[] LongIntegerArray short ShortInteger short[] ShortIntegerArray String[] StringArray void Void

Parameters:
s - The String to be "translated".
Returns:
The "translated" String, or the String itself if nothing has be done.

getNameWithoutPackage

public static java.lang.String getNameWithoutPackage(java.lang.String className)
Get the nameWithoutPackage attribute of the TextUtil class

Parameters:
className - No description provided
Returns:
The nameWithoutPackage value

getPackageWithoutName

public static java.lang.String getPackageWithoutName(java.lang.String className)
Get the packageWithoutName attribute of the TextUtil class

Parameters:
className - No description provided
Returns:
The packageWithoutName value