Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.dex.file

public final Class AnnotationsDirectoryItem

extends OffsettedItem
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.annotation.Annotations, .AnnotationsList, org.droidparts.dexmaker.dx.rop.cst.CstFieldRef, .CstMethodRef, org.droidparts.dexmaker.dx.util.AnnotatedOutput, .Hex, java.io.PrintWriter, java.util.ArrayList, .Collections

Per-class directory of annotations.

Field Summary

Modifier and TypeField and Description
private static final int
ALIGNMENT

the required alignment for instances of this class

private AnnotationSetItem
classAnnotations

null-ok; the class-level annotations, if any

private static final int
ELEMENT_SIZE

write size of a list element, in bytes

private ArrayList<FieldAnnotationStruct>
fieldAnnotations

null-ok; the annotated fields, if any

private static final int
HEADER_SIZE

write size of this class's header, in bytes

private ArrayList<MethodAnnotationStruct>
methodAnnotations

null-ok; the annotated methods, if any

private ArrayList<ParameterAnnotationStruct>
parameterAnnotations

null-ok; the annotated parameters, if any

Constructor Summary

AccessConstructor and Description
public
AnnotationsDirectoryItem()

Constructs an empty instance.

Method Summary

Modifier and TypeMethod and Description
public void
addContents(DexFile
non-null; the file to populate
file
)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Populates a DexFile with items from within this instance.
public void
addFieldAnnotations(CstFieldRef
non-null; field in question
field
,
Annotations
non-null; associated annotations to add
annotations
)

Adds a field annotations item to this instance.

public void
addMethodAnnotations(CstMethodRef
non-null; method in question
method
,
Annotations
non-null; associated annotations to add
annotations
)

Adds a method annotations item to this instance.

public void
addParameterAnnotations(CstMethodRef
non-null; method in question
method
,
AnnotationsList
non-null; associated list of annotation sets to add
list
)

Adds a parameter annotations item to this instance.

public int
compareTo0(OffsettedItem
non-null; instance to compare to
other
)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.compareTo0.

Compares this instance to another which is guaranteed to be of the same class.
pack-priv void
debugPrint(PrintWriter
non-null; where to output to
out
)

Prints out the contents of this instance, in a debugging-friendly way.

public Annotations

Returns:

null-ok; the method annotations, if any
getMethodAnnotations
(CstMethodRef
non-null; the method
method
)

Gets the method annotations for a given method, if any.

public AnnotationsList

Returns:

null-ok; the parameter annotations, if any
getParameterAnnotations
(CstMethodRef
non-null; the method
method
)

Gets the parameter annotations for a given method, if any.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean

Returns:

true if this item is empty, or false if not
isEmpty
()

Returns whether this item is empty (has no contents).

public boolean

Returns:

true if this is an interning candidate, or false if not
isInternable
()

Returns whether this item is a candidate for interning.

public ItemType
itemType()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Returns the item type for this instance.
private static int

Returns:

>= 0; its size
listSize
(ArrayList<?>
null-ok; the list in question
list
)

Gets the list size of the given list, or 0 if given null.

protected void
place0(Section
non-null; the section this instance has been added to
addedTo
,
int
>= 0; the offset from the start of the section where this instance was placed
offset
)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Does additional work required when placing an instance.
public void
setClassAnnotations(Annotations
non-null; annotations to set for this class
annotations
)

Sets the direct annotations on this instance.

public String
toHuman()

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Gets a short human-readable string representing this instance.
protected void
writeTo0(DexFile
non-null; the file to use for reference
file
,
AnnotatedOutput
non-null; where to write to
out
)

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Performs the actual write of the contents of this instance to the given data section.
Inherited from org.droidparts.dexmaker.dx.dex.file.OffsettedItem:
compareToequalsgetAbsoluteOffsetgetAbsoluteOffsetOr0getAlignmentgetRelativeOffsetoffsetStringplacesetWriteSizewriteSizewriteTo

Field Detail

ALIGNMENTback to summary
private static final int ALIGNMENT

the required alignment for instances of this class

classAnnotationsback to summary
private AnnotationSetItem classAnnotations

null-ok; the class-level annotations, if any

ELEMENT_SIZEback to summary
private static final int ELEMENT_SIZE

write size of a list element, in bytes

fieldAnnotationsback to summary
private ArrayList<FieldAnnotationStruct> fieldAnnotations

null-ok; the annotated fields, if any

HEADER_SIZEback to summary
private static final int HEADER_SIZE

write size of this class's header, in bytes

methodAnnotationsback to summary
private ArrayList<MethodAnnotationStruct> methodAnnotations

null-ok; the annotated methods, if any

