本文整理汇总了Java中org.apache.bcel.classfile.AnnotationEntry.getElementValuePairs方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationEntry.getElementValuePairs方法的具体用法?Java AnnotationEntry.getElementValuePairs怎么用?Java AnnotationEntry.getElementValuePairs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.AnnotationEntry
的用法示例。
在下文中一共展示了AnnotationEntry.getElementValuePairs方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyzeField
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
private void analyzeField(Field field, JavaClass javaClass) {
for (AnnotationEntry annotation : field.getAnnotationEntries()) {
if (ANNOTATION_TYPES.contains(annotation.getAnnotationType()) ||
annotation.getAnnotationType().contains("JsonTypeInfo")) {
for (ElementValuePair elementValuePair : annotation.getElementValuePairs()) {
if ("use".equals((elementValuePair.getNameString())) &&
VULNERABLE_USE_NAMES.contains(elementValuePair.getValue().stringifyValue())) {
bugReporter.reportBug(new BugInstance(this, DESERIALIZATION_TYPE, HIGH_PRIORITY)
.addClass(javaClass)
.addString(javaClass.getClassName() + " on field " +
field.getName() + " of type " + field.getType() +
" annotated with " + annotation.toShortString())
.addField(FieldAnnotation.fromBCELField(javaClass, field))
.addString("")
);
}
}
}
}
}
示例2: addAnnotations
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
private void addAnnotations(Element node, AnnotationEntry[] annotations) {
if (annotations.length == 0) {
return;
}
Element a = new Element("annotations", nsXMLVM);
node.addContent(a);
for (AnnotationEntry annotation : annotations) {
String type = annotation.getAnnotationType();
// Turn into a scoped name. Strip off leading "L" and
// trailing
// ";"
type = type.substring(1, type.length() - 1);
type = type.replaceAll("/", ".");
Element newAnnotation = new Element("annotation", nsXMLVM);
a.addContent(newAnnotation);
newAnnotation.setAttribute("type", type);
ElementValuePair[] values = annotation.getElementValuePairs();
for (ElementValuePair value : values) {
Element property = new Element("property", nsXMLVM);
// TODO(arno) Need to add type
property.setAttribute("name", value.getNameString());
property.setAttribute("value", value.getValue().stringifyValue());
newAnnotation.addContent(property);
}
}
}
示例3: visitParameterAnnotation
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
@Override
public void visitParameterAnnotation(ParameterAnnotations arg0) {
ParameterAnnotationEntry[] parameterAnnotationEntries = arg0.getParameterAnnotationEntries();
int numParametersToMethod = getNumberMethodArguments();
int offset = 0;
if (numParametersToMethod > parameterAnnotationEntries.length) {
offset = 1;
}
for (int i = 0; i < parameterAnnotationEntries.length; i++) {
ParameterAnnotationEntry e = parameterAnnotationEntries[i];
for (AnnotationEntry ae : e.getAnnotationEntries()) {
boolean runtimeVisible = ae.isRuntimeVisible();
String name = ClassName.fromFieldSignature(ae.getAnnotationType());
if (name == null)
continue;
name = ClassName.toDottedClassName(name);
Map<String, ElementValue> map = new HashMap<String, ElementValue>();
for (ElementValuePair ev : ae.getElementValuePairs()) {
map.put(ev.getNameString(), ev.getValue());
}
visitParameterAnnotation(offset + i, name, map, runtimeVisible);
}
}
}
示例4: visitAnnotation
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
@Override
public void visitAnnotation(Annotations arg0) {
for (AnnotationEntry ae : arg0.getAnnotationEntries()) {
boolean runtimeVisible = ae.isRuntimeVisible();
String name = ClassName.fromFieldSignature(ae.getAnnotationType());
if (name == null)
continue;
name = ClassName.toDottedClassName(name);
Map<String, ElementValue> map = new HashMap<String, ElementValue>();
for (ElementValuePair ev : ae.getElementValuePairs()) {
map.put(ev.getNameString(), ev.getValue());
}
visitAnnotation(name, map, runtimeVisible);
}
}
示例5: findMethodAnnotationAttribute
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
private static ElementValuePair findMethodAnnotationAttribute(AnnotationEntry requestMappingAnnotation) {
for (ElementValuePair elementValuePair : requestMappingAnnotation.getElementValuePairs()) {
if (METHOD_ANNOTATION_ATTRIBUTE_KEY.equals(elementValuePair.getNameString())) {
return elementValuePair;
}
}
return null;
}
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:9,代码来源:SpringCsrfUnrestrictedRequestMappingDetector.java
示例6: getAttribute
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
private String getAttribute(AnnotationEntry annotationEntry, String attribute) {
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if(elementValuePair.getNameString().equalsIgnoreCase(attribute)) {
return elementValuePair.getValue().stringifyValue();
}
}
return "";
}
示例7: getAnnotationAttributesMap
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
private Map<String, String> getAnnotationAttributesMap(AnnotationEntry annotationEntry) {
Map<String, String> annotationsAttributesMap = new HashMap<String, String>();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
annotationsAttributesMap.put(elementValuePair.getNameString(), elementValuePair.getValue().stringifyValue());
}
return annotationsAttributesMap;
}
示例8: parseController
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
public static Controller parseController(AnnotationEntry annotationEntry) {
Controller controller = new Controller();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("value")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
controller.setValue(simpleElementValue.toShortString());
}
}
return controller;
}
示例9: parseService
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
public static Service parseService(AnnotationEntry annotationEntry) {
Service service = new Service();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("value")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
service.setValue(simpleElementValue.toShortString());
}
}
return service;
}
示例10: parseQualifier
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
public static Qualifier parseQualifier(AnnotationEntry annotationEntry) {
Qualifier qualifier = new Qualifier();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("value")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
qualifier.setValue(simpleElementValue.toShortString());
}
}
return qualifier;
}
示例11: parseAutowired
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
public static Autowired parseAutowired(AnnotationEntry annotationEntry) {
Autowired autowired = new Autowired();
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("required")) {
SimpleElementValue simpleElementValue = (SimpleElementValue) elementValuePair.getValue();
autowired.setRequired(Boolean.valueOf(simpleElementValue.toShortString()));
}
}
return autowired;
}
示例12: parseTable
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
public static TableInfo parseTable(AnnotationEntry annotationEntry) {
for (ElementValuePair elementValuePair : annotationEntry.getElementValuePairs()) {
if (elementValuePair.getNameString().equals("name")) {
String tableName = elementValuePair.getValue().toShortString();
if (!StringUtil.isEmpty(tableName)) {
return new TableInfo(tableName, TableInfo.Define);
}
}
}
return null;
}
示例13: visitMethod
import org.apache.bcel.classfile.AnnotationEntry; //导入方法依赖的package包/类
@Override
public void visitMethod(Method method) {
xmlMethod = new Element("method", nsXMLVM);
xmlMethod.setAttribute("name", method.getName());
addAccessModifiers(xmlMethod, method.getAccessFlags());
if (!method.isAbstract() && !method.isNative()) {
// Abstract methods don't have an implementation
Code code = method.getCode();
String maxStack = java.lang.String.valueOf(code.getMaxStack());
String maxLocals = java.lang.String.valueOf(code.getMaxLocals());
xmlMethod.setAttribute("stack", maxStack);
xmlMethod.setAttribute("locals", maxLocals);
}
Element sgn = parseSignature(method.getSignature());
xmlMethod.addContent(sgn);
// TODO(arno) this should also be handled via the <annotations>
// tag.
// Need modification in xmlvm2js.xsl
// Look for NativeInterface annotation
for (AnnotationEntry annotation : method.getAnnotationEntries()) {
String type = annotation.getAnnotationType();
if (type.equals("Lorg/xmlvm/NativeInterface;")) {
ElementValuePair[] value = annotation.getElementValuePairs();
String nativeMethodName = value[0].getValue().toString();
xmlMethod.setAttribute("nativeInterface", nativeMethodName);
break;
}
}
addAnnotations(xmlMethod, method.getAnnotationEntries());
xmlClass.addContent(xmlMethod);
this.bcelMethod = method;
}