java类org.xml.sax.helpers.AttributesImpl的实例源码

SAXCodeAdapter.java 文件源码 项目:fastAOP 阅读 24 收藏 0 点赞 0 评论 0
@Override
public final void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "owner", "owner", "", owner);
    attrs.addAttribute("", "name", "name", "", name);
    attrs.addAttribute("", "desc", "desc", "", desc);
    attrs.addAttribute("", "itf", "itf", "", itf ? "true" : "false");
    sa.addElement(Printer.OPCODES[opcode], attrs);
}
SAXClassAdapter.java 文件源码 项目:DirectLeaks-AntiReleak-Remover 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void visitSource(final String source, final String debug) {
    AttributesImpl att = new AttributesImpl();
    if (source != null) {
        att.addAttribute("", "file", "file", "", encode(source));
    }
    if (debug != null) {
        att.addAttribute("", "debug", "debug", "", encode(debug));
    }

    sa.addElement("source", att);
}
SAXClassAdapter.java 文件源码 项目:DirectLeaks-AntiReleak-Remover 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void visitOuterClass(final String owner, final String name,
        final String desc) {
    AttributesImpl att = new AttributesImpl();
    att.addAttribute("", "owner", "owner", "", owner);
    if (name != null) {
        att.addAttribute("", "name", "name", "", name);
    }
    if (desc != null) {
        att.addAttribute("", "desc", "desc", "", desc);
    }

    sa.addElement("outerclass", att);
}
SAXClassAdapter.java 文件源码 项目:DirectLeaks-AntiReleak-Remover 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void visit(final int version, final int access, final String name,
        final String signature, final String superName,
        final String[] interfaces) {
    StringBuilder sb = new StringBuilder();
    appendAccess(access | ACCESS_CLASS, sb);

    AttributesImpl att = new AttributesImpl();
    att.addAttribute("", "access", "access", "", sb.toString());
    if (name != null) {
        att.addAttribute("", "name", "name", "", name);
    }
    if (signature != null) {
        att.addAttribute("", "signature", "signature", "",
                encode(signature));
    }
    if (superName != null) {
        att.addAttribute("", "parent", "parent", "", superName);
    }
    att.addAttribute("", "major", "major", "",
            Integer.toString(version & 0xFFFF));
    att.addAttribute("", "minor", "minor", "",
            Integer.toString(version >>> 16));
    sa.addStart("class", att);

    sa.addStart("interfaces", new AttributesImpl());
    if (interfaces != null && interfaces.length > 0) {
        for (int i = 0; i < interfaces.length; i++) {
            AttributesImpl att2 = new AttributesImpl();
            att2.addAttribute("", "name", "name", "", interfaces[i]);
            sa.addElement("interface", att2);
        }
    }
    sa.addEnd("interfaces");
}
SAXClassAdapter.java 文件源码 项目:DirectLeaks-AntiReleak-Remover 阅读 28 收藏 0 点赞 0 评论 0
@Override
public MethodVisitor visitMethod(final int access, final String name,
        final String desc, final String signature, final String[] exceptions) {
    StringBuilder sb = new StringBuilder();
    appendAccess(access, sb);

    AttributesImpl att = new AttributesImpl();
    att.addAttribute("", "access", "access", "", sb.toString());
    att.addAttribute("", "name", "name", "", name);
    att.addAttribute("", "desc", "desc", "", desc);
    if (signature != null) {
        att.addAttribute("", "signature", "signature", "", signature);
    }
    sa.addStart("method", att);

    sa.addStart("exceptions", new AttributesImpl());
    if (exceptions != null && exceptions.length > 0) {
        for (int i = 0; i < exceptions.length; i++) {
            AttributesImpl att2 = new AttributesImpl();
            att2.addAttribute("", "name", "name", "", exceptions[i]);
            sa.addElement("exception", att2);
        }
    }
    sa.addEnd("exceptions");

    return new SAXCodeAdapter(sa, access);
}
SAXCodeAdapter.java 文件源码 项目:DirectLeaks-AntiReleak-Remover 阅读 27 收藏 0 点赞 0 评论 0
@Override
public void visitParameter(String name, int access) {
    AttributesImpl attrs = new AttributesImpl();
    if (name != null) {
        attrs.addAttribute("", "name", "name", "", name);
    }
    StringBuilder sb = new StringBuilder();
    SAXClassAdapter.appendAccess(access, sb);
    attrs.addAttribute("", "access", "access", "", sb.toString());
    sa.addElement("parameter", attrs);
}
SAXCodeAdapter.java 文件源码 项目:fastAOP 阅读 29 收藏 0 点赞 0 评论 0
@Override
public final void visitLookupSwitchInsn(final Label dflt, final int[] keys,
        final Label[] labels) {
    AttributesImpl att = new AttributesImpl();
    att.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
    String o = Printer.OPCODES[Opcodes.LOOKUPSWITCH];
    sa.addStart(o, att);
    for (int i = 0; i < labels.length; i++) {
        AttributesImpl att2 = new AttributesImpl();
        att2.addAttribute("", "name", "name", "", getLabel(labels[i]));
        att2.addAttribute("", "key", "key", "", Integer.toString(keys[i]));
        sa.addElement("label", att2);
    }
    sa.addEnd(o);
}
SAXCodeAdapter.java 文件源码 项目:DirectLeaks-AntiReleak-Remover 阅读 20 收藏 0 点赞 0 评论 0
@Override
public final void visitFieldInsn(final int opcode, final String owner,
        final String name, final String desc) {
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "owner", "owner", "", owner);
    attrs.addAttribute("", "name", "name", "", name);
    attrs.addAttribute("", "desc", "desc", "", desc);
    sa.addElement(Printer.OPCODES[opcode], attrs);
}
SAXCodeAdapter.java 文件源码 项目:DirectLeaks-AntiReleak-Remover 阅读 26 收藏 0 点赞 0 评论 0
@Override
public final void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "owner", "owner", "", owner);
    attrs.addAttribute("", "name", "name", "", name);
    attrs.addAttribute("", "desc", "desc", "", desc);
    attrs.addAttribute("", "itf", "itf", "", itf ? "true" : "false");
    sa.addElement(Printer.OPCODES[opcode], attrs);
}
AttrImplTest.java 文件源码 项目:openjdk-jdk10 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Basic test for getValue(int), getValue(String) and getValue(String, String).
 */
@Test
public void testcase05() {
    AttributesImpl attr = new AttributesImpl();
    attr.addAttribute(CAR_URI, CAR_LOCALNAME, CAR_QNAME, CAR_TYPE, CAR_VALUE);
    attr.addAttribute(JEEP_URI, JEEP_LOCALNAME, JEEP_QNAME, JEEP_TYPE,
            JEEP_VALUE);
    assertEquals(attr.getValue(1), JEEP_VALUE);
    assertEquals(attr.getValue(attr.getQName(1)), JEEP_VALUE);
    assertEquals(attr.getValue(attr.getURI(1), attr.getLocalName(1)), JEEP_VALUE);
}


问题


面经


文章

微信
公众号

扫码关注公众号