|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.ejen.ext.JavaClassToXML
Class reflection utility (static methods).
Usage (XSL stylesheet) |
---|
<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... xmlns:jcx="org.ejen.ext.JavaClassToXML" version="1.0"> <xsl:output method="xml" encoding="iso-8859-1"/> <xsl:template match="ejen"> <xsl:copy-of select="jcx: |
Field Summary | |
static String |
DIM_STR
String that represents one array dimension: [] |
Constructor Summary | |
protected |
JavaClassToXML()
Protected constructor (prevents instanciation). |
Method Summary | |
static String |
dimsOfType(ExpressionContext context,
String type)
Returns type array dimensions in the form of " [][][]... |
static String |
packageOfType(ExpressionContext context,
String type)
Returns type package information. |
protected static Node |
process(Document doc,
Class c)
Returns a Node that represents a Class definition.
|
static Node |
process(ExpressionContext context,
String className)
Returns a Node that represents a Class definition.
|
static String |
stripType(ExpressionContext context,
String type)
Strips a type definition (see Java signature format ), removing all array dimensions and package information.
|
static String |
stripTypeDims(ExpressionContext context,
String type)
Strips a type definition (see Java signature format ), removing only array dimensions information.
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String DIM_STR
[]
Constructor Detail |
protected JavaClassToXML()
Method Detail |
public static Node process(ExpressionContext context, String className)
Node
that represents a Class definition.
<xsl:copy-of select="jcx:process('java.lang.String')"/> |
The class definition returned is recursive (for each class/interface definition, all extended or implemented class/interface definitions are also provided).
For "java.lang.String", the returned tree as the following structure:
<class-definition interface="false"> <package><![CDATA[java.lang]]></package> <modifiers><![CDATA[public final]]></modifiers> <name><![CDATA[String]]></name> <extends> <class-definition interface="false"> <package><![CDATA[java.lang]]></package> <modifiers><![CDATA[public]]></modifiers> <name><![CDATA[Object]]></name> ... </class-definition> </extends> <implements> <class-definition interface="true"> <package><![CDATA[java.io]]></package> <modifiers><![CDATA[public abstract interface]]></modifiers> <name><![CDATA[Serializable]]></name> </class-definition> <class-definition interface="true"> <package><![CDATA[java.lang]]></package> <modifiers><![CDATA[public abstract interface]]></modifiers> <name><![CDATA[Comparable]]></name> <method> <modifiers><![CDATA[public abstract]]></modifiers> <return-type><![CDATA[int]]></return-type> <name><![CDATA[compareTo]]></name> <parameter><![CDATA[java.lang.Object]]></parameter> </method> </class-definition> </implements> <field> <modifiers><![CDATA[private]]></modifiers> <type><![CDATA[[C]]></type> <name><![CDATA[value]]></name> </field> ... <constructor> <modifiers><![CDATA[public]]></modifiers> </constructor> <constructor> <modifiers><![CDATA[public]]></modifiers> <parameter><![CDATA[java.lang.String]]></parameter> </constructor> ... <method> <modifiers><![CDATA[public]]></modifiers> <return-type><![CDATA[int]]></return-type> <name><![CDATA[hashCode]]></name> </method> <method> <modifiers><![CDATA[public]]></modifiers> <return-type><![CDATA[int]]></return-type> <name><![CDATA[compareTo]]></name> <parameter><![CDATA[java.lang.String]]></parameter> </method> ... <class-definition interface="false"> <package><![CDATA[java.lang]]></package> <modifiers/> <name><![CDATA[String$1]]></name> ... </class-definition> <class-definition interface="false"> <package><![CDATA[java.lang]]></package> <modifiers><![CDATA[private static]]></modifiers> <name><![CDATA[String$CaseInsensitiveComparator]]></name> ... </class-definition> ... </class-definition> |
Note: the two last "class-definitions" are inner class definitions in
java.lang.String
.
context
- automatically passed by the xalan extension mechanism.className
- Class name.
Node
that represents a Class definition.
WrappedRuntimeException
- errors (...).protected static Node process(Document doc, Class c)
Node
that represents a Class definition.
doc
- the current Document.c
- the Class to get definition from..
Node
that represents a Class definition.
WrappedRuntimeException
- errors (...).public static String stripType(ExpressionContext context, String type)
Java signature format
), removing all array dimensions and package information.
<xsl:value-of select="jcx:stripType('[[Ljava.lang.String;')"/> |
For example, the function will return "Object
" for
"[LLjava.lang.Object;
" (ie: java.lang.Object[][]
)
or "int
" for "[[[I
" (ie: int[][][]
).
context
- automatically passed by the xalan extension mechanism.type
- the Java type in the "Java signature format".
WrappedRuntimeException
- errors (...).public static String stripTypeDims(ExpressionContext context, String type)
Java signature format
), removing only array dimensions information.
<xsl:value-of select="jcx:stripTypeDims('[[I')"/> |
For example, the function will return "java.lang.Object
" for
"[LLjava.lang.Object;
" (ie: java.lang.Object[][]
)
or "int
" for "[[[I
" (ie: int[][][]
).
context
- automatically passed by the xalan extension mechanism.type
- [AVT] - a type definition in the "Java signature format".
WrappedRuntimeException
- errors (...).public static String dimsOfType(ExpressionContext context, String type)
[][][]...
".
<xsl:value-of select="jcx:stripTypeDims('[[I')"/> |
For example, the function will return "[][]
" for
"[LLjava.lang.Object;
" (ie: java.lang.Object[][]
)
or "[][][]
" for "[[[I
" (ie: int[][][]
).
context
- automatically passed by the xalan extension mechanism.type
- [AVT] - a type definition in the "Java signature format".
WrappedRuntimeException
- errors (...).public static String packageOfType(ExpressionContext context, String type)
<xsl:value-of select="jcx:stripTypeDims('[[java.lang.Object;')"/> |
For example, the function will return "java.lang
" for
"[LLjava.lang.Object;
" (ie: java.lang.Object[][]
)
or "" for "[[[I
" (ie: int[][][]
).
context
- automatically passed by the xalan extension mechanism.type
- [AVT] - a type definition in the "Java signature format".
WrappedRuntimeException
- errors (...).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |