com.sibvisions.util
Class SimpleJavaSource

java.lang.Object
  extended by com.sibvisions.util.SimpleJavaSource

public class SimpleJavaSource
extends Object

The SimpleJavaSource interprets Java Source.


Field Summary
protected  Map<String,String> archiveClassListMap
          Imports to find Java Classes.
protected  List<String> cachedRealImports
          Real Imports without default package.
protected  List<Class<?>> classesWithConstants
          The Name for constants.
protected  ClassLoader classLoader
          The classloader for class loading.
protected  String className
          The class name of this instance.
protected  Map<Class<?>,List<String>> ignoreProperties
          Class forName.
protected  ArrayList<String> imports
          Imports to find Java Classes.
protected  Map<Object,String> instanceNames
          The Name for any instance.
protected  Map<String,Object> instances
          All known instances.
protected  String interfaceNames
          The interfaces.
protected  Map<String,Class<?>> simpleClassNameClasses
          Class forName.
protected  String superClassName
          The super class.
protected static StringBuilder tempBuilder
          Static temporary string builder, to avoid heap consumption.
protected  List<Object> tempTags
          Parsed Tags Cache.
 
Constructor Summary
SimpleJavaSource()
          Constructs a new SimpleJavaSource.
 
Method Summary
 void addClassWithConstants(Class<?> pClass)
          Adds class to constant classes.
 void addImport(String pImport)
          Adds an import statement to find simple class names.
 Object execute(String pSource)
          Executes any java statement.
 List<String> getArchiveClassList()
          Gets the archive class list to find classes with simple class name without class loader.
 Class<?> getClassByName(String pClassName)
          Gets the class for the given name.
 Class<?> getClassByName(String pClassName, boolean pSimpleClassName)
          Gets the class for the given class name.
 Class<?>[] getClassesWithConstants()
          Gets all classes from constant classes.
 ClassLoader getClassLoader()
          Gets the class loader.
 String getClassName()
          Gets the class name.
 Class<?> getComponentType(Class<?> pComponentType, int pDimension)
          Gets the array class with the given dimension.
 String getDefaultPackage()
          Gets the default package of this class name.
 String getFieldName(Object pInstance)
          Gets the name for a instance.
 String[] getFieldNames()
          Gets all fields.
 Object getFieldValue(String pFieldName)
          Gets the instance for a specific field.
 List<String> getIgnorePropertyDefinition(Class<?> pSuperClass)
          Gets the properties to ignore.
 List<String> getImports()
          Gets all import statements.
 String getInterfaceNames()
          Gets the interface names.
 String getSuperClassName()
          Gets the super class name.
 boolean isPropertyIgnored(Object pInstance, String pPropertyName)
          True, if the given property has to be ignored.
 boolean isPropertySet(Object pInstance, String pPropertyName)
          True, if the given property is detected as set with isXxxSet.
 void removeAllImports()
          Removes all import statement.
 void removeClassWithConstants(Class<?> pClass)
          Removes class from constant classes.
 void removeField(String pFieldName)
          Removes the specific field.
 void removeImport(String pImport)
          Removes an import statement.
 void setArchiveClassList(List<String> pArchiveClassList)
          Sets the archive class list to find classes with simple class name without class loader.
 void setClassLoader(ClassLoader pClassLoader)
          Sets the class loader.
 void setClassName(String pClassName)
          Sets the class name.
 void setFieldValue(String pFieldName, Object pInstance)
          Sets the instance for a specific field.
 void setIgnorePropertyDefinition(Class<?> pSuperClass, List<String> pIgnoreProperties)
          Gets the properties to ignore.
 void setInterfaceNames(String pInterfaceNames)
          Sets the interface names.
 void setSuperClassName(String pSuperClassName)
          Sets the super class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tempBuilder

protected static StringBuilder tempBuilder
Static temporary string builder, to avoid heap consumption.


classesWithConstants

protected List<Class<?>> classesWithConstants
The Name for constants.


className

protected String className
The class name of this instance. The default package of this class name is used as implicit import.


superClassName

protected String superClassName
The super class.


interfaceNames

protected String interfaceNames
The interfaces.


imports

protected ArrayList<String> imports
Imports to find Java Classes.


cachedRealImports

protected List<String> cachedRealImports
Real Imports without default package.


ignoreProperties

protected Map<Class<?>,List<String>> ignoreProperties
Class forName.


archiveClassListMap

protected Map<String,String> archiveClassListMap
Imports to find Java Classes.


simpleClassNameClasses

protected Map<String,Class<?>> simpleClassNameClasses
Class forName.


tempTags

protected List<Object> tempTags
Parsed Tags Cache.


instances

protected Map<String,Object> instances
All known instances.


instanceNames

protected Map<Object,String> instanceNames
The Name for any instance.


classLoader

protected ClassLoader classLoader
The classloader for class loading.

Constructor Detail

