Search in sources :

Example 1 with ElementValue

use of org.apache.tomcat.util.bcel.classfile.ElementValue in project tomcat by apache.

the class ContextConfig method processAnnotationsStringArray.

protected String[] processAnnotationsStringArray(ElementValue ev) {
    ArrayList<String> values = new ArrayList<>();
    if (ev instanceof ArrayElementValue) {
        ElementValue[] arrayValues = ((ArrayElementValue) ev).getElementValuesArray();
        for (ElementValue value : arrayValues) {
            values.add(value.stringifyValue());
        }
    } else {
        values.add(ev.stringifyValue());
    }
    String[] result = new String[values.size()];
    return values.toArray(result);
}
Also used : ArrayElementValue(org.apache.tomcat.util.bcel.classfile.ArrayElementValue) ArrayList(java.util.ArrayList) AnnotationElementValue(org.apache.tomcat.util.bcel.classfile.AnnotationElementValue) ArrayElementValue(org.apache.tomcat.util.bcel.classfile.ArrayElementValue) ElementValue(org.apache.tomcat.util.bcel.classfile.ElementValue)

Example 2 with ElementValue

use of org.apache.tomcat.util.bcel.classfile.ElementValue in project tomcat by apache.

the class ContextConfig method processAnnotationWebInitParams.

protected Map<String, String> processAnnotationWebInitParams(ElementValue ev) {
    Map<String, String> result = new HashMap<>();
    if (ev instanceof ArrayElementValue) {
        ElementValue[] arrayValues = ((ArrayElementValue) ev).getElementValuesArray();
        for (ElementValue value : arrayValues) {
            if (value instanceof AnnotationElementValue) {
                List<ElementValuePair> evps = ((AnnotationElementValue) value).getAnnotationEntry().getElementValuePairs();
                String initParamName = null;
                String initParamValue = null;
                for (ElementValuePair evp : evps) {
                    if ("name".equals(evp.getNameString())) {
                        initParamName = evp.getValue().stringifyValue();
                    } else if ("value".equals(evp.getNameString())) {
                        initParamValue = evp.getValue().stringifyValue();
                    } else {
                    // Ignore
                    }
                }
                result.put(initParamName, initParamValue);
            }
        }
    }
    return result;
}
Also used : ArrayElementValue(org.apache.tomcat.util.bcel.classfile.ArrayElementValue) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ElementValuePair(org.apache.tomcat.util.bcel.classfile.ElementValuePair) AnnotationElementValue(org.apache.tomcat.util.bcel.classfile.AnnotationElementValue) ArrayElementValue(org.apache.tomcat.util.bcel.classfile.ArrayElementValue) ElementValue(org.apache.tomcat.util.bcel.classfile.ElementValue) AnnotationElementValue(org.apache.tomcat.util.bcel.classfile.AnnotationElementValue)

Aggregations

AnnotationElementValue (org.apache.tomcat.util.bcel.classfile.AnnotationElementValue)2 ArrayElementValue (org.apache.tomcat.util.bcel.classfile.ArrayElementValue)2 ElementValue (org.apache.tomcat.util.bcel.classfile.ElementValue)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ElementValuePair (org.apache.tomcat.util.bcel.classfile.ElementValuePair)1