Java Code Examples for xmlkit.XMLKit.Element

The following examples show how to use xmlkit.XMLKit.Element. These examples are extracted from open source projects. 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 Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitNameAndType(CONSTANT_NameAndType_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = visit(cfpool.get(c.name_index), c.name_index);
            value = value.concat(" " +
                    visit(cfpool.get(c.type_index), c.type_index));
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_NameAndType",
                      new String[]{"id", p.toString()},
                      value));
        } catch (InvalidIndex ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 2
Source Project: TencentKona-8   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitMethodType(CONSTANT_MethodType_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = visit(cfpool.get(c.descriptor_index), c.descriptor_index);
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_MethodType",
                      new String[]{"id", p.toString()},
                      value));
        } catch (ConstantPoolException ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 3
Source Project: jdk8u-dev-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitMethodref(CONSTANT_Methodref_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = visit(cfpool.get(c.class_index), c.class_index);
            value = value.concat(" " +
                                 visit(cfpool.get(c.name_and_type_index),
                                 c.name_and_type_index));
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_Methodref",
                      new String[]{"id", p.toString()},
                      value));

        } catch (ConstantPoolException ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 4
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitInvokeDynamic(CONSTANT_InvokeDynamic_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = bsmlist.get(c.bootstrap_method_attr_index) + " "
                    + visit(cfpool.get(c.name_and_type_index), c.name_and_type_index);
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_InvokeDynamic",
                      new String[]{"id", p.toString()},
                      value));

        } catch (ConstantPoolException ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 5
Source Project: hottub   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info c,
                                      Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = visit(cfpool.get(c.class_index), c.class_index);
            value = value.concat(" " +
                                 visit(cfpool.get(c.name_and_type_index),
                                 c.name_and_type_index));
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_InterfaceMethodref",
                      new String[]{"id", p.toString()},
                      value));

        } catch (ConstantPoolException ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 6
Source Project: jdk8u-dev-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void readCP(ClassFile c) throws IOException {
    cpool = new Element("ConstantPool", c.constant_pool.size());
    ConstantPoolVisitor cpv = new ConstantPoolVisitor(cpool, c,
            c.constant_pool.size());
    for (int i = 1 ; i < c.constant_pool.size() ; i++) {
        try {
            cpv.visit(c.constant_pool.get(i), i);
        } catch (InvalidIndex ex) {
            // can happen periodically when accessing doubles etc. ignore it
            // ex.printStackTrace();
        }
    }
    thePool = cpv.getPoolList();
    if (verbose) {
        for (int i = 0; i < thePool.size(); i++) {
            System.out.println("[" + i + "]: " + thePool.get(i));
        }
    }
    if (keepCP) {
        cfile.add(cpool);
    }
}
 
Example 7
Source Project: jdk8u60   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitClass(CONSTANT_Class_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = visit(cfpool.get(c.name_index), c.name_index);
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_Class",
                    new String[]{"id", p.toString()},
                    value));
        } catch (ConstantPoolException ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 8
Source Project: openjdk-jdk9   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitMethodHandle(CONSTANT_MethodHandle_info c, Integer p) {
String value = slist.get(p);
    if (value == null) {
        try {
            value = c.reference_kind.name();
            value = value.concat(" "
                    + visit(cfpool.get(c.reference_index), c.reference_index));
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_MethodHandle",
                      new String[]{"id", p.toString()},
                      value));

        } catch (ConstantPoolException ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 9
Source Project: openjdk-jdk8u   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitClass(CONSTANT_Class_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        try {
            value = visit(cfpool.get(c.name_index), c.name_index);
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_Class",
                    new String[]{"id", p.toString()},
                    value));
        } catch (ConstantPoolException ex) {
            ex.printStackTrace();
        }
    }
    return value;
}
 
