本文整理汇总了Java中com.android.dx.rop.annotation.Annotation类的典型用法代码示例。如果您正苦于以下问题:Java Annotation类的具体用法?Java Annotation怎么用?Java Annotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Annotation类属于com.android.dx.rop.annotation包,在下文中一共展示了Annotation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: translateEnclosingMethod
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Gets the {@code EnclosingMethod} attribute out of a given
* {@link AttributeList}, if any, translating it to an annotation.
* If the class really has an enclosing method, this returns an
* {@code EnclosingMethod} annotation; if not, this returns
* an {@code EnclosingClass} annotation.
*
* @param attribs {@code non-null;} the attributes list to search in
* @return {@code null-ok;} the converted {@code EnclosingMethod} or
* {@code EnclosingClass} annotation, if there was an
* attribute to translate
*/
private static Annotation translateEnclosingMethod(AttributeList attribs) {
AttEnclosingMethod enclosingMethod = (AttEnclosingMethod)
attribs.findFirst(AttEnclosingMethod.ATTRIBUTE_NAME);
if (enclosingMethod == null) {
return null;
}
CstType enclosingClass = enclosingMethod.getEnclosingClass();
CstNat nat = enclosingMethod.getMethod();
if (nat == null) {
/*
* Dalvik doesn't use EnclosingMethod annotations unless
* there really is an enclosing method. Anonymous classes
* are unambiguously identified by having an InnerClass
* annotation with an empty name along with an appropriate
* EnclosingClass.
*/
return AnnotationUtils.makeEnclosingClass(enclosingClass);
}
return AnnotationUtils.makeEnclosingMethod(
new CstMethodRef(enclosingClass, nat));
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:38,代码来源:AttributeTranslator.java
示例2: AnnotationItem
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs an instance.
*
* @param annotation {@code non-null;} annotation to represent
* @param dexFile {@code non-null;} dex output
*/
public AnnotationItem(Annotation annotation, DexFile dexFile) {
/*
* The write size isn't known up-front because (the variable-lengthed)
* leb128 type is used to represent some things.
*/
super(ALIGNMENT, -1);
if (annotation == null) {
throw new NullPointerException("annotation == null");
}
this.annotation = annotation;
this.type = null;
this.encodedForm = null;
addContents(dexFile);
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:23,代码来源:AnnotationItem.java
示例3: visitClassAnnotation
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* 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);
}
}
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:22,代码来源:AnnotationLister.java
示例4: AnnotationItem
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs an instance.
*
* @param annotation {@code non-null;} annotation to represent
*/
public AnnotationItem(Annotation annotation) {
/*
* The write size isn't known up-front because (the variable-lengthed)
* leb128 type is used to represent some things.
*/
super(ALIGNMENT, -1);
if (annotation == null) {
throw new NullPointerException("annotation == null");
}
this.annotation = annotation;
this.type = null;
this.encodedForm = null;
}
开发者ID:AndreJCL,项目名称:JCL,代码行数:21,代码来源:AnnotationItem.java
示例5: getAnnotations
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* 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);
if (signature != null) {
result = Annotations.combine(result, signature);
}
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:20,代码来源:AttributeTranslator.java
示例6: getClassAnnotations
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Gets the annotations out of a given class, similar to {@link
* #getAnnotations}, also including annotations for translations
* of class-level attributes {@code EnclosingMethod} and
* {@code InnerClasses}, if present. Additionally, if the
* class is an annotation class, then this also includes a
* representation of all the {@code AnnotationDefault}
* values.
*
* @param cf {@code non-null;} the class in question
* @param args {@code non-null;} the high-level options
* @return {@code non-null;} the set of annotations, which may be empty
*/
public static Annotations getClassAnnotations(DirectClassFile cf,
CfOptions args) {
CstType thisClass = cf.getThisClass();
AttributeList attribs = cf.getAttributes();
Annotations result = getAnnotations(attribs);
Annotation enclosingMethod = translateEnclosingMethod(attribs);
try {
Annotations innerClassAnnotations =
translateInnerClasses(thisClass, attribs,
enclosingMethod == null);
if (innerClassAnnotations != null) {
result = Annotations.combine(result, innerClassAnnotations);
}
} catch (Warning warn) {
args.warn.println("warning: " + warn.getMessage());
}
if (enclosingMethod != null) {
result = Annotations.combine(result, enclosingMethod);
}
if (AccessFlags.isAnnotation(cf.getAccessFlags())) {
Annotation annotationDefault =
translateAnnotationDefaults(cf);
if (annotationDefault != null) {
result = Annotations.combine(result, annotationDefault);
}
}
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:46,代码来源:AttributeTranslator.java
示例7: getMethodAnnotations
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Gets the annotations out of a given method, similar to {@link
* #getAnnotations}, also including an annotation for the translation
* of the method-specific attribute {@code Exceptions}.
*
* @param method {@code non-null;} the method in question
* @return {@code non-null;} the set of annotations, which may be empty
*/
public static Annotations getMethodAnnotations(Method method) {
Annotations result = getAnnotations(method.getAttributes());
TypeList exceptions = getExceptions(method);
if (exceptions.size() != 0) {
Annotation throwsAnnotation =
AnnotationUtils.makeThrows(exceptions);
result = Annotations.combine(result, throwsAnnotation);
}
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:21,代码来源:AttributeTranslator.java
示例8: getSignature
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Gets the {@code Signature} attribute out of a given
* {@link AttributeList}, if any, translating it to an annotation.
*
* @param attribs {@code non-null;} the attributes list to search in
* @return {@code null-ok;} the converted {@code Signature} annotation,
* if there was an attribute to translate
*/
private static Annotation getSignature(AttributeList attribs) {
AttSignature signature = (AttSignature)
attribs.findFirst(AttSignature.ATTRIBUTE_NAME);
if (signature == null) {
return null;
}
return AnnotationUtils.makeSignature(signature.getSignature());
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:AttributeTranslator.java
示例9: translateAnnotationDefaults
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Gets the {@code AnnotationDefault} attributes out of a
* given class, if any, reforming them as an
* {@code AnnotationDefault} annotation.
*
* @param cf {@code non-null;} the class in question
* @return {@code null-ok;} an appropriately-constructed
* {@code AnnotationDefault} annotation, if there were any
* annotation defaults in the class, or {@code null} if not
*/
private static Annotation translateAnnotationDefaults(DirectClassFile cf) {
CstType thisClass = cf.getThisClass();
MethodList methods = cf.getMethods();
int sz = methods.size();
Annotation result =
new Annotation(thisClass, AnnotationVisibility.EMBEDDED);
boolean any = false;
for (int i = 0; i < sz; i++) {
Method one = methods.get(i);
AttributeList attribs = one.getAttributes();
AttAnnotationDefault oneDefault = (AttAnnotationDefault)
attribs.findFirst(AttAnnotationDefault.ATTRIBUTE_NAME);
if (oneDefault != null) {
NameValuePair pair = new NameValuePair(
one.getNat().getName(),
oneDefault.getValue());
result.add(pair);
any = true;
}
}
if (! any) {
return null;
}
result.setImmutable();
return AnnotationUtils.makeAnnotationDefault(result);
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:41,代码来源:AttributeTranslator.java
示例10: AnnotationSetItem
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs an instance.
*
* @param annotations {@code non-null;} set of annotations
* @param dexFile {@code non-null;} dex output
*/
public AnnotationSetItem(Annotations annotations, DexFile dexFile) {
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, dexFile);
at++;
}
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:AnnotationSetItem.java
示例11: makeAnnotationDefault
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs a standard {@code AnnotationDefault} annotation.
*
* @param defaults {@code non-null;} the defaults, itself as an annotation
* @return {@code non-null;} the constructed annotation
*/
public static Annotation makeAnnotationDefault(Annotation defaults) {
Annotation result = new Annotation(ANNOTATION_DEFAULT_TYPE, SYSTEM);
result.put(new NameValuePair(VALUE_STRING, new CstAnnotation(defaults)));
result.setImmutable();
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:AnnotationUtils.java
示例12: makeEnclosingClass
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs a standard {@code EnclosingClass} annotation.
*
* @param clazz {@code non-null;} the enclosing class
* @return {@code non-null;} the annotation
*/
public static Annotation makeEnclosingClass(CstType clazz) {
Annotation result = new Annotation(ENCLOSING_CLASS_TYPE, SYSTEM);
result.put(new NameValuePair(VALUE_STRING, clazz));
result.setImmutable();
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:AnnotationUtils.java
示例13: makeEnclosingMethod
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs a standard {@code EnclosingMethod} annotation.
*
* @param method {@code non-null;} the enclosing method
* @return {@code non-null;} the annotation
*/
public static Annotation makeEnclosingMethod(CstMethodRef method) {
Annotation result = new Annotation(ENCLOSING_METHOD_TYPE, SYSTEM);
result.put(new NameValuePair(VALUE_STRING, method));
result.setImmutable();
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:AnnotationUtils.java
示例14: makeInnerClass
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs a standard {@code InnerClass} annotation.
*
* @param name {@code null-ok;} the original name of the class, or
* {@code null} to represent an anonymous class
* @param accessFlags the original access flags
* @return {@code non-null;} the annotation
*/
public static Annotation makeInnerClass(CstString name, int accessFlags) {
Annotation result = new Annotation(INNER_CLASS_TYPE, SYSTEM);
Constant nameCst = (name != null) ? name : CstKnownNull.THE_ONE;
result.put(new NameValuePair(NAME_STRING, nameCst));
result.put(new NameValuePair(ACCESS_FLAGS_STRING,
CstInteger.make(accessFlags)));
result.setImmutable();
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:19,代码来源:AnnotationUtils.java
示例15: makeMemberClasses
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs a standard {@code MemberClasses} annotation.
*
* @param types {@code non-null;} the list of (the types of) the member classes
* @return {@code non-null;} the annotation
*/
public static Annotation makeMemberClasses(TypeList types) {
CstArray array = makeCstArray(types);
Annotation result = new Annotation(MEMBER_CLASSES_TYPE, SYSTEM);
result.put(new NameValuePair(VALUE_STRING, array));
result.setImmutable();
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:AnnotationUtils.java
示例16: makeThrows
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Constructs a standard {@code Throws} annotation.
*
* @param types {@code non-null;} the list of thrown types
* @return {@code non-null;} the annotation
*/
public static Annotation makeThrows(TypeList types) {
CstArray array = makeCstArray(types);
Annotation result = new Annotation(THROWS_TYPE, SYSTEM);
result.put(new NameValuePair(VALUE_STRING, array));
result.setImmutable();
return result;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:14,代码来源:AnnotationUtils.java
示例17: addContents
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Helper for {@code addContents()} methods, which adds
* contents for a particular {@link Annotation}, calling itself
* recursively should it encounter a nested annotation.
*
* @param file {@code non-null;} the file to add to
* @param annotation {@code non-null;} the annotation to add contents for
*/
public static void addContents(DexFile file, Annotation annotation) {
TypeIdsSection typeIds = file.getTypeIds();
StringIdsSection stringIds = file.getStringIds();
typeIds.intern(annotation.getType());
for (NameValuePair pair : annotation.getNameValuePairs()) {
stringIds.intern(pair.getName());
addContents(file, pair.getValue());
}
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:20,代码来源:ValueEncoder.java
示例18: parseAnnotations
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* 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;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:35,代码来源:AnnotationParser.java
示例19: parseAnnotation
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Parses a single annotation.
*
* @param visibility {@code non-null;} visibility of the parsed annotation
* @return {@code non-null;} the parsed annotation
*/
private Annotation parseAnnotation(AnnotationVisibility visibility)
throws IOException {
requireLength(4);
int typeIndex = input.readUnsignedShort();
int numElements = input.readUnsignedShort();
CstString typeString = (CstString) pool.get(typeIndex);
CstType type = new CstType(Type.intern(typeString.getString()));
if (observer != null) {
parsed(2, "type: " + type.toHuman());
parsed(2, "num_elements: " + numElements);
}
Annotation annotation = new Annotation(type, visibility);
for (int i = 0; i < numElements; i++) {
if (observer != null) {
parsed(0, "elements[" + i + "]:");
changeIndent(1);
}
NameValuePair element = parseElement();
annotation.add(element);
if (observer != null) {
changeIndent(-1);
}
}
annotation.setImmutable();
return annotation;
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:40,代码来源:AnnotationParser.java
示例20: visitPackageAnnotation
import com.android.dx.rop.annotation.Annotation; //导入依赖的package包/类
/**
* Inspects a package annotation
*
* @param cf {@code non-null;} class file of "package-info" pseudo-class
* @param ann {@code non-null;} annotation
*/
private void visitPackageAnnotation(
DirectClassFile cf, BaseAnnotations ann) {
if (!args.eTypes.contains(ElementType.PACKAGE)) {
return;
}
String packageName = cf.getThisClass().getClassType().getClassName();
int slashIndex = packageName.lastIndexOf('/');
if (slashIndex == -1) {
packageName = "";
} else {
packageName
= packageName.substring(0, slashIndex);
}
for (Annotation anAnn : ann.getAnnotations().getAnnotations()) {
String annClassName
= anAnn.getType().getClassType().getClassName();
if (args.aclass.equals(annClassName)) {
printMatchPackage(packageName);
}
}
}
开发者ID:JLLK,项目名称:multidex-maker,代码行数:34,代码来源:AnnotationLister.java
注:本文中的com.android.dx.rop.annotation.Annotation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论