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

The following examples show how to use xmlkit.XMLKit.Element#setAttr() . 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: hottub   File: ClassReader.java    License: 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
@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 3
@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 4
@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 5
@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 6
@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 7
@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 8
@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 9
Source Project: hottub   File: ClassReader.java    License: 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 10
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 11
@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 12
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 13
@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 14
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 15
@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 16
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}
 
Example 17
@Override
public Element visitLocal(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("loc", "" + i1);
    return ie;
}
 
Example 18
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}
 
Example 19
@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 20
@Override
public Element visitValue(Instruction i, int i1, Void p) {
    Element ie = new Element(i.getMnemonic());
    ie.setAttr("num", "" + i1);
    return ie;
}