Java Code Examples for xmlkit.XMLKit.Element#setAttr()

The following examples show how to use xmlkit.XMLKit.Element#setAttr() . 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: ClassReader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void readClass(ClassFile c) throws IOException,
                                           ConstantPoolException,
                                           InvalidDescriptor {
    klass = new Element("Class");
    cfile.add(klass);
    String thisk = c.getName();

    klass.setAttr("name", thisk);

    AccessFlags af = new AccessFlags(c.access_flags.flags);
    klass.setAttr("flags", flagString(af, klass));
    if (!"java/lang/Object".equals(thisk)) {
        klass.setAttr("super", c.getSuperclassName());
    }
    for (int i : c.interfaces) {
        klass.add(new Element("Interface", "name", getCpString(i)));
    }
    readFields(c, klass);
    readMethods(c, klass);
    readAttributesFor(c, c.attributes, klass);
    klass.trimToSize();
}
 
Example 2
Source File: ClassReader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visit_same_frame_extended(same_frame_extended s, Void p) {
    Element e = new Element("SameFrameExtended");
    e.setAttr("tag", "" + s.frame_type);
    e.setAttr("offset", "" + s.offset_delta);
    return e;
}
 
Example 3
Source File: ClassReader.java    From jdk8u_jdk with 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 4
Source File: ClassReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void attachAttrTo(Element x, String aname, String aval) {
    String aval0 = x.getAttr(aname);
    if (aval0 != null) {
        aval = aval0 + " " + aval;
    }
    x.setAttr(aname, aval);
}
 
Example 5
Source File: ClassReader.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArrayType(Instruction i, TypeKind tk, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + tk.value);
    ie.setAttr("val", tk.name);
    return ie;
}
 
Example 6
Source File: ClassReader.java    From jdk8u-dev-jdk with 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 7
Source File: ClassReader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitNoOperands(Instruction i, Void p) {
    Opcode o = i.getOpcode();
    Element e = new Element(i.getMnemonic());
    if (o.opcode > 0xab && o.opcode <= 0xb1) {
        e.setAttr("pc", "" + i.getPC());
    }
    return e;
}
 
Example 8
Source File: ClassReader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void attachAttrTo(Element x, String aname, String aval) {
    String aval0 = x.getAttr(aname);
    if (aval0 != null) {
        aval = aval0 + " " + aval;
    }
    x.setAttr(aname, aval);
}
 
Example 9
Source File: ClassReader.java    From jdk8u60 with 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 10
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitArrayType(Instruction i, TypeKind tk, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + tk.value);
    ie.setAttr("val", tk.name);
    return ie;
}
 
Example 11
Source File: ClassReader.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitAnnotationDefault(AnnotationDefault_attribute ad, Element p) {
    Element e = new Element(x.getCpString(ad.attribute_name_index));
    e.setAttr("tag", "" + ad.default_value.tag);
    Element child = aev.visit(ad.default_value, e);
    if (child != null) {
        e.add(child);
    }
    e.trimToSize();
    p.add(e);
    return null;
}
 
Example 12
Source File: ClassReader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitLookupSwitch(Instruction i, int i1, int i2, int[] ints,
                                 int[] ints1, Void p) {
    Element ie = new Element(i.getMnemonic());
    int pc = i.getPC();
    ie.setAttr("lab", "" + (pc + i1));
    for (int k = 0 ; k < i2 ; k++) {
        Element c = new Element("Case");
        c.setAttr("num", "" + (ints[k]));
        c.setAttr("lab", "" + (pc + ints1[k]));
        c.trimToSize();
        ie.add(c);
    }
    return ie;
}
 
Example 13
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visitInnerClasses(InnerClasses_attribute ic, Element p) {
    for (Info info : ic.classes) {
        Element e = new Element(x.getCpString(ic.attribute_name_index));
        e.setAttr("class", x.getCpString(info.inner_class_info_index));
        e.setAttr("outer", x.getCpString(info.outer_class_info_index));
        e.setAttr("name", x.getCpString(info.inner_name_index));
        e.setAttr("flags", x.flagString(info.inner_class_access_flags,
                "InnerClass"));
        e.trimToSize();
        p.add(e);
    }
    return null;
}
 
Example 14
Source File: ClassReader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Element visit_same_frame_extended(same_frame_extended s, Void p) {
    Element e = new Element("SameFrameExtended");
    e.setAttr("tag", "" + s.frame_type);
    e.setAttr("offset", "" + s.offset_delta);
    return e;
}
 
Example 15
Source File: ClassReader.java    From jdk8u-jdk with 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 16
Source File: ClassReader.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}
 
Example 17
Source File: ClassReader.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitConstantPoolRef(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("ref", x.getCpString(i1));
    return ie;
}
 
Example 18
Source File: ClassReader.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}
 
Example 19
Source File: ClassReader.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitLocal(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("loc", "" + i1);
    return ie;
}
 
Example 20
Source File: ClassReader.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}