Example 10
Source Project: jdk8u60   Source File: ClassReader.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public String visitString(CONSTANT_String_info c, Integer p) {
    try {

        String value = slist.get(p);
        if (value == null) {
            value = c.getString();
            slist.set(p, value);
            xpool.add(new Element("CONSTANT_String",
                      new String[]{"id", p.toString()},
                      value));
        }
        return value;
    } catch (ConstantPoolException ex) {
        throw new RuntimeException("Fatal error", ex);
    }
}
 
Example 11
Source Project: hottub   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute rita, Element p) {
    Element e = new Element(x.getCpString(rita.attribute_name_index));
    for (TypeAnnotation pa : rita.annotations) {
        parseTypeAnnotations(pa, e);
    }
    e.sort();
    p.add(e);
    return null;
}
 
Example 12
Source Project: hottub   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitSourceDebugExtension(SourceDebugExtension_attribute sde,
                                            Element p) {
    String aname = x.getCpString(sde.attribute_name_index);
    Element se = new Element(aname);
    se.setAttr("val", sde.getValue());
    se.trimToSize();
    p.add(se);
    return null;
}
 
Example 13
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute ripa,
                                                         Element p) {
    Element e = new Element(x.getCpString(ripa.attribute_name_index));
    for (Annotation[] pa : ripa.parameter_annotations) {
        parseAnnotations(pa, e);
    }
    p.add(e);
    return null;
}
 
Example 14
Source Project: dragonwell8_jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Element readFrom(File file) throws IOException {
    try (InputStream strm = new FileInputStream(file)) {
        Element e = readFrom(new BufferedInputStream(strm));
        if (keepPath) {
            e.setAttr("path", file.toString());
        }
        return e;
    }
}
 
Example 15
Source Project: openjdk-8   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitSourceID(SourceID_attribute sid, Element p) {
    Element e = new Element(x.getCpString(sid.attribute_name_index));
    e.add(x.getCpString(sid.sourceID_index));
    e.trimToSize();
    p.add(e);
    return null;
}
 
Example 16
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public String visitDouble(CONSTANT_Double_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        value = Double.toString(c.value);
        slist.set(p, value);
        xpool.add(new Element("CONSTANT_Double",
                  new String[]{"id", p.toString()},
                  value));
    }
    return value;
}
 
Example 17
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visit_append_frame(append_frame a, Void p) {
   Element e = new Element("AppendFrame" + (a.frame_type - 251));
   e.setAttr("tag", "" + a.frame_type);
   e.addAll(getVerificationTypeInfo("Local", a.locals));
   e.trimToSize();
   return e;
}
 
Example 18
Source Project: openjdk-8-source   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
private AccessFlags.Kind getKind(Element e) {
    switch(e.getName()) {
        case "Class":
            return AccessFlags.Kind.Class;
        case "InnerClass":
            return AccessFlags.Kind.InnerClass;
        case "Field":
            return AccessFlags.Kind.Field ;
        case "Method":
            return AccessFlags.Kind.Method;
        default: throw new RuntimeException("should not reach here");
    }
}
 
Example 19
Source Project: openjdk-jdk8u   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitCharacterRangeTable(CharacterRangeTable_attribute crt,
                                        Element p) {
    Element e = new Element(x.getCpString(crt.attribute_name_index));
    for (CharacterRangeTable_attribute.Entry ce : crt.character_range_table) {
        e.setAttr("start_pc", "" + ce.start_pc);
        e.setAttr("end_pc", "" + ce.end_pc);
        e.setAttr("range_start", "" + ce.character_range_start);
        e.setAttr("range_end", "" + ce.character_range_end);
        e.setAttr("flags", x.flagString(ce.flags, "Method"));
    }
    e.trimToSize();
    p.add(e);
    return null;
}
 
Example 20
Source Project: jdk8u_jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArray(Array_element_value a, Element p) {
 Element el = new Element("Array");
    for (Annotation.element_value v : a.values) {
       Element child = visit(v, el);
       if (child != null) {
           el.add(child);
       }
    }
    el.trimToSize();
    return el;
}
 
