- Type Parameters:
A- the attribute type
- All Known Implementing Classes:
AbstractAttributeMapper
public interface AttributeMapper<A>
Bidirectional mapper between the classfile representation of an attribute and
how that attribute is modeled in the API. The attribute mapper is used
to parse the classfile representation into a model, and to write the model
representation back to a classfile. For each standard attribute, there is a
predefined attribute mapper defined in
Attributes. For nonstandard
attributes, clients can define their own AttributeMapper.
Classes that model nonstandard attributes should extend CustomAttribute.- Since:
- 22
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumAttribute stability indicator -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanReturns whether this attribute may appear more than once in a given location.name()Returns the name of the attribute.readAttribute(AttributedElement enclosing, ClassReader cf, int pos) Create anAttributeinstance from a classfile.Returns attribute stability indicator.voidwriteAttribute(BufWriter buf, A attr) Write anAttributeinstance to a classfile.
-
Method Details
-
name
String name()Returns the name of the attribute.- Returns:
- the name of the attribute
-
readAttribute
Create anAttributeinstance from a classfile.- Parameters:
enclosing- The class, method, field, or code attribute in which this attribute appearscf- TheClassReaderdescribing the classfile to read frompos- The offset into the classfile at which the attribute starts- Returns:
- the new attribute
-
writeAttribute
Write anAttributeinstance to a classfile.- Parameters:
buf- TheBufWriterto which the attribute should be writtenattr- The attribute to write
-
allowMultiple
default boolean allowMultiple()Returns whether this attribute may appear more than once in a given location.- Returns:
- whether this attribute may appear more than once in a given location
- ImplSpec:
- The default implementation returns
false
-
stability
AttributeMapper.AttributeStability stability()Returns attribute stability indicator.- Returns:
- attribute stability indicator
-