summaryrefslogtreecommitdiff
path: root/tools/external/asm/org/objectweb/asm/xml
diff options
context:
space:
mode:
Diffstat (limited to 'tools/external/asm/org/objectweb/asm/xml')
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java1215
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/Processor.java1048
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java91
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java191
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java351
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java310
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java77
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/asm-xml.dtd340
-rw-r--r--tools/external/asm/org/objectweb/asm/xml/package.html96
9 files changed, 3719 insertions, 0 deletions
diff --git a/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java b/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java
new file mode 100644
index 000000000..1f6fee0ff
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/ASMContentHandler.java
@@ -0,0 +1,1215 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Type;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} that transforms XML
+ * document into Java class file. This class can be feeded by any kind of SAX
+ * 2.0 event producers, e.g. XML parser, XSLT or XPath engines, or custom code.
+ *
+ * @see org.objectweb.asm.xml.SAXClassAdapter
+ * @see org.objectweb.asm.xml.Processor
+ *
+ * @author Eugene Kuleshov
+ */
+public class ASMContentHandler extends DefaultHandler implements Opcodes {
+ /**
+ * Stack of the intermediate processing contexts.
+ */
+ private List stack = new ArrayList();
+
+ /**
+ * Complete name of the current element.
+ */
+ private String match = "";
+
+ /**
+ * <tt>true</tt> if the maximum stack size and number of local variables
+ * must be automatically computed.
+ */
+ protected boolean computeMax;
+
+ /**
+ * Output stream to write result bytecode.
+ */
+ protected OutputStream os;
+
+ /**
+ * Current instance of the {@link ClassWriter ClassWriter} used to write
+ * class bytecode.
+ */
+ protected ClassWriter cw;
+
+ /**
+ * Map of the active {@link Label Label} instances for current method.
+ */
+ protected Map labels;
+
+ private static final String BASE = "class";
+
+ private final RuleSet RULES = new RuleSet();
+ {
+ RULES.add(BASE, new ClassRule());
+ RULES.add(BASE + "/interfaces/interface", new InterfaceRule());
+ RULES.add(BASE + "/interfaces", new InterfacesRule());
+ RULES.add(BASE + "/outerclass", new OuterClassRule());
+ RULES.add(BASE + "/innerclass", new InnerClassRule());
+ RULES.add(BASE + "/source", new SourceRule());
+ RULES.add(BASE + "/field", new FieldRule());
+
+ RULES.add(BASE + "/method", new MethodRule());
+ RULES.add(BASE + "/method/exceptions/exception", new ExceptionRule());
+ RULES.add(BASE + "/method/exceptions", new ExceptionsRule());
+
+ RULES.add(BASE + "/method/annotationDefault",
+ new AnnotationDefaultRule());
+
+ RULES.add(BASE + "/method/code/*", new OpcodesRule()); // opcodes
+
+ RULES.add(BASE + "/method/code/TABLESWITCH", new TableSwitchRule());
+ RULES.add(BASE + "/method/code/TABLESWITCH/label",
+ new TableSwitchLabelRule());
+ RULES.add(BASE + "/method/code/LOOKUPSWITCH", new LookupSwitchRule());
+ RULES.add(BASE + "/method/code/LOOKUPSWITCH/label",
+ new LookupSwitchLabelRule());
+
+ RULES.add(BASE + "/method/code/Label", new LabelRule());
+ RULES.add(BASE + "/method/code/TryCatch", new TryCatchRule());
+ RULES.add(BASE + "/method/code/LineNumber", new LineNumberRule());
+ RULES.add(BASE + "/method/code/LocalVar", new LocalVarRule());
+ RULES.add(BASE + "/method/code/Max", new MaxRule());
+
+ RULES.add("*/annotation", new AnnotationRule());
+ RULES.add("*/parameterAnnotation", new AnnotationParameterRule());
+ RULES.add("*/annotationValue", new AnnotationValueRule());
+ RULES.add("*/annotationValueAnnotation",
+ new AnnotationValueAnnotationRule());
+ RULES.add("*/annotationValueEnum", new AnnotationValueEnumRule());
+ RULES.add("*/annotationValueArray", new AnnotationValueArrayRule());
+ };
+
+ private static interface OpcodeGroup {
+ public static final int INSN = 0;
+ public static final int INSN_INT = 1;
+ public static final int INSN_VAR = 2;
+ public static final int INSN_TYPE = 3;
+ public static final int INSN_FIELD = 4;
+ public static final int INSN_METHOD = 5;
+ public static final int INSN_JUMP = 6;
+ public static final int INSN_LDC = 7;
+ public static final int INSN_IINC = 8;
+ public static final int INSN_MULTIANEWARRAY = 9;
+ }
+
+ /**
+ * Map of the opcode names to opcode and opcode group
+ */
+ static final Map OPCODES = new HashMap();
+ static {
+ OPCODES.put("NOP", new Opcode(NOP, OpcodeGroup.INSN));
+ OPCODES.put("ACONST_NULL", new Opcode(ACONST_NULL, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_M1", new Opcode(ICONST_M1, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_0", new Opcode(ICONST_0, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_1", new Opcode(ICONST_1, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_2", new Opcode(ICONST_2, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_3", new Opcode(ICONST_3, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_4", new Opcode(ICONST_4, OpcodeGroup.INSN));
+ OPCODES.put("ICONST_5", new Opcode(ICONST_5, OpcodeGroup.INSN));
+ OPCODES.put("LCONST_0", new Opcode(LCONST_0, OpcodeGroup.INSN));
+ OPCODES.put("LCONST_1", new Opcode(LCONST_1, OpcodeGroup.INSN));
+ OPCODES.put("FCONST_0", new Opcode(FCONST_0, OpcodeGroup.INSN));
+ OPCODES.put("FCONST_1", new Opcode(FCONST_1, OpcodeGroup.INSN));
+ OPCODES.put("FCONST_2", new Opcode(FCONST_2, OpcodeGroup.INSN));
+ OPCODES.put("DCONST_0", new Opcode(DCONST_0, OpcodeGroup.INSN));
+ OPCODES.put("DCONST_1", new Opcode(DCONST_1, OpcodeGroup.INSN));
+ OPCODES.put("BIPUSH", new Opcode(BIPUSH, OpcodeGroup.INSN_INT));
+ OPCODES.put("SIPUSH", new Opcode(SIPUSH, OpcodeGroup.INSN_INT));
+ OPCODES.put("LDC", new Opcode(LDC, OpcodeGroup.INSN_LDC));
+ OPCODES.put("ILOAD", new Opcode(ILOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("LLOAD", new Opcode(LLOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("FLOAD", new Opcode(FLOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("DLOAD", new Opcode(DLOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("ALOAD", new Opcode(ALOAD, OpcodeGroup.INSN_VAR));
+ OPCODES.put("IALOAD", new Opcode(IALOAD, OpcodeGroup.INSN));
+ OPCODES.put("LALOAD", new Opcode(LALOAD, OpcodeGroup.INSN));
+ OPCODES.put("FALOAD", new Opcode(FALOAD, OpcodeGroup.INSN));
+ OPCODES.put("DALOAD", new Opcode(DALOAD, OpcodeGroup.INSN));
+ OPCODES.put("AALOAD", new Opcode(AALOAD, OpcodeGroup.INSN));
+ OPCODES.put("BALOAD", new Opcode(BALOAD, OpcodeGroup.INSN));
+ OPCODES.put("CALOAD", new Opcode(CALOAD, OpcodeGroup.INSN));
+ OPCODES.put("SALOAD", new Opcode(SALOAD, OpcodeGroup.INSN));
+ OPCODES.put("ISTORE", new Opcode(ISTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("LSTORE", new Opcode(LSTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("FSTORE", new Opcode(FSTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("DSTORE", new Opcode(DSTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("ASTORE", new Opcode(ASTORE, OpcodeGroup.INSN_VAR));
+ OPCODES.put("IASTORE", new Opcode(IASTORE, OpcodeGroup.INSN));
+ OPCODES.put("LASTORE", new Opcode(LASTORE, OpcodeGroup.INSN));
+ OPCODES.put("FASTORE", new Opcode(FASTORE, OpcodeGroup.INSN));
+ OPCODES.put("DASTORE", new Opcode(DASTORE, OpcodeGroup.INSN));
+ OPCODES.put("AASTORE", new Opcode(AASTORE, OpcodeGroup.INSN));
+ OPCODES.put("BASTORE", new Opcode(BASTORE, OpcodeGroup.INSN));
+ OPCODES.put("CASTORE", new Opcode(CASTORE, OpcodeGroup.INSN));
+ OPCODES.put("SASTORE", new Opcode(SASTORE, OpcodeGroup.INSN));
+ OPCODES.put("POP", new Opcode(POP, OpcodeGroup.INSN));
+ OPCODES.put("POP2", new Opcode(POP2, OpcodeGroup.INSN));
+ OPCODES.put("DUP", new Opcode(DUP, OpcodeGroup.INSN));
+ OPCODES.put("DUP_X1", new Opcode(DUP_X1, OpcodeGroup.INSN));
+ OPCODES.put("DUP_X2", new Opcode(DUP_X2, OpcodeGroup.INSN));
+ OPCODES.put("DUP2", new Opcode(DUP2, OpcodeGroup.INSN));
+ OPCODES.put("DUP2_X1", new Opcode(DUP2_X1, OpcodeGroup.INSN));
+ OPCODES.put("DUP2_X2", new Opcode(DUP2_X2, OpcodeGroup.INSN));
+ OPCODES.put("SWAP", new Opcode(SWAP, OpcodeGroup.INSN));
+ OPCODES.put("IADD", new Opcode(IADD, OpcodeGroup.INSN));
+ OPCODES.put("LADD", new Opcode(LADD, OpcodeGroup.INSN));
+ OPCODES.put("FADD", new Opcode(FADD, OpcodeGroup.INSN));
+ OPCODES.put("DADD", new Opcode(DADD, OpcodeGroup.INSN));
+ OPCODES.put("ISUB", new Opcode(ISUB, OpcodeGroup.INSN));
+ OPCODES.put("LSUB", new Opcode(LSUB, OpcodeGroup.INSN));
+ OPCODES.put("FSUB", new Opcode(FSUB, OpcodeGroup.INSN));
+ OPCODES.put("DSUB", new Opcode(DSUB, OpcodeGroup.INSN));
+ OPCODES.put("IMUL", new Opcode(IMUL, OpcodeGroup.INSN));
+ OPCODES.put("LMUL", new Opcode(LMUL, OpcodeGroup.INSN));
+ OPCODES.put("FMUL", new Opcode(FMUL, OpcodeGroup.INSN));
+ OPCODES.put("DMUL", new Opcode(DMUL, OpcodeGroup.INSN));
+ OPCODES.put("IDIV", new Opcode(IDIV, OpcodeGroup.INSN));
+ OPCODES.put("LDIV", new Opcode(LDIV, OpcodeGroup.INSN));
+ OPCODES.put("FDIV", new Opcode(FDIV, OpcodeGroup.INSN));
+ OPCODES.put("DDIV", new Opcode(DDIV, OpcodeGroup.INSN));
+ OPCODES.put("IREM", new Opcode(IREM, OpcodeGroup.INSN));
+ OPCODES.put("LREM", new Opcode(LREM, OpcodeGroup.INSN));
+ OPCODES.put("FREM", new Opcode(FREM, OpcodeGroup.INSN));
+ OPCODES.put("DREM", new Opcode(DREM, OpcodeGroup.INSN));
+ OPCODES.put("INEG", new Opcode(INEG, OpcodeGroup.INSN));
+ OPCODES.put("LNEG", new Opcode(LNEG, OpcodeGroup.INSN));
+ OPCODES.put("FNEG", new Opcode(FNEG, OpcodeGroup.INSN));
+ OPCODES.put("DNEG", new Opcode(DNEG, OpcodeGroup.INSN));
+ OPCODES.put("ISHL", new Opcode(ISHL, OpcodeGroup.INSN));
+ OPCODES.put("LSHL", new Opcode(LSHL, OpcodeGroup.INSN));
+ OPCODES.put("ISHR", new Opcode(ISHR, OpcodeGroup.INSN));
+ OPCODES.put("LSHR", new Opcode(LSHR, OpcodeGroup.INSN));
+ OPCODES.put("IUSHR", new Opcode(IUSHR, OpcodeGroup.INSN));
+ OPCODES.put("LUSHR", new Opcode(LUSHR, OpcodeGroup.INSN));
+ OPCODES.put("IAND", new Opcode(IAND, OpcodeGroup.INSN));
+ OPCODES.put("LAND", new Opcode(LAND, OpcodeGroup.INSN));
+ OPCODES.put("IOR", new Opcode(IOR, OpcodeGroup.INSN));
+ OPCODES.put("LOR", new Opcode(LOR, OpcodeGroup.INSN));
+ OPCODES.put("IXOR", new Opcode(IXOR, OpcodeGroup.INSN));
+ OPCODES.put("LXOR", new Opcode(LXOR, OpcodeGroup.INSN));
+ OPCODES.put("IINC", new Opcode(IINC, OpcodeGroup.INSN_IINC));
+ OPCODES.put("I2L", new Opcode(I2L, OpcodeGroup.INSN));
+ OPCODES.put("I2F", new Opcode(I2F, OpcodeGroup.INSN));
+ OPCODES.put("I2D", new Opcode(I2D, OpcodeGroup.INSN));
+ OPCODES.put("L2I", new Opcode(L2I, OpcodeGroup.INSN));
+ OPCODES.put("L2F", new Opcode(L2F, OpcodeGroup.INSN));
+ OPCODES.put("L2D", new Opcode(L2D, OpcodeGroup.INSN));
+ OPCODES.put("F2I", new Opcode(F2I, OpcodeGroup.INSN));
+ OPCODES.put("F2L", new Opcode(F2L, OpcodeGroup.INSN));
+ OPCODES.put("F2D", new Opcode(F2D, OpcodeGroup.INSN));
+ OPCODES.put("D2I", new Opcode(D2I, OpcodeGroup.INSN));
+ OPCODES.put("D2L", new Opcode(D2L, OpcodeGroup.INSN));
+ OPCODES.put("D2F", new Opcode(D2F, OpcodeGroup.INSN));
+ OPCODES.put("I2B", new Opcode(I2B, OpcodeGroup.INSN));
+ OPCODES.put("I2C", new Opcode(I2C, OpcodeGroup.INSN));
+ OPCODES.put("I2S", new Opcode(I2S, OpcodeGroup.INSN));
+ OPCODES.put("LCMP", new Opcode(LCMP, OpcodeGroup.INSN));
+ OPCODES.put("FCMPL", new Opcode(FCMPL, OpcodeGroup.INSN));
+ OPCODES.put("FCMPG", new Opcode(FCMPG, OpcodeGroup.INSN));
+ OPCODES.put("DCMPL", new Opcode(DCMPL, OpcodeGroup.INSN));
+ OPCODES.put("DCMPG", new Opcode(DCMPG, OpcodeGroup.INSN));
+ OPCODES.put("IFEQ", new Opcode(IFEQ, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFNE", new Opcode(IFNE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFLT", new Opcode(IFLT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFGE", new Opcode(IFGE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFGT", new Opcode(IFGT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFLE", new Opcode(IFLE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPEQ", new Opcode(IF_ICMPEQ, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPNE", new Opcode(IF_ICMPNE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPLT", new Opcode(IF_ICMPLT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPGE", new Opcode(IF_ICMPGE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPGT", new Opcode(IF_ICMPGT, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ICMPLE", new Opcode(IF_ICMPLE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ACMPEQ", new Opcode(IF_ACMPEQ, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IF_ACMPNE", new Opcode(IF_ACMPNE, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("GOTO", new Opcode(GOTO, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("JSR", new Opcode(JSR, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("RET", new Opcode(RET, OpcodeGroup.INSN_VAR));
+ // OPCODES.put( "TABLESWITCH", new Opcode( TABLESWITCH,
+ // "visiTableSwitchInsn"));
+ // OPCODES.put( "LOOKUPSWITCH", new Opcode( LOOKUPSWITCH,
+ // "visitLookupSwitch"));
+ OPCODES.put("IRETURN", new Opcode(IRETURN, OpcodeGroup.INSN));
+ OPCODES.put("LRETURN", new Opcode(LRETURN, OpcodeGroup.INSN));
+ OPCODES.put("FRETURN", new Opcode(FRETURN, OpcodeGroup.INSN));
+ OPCODES.put("DRETURN", new Opcode(DRETURN, OpcodeGroup.INSN));
+ OPCODES.put("ARETURN", new Opcode(ARETURN, OpcodeGroup.INSN));
+ OPCODES.put("RETURN", new Opcode(RETURN, OpcodeGroup.INSN));
+ OPCODES.put("GETSTATIC", new Opcode(GETSTATIC, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("PUTSTATIC", new Opcode(PUTSTATIC, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("GETFIELD", new Opcode(GETFIELD, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("PUTFIELD", new Opcode(PUTFIELD, OpcodeGroup.INSN_FIELD));
+ OPCODES.put("INVOKEVIRTUAL", new Opcode(INVOKEVIRTUAL,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("INVOKESPECIAL", new Opcode(INVOKESPECIAL,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("INVOKESTATIC", new Opcode(INVOKESTATIC,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("INVOKEINTERFACE", new Opcode(INVOKEINTERFACE,
+ OpcodeGroup.INSN_METHOD));
+ OPCODES.put("NEW", new Opcode(NEW, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("NEWARRAY", new Opcode(NEWARRAY, OpcodeGroup.INSN_INT));
+ OPCODES.put("ANEWARRAY", new Opcode(ANEWARRAY, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("ARRAYLENGTH", new Opcode(ARRAYLENGTH, OpcodeGroup.INSN));
+ OPCODES.put("ATHROW", new Opcode(ATHROW, OpcodeGroup.INSN));
+ OPCODES.put("CHECKCAST", new Opcode(CHECKCAST, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("INSTANCEOF", new Opcode(INSTANCEOF, OpcodeGroup.INSN_TYPE));
+ OPCODES.put("MONITORENTER", new Opcode(MONITORENTER, OpcodeGroup.INSN));
+ OPCODES.put("MONITOREXIT", new Opcode(MONITOREXIT, OpcodeGroup.INSN));
+ OPCODES.put("MULTIANEWARRAY", new Opcode(MULTIANEWARRAY,
+ OpcodeGroup.INSN_MULTIANEWARRAY));
+ OPCODES.put("IFNULL", new Opcode(IFNULL, OpcodeGroup.INSN_JUMP));
+ OPCODES.put("IFNONNULL", new Opcode(IFNONNULL, OpcodeGroup.INSN_JUMP));
+ }
+
+ /**
+ * Constructs a new {@link ASMContentHandler ASMContentHandler} object.
+ *
+ * @param os output stream to write generated class.
+ * @param computeMax <tt>true</tt> if the maximum stack size and the
+ * maximum number of local variables must be automatically computed.
+ * This value is passed to {@link ClassWriter ClassWriter} instance.
+ */
+ public ASMContentHandler(OutputStream os, boolean computeMax) {
+ this.os = os;
+ this.computeMax = computeMax;
+ }
+
+ /**
+ * Returns the bytecode of the class that was build with underneath class
+ * writer.
+ *
+ * @return the bytecode of the class that was build with underneath class
+ * writer or null if there are no classwriter created.
+ */
+ public byte[] toByteArray() {
+ return cw == null ? null : cw.toByteArray();
+ }
+
+ /**
+ * Process notification of the start of an XML element being reached.
+ *
+ * @param ns - The Namespace URI, or the empty string if the element has no
+ * Namespace URI or if Namespace processing is not being performed.
+ * @param localName - The local name (without prefix), or the empty string
+ * if Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix), or the empty string if
+ * qualified names are not available.
+ * @param list - The attributes attached to the element. If there are no
+ * attributes, it shall be an empty Attributes object.
+ * @exception SAXException if a parsing error is to be reported
+ */
+ public final void startElement(
+ String ns,
+ String localName,
+ String qName,
+ Attributes list) throws SAXException
+ {
+ // the actual element name is either in localName or qName, depending
+ // on whether the parser is namespace aware
+ String name = localName;
+ if (name == null || name.length() < 1) {
+ name = qName;
+ }
+
+ // Compute the current matching rule
+ StringBuffer sb = new StringBuffer(match);
+ if (match.length() > 0) {
+ sb.append('/');
+ }
+ sb.append(name);
+ match = sb.toString();
+
+ // Fire "begin" events for all relevant rules
+ Rule r = (Rule) RULES.match(match);
+ if (r != null)
+ r.begin(name, list);
+ }
+
+ /**
+ * Process notification of the end of an XML element being reached.
+ *
+ * @param ns - The Namespace URI, or the empty string if the element has no
+ * Namespace URI or if Namespace processing is not being performed.
+ * @param localName - The local name (without prefix), or the empty string
+ * if Namespace processing is not being performed.
+ * @param qName - The qualified XML 1.0 name (with prefix), or the empty
+ * string if qualified names are not available.
+ *
+ * @exception SAXException if a parsing error is to be reported
+ */
+ public final void endElement(String ns, String localName, String qName)
+ throws SAXException
+ {
+ // the actual element name is either in localName or qName, depending
+ // on whether the parser is namespace aware
+ String name = localName;
+ if (name == null || name.length() < 1) {
+ name = qName;
+ }
+
+ // Fire "end" events for all relevant rules in reverse order
+ Rule r = (Rule) RULES.match(match);
+ if (r != null)
+ r.end(name);
+
+ // Recover the previous match expression
+ int slash = match.lastIndexOf('/');
+ if (slash >= 0) {
+ match = match.substring(0, slash);
+ } else {
+ match = "";
+ }
+ }
+
+ /**
+ * Process notification of the end of a document and write generated
+ * bytecode into output stream.
+ *
+ * @exception SAXException if parsing or writing error is to be reported.
+ */
+ public final void endDocument() throws SAXException {
+ try {
+ os.write(cw.toByteArray());
+ } catch (IOException ex) {
+ throw new SAXException(ex.toString(), ex);
+ }
+ }
+
+ /**
+ * Return the top object on the stack without removing it. If there are no
+ * objects on the stack, return <code>null</code>.
+ *
+ * @return the top object on the stack without removing it.
+ */
+ final Object peek() {
+ return stack.size() == 0 ? null : stack.get(stack.size() - 1);
+ }
+
+ /**
+ * Return the n'th object down the stack, where 0 is the top element and
+ * [getCount()-1] is the bottom element. If the specified index is out of
+ * range, return <code>null</code>.
+ *
+ * @param n Index of the desired element, where 0 is the top of the stack, 1
+ * is the next element down, and so on.
+ * @return the n'th object down the stack.
+ */
+ final Object peek(int n) {
+ return stack.size() < (n + 1) ? null : stack.get(n);
+ }
+
+ /**
+ * Pop the top object off of the stack, and return it. If there are no
+ * objects on the stack, return <code>null</code>.
+ *
+ * @return the top object off of the stack.
+ */
+ final Object pop() {
+ return stack.size() == 0 ? null : stack.remove(stack.size() - 1);
+ }
+
+ /**
+ * Push a new object onto the top of the object stack.
+ *
+ * @param object The new object
+ */
+ final void push(Object object) {
+ stack.add(object);
+ }
+
+ private static final class RuleSet {
+ private Map rules = new HashMap();
+
+ private List lpatterns = new ArrayList();
+
+ private List rpatterns = new ArrayList();
+
+ public void add(String path, Object rule) {
+ String pattern = path;
+ if (path.startsWith("*/")) {
+ pattern = path.substring(1);
+ lpatterns.add(pattern);
+ } else if (path.endsWith("/*")) {
+ pattern = path.substring(0, path.length() - 1);
+ rpatterns.add(pattern);
+ }
+ rules.put(pattern, rule);
+ }
+
+ public Object match(String path) {
+ if (rules.containsKey(path)) {
+ return rules.get(path);
+ }
+
+ int n = path.lastIndexOf('/');
+ for (Iterator it = lpatterns.iterator(); it.hasNext();) {
+ String pattern = (String) it.next();
+ if (path.substring(n).endsWith(pattern)) {
+ return rules.get(pattern);
+ }
+ }
+
+ for (Iterator it = rpatterns.iterator(); it.hasNext();) {
+ String pattern = (String) it.next();
+ if (path.startsWith(pattern)) {
+ return rules.get(pattern);
+ }
+ }
+
+ return null;
+ }
+
+ }
+
+ /**
+ * Rule
+ */
+ protected abstract class Rule {
+
+ public void begin(String name, Attributes attrs) {
+ }
+
+ public void end(String name) {
+ }
+
+ protected final Object getValue(String desc, String val) {
+ Object value = null;
+ if (val != null) {
+ if (desc.equals("Ljava/lang/String;")) {
+ value = decode(val);
+ } else if ("Ljava/lang/Integer;".equals(desc)
+ || "I".equals(desc) || "S".equals(desc)
+ || "B".equals(desc) || "C".equals(desc)
+ || desc.equals("Z"))
+ {
+ value = new Integer(val);
+
+ } else if ("Ljava/lang/Short;".equals(desc)) {
+ value = new Short(val);
+
+ } else if ("Ljava/lang/Byte;".equals(desc)) {
+ value = new Byte(val);
+
+ } else if ("Ljava/lang/Character;".equals(desc)) {
+ value = new Character(decode(val).charAt(0));
+
+ } else if ("Ljava/lang/Boolean;".equals(desc)) {
+ value = Boolean.valueOf(val);
+
+ // } else if ("Ljava/lang/Integer;".equals(desc)
+ // || desc.equals("I"))
+ // {
+ // value = new Integer(val);
+ // } else if ("Ljava/lang/Character;".equals(desc)
+ // || desc.equals("C"))
+ // {
+ // value = new Character(decode(val).charAt(0));
+ // } else if ("Ljava/lang/Short;".equals(desc) ||
+ // desc.equals("S"))
+ // {
+ // value = Short.valueOf(val);
+ // } else if ("Ljava/lang/Byte;".equals(desc) ||
+ // desc.equals("B"))
+ // {
+ // value = Byte.valueOf(val);
+
+ } else if ("Ljava/lang/Long;".equals(desc) || desc.equals("J"))
+ {
+ value = new Long(val);
+ } else if ("Ljava/lang/Float;".equals(desc) || desc.equals("F"))
+ {
+ value = new Float(val);
+ } else if ("Ljava/lang/Double;".equals(desc)
+ || desc.equals("D"))
+ {
+ value = new Double(val);
+ } else if (Type.getDescriptor(Type.class).equals(desc)) {
+ value = Type.getType(val);
+
+ // } else if ("[I".equals(desc)) {
+ // value = new int[0]; // TODO
+ // } else if ("[C".equals(desc)) {
+ // value = new char[0]; // TODO
+ // } else if ("[Z".equals(desc)) {
+ // value = new boolean[0]; // TODO
+ // } else if ("[S".equals(desc)) {
+ // value = new short[0]; // TODO
+ // } else if ("[B".equals(desc)) {
+ // value = new byte[0]; // TODO
+ // } else if ("[J".equals(desc)) {
+ // value = new long[0]; // TODO
+ // } else if ("[F".equals(desc)) {
+ // value = new float[0]; // TODO
+ // } else if ("[D".equals(desc)) {
+ // value = new double[0]; // TODO
+
+ } else {
+ throw new RuntimeException("Invalid value:" + val
+ + " desc:" + desc + " ctx:" + this);
+ }
+ }
+ return value;
+ }
+
+ private final String decode(String val) {
+ StringBuffer sb = new StringBuffer(val.length());
+ try {
+ int n = 0;
+ while (n < val.length()) {
+ char c = val.charAt(n);
+ if (c == '\\') {
+ n++;
+ c = val.charAt(n);
+ if (c == '\\') {
+ sb.append('\\');
+ } else {
+ n++; // skip 'u'
+ sb.append((char) Integer.parseInt(val.substring(n,
+ n + 4), 16));
+ n += 3;
+ }
+ } else {
+ sb.append(c);
+ }
+ n++;
+ }
+
+ } catch (RuntimeException ex) {
+ System.err.println(val + "\n" + ex.toString());
+ ex.printStackTrace();
+ throw ex;
+ }
+ return sb.toString();
+ }
+
+ protected final Label getLabel(Object label) {
+ Label lbl = (Label) labels.get(label);
+ if (lbl == null) {
+ lbl = new Label();
+ labels.put(label, lbl);
+ }
+ return lbl;
+ }
+
+ // TODO verify move to stack
+ protected final MethodVisitor getCodeVisitor() {
+ return (MethodVisitor) peek();
+ }
+
+ protected final int getAccess(String s) {
+ int access = 0;
+ if (s.indexOf("public") != -1)
+ access |= Opcodes.ACC_PUBLIC;
+ if (s.indexOf("private") != -1)
+ access |= Opcodes.ACC_PRIVATE;
+ if (s.indexOf("protected") != -1)
+ access |= Opcodes.ACC_PROTECTED;
+ if (s.indexOf("static") != -1)
+ access |= Opcodes.ACC_STATIC;
+ if (s.indexOf("final") != -1)
+ access |= Opcodes.ACC_FINAL;
+ if (s.indexOf("super") != -1)
+ access |= Opcodes.ACC_SUPER;
+ if (s.indexOf("synchronized") != -1)
+ access |= Opcodes.ACC_SYNCHRONIZED;
+ if (s.indexOf("volatile") != -1)
+ access |= Opcodes.ACC_VOLATILE;
+ if (s.indexOf("bridge") != -1)
+ access |= Opcodes.ACC_BRIDGE;
+ if (s.indexOf("varargs") != -1)
+ access |= Opcodes.ACC_VARARGS;
+ if (s.indexOf("transient") != -1)
+ access |= Opcodes.ACC_TRANSIENT;
+ if (s.indexOf("native") != -1)
+ access |= Opcodes.ACC_NATIVE;
+ if (s.indexOf("interface") != -1)
+ access |= Opcodes.ACC_INTERFACE;
+ if (s.indexOf("abstract") != -1)
+ access |= Opcodes.ACC_ABSTRACT;
+ if (s.indexOf("strict") != -1)
+ access |= Opcodes.ACC_STRICT;
+ if (s.indexOf("synthetic") != -1)
+ access |= Opcodes.ACC_SYNTHETIC;
+ if (s.indexOf("annotation") != -1)
+ access |= Opcodes.ACC_ANNOTATION;
+ if (s.indexOf("enum") != -1)
+ access |= Opcodes.ACC_ENUM;
+ if (s.indexOf("deprecated") != -1)
+ access |= Opcodes.ACC_DEPRECATED;
+ return access;
+ }
+
+ }
+
+ /**
+ * ClassRule
+ */
+ private final class ClassRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ int major = Integer.parseInt(attrs.getValue("major"));
+ int minor = Integer.parseInt(attrs.getValue("minor"));
+ cw = new ClassWriter(computeMax);
+ Map vals = new HashMap();
+ vals.put("version", new Integer(minor << 16 | major));
+ vals.put("access", attrs.getValue("access"));
+ vals.put("name", attrs.getValue("name"));
+ vals.put("parent", attrs.getValue("parent"));
+ vals.put("source", attrs.getValue("source"));
+ vals.put("signature", attrs.getValue("signature"));
+ vals.put("interfaces", new ArrayList());
+ push(vals);
+ // values will be extracted in InterfacesRule.end();
+ }
+
+ }
+
+ private final class SourceRule extends Rule {
+
+ public void begin(String name, Attributes attrs) {
+ String file = attrs.getValue("file");
+ String debug = attrs.getValue("debug");
+ cw.visitSource(file, debug);
+ }
+
+ }
+
+ /**
+ * InterfaceRule
+ */
+ private final class InterfaceRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ ((List) ((Map) peek()).get("interfaces")).add(attrs.getValue("name"));
+ }
+
+ }
+
+ /**
+ * InterfacesRule
+ */
+ private final class InterfacesRule extends Rule {
+
+ public final void end(String element) {
+ Map vals = (Map) pop();
+ int version = ((Integer) vals.get("version")).intValue();
+ int access = getAccess((String) vals.get("access"));
+ String name = (String) vals.get("name");
+ String signature = (String) vals.get("signature");
+ String parent = (String) vals.get("parent");
+ List infs = (List) vals.get("interfaces");
+ String[] interfaces = (String[]) infs.toArray(new String[infs.size()]);
+ cw.visit(version, access, name, signature, parent, interfaces);
+ push(cw);
+ }
+
+ }
+
+ /**
+ * OuterClassRule
+ */
+ private final class OuterClassRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ String owner = attrs.getValue("owner");
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ cw.visitOuterClass(owner, name, desc);
+ }
+
+ }
+
+ /**
+ * InnerClassRule
+ */
+ private final class InnerClassRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ int access = getAccess(attrs.getValue("access"));
+ String name = attrs.getValue("name");
+ String outerName = attrs.getValue("outerName");
+ String innerName = attrs.getValue("innerName");
+ cw.visitInnerClass(name, outerName, innerName, access);
+ }
+
+ }
+
+ /**
+ * FieldRule
+ */
+ private final class FieldRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ int access = getAccess(attrs.getValue("access"));
+ String name = attrs.getValue("name");
+ String signature = attrs.getValue("signature");
+ String desc = attrs.getValue("desc");
+ Object value = getValue(desc, attrs.getValue("value"));
+ push(cw.visitField(access, name, desc, signature, value));
+ }
+
+ public void end(String name) {
+ ((FieldVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ /**
+ * MethodRule
+ */
+ private final class MethodRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ labels = new HashMap();
+ Map vals = new HashMap();
+ vals.put("access", attrs.getValue("access"));
+ vals.put("name", attrs.getValue("name"));
+ vals.put("desc", attrs.getValue("desc"));
+ vals.put("signature", attrs.getValue("signature"));
+ vals.put("exceptions", new ArrayList());
+ push(vals);
+ // values will be extracted in ExceptionsRule.end();
+ }
+
+ public final void end(String name) {
+ ((MethodVisitor) pop()).visitEnd();
+ labels = null;
+ }
+
+ }
+
+ /**
+ * ExceptionRule
+ */
+ private final class ExceptionRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ ((List) ((Map) peek()).get("exceptions")).add(attrs.getValue("name"));
+ }
+
+ }
+
+ /**
+ * ExceptionsRule
+ */
+ private final class ExceptionsRule extends Rule {
+
+ public final void end(String element) {
+ Map vals = (Map) pop();
+ int access = getAccess((String) vals.get("access"));
+ String name = (String) vals.get("name");
+ String desc = (String) vals.get("desc");
+ String signature = (String) vals.get("signature");
+ List excs = (List) vals.get("exceptions");
+ String[] exceptions = (String[]) excs.toArray(new String[excs.size()]);
+
+ push(cw.visitMethod(access, name, desc, signature, exceptions));
+ }
+
+ }
+
+ /**
+ * TableSwitchRule
+ */
+ private class TableSwitchRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Map vals = new HashMap();
+ vals.put("min", attrs.getValue("min"));
+ vals.put("max", attrs.getValue("max"));
+ vals.put("dflt", attrs.getValue("dflt"));
+ vals.put("labels", new ArrayList());
+ push(vals);
+ }
+
+ public final void end(String name) {
+ Map vals = (Map) pop();
+ int min = Integer.parseInt((String) vals.get("min"));
+ int max = Integer.parseInt((String) vals.get("max"));
+ Label dflt = getLabel(vals.get("dflt"));
+ List lbls = (List) vals.get("labels");
+ Label[] labels = (Label[]) lbls.toArray(new Label[lbls.size()]);
+ getCodeVisitor().visitTableSwitchInsn(min, max, dflt, labels);
+ }
+
+ }
+
+ /**
+ * TableSwitchLabelRule
+ */
+ private final class TableSwitchLabelRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ ((List) ((Map) peek()).get("labels")).add(getLabel(attrs.getValue("name")));
+ }
+
+ }
+
+ /**
+ * LookupSwitchRule
+ */
+ private final class LookupSwitchRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Map vals = new HashMap();
+ vals.put("dflt", attrs.getValue("dflt"));
+ vals.put("labels", new ArrayList());
+ vals.put("keys", new ArrayList());
+ push(vals);
+ }
+
+ public final void end(String name) {
+ Map vals = (Map) pop();
+ Label dflt = getLabel(vals.get("dflt"));
+ List keyList = (List) vals.get("keys");
+ List lbls = (List) vals.get("labels");
+ Label[] labels = (Label[]) lbls.toArray(new Label[lbls.size()]);
+ int[] keys = new int[keyList.size()];
+ for (int i = 0; i < keys.length; i++) {
+ keys[i] = Integer.parseInt((String) keyList.get(i));
+ }
+ getCodeVisitor().visitLookupSwitchInsn(dflt, keys, labels);
+ }
+
+ }
+
+ /**
+ * LookupSwitchLabelRule
+ */
+ private final class LookupSwitchLabelRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Map vals = (Map) peek();
+ ((List) vals.get("labels")).add(getLabel(attrs.getValue("name")));
+ ((List) vals.get("keys")).add(attrs.getValue("key"));
+ }
+
+ }
+
+ /**
+ * LabelRule
+ */
+ private final class LabelRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ getCodeVisitor().visitLabel(getLabel(attrs.getValue("name")));
+ }
+
+ }
+
+ /**
+ * TryCatchRule
+ */
+ private final class TryCatchRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ Label start = getLabel(attrs.getValue("start"));
+ Label end = getLabel(attrs.getValue("end"));
+ Label handler = getLabel(attrs.getValue("handler"));
+ String type = attrs.getValue("type");
+ getCodeVisitor().visitTryCatchBlock(start, end, handler, type);
+ }
+
+ }
+
+ /**
+ * LineNumberRule
+ */
+ private final class LineNumberRule extends Rule {
+
+ public final void begin(String name, Attributes attrs) {
+ int line = Integer.parseInt(attrs.getValue("line"));
+ Label start = getLabel(attrs.getValue("start"));
+ getCodeVisitor().visitLineNumber(line, start);
+ }
+
+ }
+
+ /**
+ * LocalVarRule
+ */
+ private final class LocalVarRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ String signature = attrs.getValue("signature");
+ Label start = getLabel(attrs.getValue("start"));
+ Label end = getLabel(attrs.getValue("end"));
+ int var = Integer.parseInt(attrs.getValue("var"));
+ getCodeVisitor().visitLocalVariable(name,
+ desc,
+ signature,
+ start,
+ end,
+ var);
+ }
+
+ }
+
+ /**
+ * OpcodesRule
+ */
+ private final class OpcodesRule extends Rule {
+
+ // public boolean match( String match, String element) {
+ // return match.startsWith( path) && OPCODES.containsKey( element);
+ // }
+
+ public final void begin(String element, Attributes attrs) {
+ Opcode o = ((Opcode) OPCODES.get(element));
+ if (o == null)
+ return;
+
+ switch (o.type) {
+ case OpcodeGroup.INSN:
+ getCodeVisitor().visitInsn(o.opcode);
+ break;
+
+ case OpcodeGroup.INSN_FIELD:
+ getCodeVisitor().visitFieldInsn(o.opcode,
+ attrs.getValue("owner"),
+ attrs.getValue("name"),
+ attrs.getValue("desc"));
+ break;
+
+ case OpcodeGroup.INSN_INT:
+ getCodeVisitor().visitIntInsn(o.opcode,
+ Integer.parseInt(attrs.getValue("value")));
+ break;
+
+ case OpcodeGroup.INSN_JUMP:
+ getCodeVisitor().visitJumpInsn(o.opcode,
+ getLabel(attrs.getValue("label")));
+ break;
+
+ case OpcodeGroup.INSN_METHOD:
+ getCodeVisitor().visitMethodInsn(o.opcode,
+ attrs.getValue("owner"),
+ attrs.getValue("name"),
+ attrs.getValue("desc"));
+ break;
+
+ case OpcodeGroup.INSN_TYPE:
+ getCodeVisitor().visitTypeInsn(o.opcode,
+ attrs.getValue("desc"));
+ break;
+
+ case OpcodeGroup.INSN_VAR:
+ getCodeVisitor().visitVarInsn(o.opcode,
+ Integer.parseInt(attrs.getValue("var")));
+ break;
+
+ case OpcodeGroup.INSN_IINC:
+ getCodeVisitor().visitIincInsn(Integer.parseInt(attrs.getValue("var")),
+ Integer.parseInt(attrs.getValue("inc")));
+ break;
+
+ case OpcodeGroup.INSN_LDC:
+ getCodeVisitor().visitLdcInsn(getValue(attrs.getValue("desc"),
+ attrs.getValue("cst")));
+ break;
+
+ case OpcodeGroup.INSN_MULTIANEWARRAY:
+ getCodeVisitor().visitMultiANewArrayInsn(attrs.getValue("desc"),
+ Integer.parseInt(attrs.getValue("dims")));
+ break;
+
+ default:
+ throw new RuntimeException("Invalid element: " + element
+ + " at " + match);
+
+ }
+ }
+ }
+
+ /**
+ * MaxRule
+ */
+ private final class MaxRule extends Rule {
+
+ public final void begin(String element, Attributes attrs) {
+ int maxStack = Integer.parseInt(attrs.getValue("maxStack"));
+ int maxLocals = Integer.parseInt(attrs.getValue("maxLocals"));
+ getCodeVisitor().visitMaxs(maxStack, maxLocals);
+ }
+
+ }
+
+ private final class AnnotationRule extends Rule {
+
+ public void begin(String name, Attributes attrs) {
+ String desc = attrs.getValue("desc");
+ boolean visible = Boolean.valueOf(attrs.getValue("visible"))
+ .booleanValue();
+
+ Object v = peek();
+ if (v instanceof ClassVisitor) {
+ push(((ClassVisitor) v).visitAnnotation(desc, visible));
+ } else if (v instanceof FieldVisitor) {
+ push(((FieldVisitor) v).visitAnnotation(desc, visible));
+ } else if (v instanceof MethodVisitor) {
+ push(((MethodVisitor) v).visitAnnotation(desc, visible));
+ }
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationParameterRule extends Rule {
+
+ public void begin(String name, Attributes attrs) {
+ int parameter = Integer.parseInt(attrs.getValue("parameter"));
+ String desc = attrs.getValue("desc");
+ boolean visible = Boolean.valueOf(attrs.getValue("visible"))
+ .booleanValue();
+
+ push(((MethodVisitor) peek()).visitParameterAnnotation(parameter,
+ desc,
+ visible));
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationValueRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ String value = attrs.getValue("value");
+ ((AnnotationVisitor) peek()).visit(name, getValue(desc, value));
+ }
+
+ }
+
+ private final class AnnotationValueEnumRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ String value = attrs.getValue("value");
+ ((AnnotationVisitor) peek()).visitEnum(name, desc, value);
+ }
+
+ }
+
+ private final class AnnotationValueAnnotationRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ String desc = attrs.getValue("desc");
+ push(((AnnotationVisitor) peek()).visitAnnotation(name, desc));
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationValueArrayRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ String name = attrs.getValue("name");
+ push(((AnnotationVisitor) peek()).visitArray(name));
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ private final class AnnotationDefaultRule extends Rule {
+
+ public void begin(String nm, Attributes attrs) {
+ push(((MethodVisitor) peek()).visitAnnotationDefault());
+ }
+
+ public void end(String name) {
+ ((AnnotationVisitor) pop()).visitEnd();
+ }
+
+ }
+
+ /**
+ * Opcode
+ */
+ private final static class Opcode {
+ public int opcode;
+
+ public int type;
+
+ public Opcode(int opcode, int type) {
+ this.opcode = opcode;
+ this.type = type;
+ }
+
+ }
+
+}
diff --git a/tools/external/asm/org/objectweb/asm/xml/Processor.java b/tools/external/asm/org/objectweb/asm/xml/Processor.java
new file mode 100644
index 000000000..2baeb0f36
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/Processor.java
@@ -0,0 +1,1048 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamSource;
+
+import org.objectweb.asm.ClassReader;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Processor is a command line tool that can be used for bytecode waving
+ * directed by XSL transformation. <p> In order to use a concrete XSLT engine,
+ * system property <tt>javax.xml.transform.TransformerFactory</tt> must be set
+ * to one of the following values.
+ *
+ * <blockquote> <table border="1" cellspacing="0" cellpadding="3"> <tr> <td>jd.xslt</td>
+ * <td>jd.xml.xslt.trax.TransformerFactoryImpl</td> </tr>
+ *
+ * <tr> <td>Saxon</td> <td>net.sf.saxon.TransformerFactoryImpl</td> </tr>
+ *
+ * <tr> <td>Caucho</td> <td>com.caucho.xsl.Xsl</td> </tr>
+ *
+ * <tr> <td>Xalan interpeter</td> <td>org.apache.xalan.processor.TransformerFactory</td>
+ * </tr>
+ *
+ * <tr> <td>Xalan xsltc</td> <td>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</td>
+ * </tr> </table> </blockquote>
+ *
+ * @author Eugene Kuleshov
+ */
+public class Processor {
+
+ public static final int BYTECODE = 1;
+
+ public static final int MULTI_XML = 2;
+
+ public static final int SINGLE_XML = 3;
+
+ private static final String SINGLE_XML_NAME = "classes.xml";
+
+ private int inRepresentation;
+
+ private int outRepresentation;
+
+ private InputStream input = null;
+
+ private OutputStream output = null;
+
+ private Source xslt = null;
+
+ private boolean computeMax;
+
+ private int n = 0;
+
+ public Processor(
+ int inRepresenation,
+ int outRepresentation,
+ InputStream input,
+ OutputStream output,
+ Source xslt)
+ {
+ this.inRepresentation = inRepresenation;
+ this.outRepresentation = outRepresentation;
+ this.input = input;
+ this.output = output;
+ this.xslt = xslt;
+ this.computeMax = true;
+ }
+
+ public int process() throws TransformerException, IOException, SAXException
+ {
+ ZipInputStream zis = new ZipInputStream(input);
+ final ZipOutputStream zos = new ZipOutputStream(output);
+ final OutputStreamWriter osw = new OutputStreamWriter(zos);
+
+ Thread.currentThread()
+ .setContextClassLoader(getClass().getClassLoader());
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+ if (!tf.getFeature(SAXSource.FEATURE)
+ || !tf.getFeature(SAXResult.FEATURE))
+ return 0;
+
+ SAXTransformerFactory saxtf = (SAXTransformerFactory) tf;
+ Templates templates = null;
+ if (xslt != null) {
+ templates = saxtf.newTemplates(xslt);
+ }
+
+ // configuring outHandlerFactory
+ // ///////////////////////////////////////////////////////
+
+ EntryElement entryElement = getEntryElement(zos);
+
+ ContentHandler outDocHandler = null;
+ switch (outRepresentation) {
+ case BYTECODE:
+ outDocHandler = new OutputSlicingHandler(new ASMContentHandlerFactory(zos,
+ computeMax),
+ entryElement,
+ false);
+ break;
+
+ case MULTI_XML:
+ outDocHandler = new OutputSlicingHandler(new SAXWriterFactory(osw,
+ true),
+ entryElement,
+ true);
+ break;
+
+ case SINGLE_XML:
+ ZipEntry outputEntry = new ZipEntry(SINGLE_XML_NAME);
+ zos.putNextEntry(outputEntry);
+ outDocHandler = new SAXWriter(osw, false);
+ break;
+
+ }
+
+ // configuring inputDocHandlerFactory
+ // /////////////////////////////////////////////////
+ ContentHandler inDocHandler = null;
+ if (templates == null) {
+ inDocHandler = outDocHandler;
+ } else {
+ inDocHandler = new InputSlicingHandler("class",
+ outDocHandler,
+ new TransformerHandlerFactory(saxtf,
+ templates,
+ outDocHandler));
+ }
+ ContentHandlerFactory inDocHandlerFactory = new SubdocumentHandlerFactory(inDocHandler);
+
+ if (inDocHandler != null && inRepresentation != SINGLE_XML) {
+ inDocHandler.startDocument();
+ inDocHandler.startElement("",
+ "classes",
+ "classes",
+ new AttributesImpl());
+ }
+
+ int i = 0;
+ ZipEntry ze = null;
+ while ((ze = zis.getNextEntry()) != null) {
+ update(ze.getName(), n++);
+ if (isClassEntry(ze)) {
+ processEntry(zis, ze, inDocHandlerFactory);
+ } else {
+ OutputStream os = entryElement.openEntry(getName(ze));
+ copyEntry(zis, os);
+ entryElement.closeEntry();
+ }
+
+ i++;
+ }
+
+ if (inDocHandler != null && inRepresentation != SINGLE_XML) {
+ inDocHandler.endElement("", "classes", "classes");
+ inDocHandler.endDocument();
+ }
+
+ if (outRepresentation == SINGLE_XML) {
+ zos.closeEntry();
+ }
+ zos.flush();
+ zos.close();
+
+ return i;
+ }
+
+ private void copyEntry(InputStream is, OutputStream os) throws IOException {
+ if (outRepresentation == SINGLE_XML)
+ return;
+
+ byte[] buff = new byte[2048];
+ int i;
+ while ((i = is.read(buff)) != -1) {
+ os.write(buff, 0, i);
+ }
+ }
+
+ private boolean isClassEntry(ZipEntry ze) {
+ String name = ze.getName();
+ return inRepresentation == SINGLE_XML && name.equals(SINGLE_XML_NAME)
+ || name.endsWith(".class") || name.endsWith(".class.xml");
+ }
+
+ private void processEntry(
+ final ZipInputStream zis,
+ ZipEntry ze,
+ ContentHandlerFactory handlerFactory)
+ {
+ ContentHandler handler = handlerFactory.createContentHandler();
+ try {
+
+ // if (CODE2ASM.equals(command)) { // read bytecode and process it
+ // // with TraceClassVisitor
+ // ClassReader cr = new ClassReader(readEntry(zis, ze));
+ // cr.accept(new TraceClassVisitor(null, new PrintWriter(os)),
+ // false);
+ // }
+
+ boolean singleInputDocument = inRepresentation == SINGLE_XML;
+ if (inRepresentation == BYTECODE) { // read bytecode and process it
+ // with handler
+ ClassReader cr = new ClassReader(readEntry(zis, ze));
+ cr.accept(new SAXClassAdapter(handler, singleInputDocument),
+ false);
+
+ } else { // read XML and process it with handler
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(singleInputDocument
+ ? (InputStream) new ProtectedInputStream(zis)
+ : new ByteArrayInputStream(readEntry(zis, ze))));
+
+ }
+ } catch (Exception ex) {
+ update(ze.getName(), 0);
+ update(ex, 0);
+ }
+ }
+
+ private EntryElement getEntryElement(ZipOutputStream zos) {
+ if (outRepresentation == SINGLE_XML) {
+ return new SingleDocElement(zos);
+ }
+ return new ZipEntryElement(zos);
+ }
+
+ // private ContentHandlerFactory getHandlerFactory(
+ // OutputStream os,
+ // SAXTransformerFactory saxtf,
+ // Templates templates)
+ // {
+ // ContentHandlerFactory factory = null;
+ // if (templates == null) {
+ // if (outputRepresentation == BYTECODE) { // factory used to write
+ // // bytecode
+ // factory = new ASMContentHandlerFactory(os, computeMax);
+ // } else { // factory used to write XML
+ // factory = new SAXWriterFactory(os, true);
+ // }
+ // } else {
+ // if (outputRepresentation == BYTECODE) { // factory used to transform
+ // // and then write bytecode
+ // factory = new ASMTransformerHandlerFactory(saxtf,
+ // templates,
+ // os,
+ // computeMax);
+ // } else { // factory used to transformand then write XML
+ // factory = new TransformerHandlerFactory(saxtf,
+ // templates,
+ // os,
+ // outputRepresentation == SINGLE_XML);
+ // }
+ // }
+ // return factory;
+ // }
+
+ private String getName(ZipEntry ze) {
+ String name = ze.getName();
+ if (isClassEntry(ze)) {
+ if (inRepresentation != BYTECODE && outRepresentation == BYTECODE) {
+ name = name.substring(0, name.length() - 4); // .class.xml to
+ // .class
+ } else if (inRepresentation == BYTECODE
+ && outRepresentation != BYTECODE)
+ {
+ name = name.concat(".xml"); // .class to .class.xml
+ }
+ // } else if( CODE2ASM.equals( command)) {
+ // name = name.substring( 0, name.length()-6).concat( ".asm");
+ }
+ return name;
+ }
+
+ private byte[] readEntry(ZipInputStream zis, ZipEntry ze)
+ throws IOException
+ {
+ long size = ze.getSize();
+ if (size > -1) {
+ byte[] buff = new byte[(int) size];
+ int k = 0;
+ int n;
+ while(( n = zis.read(buff, k, buff.length-k)) > 0) {
+ k += n;
+ }
+ return buff;
+ }
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ byte[] buff = new byte[4096];
+ int i;
+ while ((i = zis.read(buff)) != -1) {
+ bos.write(buff, 0, i);
+ }
+ return bos.toByteArray();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
+ */
+ protected void update(Object arg, int n) {
+ if (arg instanceof Throwable) {
+ ((Throwable) arg).printStackTrace();
+ } else {
+ if ((n % 100) == 0) {
+ System.err.println(n + " " + arg);
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (args.length < 2) {
+ showUsage();
+ return;
+ }
+
+ int inRepresentation = getRepresentation(args[0]);
+ int outRepresentation = getRepresentation(args[1]);
+
+ InputStream is = System.in;
+ OutputStream os = new BufferedOutputStream(System.out);
+
+ Source xslt = null;
+ // boolean computeMax = true;
+
+ for (int i = 2; i < args.length; i++) {
+ if ("-in".equals(args[i])) {
+ is = new FileInputStream(args[++i]);
+
+ } else if ("-out".equals(args[i])) {
+ os = new BufferedOutputStream(new FileOutputStream(args[++i]));
+
+ } else if ("-xslt".equals(args[i])) {
+ xslt = new StreamSource(new FileInputStream(args[++i]));
+
+ // } else if( "-computemax".equals( args[ i].toLowerCase())) {
+ // computeMax = true;
+
+ } else {
+ showUsage();
+ return;
+
+ }
+ }
+
+ if (inRepresentation == 0 || outRepresentation == 0) {
+ showUsage();
+ return;
+ }
+
+ Processor m = new Processor(inRepresentation,
+ outRepresentation,
+ is,
+ os,
+ xslt);
+
+ long l1 = System.currentTimeMillis();
+ int n = m.process();
+ long l2 = System.currentTimeMillis();
+ System.err.println(n);
+ System.err.println("" + (l2 - l1) + "ms " + (1000f * n / (l2 - l1))
+ + " resources/sec");
+ }
+
+ private static int getRepresentation(String s) {
+ if ("code".equals(s)) {
+ return BYTECODE;
+ } else if ("xml".equals(s)) {
+ return MULTI_XML;
+ } else if ("singlexml".equals(s)) {
+ return SINGLE_XML;
+ }
+ return 0;
+ }
+
+ private static void showUsage() {
+ System.err.println("Usage: Main <in format> <out format> [-in <input jar>] [-out <output jar>] [-xslt <xslt file>]");
+ System.err.println(" when -in or -out is omitted sysin and sysout would be used");
+ System.err.println(" <in format> and <out format> - code | xml | singlexml");
+ }
+
+ /**
+ * IputStream wrapper class used to protect input streams from being closed
+ * by some stupid XML parsers.
+ */
+ private static final class ProtectedInputStream extends InputStream {
+ private final InputStream is;
+
+ private ProtectedInputStream(InputStream is) {
+ super();
+ this.is = is;
+ }
+
+ public final void close() throws IOException {
+ }
+
+ public final int read() throws IOException {
+ return is.read();
+ }
+
+ public final int read(byte[] b, int off, int len) throws IOException {
+ return is.read(b, off, len);
+ }
+
+ public final int available() throws IOException {
+ return is.available();
+ }
+ }
+
+ /**
+ * A {@link ContentHandlerFactory ContentHandlerFactory} is used to create
+ * {@link org.xml.sax.ContentHandler ContentHandler} instances for concrete
+ * context.
+ */
+ private static interface ContentHandlerFactory {
+
+ /**
+ * Creates an instance of the content handler.
+ *
+ * @return content handler
+ */
+ ContentHandler createContentHandler();
+
+ }
+
+ /**
+ * SAXWriterFactory
+ */
+ private static final class SAXWriterFactory implements
+ ContentHandlerFactory
+ {
+ private Writer w;
+
+ private boolean optimizeEmptyElements;
+
+ public SAXWriterFactory(Writer w, boolean optimizeEmptyElements) {
+ this.w = w;
+ this.optimizeEmptyElements = optimizeEmptyElements;
+ }
+
+ public final ContentHandler createContentHandler() {
+ return new SAXWriter(w, optimizeEmptyElements);
+ }
+
+ }
+
+ /**
+ * ASMContentHandlerFactory
+ */
+ private static final class ASMContentHandlerFactory implements
+ ContentHandlerFactory
+ {
+ private OutputStream os;
+
+ private boolean computeMax;
+
+ public ASMContentHandlerFactory(OutputStream os, boolean computeMax) {
+ this.os = os;
+ this.computeMax = computeMax;
+ }
+
+ public final ContentHandler createContentHandler() {
+ return new ASMContentHandler(os, computeMax);
+ }
+
+ }
+
+ /**
+ * TransformerHandlerFactory
+ */
+ private static final class TransformerHandlerFactory implements
+ ContentHandlerFactory
+ {
+ private SAXTransformerFactory saxtf;
+
+ private Templates templates;
+
+ private ContentHandler outputHandler;
+
+ public TransformerHandlerFactory(
+ SAXTransformerFactory saxtf,
+ Templates templates,
+ ContentHandler outputHandler)
+ {
+ this.saxtf = saxtf;
+ this.templates = templates;
+ this.outputHandler = outputHandler;
+ }
+
+ public final ContentHandler createContentHandler() {
+ try {
+ TransformerHandler handler = saxtf.newTransformerHandler(templates);
+ handler.setResult(new SAXResult(outputHandler));
+ return handler;
+ } catch (TransformerConfigurationException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+ }
+
+ /**
+ * SubdocumentHandlerFactory
+ */
+ private final static class SubdocumentHandlerFactory implements
+ ContentHandlerFactory
+ {
+ private ContentHandler subdocumentHandler;
+
+ public SubdocumentHandlerFactory(ContentHandler subdocumentHandler) {
+ this.subdocumentHandler = subdocumentHandler;
+ }
+
+ public final ContentHandler createContentHandler() {
+ return subdocumentHandler;
+ }
+
+ }
+
+ /**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} and
+ * {@link org.xml.sax.ext.LexicalHandler LexicalHandler} that serializes XML
+ * from SAX 2.0 events into {@link java.io.Writer Writer}.
+ *
+ * <i><blockquote> This implementation does not support namespaces, entity
+ * definitions (uncluding DTD), CDATA and text elements. </blockquote></i>
+ */
+ private final static class SAXWriter extends DefaultHandler implements
+ LexicalHandler
+ {
+ private static final char[] OFF = " ".toCharArray();
+
+ private Writer w;
+
+ private boolean optimizeEmptyElements;
+
+ private boolean openElement = false;
+
+ private int ident = 0;
+
+ /**
+ * Creates <code>SAXWriter</code>.
+ *
+ * @param w writer
+ * @param optimizeEmptyElements if set to <code>true</code>, short
+ * XML syntax will be used for empty elements
+ */
+ public SAXWriter(Writer w, boolean optimizeEmptyElements) {
+ this.w = w;
+ this.optimizeEmptyElements = optimizeEmptyElements;
+ }
+
+ public final void startElement(
+ String ns,
+ String localName,
+ String qName,
+ Attributes atts) throws SAXException
+ {
+ try {
+ closeElement();
+
+ writeIdent();
+ w.write("<".concat(qName));
+ if (atts != null && atts.getLength() > 0)
+ writeAttributes(atts);
+
+ if (!optimizeEmptyElements) {
+ w.write(">\n");
+ } else {
+ openElement = true;
+ }
+ ident += 2;
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void endElement(String ns, String localName, String qName)
+ throws SAXException
+ {
+ ident -= 2;
+ try {
+ if (openElement) {
+ w.write("/>\n");
+ openElement = false;
+ } else {
+ writeIdent();
+ w.write("</" + qName + ">\n");
+ }
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void endDocument() throws SAXException {
+ try {
+ w.flush();
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void comment(char[] ch, int off, int len)
+ throws SAXException
+ {
+ try {
+ closeElement();
+
+ writeIdent();
+ w.write("<!-- ");
+ w.write(ch, off, len);
+ w.write(" -->\n");
+
+ } catch (IOException ex) {
+ throw new SAXException(ex);
+
+ }
+ }
+
+ public final void startDTD(String arg0, String arg1, String arg2)
+ throws SAXException
+ {
+ }
+
+ public final void endDTD() throws SAXException {
+ }
+
+ public final void startEntity(String arg0) throws SAXException {
+ }
+
+ public final void endEntity(String arg0) throws SAXException {
+ }
+
+ public final void startCDATA() throws SAXException {
+ }
+
+ public final void endCDATA() throws SAXException {
+ }
+
+ private final void writeAttributes(Attributes atts) throws IOException {
+ StringBuffer sb = new StringBuffer();
+ int len = atts.getLength();
+ for (int i = 0; i < len; i++) {
+ sb.append(" ")
+ .append(atts.getLocalName(i))
+ .append("=\"")
+ .append(esc(atts.getValue(i)))
+ .append("\"");
+ }
+ w.write(sb.toString());
+ }
+
+ /**
+ * Encode string with escaping.
+ *
+ * @param str string to encode.
+ * @return encoded string
+ */
+ private final String esc(String str) {
+ StringBuffer sb = new StringBuffer(str.length());
+ for (int i = 0; i < str.length(); i++) {
+ char ch = str.charAt(i);
+ switch (ch) {
+ case '&':
+ sb.append("&amp;");
+ break;
+
+ case '<':
+ sb.append("&lt;");
+ break;
+
+ case '>':
+ sb.append("&gt;");
+ break;
+
+ case '\"':
+ sb.append("&quot;");
+ break;
+
+ default:
+ if (ch > 0x7f) {
+ sb.append("&#")
+ .append(Integer.toString(ch))
+ .append(';');
+ } else {
+ sb.append(ch);
+ }
+
+ }
+ }
+ return sb.toString();
+ }
+
+ private final void writeIdent() throws IOException {
+ int n = ident;
+ while (n > 0) {
+ if (n > OFF.length) {
+ w.write(OFF);
+ n -= OFF.length;
+ } else {
+ w.write(OFF, 0, n);
+ n = 0;
+ }
+ }
+ }
+
+ private final void closeElement() throws IOException {
+ if (openElement) {
+ w.write(">\n");
+ }
+ openElement = false;
+ }
+
+ }
+
+ /**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} that splits XML
+ * documents into smaller chunks. Each chunk is processed by the nested
+ * {@link org.xml.sax.ContentHandler ContentHandler} obtained from
+ * {@link java.net.ContentHandlerFactory ContentHandlerFactory}. This is
+ * useful for running XSLT engine against large XML document that will
+ * hardly fit into the memory all together. <p> TODO use complete path for
+ * subdocumentRoot
+ */
+ private final static class InputSlicingHandler extends DefaultHandler {
+ private String subdocumentRoot;
+
+ private ContentHandler rootHandler;
+
+ private ContentHandlerFactory subdocumentHandlerFactory;
+
+ private boolean subdocument = false;
+
+ private ContentHandler subdocumentHandler;
+
+ /**
+ * Constructs a new {@link InputSlicingHandler SubdocumentHandler}
+ * object.
+ *
+ * @param subdocumentRoot name/path to the root element of the
+ * subdocument
+ * @param rootHandler content handler for the entire document
+ * (subdocument envelope).
+ * @param subdocumentHandlerFactory a
+ * {@link ContentHandlerFactory ContentHandlerFactory} used to
+ * create {@link ContentHandler ContentHandler} instances for
+ * subdocuments.
+ */
+ public InputSlicingHandler(
+ String subdocumentRoot,
+ ContentHandler rootHandler,
+ ContentHandlerFactory subdocumentHandlerFactory)
+ {
+ this.subdocumentRoot = subdocumentRoot;
+ this.rootHandler = rootHandler;
+ this.subdocumentHandlerFactory = subdocumentHandlerFactory;
+ }
+
+ public final void startElement(
+ String namespaceURI,
+ String localName,
+ String qName,
+ Attributes list) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ } else if (localName.equals(subdocumentRoot)) {
+ subdocumentHandler = subdocumentHandlerFactory.createContentHandler();
+ subdocumentHandler.startDocument();
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ subdocument = true;
+ } else if (rootHandler != null) {
+ rootHandler.startElement(namespaceURI, localName, qName, list);
+ }
+ }
+
+ public final void endElement(
+ String namespaceURI,
+ String localName,
+ String qName) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.endElement(namespaceURI, localName, qName);
+ if (localName.equals(subdocumentRoot)) {
+ subdocumentHandler.endDocument();
+ subdocument = false;
+ }
+ } else if (rootHandler != null) {
+ rootHandler.endElement(namespaceURI, localName, qName);
+ }
+ }
+
+ public final void startDocument() throws SAXException {
+ if (rootHandler != null) {
+ rootHandler.startDocument();
+ }
+ }
+
+ public final void endDocument() throws SAXException {
+ if (rootHandler != null) {
+ rootHandler.endDocument();
+
+ }
+ }
+
+ public final void characters(char[] buff, int offset, int size)
+ throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.characters(buff, offset, size);
+ } else if (rootHandler != null) {
+ rootHandler.characters(buff, offset, size);
+ }
+ }
+
+ }
+
+ /**
+ * A {@link org.xml.sax.ContentHandler ContentHandler} that splits XML
+ * documents into smaller chunks. Each chunk is processed by the nested
+ * {@link org.xml.sax.ContentHandler ContentHandler} obtained from
+ * {@link java.net.ContentHandlerFactory ContentHandlerFactory}. This is
+ * useful for running XSLT engine against large XML document that will
+ * hardly fit into the memory all together. <p> TODO use complete path for
+ * subdocumentRoot
+ */
+ private static final class OutputSlicingHandler extends DefaultHandler {
+ private String subdocumentRoot;
+
+ private ContentHandlerFactory subdocumentHandlerFactory;
+
+ private EntryElement entryElement;
+
+ private boolean isXml;
+
+ private boolean subdocument = false;
+
+ private ContentHandler subdocumentHandler;
+
+ /**
+ * Constructs a new {@link OutputSlicingHandler SubdocumentHandler}
+ * object.
+ *
+ * @param subdocumentHandlerFactory a
+ * {@link ContentHandlerFactory ContentHandlerFactory} used to
+ * create {@link ContentHandler ContentHandler} instances for
+ * subdocuments.
+ * @param entryElement TODO.
+ * @param isXml TODO.
+ */
+ public OutputSlicingHandler(
+ ContentHandlerFactory subdocumentHandlerFactory,
+ EntryElement entryElement,
+ boolean isXml)
+ {
+ this.subdocumentRoot = "class";
+ this.subdocumentHandlerFactory = subdocumentHandlerFactory;
+ this.entryElement = entryElement;
+ this.isXml = isXml;
+ }
+
+ public final void startElement(
+ String namespaceURI,
+ String localName,
+ String qName,
+ Attributes list) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ } else if (localName.equals(subdocumentRoot)) {
+ String name = list.getValue("name");
+ if (name == null || name.length() == 0)
+ throw new SAXException("Class element without name attribute.");
+ try {
+ entryElement.openEntry(isXml
+ ? name.concat(".class.xml")
+ : name.concat(".class"));
+ } catch (IOException ex) {
+ throw new SAXException(ex.toString(), ex);
+ }
+ subdocumentHandler = subdocumentHandlerFactory.createContentHandler();
+ subdocumentHandler.startDocument();
+ subdocumentHandler.startElement(namespaceURI,
+ localName,
+ qName,
+ list);
+ subdocument = true;
+ }
+ }
+
+ public final void endElement(
+ String namespaceURI,
+ String localName,
+ String qName) throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.endElement(namespaceURI, localName, qName);
+ if (localName.equals(subdocumentRoot)) {
+ subdocumentHandler.endDocument();
+ subdocument = false;
+ try {
+ entryElement.closeEntry();
+ } catch (IOException ex) {
+ throw new SAXException(ex.toString(), ex);
+ }
+ }
+ }
+ }
+
+ public final void startDocument() throws SAXException {
+ }
+
+ public final void endDocument() throws SAXException {
+ }
+
+ public final void characters(char[] buff, int offset, int size)
+ throws SAXException
+ {
+ if (subdocument) {
+ subdocumentHandler.characters(buff, offset, size);
+ }
+ }
+
+ }
+
+ private static interface EntryElement {
+
+ OutputStream openEntry(String name) throws IOException;
+
+ void closeEntry() throws IOException;
+
+ }
+
+ private static final class SingleDocElement implements EntryElement {
+ private OutputStream os;
+
+ public SingleDocElement(OutputStream os) {
+ this.os = os;
+ }
+
+ public OutputStream openEntry(String name) throws IOException {
+ return os;
+ }
+
+ public void closeEntry() throws IOException {
+ os.flush();
+ }
+
+ }
+
+ private static final class ZipEntryElement implements EntryElement {
+ private ZipOutputStream zos;
+
+ public ZipEntryElement(ZipOutputStream zos) {
+ this.zos = zos;
+ }
+
+ public OutputStream openEntry(String name) throws IOException {
+ ZipEntry entry = new ZipEntry(name);
+ zos.putNextEntry(entry);
+ return zos;
+ }
+
+ public void closeEntry() throws IOException {
+ zos.flush();
+ zos.closeEntry();
+ }
+
+ }
+
+}
diff --git a/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java b/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java
new file mode 100644
index 000000000..c8f6ecb99
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/SAXAdapter.java
@@ -0,0 +1,91 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * SAXAdapter
+ *
+ * @author Eugene Kuleshov
+ */
+public abstract class SAXAdapter {
+ private final ContentHandler h;
+
+ public SAXAdapter(ContentHandler h) {
+ this.h = h;
+ }
+
+ protected ContentHandler getContentHandler() {
+ return h;
+ }
+
+ protected final void addEnd(String name) {
+ try {
+ h.endElement("", name, name);
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+ protected final void addStart(String name, Attributes attrs) {
+ try {
+ h.startElement("", name, name, attrs);
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+ protected final void addElement(String name, Attributes attrs) {
+ addStart(name, attrs);
+ addEnd(name);
+ }
+
+ protected void addDocumentStart() {
+ try {
+ h.startDocument();
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.getException());
+ }
+ }
+
+ protected void addDocumentEnd() {
+ try {
+ h.endDocument();
+ } catch (SAXException ex) {
+ // ex.getException().printStackTrace();
+ // ex.printStackTrace();
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+}
diff --git a/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java b/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java
new file mode 100644
index 000000000..e7382414b
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/SAXAnnotationAdapter.java
@@ -0,0 +1,191 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Type;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * SAXAnnotationAdapter
+ *
+ * @author Eugene Kuleshov
+ */
+public class SAXAnnotationAdapter extends SAXAdapter implements
+ AnnotationVisitor
+{
+ private final String elementName;
+
+ public SAXAnnotationAdapter(
+ ContentHandler h,
+ String elementName,
+ int visible,
+ String name,
+ String desc)
+ {
+ this(h, elementName, visible, desc, name, -1);
+ }
+
+ public SAXAnnotationAdapter(
+ ContentHandler h,
+ String elementName,
+ int visible,
+ int parameter,
+ String desc)
+ {
+ this(h, elementName, visible, desc, null, parameter);
+ }
+
+ private SAXAnnotationAdapter(
+ ContentHandler h,
+ String elementName,
+ int visible,
+ String desc,
+ String name,
+ int parameter)
+ {
+ super(h);
+ this.elementName = elementName;
+
+ AttributesImpl att = new AttributesImpl();
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (visible != 0)
+ att.addAttribute("", "visible", "visible", "", visible > 0
+ ? "true"
+ : "false");
+ if (parameter != -1)
+ att.addAttribute("",
+ "parameter",
+ "parameter",
+ "",
+ Integer.toString(parameter));
+ if (desc != null)
+ att.addAttribute("", "desc", "desc", "", desc);
+
+ addStart(elementName, att);
+ }
+
+ public void visit(String name, Object value) {
+ Class c = value.getClass();
+ if (c.isArray()) {
+ AnnotationVisitor av = visitArray(name);
+ if (value instanceof byte[]) {
+ byte[] b = (byte[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Byte(b[i]));
+
+ } else if (value instanceof char[]) {
+ char[] b = (char[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Character(b[i]));
+
+ } else if (value instanceof boolean[]) {
+ boolean[] b = (boolean[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, Boolean.valueOf(b[i]));
+
+ } else if (value instanceof int[]) {
+ int[] b = (int[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Integer(b[i]));
+
+ } else if (value instanceof long[]) {
+ long[] b = (long[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Long(b[i]));
+
+ } else if (value instanceof float[]) {
+ float[] b = (float[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Float(b[i]));
+
+ } else if (value instanceof double[]) {
+ double[] b = (double[]) value;
+ for (int i = 0; i < b.length; i++)
+ av.visit(null, new Double(b[i]));
+
+ }
+ av.visitEnd();
+ } else {
+ addValueElement("annotationValue",
+ name,
+ Type.getDescriptor(c),
+ value.toString());
+ }
+ }
+
+ public void visitEnum(String name, String desc, String value) {
+ addValueElement("annotationValueEnum", name, desc, value);
+ }
+
+ public AnnotationVisitor visitAnnotation(String name, String desc) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotationValueAnnotation",
+ 0,
+ name,
+ desc);
+ }
+
+ public AnnotationVisitor visitArray(String name) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotationValueArray",
+ 0,
+ name,
+ null);
+ }
+
+ public void visitEnd() {
+ addEnd(elementName);
+ }
+
+ private void addValueElement(
+ String element,
+ String name,
+ String desc,
+ String value)
+ {
+ AttributesImpl att = new AttributesImpl();
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (desc != null)
+ att.addAttribute("", "desc", "desc", "", desc);
+ if (value != null)
+ att.addAttribute("",
+ "value",
+ "value",
+ "",
+ SAXClassAdapter.encode(value));
+
+ addElement(element, att);
+ }
+
+}
diff --git a/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java b/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java
new file mode 100644
index 000000000..ba362d060
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/SAXClassAdapter.java
@@ -0,0 +1,351 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * A {@link org.objectweb.asm.ClassVisitor ClassVisitor} that generates SAX 2.0
+ * events from the visited class. It can feed any kind of
+ * {@link org.xml.sax.ContentHandler ContentHandler}, e.g. XML serializer, XSLT
+ * or XQuery engines.
+ *
+ * @see org.objectweb.asm.xml.Processor
+ * @see org.objectweb.asm.xml.ASMContentHandler
+ *
+ * @author Eugene Kuleshov
+ */
+public final class SAXClassAdapter extends SAXAdapter implements ClassVisitor {
+ private boolean singleDocument;
+
+ /**
+ * Constructs a new {@link SAXClassAdapter SAXClassAdapter} object.
+ *
+ * @param h content handler that will be used to send SAX 2.0 events.
+ * @param singleDocument if <tt>true</tt> adapter will not produce
+ * {@link ContentHandler#startDocument() startDocument()} and
+ * {@link ContentHandler#endDocument() endDocument()} events.
+ */
+ public SAXClassAdapter(ContentHandler h, boolean singleDocument) {
+ super(h);
+ this.singleDocument = singleDocument;
+ if (!singleDocument) {
+ addDocumentStart();
+ }
+ }
+
+ public void visitSource(String source, String debug) {
+ if (source == null && debug == null) {
+ return;
+ }
+
+ AttributesImpl att = new AttributesImpl();
+ if (source != null)
+ att.addAttribute("", "file", "file", "", encode(source));
+ if (debug != null)
+ att.addAttribute("", "debug", "debug", "", encode(debug));
+
+ addElement("source", att);
+ }
+
+ public void visitOuterClass(String owner, String name, 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);
+
+ addElement("outerclass", att);
+ }
+
+ public final void visitAttribute(Attribute attr) {
+ // TODO Auto-generated SAXClassAdapter.visitAttribute
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotation",
+ visible ? 1 : -1,
+ null,
+ desc);
+ }
+
+ public void visit(
+ int version,
+ int access,
+ String name,
+ String signature,
+ String superName,
+ String[] interfaces)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_SUPER) != 0)
+ sb.append("super ");
+ if ((access & Opcodes.ACC_INTERFACE) != 0)
+ sb.append("interface ");
+ if ((access & Opcodes.ACC_ABSTRACT) != 0)
+ sb.append("abstract ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_ANNOTATION) != 0)
+ sb.append("annotation ");
+ if ((access & Opcodes.ACC_ENUM) != 0)
+ sb.append("enum ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ 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));
+ addStart("class", att);
+
+ 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]);
+ addElement("interface", att2);
+ }
+ }
+ addEnd("interfaces");
+ }
+
+ public FieldVisitor visitField(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ Object value)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_STATIC) != 0)
+ sb.append("static ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_VOLATILE) != 0)
+ sb.append("volatile ");
+ if ((access & Opcodes.ACC_TRANSIENT) != 0)
+ sb.append("transient ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_ENUM) != 0)
+ sb.append("enum ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ 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",
+ "",
+ encode(signature));
+ if (value != null) {
+ att.addAttribute("", "value", "value", "", encode(value.toString()));
+ }
+
+ return new SAXFieldAdapter(getContentHandler(), att);
+ }
+
+ public MethodVisitor visitMethod(
+ int access,
+ String name,
+ String desc,
+ String signature,
+ String[] exceptions)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_STATIC) != 0)
+ sb.append("static ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_SYNCHRONIZED) != 0)
+ sb.append("synchronized ");
+ if ((access & Opcodes.ACC_BRIDGE) != 0)
+ sb.append("bridge ");
+ if ((access & Opcodes.ACC_VARARGS) != 0)
+ sb.append("varargs ");
+ if ((access & Opcodes.ACC_NATIVE) != 0)
+ sb.append("native ");
+ if ((access & Opcodes.ACC_ABSTRACT) != 0)
+ sb.append("abstract ");
+ if ((access & Opcodes.ACC_STRICT) != 0)
+ sb.append("strict ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ 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);
+ }
+ addStart("method", att);
+
+ 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]);
+ addElement("exception", att2);
+ }
+ }
+ addEnd("exceptions");
+
+ return new SAXCodeAdapter(getContentHandler(), access);
+ }
+
+ public final void visitInnerClass(
+ String name,
+ String outerName,
+ String innerName,
+ int access)
+ {
+ StringBuffer sb = new StringBuffer();
+ if ((access & Opcodes.ACC_PUBLIC) != 0)
+ sb.append("public ");
+ if ((access & Opcodes.ACC_PRIVATE) != 0)
+ sb.append("private ");
+ if ((access & Opcodes.ACC_PROTECTED) != 0)
+ sb.append("protected ");
+ if ((access & Opcodes.ACC_STATIC) != 0)
+ sb.append("static ");
+ if ((access & Opcodes.ACC_FINAL) != 0)
+ sb.append("final ");
+ if ((access & Opcodes.ACC_SUPER) != 0)
+ sb.append("super ");
+ if ((access & Opcodes.ACC_INTERFACE) != 0)
+ sb.append("interface ");
+ if ((access & Opcodes.ACC_ABSTRACT) != 0)
+ sb.append("abstract ");
+ if ((access & Opcodes.ACC_SYNTHETIC) != 0)
+ sb.append("synthetic ");
+ if ((access & Opcodes.ACC_ANNOTATION) != 0)
+ sb.append("annotation ");
+ if ((access & Opcodes.ACC_ENUM) != 0)
+ sb.append("enum ");
+ if ((access & Opcodes.ACC_DEPRECATED) != 0)
+ sb.append("deprecated ");
+
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "access", "access", "", sb.toString());
+ if (name != null)
+ att.addAttribute("", "name", "name", "", name);
+ if (outerName != null)
+ att.addAttribute("", "outerName", "outerName", "", outerName);
+ if (innerName != null)
+ att.addAttribute("", "innerName", "innerName", "", innerName);
+ addElement("innerclass", att);
+ }
+
+ public final void visitEnd() {
+ addEnd("class");
+ if (!singleDocument) {
+ addDocumentEnd();
+ }
+ }
+
+ static final String encode(String s) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (c == '\\') {
+ sb.append("\\\\");
+ } else if (c < 0x20 || c > 0x7f) {
+ sb.append("\\u");
+ if (c < 0x10) {
+ sb.append("000");
+ } else if (c < 0x100) {
+ sb.append("00");
+ } else if (c < 0x1000) {
+ sb.append("0");
+ }
+ sb.append(Integer.toString(c, 16));
+ } else {
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java b/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java
new file mode 100644
index 000000000..abea7fbf4
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/SAXCodeAdapter.java
@@ -0,0 +1,310 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.util.AbstractVisitor;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * A {@link MethodVisitor} that generates SAX 2.0 events from the visited
+ * method.
+ *
+ * @see org.objectweb.asm.xml.SAXClassAdapter
+ * @see org.objectweb.asm.xml.Processor
+ *
+ * @author Eugene Kuleshov
+ */
+public final class SAXCodeAdapter extends SAXAdapter implements MethodVisitor {
+ private Map labelNames;
+
+ /**
+ * Constructs a new {@link SAXCodeAdapter SAXCodeAdapter} object.
+ *
+ * @param h content handler that will be used to send SAX 2.0 events.
+ * @param access
+ */
+ public SAXCodeAdapter(ContentHandler h, int access) {
+ super(h);
+ labelNames = new HashMap();
+
+ if ((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE | Opcodes.ACC_NATIVE)) == 0)
+ {
+ addStart("code", new AttributesImpl());
+ }
+ }
+
+ public final void visitCode() {
+ }
+
+ public final void visitInsn(int opcode) {
+ addElement(AbstractVisitor.OPCODES[opcode], new AttributesImpl());
+ }
+
+ public final void visitIntInsn(int opcode, int operand) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "value", "value", "", Integer.toString(operand));
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitVarInsn(int opcode, int var) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "var", "var", "", Integer.toString(var));
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitTypeInsn(int opcode, String desc) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitFieldInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "owner", "owner", "", owner);
+ attrs.addAttribute("", "name", "name", "", name);
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitMethodInsn(
+ int opcode,
+ String owner,
+ String name,
+ String desc)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "owner", "owner", "", owner);
+ attrs.addAttribute("", "name", "name", "", name);
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitJumpInsn(int opcode, Label label) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "label", "label", "", getLabel(label));
+ addElement(AbstractVisitor.OPCODES[opcode], attrs);
+ }
+
+ public final void visitLabel(Label label) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "name", "name", "", getLabel(label));
+ addElement("Label", attrs);
+ }
+
+ public final void visitLdcInsn(Object cst) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("",
+ "cst",
+ "cst",
+ "",
+ SAXClassAdapter.encode(cst.toString()));
+ attrs.addAttribute("",
+ "desc",
+ "desc",
+ "",
+ Type.getDescriptor(cst.getClass()));
+ addElement(AbstractVisitor.OPCODES[Opcodes.LDC], attrs);
+ }
+
+ public final void visitIincInsn(int var, int increment) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "var", "var", "", Integer.toString(var));
+ attrs.addAttribute("", "inc", "inc", "", Integer.toString(increment));
+ addElement(AbstractVisitor.OPCODES[Opcodes.IINC], attrs);
+ }
+
+ public final void visitTableSwitchInsn(
+ int min,
+ int max,
+ Label dflt,
+ Label[] labels)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "min", "min", "", Integer.toString(min));
+ attrs.addAttribute("", "max", "max", "", Integer.toString(max));
+ attrs.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
+ String o = AbstractVisitor.OPCODES[Opcodes.TABLESWITCH];
+ addStart(o, attrs);
+ for (int i = 0; i < labels.length; i++) {
+ AttributesImpl att2 = new AttributesImpl();
+ att2.addAttribute("", "name", "name", "", getLabel(labels[i]));
+ addElement("label", att2);
+ }
+ addEnd(o);
+ }
+
+ public final void visitLookupSwitchInsn(
+ Label dflt,
+ int[] keys,
+ Label[] labels)
+ {
+ AttributesImpl att = new AttributesImpl();
+ att.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
+ String o = AbstractVisitor.OPCODES[Opcodes.LOOKUPSWITCH];
+ 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]));
+ addElement("label", att2);
+ }
+ addEnd(o);
+ }
+
+ public final void visitMultiANewArrayInsn(String desc, int dims) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ attrs.addAttribute("", "dims", "dims", "", Integer.toString(dims));
+ addElement(AbstractVisitor.OPCODES[Opcodes.MULTIANEWARRAY], attrs);
+ }
+
+ public final void visitTryCatchBlock(
+ Label start,
+ Label end,
+ Label handler,
+ String type)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "start", "start", "", getLabel(start));
+ attrs.addAttribute("", "end", "end", "", getLabel(end));
+ attrs.addAttribute("", "handler", "handler", "", getLabel(handler));
+ if (type != null)
+ attrs.addAttribute("", "type", "type", "", type);
+ addElement("TryCatch", attrs);
+ }
+
+ public final void visitMaxs(int maxStack, int maxLocals) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("",
+ "maxStack",
+ "maxStack",
+ "",
+ Integer.toString(maxStack));
+ attrs.addAttribute("",
+ "maxLocals",
+ "maxLocals",
+ "",
+ Integer.toString(maxLocals));
+ addElement("Max", attrs);
+
+ addEnd("code");
+ }
+
+ public void visitLocalVariable(
+ String name,
+ String desc,
+ String signature,
+ Label start,
+ Label end,
+ int index)
+ {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "name", "name", "", name);
+ attrs.addAttribute("", "desc", "desc", "", desc);
+ if (signature != null)
+ attrs.addAttribute("",
+ "signature",
+ "signature",
+ "",
+ SAXClassAdapter.encode(signature));
+ attrs.addAttribute("", "start", "start", "", getLabel(start));
+ attrs.addAttribute("", "end", "end", "", getLabel(end));
+ attrs.addAttribute("", "var", "var", "", Integer.toString(index));
+ addElement("LocalVar", attrs);
+ }
+
+ public final void visitLineNumber(int line, Label start) {
+ AttributesImpl attrs = new AttributesImpl();
+ attrs.addAttribute("", "line", "line", "", Integer.toString(line));
+ attrs.addAttribute("", "start", "start", "", getLabel(start));
+ addElement("LineNumber", attrs);
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotationDefault",
+ 0,
+ null,
+ null);
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "annotation",
+ visible ? 1 : -1,
+ null,
+ desc);
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(
+ int parameter,
+ String desc,
+ boolean visible)
+ {
+ return new SAXAnnotationAdapter(getContentHandler(),
+ "parameterAnnotation",
+ visible ? 1 : -1,
+ parameter,
+ desc);
+ }
+
+ public void visitEnd() {
+ addEnd("method");
+ }
+
+ public final void visitAttribute(Attribute attr) {
+ // TODO Auto-generated SAXCodeAdapter.visitAttribute
+ }
+
+ private final String getLabel(Label label) {
+ String name = (String) labelNames.get(label);
+ if (name == null) {
+ name = Integer.toString(labelNames.size());
+ labelNames.put(label, name);
+ }
+ return name;
+ }
+
+}
diff --git a/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java b/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java
new file mode 100644
index 000000000..eabf00dfc
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/SAXFieldAdapter.java
@@ -0,0 +1,77 @@
+/***
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.objectweb.asm.xml;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.FieldVisitor;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * SAXFieldAdapter
+ *
+ * @author Eugene Kuleshov
+ */
+public class SAXFieldAdapter implements FieldVisitor {
+ private final ContentHandler h;
+
+ public SAXFieldAdapter(ContentHandler h, AttributesImpl att) {
+ this.h = h;
+
+ try {
+ h.startElement("", "field", "field", att);
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return new SAXAnnotationAdapter(h,
+ "annotation",
+ visible ? 1 : -1,
+ null,
+ desc);
+ }
+
+ public void visitAttribute(Attribute attr) {
+ // TODO Auto-generated method stub
+ }
+
+ public void visitEnd() {
+ try {
+ h.endElement("", "field", "field");
+ } catch (SAXException ex) {
+ throw new RuntimeException(ex.toString());
+ }
+ }
+
+}
diff --git a/tools/external/asm/org/objectweb/asm/xml/asm-xml.dtd b/tools/external/asm/org/objectweb/asm/xml/asm-xml.dtd
new file mode 100644
index 000000000..7859259e0
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/asm-xml.dtd
@@ -0,0 +1,340 @@
+<!--
+ ASM XML Adapter
+ Copyright (c) 2004, Eugene Kuleshov
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<!--
+ This DTD must be used to create XML documents to be processed by
+ org.objectweb.asm.xml.ASMContentHandler
+-->
+
+<!--
+ Root element used to aggregate multiple classes into single document.
+-->
+<!ELEMENT classes ( class+ )>
+
+<!--
+ Root element for a single class.
+-->
+<!ELEMENT class ( interfaces, ( field | innerclass | method )*)>
+<!ATTLIST class access CDATA #REQUIRED>
+<!ATTLIST class name CDATA #REQUIRED>
+<!ATTLIST class parent CDATA #REQUIRED>
+<!ATTLIST class major CDATA #REQUIRED>
+<!ATTLIST class minor CDATA #REQUIRED>
+<!ATTLIST class source CDATA #IMPLIED>
+
+<!ELEMENT interfaces ( interface* )>
+<!ELEMENT interface EMPTY>
+<!ATTLIST interface name CDATA #REQUIRED>
+
+<!ELEMENT field EMPTY>
+<!ATTLIST field access CDATA #REQUIRED>
+<!ATTLIST field desc CDATA #REQUIRED>
+<!ATTLIST field name CDATA #REQUIRED>
+<!--
+ All characters out of interval 0x20 to 0x7f (inclusive) must
+ be encoded (\uXXXX) and character '\' must be replaced by "\\"
+-->
+<!ATTLIST field value CDATA #IMPLIED>
+
+<!ELEMENT innerclass EMPTY>
+<!ATTLIST innerclass access CDATA #REQUIRED>
+<!ATTLIST innerclass innerName CDATA #IMPLIED>
+<!ATTLIST innerclass name CDATA #REQUIRED>
+<!ATTLIST innerclass outerName CDATA #IMPLIED>
+
+<!--
+ Root element for method definition.
+-->
+<!ELEMENT method ( exceptions, code? )>
+<!ATTLIST method access CDATA #REQUIRED>
+<!ATTLIST method desc CDATA #REQUIRED>
+<!ATTLIST method name CDATA #REQUIRED>
+
+<!ELEMENT exceptions ( exception* )>
+<!ELEMENT exception EMPTY>
+<!ATTLIST exception name CDATA #REQUIRED>
+
+<!--
+ code element contains bytecode instructions and definitions for labels, line numbers, try/catch and max
+-->
+<!ELEMENT code (( AALOAD | AASTORE | ACONST_NULL | ALOAD | ANEWARRAY | ARETURN | ARRAYLENGTH | ASTORE | ATHROW | BALOAD | BASTORE | BIPUSH | CALOAD | CASTORE | CHECKCAST | D2F | D2I | D2L | DADD | DALOAD | DASTORE | DCMPG | DCMPL | DCONST_0 | DCONST_1 | DDIV | DLOAD | DMUL | DNEG | DREM | DRETURN | DSTORE | DSUB | DUP | DUP2 | DUP2_X1 | DUP2_X2 | DUP_X1 | DUP_X2 | F2D | F2I | F2L | FADD | FALOAD | FASTORE | FCMPG | FCMPL | FCONST_0 | FCONST_1 | FCONST_2 | FDIV | FLOAD | FMUL | FNEG | FRETURN | FSTORE | FSUB | GETFIELD | GETSTATIC | GOTO | I2B | I2C | I2D | I2F | I2L | I2S | IADD | IALOAD | IAND | IASTORE | ICONST_0 | ICONST_1 | ICONST_2 | ICONST_3 | ICONST_4 | ICONST_5 | ICONST_M1 | IDIV | IFEQ | IFGE | IFGT | IFLE | IFLT | IFNE | IFNONNULL | IFNULL | IF_ACMPEQ | IF_ACMPNE | IF_ICMPEQ | IF_ICMPGE | IF_ICMPGT | IF_ICMPLE | IF_ICMPLT | IF_ICMPNE | IINC | ILOAD | IMUL | INEG | INSTANCEOF | INVOKEINTERFACE | INVOKESPECIAL | INVOKESTATIC | INVOKEVIRTUAL | IOR | IREM | IRETURN | ISHL | ISHR | ISTORE | ISUB | IUSHR | IXOR | JSR | L2D | L2F | L2I | LADD | LALOAD | LAND | LASTORE | LCMP | LCONST_0 | LCONST_1 | LDC | LDIV | LLOAD | LMUL | LNEG | LOOKUPSWITCH | LOR | LREM | LRETURN | LSHL | LSHR | LSTORE | LSUB | LUSHR | LXOR | MONITORENTER | MONITOREXIT | MULTIANEWARRAY | NEW | NEWARRAY | NOP | POP | POP2 | PUTFIELD | PUTSTATIC | RET | RETURN | SALOAD | SASTORE | SIPUSH | TABLESWITCH | Label | LineNumber | TryCatch )*, Max)>
+
+<!ELEMENT Label EMPTY>
+<!ATTLIST Label name CDATA #REQUIRED>
+
+<!ELEMENT TryCatch EMPTY>
+<!ATTLIST TryCatch end CDATA #REQUIRED>
+<!ATTLIST TryCatch handler CDATA #REQUIRED>
+<!ATTLIST TryCatch start CDATA #REQUIRED>
+<!ATTLIST TryCatch type CDATA #IMPLIED>
+
+<!ELEMENT LineNumber EMPTY>
+<!ATTLIST LineNumber line CDATA #REQUIRED>
+<!ATTLIST LineNumber start CDATA #REQUIRED>
+
+<!ELEMENT Max EMPTY>
+<!ATTLIST Max maxLocals CDATA #REQUIRED>
+<!ATTLIST Max maxStack CDATA #REQUIRED>
+
+<!ELEMENT AALOAD EMPTY>
+<!ELEMENT AASTORE EMPTY>
+<!ELEMENT ACONST_NULL EMPTY>
+<!ELEMENT ALOAD EMPTY>
+<!ATTLIST ALOAD var CDATA #REQUIRED>
+<!ELEMENT ANEWARRAY EMPTY>
+<!ATTLIST ANEWARRAY desc CDATA #REQUIRED>
+<!ELEMENT ARETURN EMPTY>
+<!ELEMENT ARRAYLENGTH EMPTY>
+<!ELEMENT ASTORE EMPTY>
+<!ATTLIST ASTORE var CDATA #REQUIRED>
+<!ELEMENT ATHROW EMPTY>
+<!ELEMENT BALOAD EMPTY>
+<!ELEMENT BASTORE EMPTY>
+<!ELEMENT BIPUSH EMPTY>
+<!ATTLIST BIPUSH value CDATA #REQUIRED>
+<!ELEMENT CALOAD EMPTY>
+<!ELEMENT CASTORE EMPTY>
+<!ELEMENT CHECKCAST EMPTY>
+<!ATTLIST CHECKCAST desc CDATA #REQUIRED>
+<!ELEMENT D2F EMPTY>
+<!ELEMENT D2I EMPTY>
+<!ELEMENT D2L EMPTY>
+<!ELEMENT DADD EMPTY>
+<!ELEMENT DALOAD EMPTY>
+<!ELEMENT DASTORE EMPTY>
+<!ELEMENT DCMPG EMPTY>
+<!ELEMENT DCMPL EMPTY>
+<!ELEMENT DCONST_0 EMPTY>
+<!ELEMENT DCONST_1 EMPTY>
+<!ELEMENT DDIV EMPTY>
+<!ELEMENT DLOAD EMPTY>
+<!ATTLIST DLOAD var CDATA #REQUIRED>
+<!ELEMENT DMUL EMPTY>
+<!ELEMENT DNEG EMPTY>
+<!ELEMENT DREM EMPTY>
+<!ELEMENT DRETURN EMPTY>
+<!ELEMENT DSTORE EMPTY>
+<!ATTLIST DSTORE var CDATA #REQUIRED>
+<!ELEMENT DSUB EMPTY>
+<!ELEMENT DUP EMPTY>
+<!ELEMENT DUP2 EMPTY>
+<!ELEMENT DUP2_X1 EMPTY>
+<!ELEMENT DUP2_X2 EMPTY>
+<!ELEMENT DUP_X1 EMPTY>
+<!ELEMENT DUP_X2 EMPTY>
+<!ELEMENT F2D EMPTY>
+<!ELEMENT F2I EMPTY>
+<!ELEMENT F2L EMPTY>
+<!ELEMENT FADD EMPTY>
+<!ELEMENT FALOAD EMPTY>
+<!ELEMENT FASTORE EMPTY>
+<!ELEMENT FCMPG EMPTY>
+<!ELEMENT FCMPL EMPTY>
+<!ELEMENT FCONST_0 EMPTY>
+<!ELEMENT FCONST_1 EMPTY>
+<!ELEMENT FCONST_2 EMPTY>
+<!ELEMENT FDIV EMPTY>
+<!ELEMENT FLOAD EMPTY>
+<!ATTLIST FLOAD var CDATA #REQUIRED>
+<!ELEMENT FMUL EMPTY>
+<!ELEMENT FNEG EMPTY>
+<!ELEMENT FRETURN EMPTY>
+<!ELEMENT FSTORE EMPTY>
+<!ATTLIST FSTORE var CDATA #REQUIRED>
+<!ELEMENT FSUB EMPTY>
+<!ELEMENT GETFIELD EMPTY>
+<!ATTLIST GETFIELD desc CDATA #REQUIRED>
+<!ATTLIST GETFIELD name CDATA #REQUIRED>
+<!ATTLIST GETFIELD owner CDATA #REQUIRED>
+<!ELEMENT GETSTATIC EMPTY>
+<!ATTLIST GETSTATIC desc CDATA #REQUIRED>
+<!ATTLIST GETSTATIC name CDATA #REQUIRED>
+<!ATTLIST GETSTATIC owner CDATA #REQUIRED>
+<!ELEMENT GOTO EMPTY>
+<!ATTLIST GOTO label CDATA #REQUIRED>
+<!ELEMENT I2B EMPTY>
+<!ELEMENT I2C EMPTY>
+<!ELEMENT I2D EMPTY>
+<!ELEMENT I2F EMPTY>
+<!ELEMENT I2L EMPTY>
+<!ELEMENT I2S EMPTY>
+<!ELEMENT IADD EMPTY>
+<!ELEMENT IALOAD EMPTY>
+<!ELEMENT IAND EMPTY>
+<!ELEMENT IASTORE EMPTY>
+<!ELEMENT ICONST_0 EMPTY>
+<!ELEMENT ICONST_1 EMPTY>
+<!ELEMENT ICONST_2 EMPTY>
+<!ELEMENT ICONST_3 EMPTY>
+<!ELEMENT ICONST_4 EMPTY>
+<!ELEMENT ICONST_5 EMPTY>
+<!ELEMENT ICONST_M1 EMPTY>
+<!ELEMENT IDIV EMPTY>
+<!ELEMENT IFEQ EMPTY>
+<!ATTLIST IFEQ label CDATA #REQUIRED>
+<!ELEMENT IFGE EMPTY>
+<!ATTLIST IFGE label CDATA #REQUIRED>
+<!ELEMENT IFGT EMPTY>
+<!ATTLIST IFGT label CDATA #REQUIRED>
+<!ELEMENT IFLE EMPTY>
+<!ATTLIST IFLE label CDATA #REQUIRED>
+<!ELEMENT IFLT EMPTY>
+<!ATTLIST IFLT label CDATA #REQUIRED>
+<!ELEMENT IFNE EMPTY>
+<!ATTLIST IFNE label CDATA #REQUIRED>
+<!ELEMENT IFNONNULL EMPTY>
+<!ATTLIST IFNONNULL label CDATA #REQUIRED>
+<!ELEMENT IFNULL EMPTY>
+<!ATTLIST IFNULL label CDATA #REQUIRED>
+<!ELEMENT IF_ACMPEQ EMPTY>
+<!ATTLIST IF_ACMPEQ label CDATA #REQUIRED>
+<!ELEMENT IF_ACMPNE EMPTY>
+<!ATTLIST IF_ACMPNE label CDATA #REQUIRED>
+<!ELEMENT IF_ICMPEQ EMPTY>
+<!ATTLIST IF_ICMPEQ label CDATA #REQUIRED>
+<!ELEMENT IF_ICMPGE EMPTY>
+<!ATTLIST IF_ICMPGE label CDATA #REQUIRED>
+<!ELEMENT IF_ICMPGT EMPTY>
+<!ATTLIST IF_ICMPGT label CDATA #REQUIRED>
+<!ELEMENT IF_ICMPLE EMPTY>
+<!ATTLIST IF_ICMPLE label CDATA #REQUIRED>
+<!ELEMENT IF_ICMPLT EMPTY>
+<!ATTLIST IF_ICMPLT label CDATA #REQUIRED>
+<!ELEMENT IF_ICMPNE EMPTY>
+<!ATTLIST IF_ICMPNE label CDATA #REQUIRED>
+<!ELEMENT IINC EMPTY>
+<!ATTLIST IINC inc CDATA #REQUIRED>
+<!ATTLIST IINC var CDATA #REQUIRED>
+<!ELEMENT ILOAD EMPTY>
+<!ATTLIST ILOAD var CDATA #REQUIRED>
+<!ELEMENT IMUL EMPTY>
+<!ELEMENT INEG EMPTY>
+<!ELEMENT INSTANCEOF EMPTY>
+<!ATTLIST INSTANCEOF desc CDATA #REQUIRED>
+<!ELEMENT INVOKEINTERFACE EMPTY>
+<!ATTLIST INVOKEINTERFACE desc CDATA #REQUIRED>
+<!ATTLIST INVOKEINTERFACE name CDATA #REQUIRED>
+<!ATTLIST INVOKEINTERFACE owner CDATA #REQUIRED>
+<!ELEMENT INVOKESPECIAL EMPTY>
+<!ATTLIST INVOKESPECIAL desc CDATA #REQUIRED>
+<!ATTLIST INVOKESPECIAL name CDATA #REQUIRED>
+<!ATTLIST INVOKESPECIAL owner CDATA #REQUIRED>
+<!ELEMENT INVOKESTATIC EMPTY>
+<!ATTLIST INVOKESTATIC desc CDATA #REQUIRED>
+<!ATTLIST INVOKESTATIC name CDATA #REQUIRED>
+<!ATTLIST INVOKESTATIC owner CDATA #REQUIRED>
+<!ELEMENT INVOKEVIRTUAL EMPTY>
+<!ATTLIST INVOKEVIRTUAL desc CDATA #REQUIRED>
+<!ATTLIST INVOKEVIRTUAL name CDATA #REQUIRED>
+<!ATTLIST INVOKEVIRTUAL owner CDATA #REQUIRED>
+<!ELEMENT IOR EMPTY>
+<!ELEMENT IREM EMPTY>
+<!ELEMENT IRETURN EMPTY>
+<!ELEMENT ISHL EMPTY>
+<!ELEMENT ISHR EMPTY>
+<!ELEMENT ISTORE EMPTY>
+<!ATTLIST ISTORE var CDATA #REQUIRED>
+<!ELEMENT ISUB EMPTY>
+<!ELEMENT IUSHR EMPTY>
+<!ELEMENT IXOR EMPTY>
+<!ELEMENT JSR EMPTY>
+<!ATTLIST JSR label CDATA #REQUIRED>
+<!ELEMENT L2D EMPTY>
+<!ELEMENT L2F EMPTY>
+<!ELEMENT L2I EMPTY>
+<!ELEMENT LADD EMPTY>
+<!ELEMENT LALOAD EMPTY>
+<!ELEMENT LAND EMPTY>
+<!ELEMENT LASTORE EMPTY>
+<!ELEMENT LCMP EMPTY>
+<!ELEMENT LCONST_0 EMPTY>
+<!ELEMENT LCONST_1 EMPTY>
+<!ELEMENT LDC EMPTY>
+<!--
+ All characters out of interval 0x20 to 0x7f (inclusive) must
+ be encoded (\uXXXX) and character '\' must be replaced by "\\"
+-->
+<!ATTLIST LDC cst CDATA #REQUIRED>
+<!ATTLIST LDC desc CDATA #REQUIRED>
+<!ELEMENT LDIV EMPTY>
+<!ELEMENT LLOAD EMPTY>
+<!ATTLIST LLOAD var CDATA #REQUIRED>
+<!ELEMENT LMUL EMPTY>
+<!ELEMENT LNEG EMPTY>
+<!ELEMENT LOR EMPTY>
+<!ELEMENT LREM EMPTY>
+<!ELEMENT LRETURN EMPTY>
+<!ELEMENT LSHL EMPTY>
+<!ELEMENT LSHR EMPTY>
+<!ELEMENT LSTORE EMPTY>
+<!ATTLIST LSTORE var CDATA #REQUIRED>
+<!ELEMENT LSUB EMPTY>
+<!ELEMENT LUSHR EMPTY>
+<!ELEMENT LXOR EMPTY>
+<!ELEMENT MONITORENTER EMPTY>
+<!ELEMENT MONITOREXIT EMPTY>
+<!ELEMENT MULTIANEWARRAY EMPTY>
+<!ATTLIST MULTIANEWARRAY desc CDATA #REQUIRED>
+<!ATTLIST MULTIANEWARRAY dims CDATA #REQUIRED>
+<!ELEMENT NEW EMPTY>
+<!ATTLIST NEW desc CDATA #REQUIRED>
+<!ELEMENT NEWARRAY EMPTY>
+<!ATTLIST NEWARRAY value CDATA #REQUIRED>
+<!ELEMENT NOP EMPTY>
+<!ELEMENT POP EMPTY>
+<!ELEMENT POP2 EMPTY>
+<!ELEMENT PUTFIELD EMPTY>
+<!ATTLIST PUTFIELD desc CDATA #REQUIRED>
+<!ATTLIST PUTFIELD name CDATA #REQUIRED>
+<!ATTLIST PUTFIELD owner CDATA #REQUIRED>
+<!ELEMENT PUTSTATIC EMPTY>
+<!ATTLIST PUTSTATIC desc CDATA #REQUIRED>
+<!ATTLIST PUTSTATIC name CDATA #REQUIRED>
+<!ATTLIST PUTSTATIC owner CDATA #REQUIRED>
+<!ELEMENT RET EMPTY>
+<!ATTLIST RET var CDATA #REQUIRED>
+<!ELEMENT RETURN EMPTY>
+<!ELEMENT SALOAD EMPTY>
+<!ELEMENT SASTORE EMPTY>
+<!ELEMENT SIPUSH EMPTY>
+<!ATTLIST SIPUSH value CDATA #REQUIRED>
+
+<!ELEMENT LOOKUPSWITCH ( label+ )>
+<!ATTLIST LOOKUPSWITCH dflt CDATA #REQUIRED>
+
+<!ELEMENT TABLESWITCH ( label+ )>
+<!ATTLIST TABLESWITCH dflt CDATA #REQUIRED>
+<!ATTLIST TABLESWITCH max CDATA #REQUIRED>
+<!ATTLIST TABLESWITCH min CDATA #REQUIRED>
+
+<!ELEMENT label EMPTY>
+<!ATTLIST label key CDATA #IMPLIED>
+<!ATTLIST label name CDATA #REQUIRED>
+
diff --git a/tools/external/asm/org/objectweb/asm/xml/package.html b/tools/external/asm/org/objectweb/asm/xml/package.html
new file mode 100644
index 000000000..3bbb95f8c
--- /dev/null
+++ b/tools/external/asm/org/objectweb/asm/xml/package.html
@@ -0,0 +1,96 @@
+<html>
+<!--
+ * ASM XML Adapter
+ * Copyright (c) 2004, Eugene Kuleshov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<body>
+Provides <a href="http://sax.sourceforge.net/">SAX 2.0</a> adapters for ASM
+visitors to convert classes to and from XML.
+These adapters can be chained with other SAX compliant content handlers and
+filters, eg. XSLT or XQuery engines. This package is bundled as
+a separate <tt>asm-xml.jar</tt> library and requires <tt>asm.jar</tt>.
+<p>
+<tt>ASMContentHandler</tt> and <tt>SAXClassAdapter/SAXCodeAdapter</tt>
+are using <a href="asm-xml.dtd">asm-xml.dtd</a>.
+Here is the example of bytecode to bytecode XSLT transformation.
+
+<pre>
+ SAXTransformerFactory saxtf = ( SAXTransformerFactory) TransformerFactory.newInstance();
+ Templates templates = saxtf.newTemplates( xsltSource);
+
+ TransformerHandler handler = saxtf.newTransformerHandler( templates);
+ handler.setResult( new SAXResult( new ASMContentHandler( outputStream, computeMax)));
+
+ ClassReader cr = new ClassReader( bytecode);
+ cr.accept( new SAXClassAdapter( handler, cr.getVersion(), false), false);
+</pre>
+
+See JAXP and SAX documentation for more detils.
+
+<p>
+There are few illustrations of the bytecode transformation with XSLT in
+examples directory. The following XSLT procesors has been tested.
+
+<blockquote>
+<table border="1" cellspacing="0" cellpadding="3">
+<tr>
+<th>Engine</td>
+<th>javax.xml.transform.TransformerFactory property</td>
+</tr>
+
+<tr>
+<td>jd.xslt</td>
+<td>jd.xml.xslt.trax.TransformerFactoryImpl</td>
+</tr>
+
+<tr>
+<td>Saxon</td>
+<td>net.sf.saxon.TransformerFactoryImpl</td>
+</tr>
+
+<tr>
+<td>Caucho</td>
+<td>com.caucho.xsl.Xsl</td>
+</tr>
+
+<tr>
+<td>Xalan interpeter</td>
+<td>org.apache.xalan.processor.TransformerFactory</td>
+</tr>
+
+<tr>
+<td>Xalan xsltc</td>
+<td>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</td>
+</tr>
+</table>
+</blockquote>
+
+@since ASM 1.4.3
+
+</body>
+</html>