org.apache.bcel.classfile.ArrayElementValue Java Examples
The following examples show how to use
org.apache.bcel.classfile.ArrayElementValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringCsrfUnrestrictedRequestMappingDetector.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean isEmptyArray(ElementValue methodAnnotationAttributeValue) { if (!(methodAnnotationAttributeValue instanceof ArrayElementValue)) { return false; } ArrayElementValue arrayElementValue = (ArrayElementValue) methodAnnotationAttributeValue; return arrayElementValue.getElementValuesArraySize() == 0; }
Example #2
Source File: SpringCsrfUnrestrictedRequestMappingDetector.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
private static boolean isMixOfUnprotectedAndProtectedHttpRequestMethods(ElementValue methodAnnotationAttributeValue) { if (!(methodAnnotationAttributeValue instanceof ArrayElementValue)) { return false; } ArrayElementValue arrayElementValue = (ArrayElementValue) methodAnnotationAttributeValue; // There cannot be a mix if there is no more than one element. if (arrayElementValue.getElementValuesArraySize() <= 1) { return false; } // Return `true` as soon as we find at least one unprotected and at least one protected HTTP request method. boolean atLeastOneUnprotected = false; boolean atLeastOneProtected = false; ElementValue[] elementValues = arrayElementValue.getElementValuesArray(); for (ElementValue elementValue : elementValues) { if (UNPROTECTED_HTTP_REQUEST_METHODS.contains(elementValue.stringifyValue())) { atLeastOneUnprotected = true; } else { atLeastOneProtected = true; } if (atLeastOneUnprotected && atLeastOneProtected) { return true; } } return false; }
Example #3
Source File: BuildNonNullAnnotationDatabase.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void visitAnnotation(String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) { if (database == null) { return; } NullnessAnnotation n = NullnessAnnotation.Parser.parse(annotationClass); annotationClass = lastPortion(annotationClass); if (n == null) { if (annotationClass.startsWith("DefaultAnnotation")) { annotationClass = annotationClass.substring("DefaultAnnotation".length()); Target annotationTarget = defaultKind.get(annotationClass); if (annotationTarget != Target.METHOD) { return; } ElementValue v = map.get("value"); if (v instanceof ClassElementValue) { handleClassElementValue((ClassElementValue) v, annotationTarget); } else if (v instanceof ArrayElementValue) { for (ElementValue v2 : ((ArrayElementValue) v).getElementValuesArray()) { if (v2 instanceof ClassElementValue) { handleClassElementValue((ClassElementValue) v2, annotationTarget); } } } return; } } else if (visitingMethod()) { database.addDirectAnnotation(XFactory.createXMethod(this), n); } else if (visitingField()) { database.addDirectAnnotation(XFactory.createXField(this), n); } }
Example #4
Source File: ArrayElementValueGen.java From commons-bcel with Apache License 2.0 | 5 votes |
/** * Return immutable variant of this ArrayElementValueGen */ @Override public ElementValue getElementValue() { final ElementValue[] immutableData = new ElementValue[evalues.size()]; int i = 0; for (final ElementValueGen element : evalues) { immutableData[i++] = element.getElementValue(); } return new ArrayElementValue(super.getElementValueType(), immutableData, getConstantPool().getConstantPool()); }
Example #5
Source File: ArrayElementValueGen.java From commons-bcel with Apache License 2.0 | 5 votes |
/** * @param value * @param cpool */ public ArrayElementValueGen(final ArrayElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { super(ARRAY, cpool); evalues = new ArrayList<>(); final ElementValue[] in = value.getElementValuesArray(); for (final ElementValue element : in) { evalues.add(ElementValueGen.copy(element, cpool, copyPoolEntries)); } }
Example #6
Source File: ElementValueGen.java From commons-bcel with Apache License 2.0 | 5 votes |
/** * Creates an (modifiable) ElementValueGen copy of an (immutable) * ElementValue - constant pool is assumed correct. */ public static ElementValueGen copy(final ElementValue value, final ConstantPoolGen cpool, final boolean copyPoolEntries) { switch (value.getElementValueType()) { case 'B': // byte case 'C': // char case 'D': // double case 'F': // float case 'I': // int case 'J': // long case 'S': // short case 'Z': // boolean case 's': // String return new SimpleElementValueGen((SimpleElementValue) value, cpool, copyPoolEntries); case 'e': // Enum constant return new EnumElementValueGen((EnumElementValue) value, cpool, copyPoolEntries); case '@': // Annotation return new AnnotationElementValueGen( (AnnotationElementValue) value, cpool, copyPoolEntries); case '[': // Array return new ArrayElementValueGen((ArrayElementValue) value, cpool, copyPoolEntries); case 'c': // Class return new ClassElementValueGen((ClassElementValue) value, cpool, copyPoolEntries); default: throw new UnsupportedOperationException("Not implemented yet! (" + value.getElementValueType() + ")"); } }
Example #7
Source File: GeneratingAnnotatedClassesTestCase.java From commons-bcel with Apache License 2.0 | 5 votes |
private void assertArrayElementValue(final int nExpectedArrayValues, final AnnotationEntry anno) { final ElementValuePair elementValuePair = anno.getElementValuePairs()[0]; assertEquals("value", elementValuePair.getNameString()); final ArrayElementValue ev = (ArrayElementValue) elementValuePair.getValue(); final ElementValue[] eva = ev.getElementValuesArray(); assertEquals(nExpectedArrayValues, eva.length); }