Package lucee.runtime.util
Interface ClassUtil
public interface ClassUtil
-
Method Summary
Modifier and TypeMethodDescriptionorg.osgi.framework.Bundle
addBundle
(org.osgi.framework.BundleContext context, InputStream is, boolean closeStream, boolean checkExistence) callConstructor
(Class<?> clazz, Object[] args) call constructor of a Class with matching argumentscallConstructor
(Class<?> clazz, Object[] args, Object defaultValue) callMethod
(Object obj, Collection.Key methodName, Object[] args) calls a Method of an ObjectcallMethod
(Object obj, Collection.Key methodName, Object[] args, Object defaultValue) callStaticMethod
(Class<?> clazz, String methodName, Object[] args) calls a Static Method on the given CLassboolean
canConvert
(Class<?> from, Class<?> to) check if given Class "from" can be converted to Class "to" without explicit castingconvert
(Object src, Class<?> trgClass, RefInteger rating) convert Object from src to trg Type, if possibleextractName
(String className) extracts the Class name of a classname with packageextractPackage
(String className) extracts the package from a className, return null, if there is none.Class<?>[]
getClasses
(Object[] objs) get all Classes from an Object ArrayMethod[]
getDeclaredMethods
(Class<?> clazz) return all methods that are defined by the Class itself (not extended)to get a visible Field of an objectString[]
getFieldNames
(Class<?> clazz) return all field names as String arrayField[]
getFieldsIgnoreCase
(Class<?> clazz, String name) same like method getField from Class but ignore case from field nameField[]
getFieldsIgnoreCase
(Class<?> clazz, String name, Field[] defaultValue) getMethodIgnoreCase
(Class<?> clazz, String methodName, Class<?>[] args) getMethodIgnoreCase
(Class<?> clazz, String methodName, Class<?>[] args, Method defaultValue) getProperty
(Object obj, String prop) to get a visible Property (Field or Getter) of an objectgetProperty
(Object obj, String prop, Object defaultValue) to get a visible Property (Field or Getter) of an objectString[]
getPropertyKeys
(Class<?> clazz) getSourcePathForClass
(Class<?> clazz, String defaultValue) returns the path to the directory or jar file that the Class was loaded fromgetSourcePathForClass
(String className, String defaultValue) tries to load the Class and returns the path that it was loaded fromboolean
hasFieldIgnoreCase
(Class<?> clazz, String name) boolean
hasPropertyIgnoreCase
(Class<?> clazz, String name) boolean
isBytecode
(byte[] barr) boolean
check if given stream is a bytecode stream, if yes remove bytecode markboolean
isInstaneOf
(Class<?> src, Class<?> trg) check if Class is instanceof another Classboolean
isInstaneOf
(Class<?> src, String trgClassName) check if Class is instanceof another Classboolean
isInstaneOf
(String srcClassName, Class<?> trg) check if Class is instanceof another Classboolean
isInstaneOf
(String srcClassName, String trgClassName) boolean
isInstaneOfIgnoreCase
(Class<?> src, String trg) boolean
checks if src Class is "like" trg classloadBIF
(PageContext pc, String name) Class
<?> loadClass
(ClassLoader cl, String className) loads a Class from a specified Classloader with given classnameClass
<?> loadClass
(ClassLoader cl, String className, Class<?> defaultValue) loads a Class from a specified Classloader with given classnameClass
<?> loads Class that match given classname, this Class can be from the Lucee core as wellClass
<?> loads a Class from a String classnameClass
<?> loadClass
(PageContext pc, String className, String bundleName, String bundleVersion) loads Class that match given classname and the given bundle name and version, this Class can be from the Lucee core as wellClass
<?> loadClassByBundle
(String className, String name, String strVersion, Identification id) Class
<?> loadClassByBundle
(String className, String name, org.osgi.framework.Version version, Identification id) loadInstance
(Class<?> clazz) loads a Class from a String classnameloadInstance
(Class<?> clazz, Object defaultValue) loads a Class from a String classnameloadInstance
(Class<?> clazz, Object[] args) loads a Class from a String classnameloadInstance
(Class<?> clazz, Object[] args, Object defaultValue) loads a Class from a String classnameloadInstance
(ClassLoader cl, String className) loadInstance
(ClassLoader cl, String className, Object defaultValue) loadInstance
(ClassLoader cl, String className, Object[] args) loadInstance
(ClassLoader cl, String className, Object[] args, Object defaultValue) loadInstance
(String className) loadInstance
(String className, Object defaultValue) loadInstance
(String className, Object[] args) loadInstance
(String className, Object[] args, Object defaultValue) boolean
assign a value to a visible Field of an objectvoid
setProperty
(Object obj, String prop, Object value) assign a value to a visible Property (Field or Setter) of an objectvoid
setPropertyEL
(Object obj, String prop, Object value) assign a value to a visible Property (Field or Setter) of an objectvoid
start
(org.osgi.framework.Bundle bundle) Class
<?> toArrayClass
(Class<?> clazz) return an array Class based on the given Class (opposite from Class.getComponentType())byte[]
Class
<?> toComponentType
(Class<?> clazz) Class
<?> toReferenceClass
(Class<?> c) convert a primitive Class Type to a Reference Type (Example: int to java.lang.Integer)
-
Method Details
-
loadClass
loads Class that match given classname, this Class can be from the Lucee core as well- Parameters:
className
- name of the Class to load- Returns:
- Class
- Throws:
IOException
- IO Exception
-
loadClass
Class<?> loadClass(PageContext pc, String className, String bundleName, String bundleVersion) throws org.osgi.framework.BundleException, IOException loads Class that match given classname and the given bundle name and version, this Class can be from the Lucee core as well- Parameters:
pc
- Page ContextclassName
- name of the Class to loadbundleName
- name of the bundle to load frombundleVersion
- version of the bundle to load from (if null ignored)- Returns:
- class
- Throws:
org.osgi.framework.BundleException
- Bundle ExceptionIOException
- IO Exception
-
loadBIF
-
isInstaneOf
check if Class is instanceof another Class- Parameters:
srcClassName
- class name to checktrg
- class to check- Returns:
- is instance of
-
isInstaneOf
- Parameters:
srcClassName
- class name to checktrgClassName
- class name to check- Returns:
- is instance of
-
isInstaneOf
check if Class is instanceof another Class- Parameters:
src
- is Class of?trgClassName
- Class name to check- Returns:
- is Class Class of...
-
isInstaneOfIgnoreCase
-
isInstaneOf
check if Class is instanceof another Class- Parameters:
src
- Class to checktrg
- is Class of ?- Returns:
- is Class Class of...
-
getClasses
get all Classes from an Object Array- Parameters:
objs
- Objects to get- Returns:
- classes from Objects
-
toReferenceClass
convert a primitive Class Type to a Reference Type (Example: int to java.lang.Integer)- Parameters:
c
- Class to convert- Returns:
- converted Class (if primitive)
-
like
checks if src Class is "like" trg class- Parameters:
src
- Source Classtrg
- Target Class- Returns:
- is similar
-
convert
convert Object from src to trg Type, if possible- Parameters:
src
- Object to converttrgClass
- Target Classrating
- rating- Returns:
- converted Object
- Throws:
PageException
- Page Exception
-
getFieldsIgnoreCase
same like method getField from Class but ignore case from field name- Parameters:
clazz
- Class to search the fieldname
- name to search- Returns:
- Matching Field
- Throws:
NoSuchFieldException
- No Such Field Exception
-
getFieldsIgnoreCase
-
getPropertyKeys
-
hasPropertyIgnoreCase
-
hasFieldIgnoreCase
-
callConstructor
call constructor of a Class with matching arguments- Parameters:
clazz
- Class to get Instanceargs
- Arguments for the Class- Returns:
- invoked Instance
- Throws:
PageException
- Page Exception
-
callConstructor
-
callMethod
calls a Method of an Object- Parameters:
obj
- Object to call Method on itmethodName
- Name of the Method to getargs
- Arguments of the Method to get- Returns:
- return return value of the called Method
- Throws:
PageException
- Page Exception
-
callMethod
-
callStaticMethod
calls a Static Method on the given CLass- Parameters:
clazz
- Class to call Method on itmethodName
- Name of the Method to getargs
- Arguments of the Method to get- Returns:
- return return value of the called Method
- Throws:
PageException
- Page Exception
-
getField
to get a visible Field of an object- Parameters:
obj
- Object to invokeprop
- property to call- Returns:
- property value
- Throws:
PageException
- Page Exception
-
getField
-
setField
assign a value to a visible Field of an object- Parameters:
obj
- Object to assign value to his propertyprop
- name of propertyvalue
- Value to assign- Returns:
- success
- Throws:
PageException
- Page Exception
-
getProperty
to get a visible Property (Field or Getter) of an object- Parameters:
obj
- Object to invokeprop
- property to call- Returns:
- property value
- Throws:
PageException
- Page Exception
-
getProperty
to get a visible Property (Field or Getter) of an object- Parameters:
obj
- Object to invokeprop
- property to calldefaultValue
- default value- Returns:
- property value
-
setProperty
assign a value to a visible Property (Field or Setter) of an object- Parameters:
obj
- Object to assign value to his propertyprop
- name of propertyvalue
- Value to assign- Throws:
PageException
- Page Exception
-
setPropertyEL
assign a value to a visible Property (Field or Setter) of an object- Parameters:
obj
- Object to assign value to his propertyprop
- name of propertyvalue
- Value to assign
-
getDeclaredMethods
return all methods that are defined by the Class itself (not extended)- Parameters:
clazz
- class- Returns:
- Returns declared methods.
-
canConvert
check if given Class "from" can be converted to Class "to" without explicit casting- Parameters:
from
- source classto
- target class- Returns:
- is it possible to convert from "from" to "to"
-
loadClassByBundle
Class<?> loadClassByBundle(String className, String name, String strVersion, Identification id) throws IOException, org.osgi.framework.BundleException - Throws:
IOException
org.osgi.framework.BundleException
-
loadClassByBundle
Class<?> loadClassByBundle(String className, String name, org.osgi.framework.Version version, Identification id) throws org.osgi.framework.BundleException, IOException - Throws:
org.osgi.framework.BundleException
IOException
-
loadClass
loads a Class from a String classname- Parameters:
className
- class namedefaultValue
- default value- Returns:
- matching Class
-
loadClass
loads a Class from a specified Classloader with given classname- Parameters:
cl
- class loaderclassName
- class namedefaultValue
- default value- Returns:
- matching Class
-
loadClass
loads a Class from a specified Classloader with given classname- Parameters:
cl
- class loaderclassName
- class name- Returns:
- matching Class
- Throws:
IOException
- IO Exception
-
loadInstance
loads a Class from a String classname- Parameters:
clazz
- Class to load- Returns:
- matching Class
- Throws:
IOException
- IO Exception
-
loadInstance
- Throws:
IOException
-
loadInstance
- Throws:
IOException
-
loadInstance
loads a Class from a String classname- Parameters:
clazz
- Class to loaddefaultValue
- default value- Returns:
- matching Class
-
loadInstance
-
loadInstance
-
loadInstance
loads a Class from a String classname- Parameters:
clazz
- Class to loadargs
- arguments- Returns:
- matching Class
- Throws:
IOException
- IO ExceptionInvocationTargetException
- Invocation Target Exception
-
loadInstance
- Throws:
IOException
InvocationTargetException
-
loadInstance
Object loadInstance(ClassLoader cl, String className, Object[] args) throws IOException, InvocationTargetException - Throws:
IOException
InvocationTargetException
-
loadInstance
loads a Class from a String classname- Parameters:
clazz
- Class to loadargs
- argumentsdefaultValue
- default value- Returns:
- matching Class
-
loadInstance
-
loadInstance
-
isBytecode
check if given stream is a bytecode stream, if yes remove bytecode mark- Parameters:
is
- Input Stream- Returns:
- is bytecode stream
- Throws:
IOException
- IO Exception
-
isBytecode
boolean isBytecode(byte[] barr) -
getName
-
getMethodIgnoreCase
- Throws:
IOException
-
getMethodIgnoreCase
-
getFieldNames
return all field names as String array- Parameters:
clazz
- Class to get field names from- Returns:
- field names
-
toBytes
- Throws:
IOException
-
toArrayClass
return an array Class based on the given Class (opposite from Class.getComponentType())- Parameters:
clazz
- class- Returns:
- Returns an Array Class.
-
toComponentType
-
getSourcePathForClass
returns the path to the directory or jar file that the Class was loaded from- Parameters:
clazz
- - the Class object to check, for a live object pass obj.getClass();defaultValue
- - a value to return in case the source could not be determined- Returns:
- Returns the source path for the Class.
-
getSourcePathForClass
tries to load the Class and returns the path that it was loaded from- Parameters:
className
- - the name of the Class to checkdefaultValue
- - a value to return in case the source could not be determined- Returns:
- Returns the source path for the Class.
-
extractPackage
extracts the package from a className, return null, if there is none.- Parameters:
className
- Class Name- Returns:
- Returns the source path for the Class.
-
extractName
extracts the Class name of a classname with package- Parameters:
className
- Class Name- Returns:
- Returns Class name.
-
start
void start(org.osgi.framework.Bundle bundle) throws org.osgi.framework.BundleException - Throws:
org.osgi.framework.BundleException
-
addBundle
org.osgi.framework.Bundle addBundle(org.osgi.framework.BundleContext context, InputStream is, boolean closeStream, boolean checkExistence) throws org.osgi.framework.BundleException, IOException - Throws:
org.osgi.framework.BundleException
IOException
-