parameterAnnotationsback to summary
private ArrayList<ParameterAnnotationStruct> parameterAnnotations

null-ok; the annotated parameters, if any

Constructor Detail

AnnotationsDirectoryItemback to summary
public AnnotationsDirectoryItem()

Constructs an empty instance.

Method Detail

addContentsback to summary
public void addContents(DexFile file)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Populates a DexFile with items from within this instance. This will not add an item to the file for this instance itself (which should have been done by whatever refers to this instance).

Note

Subclasses must override this to do something appropriate.

Parameters
file:DexFile

non-null; the file to populate

addFieldAnnotationsback to summary
public void addFieldAnnotations(CstFieldRef field, Annotations annotations)

Adds a field annotations item to this instance.

Parameters
field:CstFieldRef

non-null; field in question

annotations:Annotations

non-null; associated annotations to add

addMethodAnnotationsback to summary
public void addMethodAnnotations(CstMethodRef method, Annotations annotations)

Adds a method annotations item to this instance.

Parameters
method:CstMethodRef

non-null; method in question

annotations:Annotations

non-null; associated annotations to add

addParameterAnnotationsback to summary
public void addParameterAnnotations(CstMethodRef method, AnnotationsList list)

Adds a parameter annotations item to this instance.

Parameters
method:CstMethodRef

non-null; method in question

list:AnnotationsList

non-null; associated list of annotation sets to add

compareTo0back to summary
public int compareTo0(OffsettedItem other)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.compareTo0.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.compareTo0.

Compares this instance to another which is guaranteed to be of the same class. The default implementation of this method is to throw an exception (unsupported operation). If a particular class needs to actually sort, then it should override this method.

Note

This throws an exception if this item is not internable.

Parameters
other:OffsettedItem

non-null; instance to compare to

Returns:int

-1, 0, or 1, depending on the sort order of this instance and the other

Annotations
@Override
See Also
isInternable
debugPrintback to summary
pack-priv void debugPrint(PrintWriter out)

Prints out the contents of this instance, in a debugging-friendly way. This is meant to be called from ClassDefItem#debugPrint.

Parameters
out:PrintWriter

non-null; where to output to

getMethodAnnotationsback to summary
public Annotations getMethodAnnotations(CstMethodRef method)

Gets the method annotations for a given method, if any. This is meant for use by debugging / dumping code.

Parameters
method:CstMethodRef

non-null; the method

Returns:Annotations

null-ok; the method annotations, if any

getParameterAnnotationsback to summary
public AnnotationsList getParameterAnnotations(CstMethodRef method)

Gets the parameter annotations for a given method, if any. This is meant for use by debugging / dumping code.

Parameters
method:CstMethodRef

non-null; the method

Returns:AnnotationsList

null-ok; the parameter annotations, if any

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Returns whether this item is empty (has no contents).

Returns:boolean

true if this item is empty, or false if not

isInternableback to summary
public boolean isInternable()

Returns whether this item is a candidate for interning. The only interning candidates are ones that only have a non-null set of class annotations, with no other lists.

Returns:boolean

true if this is an interning candidate, or false if not

itemTypeback to summary
public ItemType itemType()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Returns the item type for this instance.

Returns:ItemType

non-null; the item type

Annotations
@Override
listSizeback to summary
private static int listSize(ArrayList<?> list)

Gets the list size of the given list, or 0 if given null.

Parameters
list:ArrayList<?>

null-ok; the list in question

Returns:int

>= 0; its size

place0back to summary
protected void place0(Section addedTo, int offset)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Does additional work required when placing an instance. The default implementation of this method is a no-op. If a particular class needs to do something special, then it should override this method. In particular, if this instance did not know its write size up-front, then this method is responsible for setting it.

Parameters
addedTo:Section

non-null; the section this instance has been added to

offset:int

>= 0; the offset from the start of the section where this instance was placed

Annotations
@Override
setClassAnnotationsback to summary
public void setClassAnnotations(Annotations annotations)

Sets the direct annotations on this instance. These are annotations made on the class, per se, as opposed to on one of its members. It is only valid to call this method at most once per instance.

Parameters
annotations:Annotations

non-null; annotations to set for this class

toHumanback to summary
public String toHuman()

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Gets a short human-readable string representing this instance.

Returns:String

non-null; the human form

Annotations
@Override
writeTo0back to summary
protected void writeTo0(DexFile file, AnnotatedOutput out)

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Performs the actual write of the contents of this instance to the given data section. This is called by writeTo, which will have taken care of ensuring alignment.

Parameters
file:DexFile

non-null; the file to use for reference

out:AnnotatedOutput

non-null; where to write to

Annotations
@Override