wt.tools.generation
Class Util

java.lang.Object
  extended bywt.tools.generation.Util

public abstract class Util
extends Object


Field Summary
private static String[] javaDocTags
           
static char MODULE_SEPARATOR
           
private static ModuleRegistry moduleRegistry
           
static String targetModule
           
 
Constructor Summary
Util()
           
 
Method Summary
static int arraySize(String arrayType)
           
static String beanPropertyName(String string)
           
static String capitalize(String string)
           
static String classname(String qualifiedClassname)
          Get a String that is the base classname for a fully qualified classname.
static int containsCount(String target, String searchFor)
           
static void copyFile(File source_file, File target_file)
           
static String decapitalize(String string)
           
static String defaultValue(String type)
          Get he default value for a type.
static int getTagBlockBeginIndex(String documentation)
           
static String getTargetModule()
           
static String getterName(String root)
           
static String getterName(String root, String type)
           
static double hexToDecimal(String hexString)
          Convert a hex string to a double.
static boolean isEmpty(String theString)
           
private static boolean isJavaDocTag(String documentation)
           
static boolean isPrimitive(String type)
          Determine if a type name is a primitive type.
static boolean isPrimitiveComponent(String type)
          Determine if a type name is a primitive type, or an array of primitive types.
static boolean isPrimitiveWrapper(String type)
          Determine if a type name is a primitive wrapper type.
static boolean isPrimitiveWrapperComponent(String type)
          Determine if a type name is a primitive wrapper type, or an array of primitive wrapper types.
static boolean javaFileExists(String class_name, String package_name)
           
static String javaPackageName(String module_qualified_name)
          Get a String that is the package name of a module qualified package name.
private static String methodName(String root, String prefix)
           
static String moduleName(String module_qualified_name)
          Get the module name from a module qualified name.
static String packageName(String qualifiedClassname)
          Get a String that is the package name of a fully qualified class name.
static String packagePath(String packageName, String artifact)
          Get a String that is a path name for a particular artifact type, for a given package.
static String pathPackage(String path, String artifact)
          Get a String that is the package name for a path to a given type of artifact.
static String pathToModularPackage(String path, String artifact)
          Get a String that is the module qualified package name for a path to a given type of artifact.
static String primitiveToWrapper(String typename)
          Get a String that is the name of the object wrapper type for a primitive type.
static void printStackTrace()
           
static boolean processChangedFile(File source_file, File target_file, String target_root, boolean copy, boolean notify)
           
static void propertySetup(String[] args)
           
static String qualifiedClassname(String fullFileName, String rootPath)
          Get a String that is a fully qualified classname.
static String removerKeyedName(String root)
           
static void setTargetModule(String target_module)
           
static String setterKeyedName(String root)
           
static String setterName(String root)
           
static String setterParamName(String root)
           
static String stripArray(String type)
           
static String toArrayClassID(String type)
           
static String toConstant(String string)
          Get a String that is the constant name, based on the passed string.
static String variableName(String string)
           
static String wrapperToPrimitive(String typename)
          Get a String that is the name of the primitive type for a object wrapper type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetModule

public static String targetModule

MODULE_SEPARATOR

public static final char MODULE_SEPARATOR
See Also:
Constant Field Values

moduleRegistry

private static final ModuleRegistry moduleRegistry

javaDocTags

private static final String[] javaDocTags
Constructor Detail

Util

public Util()
Method Detail

arraySize

public static int arraySize(String arrayType)

beanPropertyName

public static final String beanPropertyName(String string)

capitalize

public static final String capitalize(String string)

classname

public static String classname(String qualifiedClassname)
Get a String that is the base classname for a fully qualified classname.
   Example Usage:
		Util.classname( "wt.test.MyClass" );			// returns "MyClass"

  

Parameters:
qualifiedClassname - - a String, which is a fully qualified classname
Returns:
The base classname, without the package qualification.

containsCount

public static int containsCount(String target,
                                String searchFor)

decapitalize

public static final String decapitalize(String string)

defaultValue

public static String defaultValue(String type)
Get he default value for a type.
   Example Usage:
  	Util.defaultValue( "boolean" )		// returns "false"

  	Util.defaultValue( "char" )			// returns "' '"

  	Util.defaultValue( "int" )			// returns "0"

  	Util.defaultValue( "Integer[]" )		// returns "null"

  	Util.defaultValue( "Integer" )		// returns "null"

  

Returns:
The default value for the type, as a String.

getTagBlockBeginIndex

public static int getTagBlockBeginIndex(String documentation)

getterName

public static String getterName(String root)

getterName

public static String getterName(String root,
                                String type)

isEmpty

public static boolean isEmpty(String theString)

isJavaDocTag

private static boolean isJavaDocTag(String documentation)

isPrimitive

public static boolean isPrimitive(String type)
Determine if a type name is a primitive type.
   Example Usage:
  	Util.isPrimitive( "int" )		// returns true

  	Util.isPrimitive( "int[]" )	// returns false

  	Util.isPrimitive( "Integer" )	// returns false

  