Example 21
Source Project: openjdk-8   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitClass(Class_element_value c, Element p) {
    Element el = new Element("Class");
    el.setAttr("name", x.getCpString(c.class_info_index));
    el.trimToSize();
    return el;
}
 
Example 22
Source Project: openjdk-jdk8u   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public String visitFloat(CONSTANT_Float_info c, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        value = Float.toString(c.value);
        slist.set(p, value);
        xpool.add(new Element("CONSTANT_Float",
                  new String[]{"id", p.toString()},
                  value));
    }
    return value;
}
 
Example 23
Source Project: jdk8u-jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute rvta, Element p) {
    Element e = new Element(x.getCpString(rvta.attribute_name_index));
    for (TypeAnnotation pa : rvta.annotations) {
        parseTypeAnnotations(pa, e);
    }
    e.sort();
    p.add(e);
    return null;
}
 
Example 24
@Override
public Element visitMethodParameters(MethodParameters_attribute mp, Element p) {
    String name = x.getCpString(mp.attribute_name_index);
    for (MethodParameters_attribute.Entry e : mp.method_parameter_table) {
        Element l = new Element(name);
        l.setAttr("name", x.getCpString(e.name_index));
        l.setAttr("flag", "" + e.flags);
        l.trimToSize();
        p.add(l);
    }
    return null; // already added to parent
}
 
Example 25
Source Project: jdk8u60   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visit_same_locals_1_stack_item_frame(same_locals_1_stack_item_frame s, Void p) {
    Element e = new Element("SameLocals1StackItemFrame");
    e.setAttr("tag", "" + s.frame_type);
    e.addAll(getVerificationTypeInfo("Stack", s.stack));
    e.trimToSize();
    return e;
}
 
Example 26
Source Project: hottub   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitStackMapTable(StackMapTable_attribute smt, Element p) {
    Element stackmap = new Element(x.getCpString(smt.attribute_name_index));
    for (StackMapTable_attribute.stack_map_frame f : smt.entries) {
       StackMapVisitor smv = new StackMapVisitor(x, cf, stackmap);
       stackmap.add(smv.visit(f));
    }
    stackmap.trimToSize();
    p.add(stackmap);
    return null;
}
 
Example 27
Source Project: jdk8u60   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitConstantValue(ConstantValue_attribute cv, Element p) {
    Element e = new Element(x.getCpString(cv.attribute_name_index));
    e.add(x.getCpString(cv.constantvalue_index));
    p.add(e);
    return null;
}
 
Example 28
Source Project: jdk8u_jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitTableSwitch(Instruction i, int i1, int i2, int i3,
                                int[] ints, Void p) {
    Element ie = new Element(i.getMnemonic());
    int pc = i.getPC();
    ie.setAttr("lab", "" + (pc + i1));
    for (int k : ints) {
        Element c = new Element("Case");
        c.setAttr("num", "" + (k + i2));
        c.setAttr("lab", "" + (pc + k));
        c.trimToSize();
        ie.add(c);
    }
    return ie;
}
 
Example 29
Source Project: jdk8u_jdk   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public String visitInteger(CONSTANT_Integer_info cnstnt, Integer p) {
    String value = slist.get(p);
    if (value == null) {
        value = Integer.toString(cnstnt.value);
        slist.set(p, value);
        xpool.add(new Element("CONSTANT_Integer",
                  new String[]{"id", p.toString()},
                  value));
    }
    return value;
}
 
Example 30
Source Project: openjdk-jdk9   Source File: ClassReader.java    License: GNU General Public License v2.0 5 votes vote down vote up
private Element instructions(Element code, Code_attribute c) {
    Element ielement = new Element("Instructions");
    for (Instruction ins : c.getInstructions()) {
        ielement.add(iv.visit(ins));
    }
    ielement.trimToSize();
    return ielement;
}