Package org.eclipse.sisu.space.asm
Class TypePath
- java.lang.Object
-
- org.eclipse.sisu.space.asm.TypePath
-
public final class TypePath extends java.lang.ObjectThe path to a type argument, wildcard bound, array element type, or static inner type within an enclosing type.
-
-
Field Summary
Fields Modifier and Type Field Description static intARRAY_ELEMENTA type path step that steps into the element type of an array type.(package private) byte[]bThe byte array where the path is stored, in Java class file format.static intINNER_TYPEA type path step that steps into the nested type of a class type.(package private) intoffsetThe offset of the first byte of the type path in 'b'.static intTYPE_ARGUMENTA type path step that steps into a type argument of a generic type.static intWILDCARD_BOUNDA type path step that steps into the bound of a wildcard type.
-
Constructor Summary
Constructors Constructor Description TypePath(byte[] b, int offset)Creates a new type path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TypePathfromString(java.lang.String typePath)Converts a type path in string form, in the format used bytoString(), into a TypePath object.intgetLength()Returns the length of this path.intgetStep(int index)Returns the value of the given step of this path.intgetStepArgument(int index)Returns the index of the type argument that the given step is stepping into.java.lang.StringtoString()Returns a string representation of this type path.
-
-
-
Field Detail
-
ARRAY_ELEMENT
public static final int ARRAY_ELEMENT
A type path step that steps into the element type of an array type. SeegetStep.- See Also:
- Constant Field Values
-
INNER_TYPE
public static final int INNER_TYPE
A type path step that steps into the nested type of a class type. SeegetStep.- See Also:
- Constant Field Values
-
WILDCARD_BOUND
public static final int WILDCARD_BOUND
A type path step that steps into the bound of a wildcard type. SeegetStep.- See Also:
- Constant Field Values
-
TYPE_ARGUMENT
public static final int TYPE_ARGUMENT
A type path step that steps into a type argument of a generic type. SeegetStep.- See Also:
- Constant Field Values
-
b
byte[] b
The byte array where the path is stored, in Java class file format.
-
offset
int offset
The offset of the first byte of the type path in 'b'.
-
-
Method Detail
-
getLength
public int getLength()
Returns the length of this path.- Returns:
- the length of this path.
-
getStep
public int getStep(int index)
Returns the value of the given step of this path.- Parameters:
index- an index between 0 andgetLength(), exclusive.- Returns:
ARRAY_ELEMENT,INNER_TYPE,WILDCARD_BOUND, orTYPE_ARGUMENT.
-
getStepArgument
public int getStepArgument(int index)
Returns the index of the type argument that the given step is stepping into. This method should only be used for steps whose value isTYPE_ARGUMENT.- Parameters:
index- an index between 0 andgetLength(), exclusive.- Returns:
- the index of the type argument that the given step is stepping into.
-
fromString
public static TypePath fromString(java.lang.String typePath)
Converts a type path in string form, in the format used bytoString(), into a TypePath object.- Parameters:
typePath- a type path in string form, in the format used bytoString(). May be null or empty.- Returns:
- the corresponding TypePath object, or null if the path is empty.
-
toString
public java.lang.String toString()
Returns a string representation of this type path.ARRAY_ELEMENTsteps are represented with '[',INNER_TYPEsteps with '.',WILDCARD_BOUNDsteps with '*' andTYPE_ARGUMENTsteps with their type argument index in decimal form.- Overrides:
toStringin classjava.lang.Object
-
-