Parameters:
type - - a String, which represent the name of a type
Returns:
True if it is the name of a primitive type, otherwise false.
See Also:
generation.Util#primitiveToObject(String), generation.Util#isPrimitiveComponent(String), generation.Util#isPrimitiveWrapper(String)

isPrimitiveComponent

public static boolean isPrimitiveComponent(String type)
Determine if a type name is a primitive type, or an array of primitive types.
   Example Usage:
  	Util.isPrimitiveComponent( "int" )		// returns true

  	Util.isPrimitiveComponent( "int[]" )		// returns true

  	Util.isPrimitiveComponent( "Integer" )	// returns false

  

Parameters:
type - - a String, which represent the name of a type
Returns:
True if it is the name of a primitive type, otherwise false.
See Also:
generation.Util#primitiveToObject(String), generation.Util#isPrimitive(String), generation.Util#isPrimitiveWrapperComponent(String)

isPrimitiveWrapper

public static boolean isPrimitiveWrapper(String type)
Determine if a type name is a primitive wrapper type.
   Example Usage:
  	Util.isPrimitiveWrapper( "int" )			// returns false

  	Util.isPrimitiveWrapper( "Integer[]" )	// returns false

  	Util.isPrimitiveWrapper( "Integer" )	// returns true

  	Util.isPrimitiveWrapper( "java.lang.Integer" )	// returns true

  

Parameters:
type - - a String, which represent the name of a type
Returns:
True if it is the name of a primitive wrapper type, otherwise false.
See Also:
generation.Util#wrapperToPrimitive(String), generation.Util#isPrimitiveWrapperComponent(String), generation.Util#isPrimitiveWrapper(String)

isPrimitiveWrapperComponent

public static boolean isPrimitiveWrapperComponent(String type)
Determine if a type name is a primitive wrapper type, or an array of primitive wrapper types.
   Example Usage:
  	Util.isPrimitiveWrapper( "int" )			// returns false

  	Util.isPrimitiveWrapper( "Integer[]" )	// returns true

  	Util.isPrimitiveWrapper( "Integer" )	// returns true

  	Util.isPrimitiveWrapper( "java.lang.Integer" )	// returns true

  

Parameters:
type - - a String, which represent the name of a type
Returns:
True if it is the name of a primitive wrapper type, otherwise false.
See Also:
generation.Util#wrapperToPrimitive(String), generation.Util#isPrimitiveWrapper(String), generation.Util#isPrimitiveComponent(String)

javaFileExists

public static boolean javaFileExists(String class_name,
                                     String package_name)

methodName

private static String methodName(String root,
                                 String prefix)

packageName

public static String packageName(String qualifiedClassname)
Get a String that is the package name of a fully qualified class name.
   Example Usage:
		Util.packageName( "wt.test.MyClass" );			// return "wt.test"

		Util.packageName( "wt.test.MyClass$Inner" );	// return "wt.test"

  

Parameters:
qualifiedClassname - - a String, which is a full qualified class name
Returns:
The package name for the class.
See Also:
generation.Util#classname(String)

javaPackageName

public static String javaPackageName(String module_qualified_name)
Get a String that is the package name of a module qualified package name.
   Example Usage:
		Util.moduleName( "WNC/CommonCore:wt.util" );  // return "wt.util"

  

Parameters:
module_qualified_name - - a String, which is a module qualified package name
Returns:
The java package name for the qualified package.
See Also:
generation.Util#moduleName(String)

moduleName

public static String moduleName(String module_qualified_name)
Get the module name from a module qualified name.
   Example Usage:
		Util.moduleName( "WNC/CommonCore:wt.util" );
           // return "WNC/CommonCore"

		Util.moduleName( "WNC/CommonCore:wt.util.MyClass" );
           // return "WNC/CommonCore"

  

Parameters:
module_qualified_name - - a String, which is a module qualified name
Returns:
The module name for the element.
See Also:
generation.Util#javaPackageName(String)

packagePath

public static String packagePath(String packageName,
                                 String artifact)
Get a String that is a path name for a particular artifact type, for a given package. The package should be fully qualified with Assembly/Module, if any.
   Example Usage:
		Util.packagePath( "wt.test", ArtifactDir.BIN );
			returns ->	"C:\Windchill\codebase\wt\test"


  

Parameters:
packageName - - a String, which is a package name
artifact - - a String, which is the type of artifact whose path will be returned.
Returns:
The path for the specified artifacts of the package.

pathPackage

public static String pathPackage(String path,
                                 String artifact)
Get a String that is the package name for a path to a given type of artifact. The module registry is searched to find the module whose path for the artifact type matches the given path. If no such modules are found, the path is assumed to represent a package in the default module.
   Example Usage:
		Util.pathPackage( "C:/CommonCore/src/wt/util/Example.java", ArtifactDir.SRC );
			// returns ->	"wt.util"

		Util.pathPackage( "C:/CommonCore/src/wt/util", ArtifactDir.SRC );
			// returns ->	"wt.util"

  