SimpleJavaSource

public SimpleJavaSource()
Constructs a new SimpleJavaSource.

Method Detail

getClassLoader

public ClassLoader getClassLoader()
Gets the class loader.

Returns:
the class loader.

setClassLoader

public void setClassLoader(ClassLoader pClassLoader)
Sets the class loader.

Parameters:
pClassLoader - the class loader.

getClassName

public String getClassName()
Gets the class name.

Returns:
the class name.

setClassName

public void setClassName(String pClassName)
Sets the class name.

Parameters:
pClassName - the class name.

getDefaultPackage

public String getDefaultPackage()
Gets the default package of this class name.

Returns:
the default package of this class name.

getSuperClassName

public String getSuperClassName()
Gets the super class name.

Returns:
the super class name.

setSuperClassName

public void setSuperClassName(String pSuperClassName)
Sets the super class name.

Parameters:
pSuperClassName - the super class name.

getInterfaceNames

public String getInterfaceNames()
Gets the interface names.

Returns:
the interface names.

setInterfaceNames

public void setInterfaceNames(String pInterfaceNames)
Sets the interface names.

Parameters:
pInterfaceNames - the interface names.

getArchiveClassList

public List<String> getArchiveClassList()
Gets the archive class list to find classes with simple class name without class loader.

Returns:
the archive class list.

setArchiveClassList

public void setArchiveClassList(List<String> pArchiveClassList)
Sets the archive class list to find classes with simple class name without class loader.

Parameters:
pArchiveClassList - the archive class list.

addClassWithConstants

public void addClassWithConstants(Class<?> pClass)
Adds class to constant classes.

Parameters:
pClass - the class to add.

removeClassWithConstants

public void removeClassWithConstants(Class<?> pClass)
Removes class from constant classes.

Parameters:
pClass - the class to remove.

getClassesWithConstants

public Class<?>[] getClassesWithConstants()
Gets all classes from constant classes.

Returns:
pClass the class to remove.

addImport

public void addImport(String pImport)
Adds an import statement to find simple class names.

Parameters:
pImport - the import.

removeImport

public void removeImport(String pImport)
Removes an import statement.

Parameters:
pImport - the class.

removeAllImports

public void removeAllImports()
Removes all import statement.


getImports

public List<String> getImports()
Gets all import statements.

Returns:
all import statements.

getIgnorePropertyDefinition

public List<String> getIgnorePropertyDefinition(Class<?> pSuperClass)
Gets the properties to ignore.

Parameters:
pSuperClass - the super class
Returns:
the properties to ignore.

setIgnorePropertyDefinition

public void setIgnorePropertyDefinition(Class<?> pSuperClass,
                                        List<String> pIgnoreProperties)
Gets the properties to ignore.

Parameters:
pSuperClass - the super class
pIgnoreProperties - the properties to ignore.

isPropertyIgnored

public boolean isPropertyIgnored(Object pInstance,
                                 String pPropertyName)
True, if the given property has to be ignored.

Parameters:
pInstance - the instance.
pPropertyName - the property.
Returns:
True, if the given property has to be ignored.

isPropertySet

public boolean isPropertySet(Object pInstance,
                             String pPropertyName)
True, if the given property is detected as set with isXxxSet.

Parameters:
pInstance - the instance.
pPropertyName - the property.
Returns:
True, if the given property is detected as set with isXxxSet.

getFieldValue

public Object getFieldValue(String pFieldName)
Gets the instance for a specific field.

Parameters:
pFieldName - the field name.
Returns:
the instance.

setFieldValue

public void setFieldValue(String pFieldName,
                          Object pInstance)
Sets the instance for a specific field.

Parameters:
pFieldName - the field name.
pInstance - the instance.

getFieldName

public String getFieldName(Object pInstance)
Gets the name for a instance.

Parameters:
pInstance - the field name.
Returns:
the instance.

removeField

public void removeField(String pFieldName)
Removes the specific field.

Parameters:
pFieldName - the field name.

getFieldNames

public String[] getFieldNames()
Gets all fields.

Returns:
all fields.

execute

public Object execute(String pSource)
Executes any java statement.

Parameters:
pSource - the source.
Returns:
the result.

getClassByName

public Class<?> getClassByName(String pClassName,
                               boolean pSimpleClassName)
Gets the class for the given class name.

Parameters:
pClassName - the class name
pSimpleClassName - true if the name is a simple class name, false otherwise
Returns:
the class or null if no class with given name was found

getClassByName

public Class<?> getClassByName(String pClassName)
Gets the class for the given name.

Parameters:
pClassName - the full qualified class name
Returns:
the class or null if no class with given name was found

getComponentType

public Class<?> getComponentType(Class<?> pComponentType,
                                 int pDimension)
Gets the array class with the given dimension.

Parameters:
pComponentType - the simple class name.
pDimension - the array dimension.
Returns:
the class.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.