public final class MemberInfo extends java.lang.Object implements ITargetSelectorRemappable, ITargetSelectorConstructor
Struct which defines an Explcit Target selector, See
ITargetSelector for other supported selector types. This struct is
also used as a general-purpose information bundle about a member (method or
field) parsed from a String token in another annotation, this is used where
target members need to be specified as Strings in order to parse the String
representation to something useful.
In general a MemberInfo consists of 4 parts, owner, name, quantifier and descriptor, all of which are optional:
| Owner | Name | Quantifier | Descriptor | Resulting selector string | ||
|---|---|---|---|---|---|---|
| Method | Lfully/qualified/OwnerClass; | methodName | {1,3} | (III)V | Lfully/qualified/OwnerClass;methodName{1,3}(III)V | |
| Field | Lfully/qualified/OwnerClass; | fieldName | * | : | Ljava/lang/String; | Lfully/qualified/OwnerClass;fieldName*:Ljava/lang/String; |
Any part of the selector can be omitted, though they must appear in the correct order. Some examples:
// selects a method or field called func_1234_a, if there are multiple
// members with the same signature, matches the first occurrence
func_1234_a
// selects a method or field called func_1234_a, if there are multiple
// members with matching name, matches all occurrences
func_1234_a*
// selects a method or field called func_1234_a, if there are multiple
// members with matching name, matches all occurrences, matching less than 1
// occurrence is an error condition
func_1234_a+
// selects a method or field called func_1234_a, if there are multiple
// members with matching name, matches up to 3 occurrences
func_1234_a{,3}
// selects a method or field called func_1234_a, if there are multiple
// members with matching name, matches exactly 3 occurrences, matching fewer
// than 3 occurrences is an error condition
func_1234_a{3}
// selects a method or field called func_1234_a, if there are multiple
// members with matching name, matches at least 3 occurrences, matching fewer
// than 3 occurrences is an error condition
func_1234_a{3,}
// selects all members of any type and descriptor
*
// selects the first member of any type and descriptor
{1}
// selects all methods which take 3 ints and return a bool
*(III)Z
// selects the first 2 methods which take a bool and return void
{2}(Z)V
// selects a method called func_1234_a which takes 3 ints and returns a
bool
func_1234_a(III)Z
// selects a field called field_5678_z which is a String
field_5678_z:Ljava/lang/String;
// selects a ctor which takes a single String argument
<init>(Ljava/lang/String;)V
// selects a method called func_1234_a in class foo.bar.Baz
Lfoo/bar/Baz;func_1234_a
// selects a field called field_5678_z in class com.example.Dave
Lcom/example/Dave;field_5678_z
// selects a field called field_5678_z in class com.example.Dave
// which is of type String
Lcom/example/Dave;field_5678_z:Ljava/lang/String;
// selects a method called func_1234_a in class foo.bar.Baz which
// takes three doubles and returns void
Lfoo/bar/Baz;func_1234_a(DDD)V
// alternate syntax for the same
foo.bar.Baz.func_1234_a(DDD)V
ITargetSelector.Configure| Constructor and Description |
|---|
MemberInfo(org.objectweb.asm.tree.AbstractInsnNode insn)
Initialise a MemberInfo using the supplied insn which must be an instance
of MethodInsnNode or FieldInsnNode.
|
MemberInfo(IMapping<?> mapping)
Initialise a MemberInfo using the supplied mapping object
|
MemberInfo(java.lang.String name,
Quantifier matches)
ctor
|
MemberInfo(java.lang.String name,
java.lang.String owner,
Quantifier matches)
ctor
|
MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc)
ctor
|
MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc,
Quantifier matches)
ctor
|
MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc,
Quantifier matches,
java.lang.String tail)
ctor
|
MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc,
Quantifier matches,
java.lang.String tail,
java.lang.String input)
ctor
|
| Modifier and Type | Method and Description |
|---|---|
MappingField |
asFieldMapping()
Returns this MemberInfo as a mapping field
|
IMapping<?> |
asMapping()
Returns this MemberInfo as a
MappingField or
MappingMethod |
MappingMethod |
asMethodMapping()
Returns this MemberInfo as a mapping method
|
ITargetSelector |
attach(ISelectorContext context)
Attach this selector to the specified context.
|
ITargetSelector |
configure(ITargetSelector.Configure request,
java.lang.String... args)
Configure and return a modified version of this selector by consuming the
supplied arguments.
|
boolean |
equals(java.lang.Object obj) |
static MemberInfo |
fromMapping(IMapping<?> mapping)
Return the supplied mapping parsed as a MemberInfo
|
java.lang.String |
getDesc()
Get the member descriptor, can be null
|
int |
getMaxMatchCount()
Maximum number of candidates this selector can match
|
int |
getMinMatchCount()
Minimum number of candidates this selector must match
|
java.lang.String |
getName()
Get the member name, can be null
|
java.lang.String |
getOwner()
Get the member owner, can be null
|
int |
hashCode() |
boolean |
isClassInitialiser()
Get whether this member represents a class initialiser
|
boolean |
isConstructor()
Get whether this member represents a constructor
|
boolean |
isField()
Get whether this MemberInfo is definitely a field, the output of this
method is undefined if
isFullyQualified() returns false. |
boolean |
isFullyQualified()
Get whether this reference is fully qualified
|
boolean |
isInitialiser()
Get whether this member represents a constructor or class initialiser
|
<TNode> MatchResult |
match(ElementNode<TNode> node)
Test whether this selector matches the supplied element node
|
MatchResult |
matches(java.lang.String owner,
java.lang.String name,
java.lang.String desc)
Test whether this selector matches the supplied values.
|
ITargetSelectorRemappable |
move(java.lang.String newOwner)
Create a new version of this member with a different owner
|
ITargetSelector |
next()
Get the next target selector in this path (or null if this
selector is the last selector in the chain.
|
static MemberInfo |
parse(java.lang.String input,
ISelectorContext context)
Parse a MemberInfo from a string
|
ITargetSelectorRemappable |
remapUsing(MappingMethod srgMethod,
boolean setOwner)
Create a remapped version of this member using the supplied method data
|
java.lang.String |
toCtorDesc()
Returns the constructor descriptor represented by this
MemberInfo, returns null if no descriptor is present.
|
java.lang.String |
toCtorType()
Returns the constructor type represented by this MemberInfo
|
java.lang.String |
toDescriptor()
Returns this MemberInfo as a java-style descriptor
|
java.lang.String |
toSrg()
Deprecated.
use m.asMethodMapping().serialise() instead
|
java.lang.String |
toString() |
ITargetSelectorRemappable |
transform(java.lang.String newDesc)
Create a new version of this member with a different descriptor
|
MemberInfo |
validate()
Perform ultra-simple validation of the descriptor, checks that the parts
of the descriptor are basically sane.
|
public MemberInfo(java.lang.String name,
Quantifier matches)
name - Member name, must not be nullmatches - Quantifier specifying the number of matches requiredpublic MemberInfo(java.lang.String name,
java.lang.String owner,
Quantifier matches)
name - Member name, must not be nullowner - Member owner, can be null otherwise must be in internal form
without L;matches - Quantifier specifying the number of matches requiredpublic MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc)
name - Member name, must not be nullowner - Member owner, can be null otherwise must be in internal form
without L;desc - Member descriptor, can be nullpublic MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc,
Quantifier matches)
name - Member name, must not be nullowner - Member owner, can be null otherwise must be in internal form
without L;desc - Member descriptor, can be nullmatches - Quantifier specifying the number of matches requiredpublic MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc,
Quantifier matches,
java.lang.String tail)
name - Member name, must not be nullowner - Member owner, can be null otherwise must be in internal form
without L;desc - Member descriptor, can be nullmatches - Quantifier specifying the number of matches requiredpublic MemberInfo(java.lang.String name,
java.lang.String owner,
java.lang.String desc,
Quantifier matches,
java.lang.String tail,
java.lang.String input)
name - Member name, must not be nullowner - Member owner, can be null otherwise must be in internal form
without L;desc - Member descriptor, can be nullmatches - Quantifier specifying the number of matches requiredpublic MemberInfo(org.objectweb.asm.tree.AbstractInsnNode insn)
insn - instruction node to copy values frompublic MemberInfo(IMapping<?> mapping)
mapping - Mapping object to copy values frompublic ITargetSelector next()
ITargetSelectorCan return null
next in interface ITargetSelectorpublic java.lang.String getOwner()
ITargetSelectorByNamegetOwner in interface ITargetSelectorByNamepublic java.lang.String getName()
ITargetSelectorByNamegetName in interface ITargetSelectorByNamepublic java.lang.String getDesc()
ITargetSelectorByNamegetDesc in interface ITargetSelectorByNamepublic int getMinMatchCount()
ITargetSelectorgetMinMatchCount in interface ITargetSelectorpublic int getMaxMatchCount()
ITargetSelectorgetMaxMatchCount in interface ITargetSelectorpublic java.lang.String toString()
toString in class java.lang.Object@Deprecated public java.lang.String toSrg()
public java.lang.String toDescriptor()
toDescriptor in interface ITargetSelectorByNamepublic java.lang.String toCtorType()
toCtorType in interface ITargetSelectorConstructorpublic java.lang.String toCtorDesc()
toCtorDesc in interface ITargetSelectorConstructorpublic IMapping<?> asMapping()
MappingField or
MappingMethodasMapping in interface ITargetSelectorRemappablepublic MappingMethod asMethodMapping()
asMethodMapping in interface ITargetSelectorRemappablepublic MappingField asFieldMapping()
asFieldMapping in interface ITargetSelectorRemappablepublic boolean isFullyQualified()
ITargetSelectorRemappableisFullyQualified in interface ITargetSelectorRemappablepublic boolean isField()
isFullyQualified() returns false.isField in interface ITargetSelectorRemappablepublic boolean isConstructor()
isConstructor in interface ITargetSelectorRemappablepublic boolean isClassInitialiser()
isClassInitialiser in interface ITargetSelectorRemappablepublic boolean isInitialiser()
isInitialiser in interface ITargetSelectorRemappablepublic MemberInfo validate() throws InvalidSelectorException
validate in interface ITargetSelectorInvalidSelectorException - if any validation check failspublic <TNode> MatchResult match(ElementNode<TNode> node)
ITargetSelectormatch in interface ITargetSelectorTNode - node typenode - node node to testpublic MatchResult matches(java.lang.String owner, java.lang.String name, java.lang.String desc)
ITargetSelectorByNamematches in interface ITargetSelectorByNameowner - Owner to compare with, null to skipname - Name to compare with, null to skipdesc - Signature to compare with, null to skippublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic ITargetSelector configure(ITargetSelector.Configure request, java.lang.String... args)
ITargetSelectorIn other words, calling configure(Configure.ORPHAN) when this object is already an orphan or does not support orphaning, may simply return this object, or might return an identically-configured copy.
Must not return null, defaults to returning unmodified selector.
configure in interface ITargetSelectorrequest - Requested operationargs - Configuration argumentspublic ITargetSelector attach(ISelectorContext context) throws InvalidSelectorException
ITargetSelectorInvalidSelectorException is thrown.attach in interface ITargetSelectorcontext - Context to attach toInvalidSelectorExceptionpublic ITargetSelectorRemappable move(java.lang.String newOwner)
move in interface ITargetSelectorRemappablenewOwner - New owner for this memberpublic ITargetSelectorRemappable transform(java.lang.String newDesc)
transform in interface ITargetSelectorRemappablenewDesc - New descriptor for this memberpublic ITargetSelectorRemappable remapUsing(MappingMethod srgMethod, boolean setOwner)
remapUsing in interface ITargetSelectorRemappablesrgMethod - SRG method data to usesetOwner - True to set the owner as well as the namepublic static MemberInfo parse(java.lang.String input, ISelectorContext context)
input - String to parse MemberInfo fromcontext - Selector context for this parse requestpublic static MemberInfo fromMapping(IMapping<?> mapping)
mapping - mapping to parse