Parameters:
path - - a String, which is a path
artifact - - a String, which represents the type of artifact represented by the path.
Returns:
The package name for the path.

pathToModularPackage

public static String pathToModularPackage(String path,
                                          String artifact)
Get a String that is the module qualified package name for a path to a given type of artifact. The module registry is searched to find the module whose path for the artifact type matches the given path. If no such modules are found, the path is assumed to represent a package in the default module.
		Util.pathToModularPackage( "C:/CommonCore/src/wt/util/Example.java", ArtifactDir.SRC );
			// returns ->	"WNC/CommonCore:wt.util"

		Util.pathToModularPackage( "C:/CommonCore/src/wt/util", ArtifactDir.SRC );
			// returns ->	"WNC/CommonCore:wt.util"

		Util.pathToModularPackage( "C:/Windchill/src/wt/util", ArtifactDir.SRC );
			// returns ->	"wt.util"

  

Parameters:
path - - a String, which is a path
artifact - - a String, which represents the type of artifact represented by the path.
Returns:
The module qualified package name for the path.

primitiveToWrapper

public static String primitiveToWrapper(String typename)
Get a String that is the name of the object wrapper type for a primitive type.
   Example Usage:
  	Util.primitiveToObject( "int" )		// returns "Integer"

  	Util.primitiveToObject( "int[]" )	// returns "Integer[]"

  	Util.primitiveToObject( "Integer" )	// returns "Integer"

  

Parameters:
typename - - a String, which represent the name of a type
Returns:
The name of an object type, which is the wrapper for the type parameter.
See Also:
generation.Util#isPrimitive(String)

printStackTrace

public static void printStackTrace()

propertySetup

public static void propertySetup(String[] args)
                          throws Exception
Throws:
Exception

qualifiedClassname

public static String qualifiedClassname(String fullFileName,
                                        String rootPath)
Get a String that is a fully qualified classname.
   Example Usage:
		Util.qualifiedClassname( "C:\classpath\wt\test\MyClass.ext", "C:\classpath" );
			returns ->	"wt.test.MyClass"

		Util.qualifiedClassname( "C:\classpath\wt\test\MyClass.ext", "C:\classpath\" );
			returns ->	"wt.test.MyClass"

		Util.qualifiedClassname( "C:\classpath\wt\test", "C:\classpath" );
			returns ->	"wt.test"

  

Parameters:
fullFileName - - a String, which is a full file name
rootPath - - a String, which is a path in the class path
Returns:
The fully qualified classname.
See Also:
generation.Util#packageName(String)

removerKeyedName

public static String removerKeyedName(String root)

setterKeyedName

public static String setterKeyedName(String root)

setterName

public static String setterName(String root)

setterParamName

public static String setterParamName(String root)

stripArray

public static String stripArray(String type)

toArrayClassID

public static String toArrayClassID(String type)

toConstant

public static String toConstant(String string)
Get a String that is the constant name, based on the passed string.
   Example Usage:
  	Util.toConstant( "myAttribute" )		// returns "MY_ATTRIBUTE"

  	Util.toConstant( "something" )		// returns "SOMETHING"

  	Util.toConstant( "aBigAttribute" )	// returns "A_BIG_ATTRIBUTE"

  

Parameters:
string - - a String, which is a name to convert
Returns:
The string converted to a constant name.

variableName

public static final String variableName(String string)

wrapperToPrimitive

public static String wrapperToPrimitive(String typename)
Get a String that is the name of the primitive type for a object wrapper type.
   Example Usage:
  	Util.wrapperToPrimitive( "int" )			// returns "int"

  	Util.wrapperToPrimitive( "Integer[]" )	// returns "int[]"

  	Util.wrapperToPrimitive( "Integer" )	// returns "int"

  	Util.wrapperToPrimitive( "java.lang.Integer" )	// returns "int"

  

Parameters:
typename - - a String, which represent the name of a type
Returns:
The name of a primitive type, which is the type wrapped by the type parameter.
See Also:
generation.Util#isPrimitiveWrapper(String), generation.Util#primitiveToWrapper(String)

hexToDecimal

public static double hexToDecimal(String hexString)
Convert a hex string to a double.
   Example Usage:
  	WTStringUtilities.hexToDecimal( "21C" )		// returns 540.0

  	WTStringUtilities.hexToDecimal( "-12" )		// returns -18.0

  

Parameters:
hexString - - a hex number as a String
Returns:
The hex string as a base 10 (decimal) number.

getTargetModule

public static String getTargetModule()

setTargetModule

public static void setTargetModule(String target_module)

processChangedFile

public static boolean processChangedFile(File source_file,
                                         File target_file,
                                         String target_root,
                                         boolean copy,
                                         boolean notify)
                                  throws IOException
Throws:
IOException

copyFile

public static void copyFile(File source_file,
                            File target_file)
                     throws IOException
Throws:
IOException