本文整理汇总了Java中com.android.dx.cf.iface.AttributeList.findFirst方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeList.findFirst方法的具体用法?Java AttributeList.findFirst怎么用?Java AttributeList.findFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.dx.cf.iface.AttributeList
的用法示例。
在下文中一共展示了AttributeList.findFirst方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAnnotations0
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的package包/类
/**
* Helper method for {@link #getAnnotations} which just gets the
* existing annotations, per se.
*
* @param attribs {@code non-null;} the attributes list to search in
* @return {@code non-null;} the set of annotations, which may be empty
*/
private static Annotations getAnnotations0(AttributeList attribs) {
AttRuntimeVisibleAnnotations visible =
(AttRuntimeVisibleAnnotations)
attribs.findFirst(AttRuntimeVisibleAnnotations.ATTRIBUTE_NAME);
AttRuntimeInvisibleAnnotations invisible =
(AttRuntimeInvisibleAnnotations)
attribs.findFirst(AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME);
if (visible == null) {
if (invisible == null) {
return Annotations.EMPTY;
}
return invisible.getAnnotations();
}
if (invisible == null) {
return visible.getAnnotations();
}
// Both are non-null, so combine them.
return Annotations.combine(visible.getAnnotations(),
invisible.getAnnotations());
}
示例2: translateEnclosingMethod
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的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));
}
示例3: getExceptions
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的package包/类
/**
* Gets the list of thrown exceptions for a given method.
*
* @param method {@code non-null;} the method in question
* @return {@code non-null;} the list of thrown exceptions
*/
public static TypeList getExceptions(Method method) {
AttributeList attribs = method.getAttributes();
AttExceptions exceptions = (AttExceptions)
attribs.findFirst(AttExceptions.ATTRIBUTE_NAME);
if (exceptions == null) {
return StdTypeList.EMPTY;
}
return exceptions.getExceptions();
}
示例4: getSignature
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的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());
}
示例5: getParameterAnnotations
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的package包/类
/**
* Gets the parameter annotations out of a given method. This
* combines both visible and invisible annotations into a single
* result set.
*
* @param method {@code non-null;} the method in question
* @return {@code non-null;} the list of annotation sets, which may be
* empty
*/
public static AnnotationsList getParameterAnnotations(Method method) {
AttributeList attribs = method.getAttributes();
AttRuntimeVisibleParameterAnnotations visible =
(AttRuntimeVisibleParameterAnnotations)
attribs.findFirst(
AttRuntimeVisibleParameterAnnotations.ATTRIBUTE_NAME);
AttRuntimeInvisibleParameterAnnotations invisible =
(AttRuntimeInvisibleParameterAnnotations)
attribs.findFirst(
AttRuntimeInvisibleParameterAnnotations.ATTRIBUTE_NAME);
if (visible == null) {
if (invisible == null) {
return AnnotationsList.EMPTY;
}
return invisible.getParameterAnnotations();
}
if (invisible == null) {
return visible.getParameterAnnotations();
}
// Both are non-null, so combine them.
return AnnotationsList.combine(visible.getParameterAnnotations(),
invisible.getParameterAnnotations());
}
示例6: getSourceFile
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的package包/类
/** {@inheritDoc} */
public CstString getSourceFile() {
AttributeList attribs = getAttributes();
Attribute attSf = attribs.findFirst(AttSourceFile.ATTRIBUTE_NAME);
if (attSf instanceof AttSourceFile) {
return ((AttSourceFile) attSf).getSourceFile();
}
return null;
}
示例7: translateAnnotationDefaults
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的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);
}
示例8: getAnnotation
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的package包/类
private static Annotation getAnnotation(AttributeList attrs, String annotationName) {
BaseAnnotations a = (BaseAnnotations) attrs
.findFirst(AttRuntimeInvisibleAnnotations.ATTRIBUTE_NAME);
if (a != null) {
for (Annotation an : a.getAnnotations().getAnnotations()) {
if (an.getType().getClassType().getClassName().equals(annotationName)) {
return an;
}
}
}
return null;
}
示例9: ConcreteMethod
import com.android.dx.cf.iface.AttributeList; //导入方法依赖的package包/类
public ConcreteMethod(Method method, int accessFlags, CstString sourceFile,
boolean keepLines, boolean keepLocals) {
this.method = method;
this.accSuper = (accessFlags & AccessFlags.ACC_SUPER) != 0;
this.sourceFile = sourceFile;
AttributeList attribs = method.getAttributes();
this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME);
AttributeList codeAttribs = attCode.getAttributes();
/*
* Combine all LineNumberTable attributes into one, with the
* combined result saved into the instance. The following code
* isn't particularly efficient for doing merges, but as far
* as I know, this situation rarely occurs "in the
* wild," so there's not much point in optimizing for it.
*/
LineNumberList lineNumbers = LineNumberList.EMPTY;
if (keepLines) {
for (AttLineNumberTable lnt = (AttLineNumberTable)
codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME);
lnt != null;
lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) {
lineNumbers = LineNumberList.concat(lineNumbers,
lnt.getLineNumbers());
}
}
this.lineNumbers = lineNumbers;
LocalVariableList localVariables = LocalVariableList.EMPTY;
if (keepLocals) {
/*
* Do likewise (and with the same caveat) for
* LocalVariableTable and LocalVariableTypeTable attributes.
* This combines both of these kinds of attribute into a
* single LocalVariableList.
*/
for (AttLocalVariableTable lvt = (AttLocalVariableTable)
codeAttribs.findFirst(
AttLocalVariableTable.ATTRIBUTE_NAME);
lvt != null;
lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) {
localVariables =
LocalVariableList.concat(localVariables,
lvt.getLocalVariables());
}
LocalVariableList typeList = LocalVariableList.EMPTY;
for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable)
codeAttribs.findFirst(
AttLocalVariableTypeTable.ATTRIBUTE_NAME);
lvtt != null;
lvtt =
(AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) {
typeList =
LocalVariableList.concat(typeList,
lvtt.getLocalVariables());
}
if (typeList.size() != 0) {
localVariables =
LocalVariableList.mergeDescriptorsAndSignatures(
localVariables, typeList);
}
}
this.localVariables = localVariables;
}