本文整理汇总了Java中org.jf.dexlib2.immutable.ImmutableAnnotationElement类的典型用法代码示例。如果您正苦于以下问题:Java ImmutableAnnotationElement类的具体用法?Java ImmutableAnnotationElement怎么用?Java ImmutableAnnotationElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImmutableAnnotationElement类属于org.jf.dexlib2.immutable包,在下文中一共展示了ImmutableAnnotationElement类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: for
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
private List<ImmutableAnnotation> buildVisibilityAnnotationTag
(VisibilityAnnotationTag t, Set<String> skipList) {
if (t.getAnnotations() == null)
return Collections.emptyList();
List<ImmutableAnnotation> annotations = new ArrayList<ImmutableAnnotation>();
for (AnnotationTag at: t.getAnnotations()) {
String type = at.getType();
if (!skipList.add(type))
continue;
Set<String> alreadyWritten = new HashSet<String>();
List<AnnotationElement> elements = null;
if (!at.getElems().isEmpty()) {
elements = new ArrayList<AnnotationElement>();
for (AnnotationElem ae : at.getElems()) {
if (ae.getName() == null || ae.getName().isEmpty())
throw new RuntimeException("Null or empty annotation name encountered");
if (!alreadyWritten.add(ae.getName()))
throw new RuntimeException("Duplicate annotation attribute: " + ae.getName());
EncodedValue value = buildEncodedValueForAnnotation(ae);
ImmutableAnnotationElement element = new ImmutableAnnotationElement
(ae.getName(), value);
elements.add(element);
}
}
String typeName = SootToDexUtils.getDexClassName(at.getType());
ImmutableAnnotation ann = new ImmutableAnnotation(getVisibility(t.getVisibility()),
typeName, elements);
annotations.add(ann);
}
return annotations;
}
示例2: buildEnclosingMethodTag
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
private Annotation buildEnclosingMethodTag(EnclosingMethodTag t, Set<String> skipList) {
if (!skipList.add("Ldalvik/annotation/EnclosingMethod;"))
return null;
if (t.getEnclosingMethod() == null)
return null;
String[] split1 = t.getEnclosingMethodSig().split("\\)");
String parametersS = split1[0].replaceAll("\\(", "");
String returnTypeS = split1[1];
List<String> typeList = new ArrayList<String>();
if (!parametersS.equals("")) {
for (String p : Util.splitParameters(parametersS)) {
if (!p.isEmpty())
typeList.add(p);
}
}
ImmutableMethodReference mRef = new ImmutableMethodReference
(SootToDexUtils.getDexClassName(t.getEnclosingClass()),
t.getEnclosingMethod(), typeList, returnTypeS);
ImmutableMethodEncodedValue methodRef = new ImmutableMethodEncodedValue
(dexFile.internMethodReference(mRef));
AnnotationElement methodElement = new ImmutableAnnotationElement("value", methodRef);
return new ImmutableAnnotation(AnnotationVisibility.SYSTEM,
"Ldalvik/annotation/EnclosingMethod;",
Collections.singleton(methodElement));
}
示例3: ImmutableAnnotationEncodedValue
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
public ImmutableAnnotationEncodedValue(@Nonnull String type,
@Nullable Collection<? extends AnnotationElement> elements) {
this.type = type;
this.elements = ImmutableAnnotationElement.immutableSetOf(elements);
}
示例4: if
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
private List<ImmutableAnnotation> buildVisibilityParameterAnnotationTag
(VisibilityParameterAnnotationTag t, Set<String> skipList,
int paramIdx) {
if (t.getVisibilityAnnotations() == null)
return Collections.emptyList();
int paramTagIdx = 0;
List<ImmutableAnnotation> annotations = new ArrayList<ImmutableAnnotation>();
for (VisibilityAnnotationTag vat : t.getVisibilityAnnotations()) {
if (paramTagIdx == paramIdx
&& vat != null
&& vat.getAnnotations() != null)
for (AnnotationTag at : vat.getAnnotations()) {
String type = at.getType();
if (!skipList.add(type))
continue;
Set<String> alreadyWritten = new HashSet<String>();
List<AnnotationElement> elements = null;
if (!at.getElems().isEmpty()) {
elements = new ArrayList<AnnotationElement>();
for (AnnotationElem ae : at.getElems()) {
if (ae.getName() == null || ae.getName().isEmpty())
throw new RuntimeException("Null or empty annotation name encountered");
if (!alreadyWritten.add(ae.getName()))
throw new RuntimeException("Duplicate annotation attribute: " + ae.getName());
EncodedValue value = buildEncodedValueForAnnotation(ae);
ImmutableAnnotationElement element = new ImmutableAnnotationElement(ae.getName(), value);
elements.add(element);
}
}
ImmutableAnnotation ann = new ImmutableAnnotation(getVisibility(vat.getVisibility()),
SootToDexUtils.getDexClassName(at.getType()),
elements);
annotations.add(ann);
}
paramTagIdx++;
}
return annotations;
}
示例5: buildInnerClassAttribute
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
private List<Annotation> buildInnerClassAttribute(SootClass parentClass,
InnerClassAttribute t, Set<String> skipList) {
if (t.getSpecs() == null)
return null;
List<Annotation> anns = null;
for (Tag t2 : t.getSpecs()) {
InnerClassTag icTag = (InnerClassTag) t2;
// In Dalvik, both the EnclosingMethod/EnclosingClass tag and the
// InnerClass tag are written to the inner class which is different
// to Java. We thus check whether this tag actually points to our
// outer class.
String outerClass = getOuterClassNameFromTag(icTag);
String innerClass = icTag.getInnerClass().replaceAll("/", ".");
// Only write the InnerClass tag to the inner class itself, not
// the other one. If the outer class points to our parent, but
// this is simply the wrong inner class, we also continue with the
// next tag.
if (!parentClass.hasOuterClass()
|| !innerClass.equals(parentClass.getName()))
continue;
// If the outer class points to the very same class, we null it
if (parentClass.getName().equals(outerClass)
&& icTag.getOuterClass() == null)
outerClass = null;
// Do not write garbage. Never.
if (parentClass.getName().equals(outerClass))
continue;
// This is an actual inner class. Write the annotation
if (skipList.add("Ldalvik/annotation/InnerClass;")) {
// InnerClass annotation
List<AnnotationElement> elements = new ArrayList<AnnotationElement>();
ImmutableAnnotationElement flagsElement = new ImmutableAnnotationElement
("accessFlags", new ImmutableIntEncodedValue(icTag.getAccessFlags()));
elements.add(flagsElement);
ImmutableEncodedValue nameValue;
if (icTag.getShortName() != null && !icTag.getShortName().isEmpty())
nameValue = new ImmutableStringEncodedValue(icTag.getShortName());
else
nameValue = ImmutableNullEncodedValue.INSTANCE;
ImmutableAnnotationElement nameElement = new ImmutableAnnotationElement
("name", nameValue);
elements.add(nameElement);
if (anns == null) anns = new ArrayList<Annotation>();
anns.add(new ImmutableAnnotation(AnnotationVisibility.SYSTEM,
"Ldalvik/annotation/InnerClass;",
elements));
}
}
return anns;
}
示例6: buildMemberClassesAttribute
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
private List<Annotation> buildMemberClassesAttribute(SootClass parentClass,
InnerClassAttribute t, Set<String> skipList) {
List<Annotation> anns = null;
Set<String> memberClasses = null;
// Collect the inner classes
for (Tag t2 : t.getSpecs()) {
InnerClassTag icTag = (InnerClassTag) t2;
String outerClass = getOuterClassNameFromTag(icTag);
// Only classes with names are member classes
if (icTag.getOuterClass() != null
&& parentClass.getName().equals(outerClass)) {
if (memberClasses == null)
memberClasses = new HashSet<String>();
memberClasses.add(SootToDexUtils.getDexClassName(icTag.getInnerClass()));
}
}
// Write the member classes
if (memberClasses != null
&& !memberClasses.isEmpty()
&& skipList.add("Ldalvik/annotation/MemberClasses;")) {
List<EncodedValue> classes = new ArrayList<EncodedValue>();
for (String memberClass : memberClasses) {
ImmutableTypeEncodedValue classValue = new ImmutableTypeEncodedValue(memberClass);
classes.add(classValue);
}
ImmutableArrayEncodedValue classesValue =
new ImmutableArrayEncodedValue(classes);
ImmutableAnnotationElement element =
new ImmutableAnnotationElement("value", classesValue);
ImmutableAnnotation memberAnnotation =
new ImmutableAnnotation(AnnotationVisibility.SYSTEM,
"Ldalvik/annotation/MemberClasses;",
Collections.singletonList(element));
if (anns == null) anns = new ArrayList<Annotation>();
anns.add(memberAnnotation);
}
return anns;
}
示例7: ImmutableAnnotationEncodedValue
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
public ImmutableAnnotationEncodedValue( String type,
Collection<? extends AnnotationElement> elements) {
this.type = type;
this.elements = ImmutableAnnotationElement.immutableSetOf(elements);
}
示例8: getElements
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
@Nonnull
@Override
public ImmutableSet<? extends ImmutableAnnotationElement> getElements() {
return elements;
}
示例9: getElements
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
@Nonnull @Override public ImmutableSet<? extends ImmutableAnnotationElement> getElements() { return elements; }
示例10: getElements
import org.jf.dexlib2.immutable.ImmutableAnnotationElement; //导入依赖的package包/类
@Override public ImmutableSet<? extends ImmutableAnnotationElement> getElements() { return elements; }