Package com.tonic.analysis.xref
Class Xref
- java.lang.Object
-
- com.tonic.analysis.xref.Xref
-
public class Xref extends Object
An immutable cross-reference from a source instruction to the class, method, or field it names.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXref.BuilderMutable accumulator for the fields of an Xref.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Xref.Builderbuilder()booleanequals(Object o)intgetBytecodeOffset()intgetInstructionIndex()intgetLineNumber()StringgetSourceClass()StringgetSourceDisplay()Renders the source as a dotted class name, optionally with method and line suffixes.StringgetSourceMethod()StringgetSourceMethodDesc()MethodReferencegetSourceMethodRef()Packages the source class, method name and descriptor as a method reference.StringgetTargetClass()StringgetTargetDescriptor()StringgetTargetDisplay()Renders the target as a dotted class name plus member, with "()" appended for method refs.FieldReferencegetTargetFieldRef()Packages the target class, member and descriptor as a field reference.StringgetTargetMember()MethodReferencegetTargetMethodRef()Packages the target class, member and descriptor as a method reference.XrefTypegetType()inthashCode()booleanisClassRef()Tests whether the reference names a class rather than a specific member.booleanisFieldRef()Tests whether the reference names a specific field.booleanisMethodRef()Tests whether the reference names a specific method.StringtoString()
-
-
-
Method Detail
-
getSourceClass
public String getSourceClass()
- Returns:
- the source class
-
getSourceMethod
public String getSourceMethod()
- Returns:
- the source method
-
getSourceMethodDesc
public String getSourceMethodDesc()
- Returns:
- the source method desc
-
getLineNumber
public int getLineNumber()
- Returns:
- the line number
-
getInstructionIndex
public int getInstructionIndex()
- Returns:
- the instruction index
-
getBytecodeOffset
public int getBytecodeOffset()
- Returns:
- the bytecode offset
-
getTargetClass
public String getTargetClass()
- Returns:
- the target class
-
getTargetMember
public String getTargetMember()
- Returns:
- the target member
-
getTargetDescriptor
public String getTargetDescriptor()
- Returns:
- the target descriptor
-
getType
public XrefType getType()
- Returns:
- the type
-
isMethodRef
public boolean isMethodRef()
Tests whether the reference names a specific method.- Returns:
- true if a member was recorded and the type is a method reference
-
isFieldRef
public boolean isFieldRef()
Tests whether the reference names a specific field.- Returns:
- true if a member was recorded and the type is a field reference
-
isClassRef
public boolean isClassRef()
Tests whether the reference names a class rather than a specific member.- Returns:
- true if the type is a type reference or no member was recorded
-
getSourceMethodRef
public MethodReference getSourceMethodRef()
Packages the source class, method name and descriptor as a method reference.- Returns:
- the enclosing method reference
-
getTargetMethodRef
public MethodReference getTargetMethodRef()
Packages the target class, member and descriptor as a method reference.- Returns:
- the target method reference, or null if this is not a method reference
-
getTargetFieldRef
public FieldReference getTargetFieldRef()
Packages the target class, member and descriptor as a field reference.- Returns:
- the target field reference, or null if this is not a field reference
-
getSourceDisplay
public String getSourceDisplay()
Renders the source as a dotted class name, optionally with method and line suffixes.- Returns:
- the display string
-
getTargetDisplay
public String getTargetDisplay()
Renders the target as a dotted class name plus member, with "()" appended for method refs.- Returns:
- the display string
-
builder
public static Xref.Builder builder()
- Returns:
- a fresh builder with an empty source and target and type METHOD_CALL
-
-