本文整理了Java中com.android.dx.rop.annotation.Annotations
类的一些代码示例,展示了Annotations
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotations
类的具体详情如下:
包路径:com.android.dx.rop.annotation.Annotations
类名称:Annotations
[英]List of Annotation instances.
[中]注释实例的列表。
代码示例来源:origin: linkedin/dexmaker
Annotations annotations = new Annotations();
for (NameValuePair nvp : elements.values()) {
annotation.add(nvp);
annotations.add(annotation);
classDefItem.addMethodAnnotations(cstMethodRef, annotations, dexMaker.getDexFile());
代码示例来源:origin: dodola/RocooFix
private boolean hasRuntimeVisibleAnnotation(HasAttribute element) {
Attribute att = element.getAttributes().findFirst(
AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME);
return (att != null && ((AttRuntimeVisibleAnnotations)att).getAnnotations().size()>0);
}
}
代码示例来源:origin: nikita36078/J2ME-Loader
/**
* Constructs an immutable instance which is the combination of the
* given instance with the given additional annotation. The latter's
* type must not already appear in the former.
*
* @param annotations {@code non-null;} the instance to augment
* @param annotation {@code non-null;} the additional annotation
* @return {@code non-null;} the combination
* @throws IllegalArgumentException thrown if there is a duplicate type
*/
public static Annotations combine(Annotations annotations,
Annotation annotation) {
Annotations result = new Annotations();
result.addAll(annotations);
result.add(annotation);
result.setImmutable();
return result;
}
代码示例来源:origin: com.android/dx
/**
* Constructs an immutable instance which is the combination of the
* two given instances. The two instances must contain disjoint sets
* of types.
*
* @param a1 {@code non-null;} an instance
* @param a2 {@code non-null;} the other instance
* @return {@code non-null;} the combination
* @throws IllegalArgumentException thrown if there is a duplicate type
*/
public static Annotations combine(Annotations a1, Annotations a2) {
Annotations result = new Annotations();
result.addAll(a1);
result.addAll(a2);
result.setImmutable();
return result;
}
代码示例来源:origin: nikita36078/J2ME-Loader
/**
* Adds all of the elements of the given instance to this one. The
* instances must not have any duplicate types.
*
* @param toAdd {@code non-null;} the annotations to add
* @throws IllegalArgumentException thrown if there is a duplicate type
*/
public void addAll(Annotations toAdd) {
throwIfImmutable();
if (toAdd == null) {
throw new NullPointerException("toAdd == null");
}
for (Annotation a : toAdd.annotations.values()) {
add(a);
}
}
代码示例来源:origin: com.google.dexmaker/dexmaker-dx
/**
* Constructs an instance.
*
* @param annotations {@code non-null;} set of annotations
*/
public AnnotationSetItem(Annotations annotations) {
super(ALIGNMENT, writeSize(annotations));
this.annotations = annotations;
this.items = new AnnotationItem[annotations.size()];
int at = 0;
for (Annotation a : annotations.getAnnotations()) {
items[at] = new AnnotationItem(a);
at++;
}
}
代码示例来源:origin: nikita36078/J2ME-Loader
/**
* Parses an annotation list.
*
* @param visibility {@code non-null;} visibility of the parsed annotations
* @return {@code non-null;} the list of annotations read from the attribute
* data
*/
private Annotations parseAnnotations(AnnotationVisibility visibility)
throws IOException {
int count = input.readUnsignedShort();
if (observer != null) {
parsed(2, "num_annotations: " + Hex.u2(count));
}
Annotations annotations = new Annotations();
for (int i = 0; i < count; i++) {
if (observer != null) {
parsed(0, "annotations[" + i + "]:");
changeIndent(1);
}
Annotation annotation = parseAnnotation(visibility);
annotations.add(annotation);
if (observer != null) {
observer.changeIndent(-1);
}
}
annotations.setImmutable();
return annotations;
}
代码示例来源:origin: nikita36078/J2ME-Loader
/**
* Gets the annotations out of a given {@link AttributeList}. This
* combines both visible and invisible annotations into a single
* result set and also adds in a system annotation for the
* {@code Signature} attribute if present.
*
* @param attribs {@code non-null;} the attributes list to search in
* @return {@code non-null;} the set of annotations, which may be empty
*/
public static Annotations getAnnotations(AttributeList attribs) {
Annotations result = getAnnotations0(attribs);
Annotation signature = getSignature(attribs);
Annotation sourceDebugExtension = getSourceDebugExtension(attribs);
if (signature != null) {
result = Annotations.combine(result, signature);
}
if (sourceDebugExtension != null) {
result = Annotations.combine(result, sourceDebugExtension);
}
return result;
}
代码示例来源:origin: com.android/dx
/**
* Inspects a class annotation.
*
* @param cf {@code non-null;} class file
* @param ann {@code non-null;} annotation
*/
private void visitClassAnnotation(DirectClassFile cf,
BaseAnnotations ann) {
if (!args.eTypes.contains(ElementType.TYPE)) {
return;
}
for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
String annClassName
= anAnn.getType().getClassType().getClassName();
if (args.aclass.equals(annClassName)) {
printMatch(cf);
}
}
}
代码示例来源:origin: dragome/dragome-sdk
/** {@inheritDoc} */
@Override
protected int compareTo0(OffsettedItem other) {
AnnotationSetItem otherSet = (AnnotationSetItem) other;
return annotations.compareTo(otherSet.annotations);
}
代码示例来源:origin: nikita36078/J2ME-Loader
/** {@inheritDoc} */
@Override
public int hashCode() {
return annotations.hashCode();
}
代码示例来源:origin: nikita36078/J2ME-Loader
/**
* Adds an element to this instance. There must not already be an
* element of the same type.
*
* @param annotation {@code non-null;} the element to add
* @throws IllegalArgumentException thrown if there is a duplicate type
*/
public void add(Annotation annotation) {
throwIfImmutable();
if (annotation == null) {
throw new NullPointerException("annotation == null");
}
CstType type = annotation.getType();
if (annotations.containsKey(type)) {
throw new IllegalArgumentException("duplicate type: " +
type.toHuman());
}
annotations.put(type, annotation);
}
代码示例来源:origin: com.google.android.tools/dx
/**
* Constructs an immutable instance which is the combination of the
* given instance with the given additional annotation. The latter's
* type must not already appear in the former.
*
* @param annotations {@code non-null;} the instance to augment
* @param annotation {@code non-null;} the additional annotation
* @return {@code non-null;} the combination
* @throws IllegalArgumentException thrown if there is a duplicate type
*/
public static Annotations combine(Annotations annotations,
Annotation annotation) {
Annotations result = new Annotations();
result.addAll(annotations);
result.add(annotation);
result.setImmutable();
return result;
}
代码示例来源:origin: com.google.android.tools/dx
/**
* Constructs an immutable instance which is the combination of the
* two given instances. The two instances must contain disjoint sets
* of types.
*
* @param a1 {@code non-null;} an instance
* @param a2 {@code non-null;} the other instance
* @return {@code non-null;} the combination
* @throws IllegalArgumentException thrown if there is a duplicate type
*/
public static Annotations combine(Annotations a1, Annotations a2) {
Annotations result = new Annotations();
result.addAll(a1);
result.addAll(a2);
result.setImmutable();
return result;
}
代码示例来源:origin: com.google.dexmaker/dexmaker-dx
/**
* Adds all of the elements of the given instance to this one. The
* instances must not have any duplicate types.
*
* @param toAdd {@code non-null;} the annotations to add
* @throws IllegalArgumentException thrown if there is a duplicate type
*/
public void addAll(Annotations toAdd) {
throwIfImmutable();
if (toAdd == null) {
throw new NullPointerException("toAdd == null");
}
for (Annotation a : toAdd.annotations.values()) {
add(a);
}
}
代码示例来源:origin: gdpancheng/LoonAndroid3
/**
* Constructs an instance.
*
* @param annotations {@code non-null;} set of annotations
*/
public AnnotationSetItem(Annotations annotations) {
super(ALIGNMENT, writeSize(annotations));
this.annotations = annotations;
this.items = new AnnotationItem[annotations.size()];
int at = 0;
for (Annotation a : annotations.getAnnotations()) {
items[at] = new AnnotationItem(a);
at++;
}
}
代码示例来源:origin: com.android/dx
/**
* Parses an annotation list.
*
* @param visibility {@code non-null;} visibility of the parsed annotations
* @return {@code non-null;} the list of annotations read from the attribute
* data
*/
private Annotations parseAnnotations(AnnotationVisibility visibility)
throws IOException {
int count = input.readUnsignedShort();
if (observer != null) {
parsed(2, "num_annotations: " + Hex.u2(count));
}
Annotations annotations = new Annotations();
for (int i = 0; i < count; i++) {
if (observer != null) {
parsed(0, "annotations[" + i + "]:");
changeIndent(1);
}
Annotation annotation = parseAnnotation(visibility);
annotations.add(annotation);
if (observer != null) {
observer.changeIndent(-1);
}
}
annotations.setImmutable();
return annotations;
}
代码示例来源:origin: com.jakewharton.android.repackaged/dalvik-dx
/**
* Gets the annotations out of a given {@link AttributeList}. This
* combines both visible and invisible annotations into a single
* result set and also adds in a system annotation for the
* {@code Signature} attribute if present.
*
* @param attribs {@code non-null;} the attributes list to search in
* @return {@code non-null;} the set of annotations, which may be empty
*/
public static Annotations getAnnotations(AttributeList attribs) {
Annotations result = getAnnotations0(attribs);
Annotation signature = getSignature(attribs);
Annotation sourceDebugExtension = getSourceDebugExtension(attribs);
if (signature != null) {
result = Annotations.combine(result, signature);
}
if (sourceDebugExtension != null) {
result = Annotations.combine(result, sourceDebugExtension);
}
return result;
}
代码示例来源:origin: com.android.tools.build/builder
/**
* Inspects a class annotation.
*
* @param cf {@code non-null;} class file
* @param ann {@code non-null;} annotation
*/
private void visitClassAnnotation(DirectClassFile cf,
BaseAnnotations ann) {
if (!args.eTypes.contains(ElementType.TYPE)) {
return;
}
for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
String annClassName
= anAnn.getType().getClassType().getClassName();
if (args.aclass.equals(annClassName)) {
printMatch(cf);
}
}
}
代码示例来源:origin: com.jakewharton.android.repackaged/dalvik-dx
/** {@inheritDoc} */
@Override
protected int compareTo0(OffsettedItem other) {
AnnotationSetItem otherSet = (AnnotationSetItem) other;
return annotations.compareTo(otherSet.annotations);
}
内容来源于网络,如有侵权,请联系作者删除!