Package com.tonic.parser.attribute
Class Attribute
- java.lang.Object
-
- com.tonic.parser.attribute.Attribute
-
- Direct Known Subclasses:
AnnotationDefaultAttribute,BootstrapMethodsAttribute,CodeAttribute,ConstantValueAttribute,DeprecatedAttribute,EnclosingMethodAttribute,ExceptionsAttribute,GenericAttribute,InnerClassesAttribute,LineNumberTableAttribute,LocalVariableTableAttribute,LocalVariableTypeTableAttribute,MethodParametersAttribute,ModuleAttribute,NestHostAttribute,NestMembersAttribute,PermittedSubclassesAttribute,RecordAttribute,RuntimeVisibleAnnotationsAttribute,RuntimeVisibleParameterAnnotationsAttribute,SignatureAttribute,SourceDebugExtensionAttribute,SourceFileAttribute,StackMapTableAttribute,SyntheticAttribute
public abstract class Attribute extends Object
Abstract base for class-file attributes, attached to a class or a member.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Attributeget(ClassFile classFile, ConstPool constPool, MemberEntry parent)Factory method to instantiate the appropriate Attribute subclass based on the attribute name.abstract voidread(ClassFile classFile, int length)Reads the attribute data from the class file.StringtoString()abstract voidupdateLength()Recomputes the attribute length field from the current in-memory content.voidwrite(DataOutputStream dos)Writes the attribute to the output stream.
-
-
-
Constructor Detail
-
Attribute
public Attribute(String name, MemberEntry parent, int nameIndex, int length)
Creates an attribute attached to a field or method.- Parameters:
name- the attribute nameparent- the member the attribute belongs tonameIndex- constant-pool index of the name Utf8length- the attribute length in bytes
-
-
Method Detail
-
read
public abstract void read(ClassFile classFile, int length)
Reads the attribute data from the class file.- Parameters:
classFile- The ClassFile utility to read data.length- The length of the attribute.
-
get
public static Attribute get(ClassFile classFile, ConstPool constPool, MemberEntry parent)
Factory method to instantiate the appropriate Attribute subclass based on the attribute name.- Parameters:
classFile- The ClassFile utility to read data.constPool- The constant pool for resolving attribute names.parent- The parent MemberEntry (e.g., FieldEntry, MethodEntry).- Returns:
- An instance of the appropriate Attribute subclass.
-
write
public void write(DataOutputStream dos) throws IOException
Writes the attribute to the output stream.- Parameters:
dos- The output stream to write to- Throws:
IOException- If an I/O error occurs
-
updateLength
public abstract void updateLength()
Recomputes the attribute length field from the current in-memory content.
-
-