Repository: tajo Updated Branches: refs/heads/master 839081ac8 -> 7603a3d4c
http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAdapter.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAdapter.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAdapter.java new file mode 100644 index 0000000..bb51d0f --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAdapter.java @@ -0,0 +1,89 @@ +/*** + * ASM XML Adapter + * Copyright (c) 2004-2011, 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.apache.tajo.org.objectweb.asm.xml; + +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +/** + * SAXAdapter + * + * @author Eugene Kuleshov + */ +public class SAXAdapter { + + private final ContentHandler h; + + protected SAXAdapter(final ContentHandler h) { + this.h = h; + } + + protected ContentHandler getContentHandler() { + return h; + } + + protected void addDocumentStart() { + try { + h.startDocument(); + } catch (SAXException ex) { + throw new RuntimeException(ex.getMessage(), ex.getException()); + } + } + + protected void addDocumentEnd() { + try { + h.endDocument(); + } catch (SAXException ex) { + throw new RuntimeException(ex.getMessage(), ex.getException()); + } + } + + protected final void addStart(final String name, final Attributes attrs) { + try { + h.startElement("", name, name, attrs); + } catch (SAXException ex) { + throw new RuntimeException(ex.getMessage(), ex.getException()); + } + } + + protected final void addEnd(final String name) { + try { + h.endElement("", name, name); + } catch (SAXException ex) { + throw new RuntimeException(ex.getMessage(), ex.getException()); + } + } + + protected final void addElement(final String name, final Attributes attrs) { + addStart(name, attrs); + addEnd(name); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAnnotationAdapter.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAnnotationAdapter.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAnnotationAdapter.java new file mode 100644 index 0000000..056f47e --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXAnnotationAdapter.java @@ -0,0 +1,185 @@ +/*** + * ASM XML Adapter + * Copyright (c) 2004-2011, 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.apache.tajo.org.objectweb.asm.xml; + +import org.apache.tajo.org.objectweb.asm.AnnotationVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; +import org.apache.tajo.org.objectweb.asm.Type; +import org.xml.sax.helpers.AttributesImpl; + +/** + * SAXAnnotationAdapter + * + * @author Eugene Kuleshov + */ +public final class SAXAnnotationAdapter extends AnnotationVisitor { + + SAXAdapter sa; + + private final String elementName; + + public SAXAnnotationAdapter(final SAXAdapter sa, final String elementName, + final int visible, final String name, final String desc) { + this(Opcodes.ASM4, sa, elementName, visible, desc, name, -1); + } + + public SAXAnnotationAdapter(final SAXAdapter sa, final String elementName, + final int visible, final int parameter, final String desc) { + this(Opcodes.ASM4, sa, elementName, visible, desc, null, parameter); + } + + protected SAXAnnotationAdapter(final int api, final SAXAdapter sa, + final String elementName, final int visible, final String desc, + final String name, final int parameter) { + super(api); + this.sa = sa; + 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); + } + + sa.addStart(elementName, att); + } + + @Override + public void visit(final String name, final 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 short[]) { + short[] b = (short[]) value; + for (int i = 0; i < b.length; i++) { + av.visit(null, new Short(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()); + } + } + + @Override + public void visitEnum(final String name, final String desc, + final String value) { + addValueElement("annotationValueEnum", name, desc, value); + } + + @Override + public AnnotationVisitor visitAnnotation(final String name, + final String desc) { + return new SAXAnnotationAdapter(sa, "annotationValueAnnotation", 0, + name, desc); + } + + @Override + public AnnotationVisitor visitArray(final String name) { + return new SAXAnnotationAdapter(sa, "annotationValueArray", 0, name, + null); + } + + @Override + public void visitEnd() { + sa.addEnd(elementName); + } + + private void addValueElement(final String element, final String name, + final String desc, final 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)); + } + + sa.addElement(element, att); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXClassAdapter.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXClassAdapter.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXClassAdapter.java new file mode 100644 index 0000000..b26451b --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXClassAdapter.java @@ -0,0 +1,324 @@ +/*** + * ASM XML Adapter + * Copyright (c) 2004-2011, 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.apache.tajo.org.objectweb.asm.xml; + +import org.apache.tajo.org.objectweb.asm.AnnotationVisitor; +import org.apache.tajo.org.objectweb.asm.ClassVisitor; +import org.apache.tajo.org.objectweb.asm.FieldVisitor; +import org.apache.tajo.org.objectweb.asm.MethodVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; +import org.xml.sax.ContentHandler; +import org.xml.sax.helpers.AttributesImpl; + +/** + * A {@link org.apache.tajo.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 Processor + * @see ASMContentHandler + * + * @author Eugene Kuleshov + */ +public final class SAXClassAdapter extends ClassVisitor { + + SAXAdapter sa; + + private final boolean singleDocument; + + /** + * Pseudo access flag used to distinguish class access flags. + */ + private static final int ACCESS_CLASS = 262144; + + /** + * Pseudo access flag used to distinguish field access flags. + */ + private static final int ACCESS_FIELD = 524288; + + /** + * Pseudo access flag used to distinguish inner class flags. + */ + private static final int ACCESS_INNER = 1048576; + + /** + * 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(final ContentHandler h, boolean singleDocument) { + super(Opcodes.ASM4); + this.sa = new SAXAdapter(h); + this.singleDocument = singleDocument; + if (!singleDocument) { + sa.addDocumentStart(); + } + } + + @Override + public void visitSource(final String source, final String debug) { + AttributesImpl att = new AttributesImpl(); + if (source != null) { + att.addAttribute("", "file", "file", "", encode(source)); + } + if (debug != null) { + att.addAttribute("", "debug", "debug", "", encode(debug)); + } + + sa.addElement("source", att); + } + + @Override + public void visitOuterClass(final String owner, final String name, + final String desc) { + AttributesImpl att = new AttributesImpl(); + att.addAttribute("", "owner", "owner", "", owner); + if (name != null) { + att.addAttribute("", "name", "name", "", name); + } + if (desc != null) { + att.addAttribute("", "desc", "desc", "", desc); + } + + sa.addElement("outerclass", att); + } + + @Override + public AnnotationVisitor visitAnnotation(final String desc, + final boolean visible) { + return new SAXAnnotationAdapter(sa, "annotation", visible ? 1 : -1, + null, desc); + } + + @Override + public void visit(final int version, final int access, final String name, + final String signature, final String superName, + final String[] interfaces) { + StringBuffer sb = new StringBuffer(); + appendAccess(access | ACCESS_CLASS, sb); + + AttributesImpl att = new AttributesImpl(); + att.addAttribute("", "access", "access", "", sb.toString()); + if (name != null) { + att.addAttribute("", "name", "name", "", name); + } + if (signature != null) { + att.addAttribute("", "signature", "signature", "", + encode(signature)); + } + if (superName != null) { + att.addAttribute("", "parent", "parent", "", superName); + } + att.addAttribute("", "major", "major", "", + Integer.toString(version & 0xFFFF)); + att.addAttribute("", "minor", "minor", "", + Integer.toString(version >>> 16)); + sa.addStart("class", att); + + sa.addStart("interfaces", new AttributesImpl()); + if (interfaces != null && interfaces.length > 0) { + for (int i = 0; i < interfaces.length; i++) { + AttributesImpl att2 = new AttributesImpl(); + att2.addAttribute("", "name", "name", "", interfaces[i]); + sa.addElement("interface", att2); + } + } + sa.addEnd("interfaces"); + } + + @Override + public FieldVisitor visitField(final int access, final String name, + final String desc, final String signature, final Object value) { + StringBuffer sb = new StringBuffer(); + appendAccess(access | ACCESS_FIELD, sb); + + AttributesImpl att = new AttributesImpl(); + att.addAttribute("", "access", "access", "", sb.toString()); + att.addAttribute("", "name", "name", "", name); + att.addAttribute("", "desc", "desc", "", desc); + if (signature != null) { + att.addAttribute("", "signature", "signature", "", + encode(signature)); + } + if (value != null) { + att.addAttribute("", "value", "value", "", encode(value.toString())); + } + + return new SAXFieldAdapter(sa, att); + } + + @Override + public MethodVisitor visitMethod(final int access, final String name, + final String desc, final String signature, final String[] exceptions) { + StringBuffer sb = new StringBuffer(); + appendAccess(access, sb); + + AttributesImpl att = new AttributesImpl(); + att.addAttribute("", "access", "access", "", sb.toString()); + att.addAttribute("", "name", "name", "", name); + att.addAttribute("", "desc", "desc", "", desc); + if (signature != null) { + att.addAttribute("", "signature", "signature", "", signature); + } + sa.addStart("method", att); + + sa.addStart("exceptions", new AttributesImpl()); + if (exceptions != null && exceptions.length > 0) { + for (int i = 0; i < exceptions.length; i++) { + AttributesImpl att2 = new AttributesImpl(); + att2.addAttribute("", "name", "name", "", exceptions[i]); + sa.addElement("exception", att2); + } + } + sa.addEnd("exceptions"); + + return new SAXCodeAdapter(sa, access); + } + + @Override + public final void visitInnerClass(final String name, + final String outerName, final String innerName, final int access) { + StringBuffer sb = new StringBuffer(); + appendAccess(access | ACCESS_INNER, sb); + + 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); + } + sa.addElement("innerclass", att); + } + + @Override + public final void visitEnd() { + sa.addEnd("class"); + if (!singleDocument) { + sa.addDocumentEnd(); + } + } + + static final String encode(final 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(); + } + + static void appendAccess(final int access, final StringBuffer sb) { + 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_STATIC) != 0) { + sb.append("static "); + } + if ((access & Opcodes.ACC_SUPER) != 0) { + if ((access & ACCESS_CLASS) == 0) { + sb.append("synchronized "); + } else { + sb.append("super "); + } + } + if ((access & Opcodes.ACC_VOLATILE) != 0) { + if ((access & ACCESS_FIELD) == 0) { + sb.append("bridge "); + } else { + sb.append("volatile "); + } + } + if ((access & Opcodes.ACC_TRANSIENT) != 0) { + if ((access & ACCESS_FIELD) == 0) { + sb.append("varargs "); + } else { + sb.append("transient "); + } + } + if ((access & Opcodes.ACC_NATIVE) != 0) { + sb.append("native "); + } + if ((access & Opcodes.ACC_STRICT) != 0) { + sb.append("strict "); + } + 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 "); + } + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXCodeAdapter.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXCodeAdapter.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXCodeAdapter.java new file mode 100644 index 0000000..c7ace51 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXCodeAdapter.java @@ -0,0 +1,362 @@ +/*** + * ASM XML Adapter + * Copyright (c) 2004-2011, 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.apache.tajo.org.objectweb.asm.xml; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.tajo.org.objectweb.asm.Label; +import org.apache.tajo.org.objectweb.asm.Type; +import org.apache.tajo.org.objectweb.asm.AnnotationVisitor; +import org.apache.tajo.org.objectweb.asm.Handle; +import org.apache.tajo.org.objectweb.asm.MethodVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; +import org.apache.tajo.org.objectweb.asm.util.Printer; +import org.xml.sax.helpers.AttributesImpl; + +/** + * A {@link MethodVisitor} that generates SAX 2.0 events from the visited + * method. + * + * @see SAXClassAdapter + * @see Processor + * + * @author Eugene Kuleshov + */ +public final class SAXCodeAdapter extends MethodVisitor { + + static final String[] TYPES = { "top", "int", "float", "double", "long", + "null", "uninitializedThis" }; + + SAXAdapter sa; + + private final Map<Label, String> labelNames; + + /** + * Constructs a new {@link SAXCodeAdapter SAXCodeAdapter} object. + * + * @param sa + * content handler that will be used to send SAX 2.0 events. + */ + public SAXCodeAdapter(final SAXAdapter sa, final int access) { + super(Opcodes.ASM4); + this.sa = sa; + this.labelNames = new HashMap<Label, String>(); + + if ((access & (Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE | Opcodes.ACC_NATIVE)) == 0) { + sa.addStart("code", new AttributesImpl()); + } + } + + @Override + public final void visitCode() { + } + + @Override + public void visitFrame(final int type, final int nLocal, + final Object[] local, final int nStack, final Object[] stack) { + AttributesImpl attrs = new AttributesImpl(); + switch (type) { + case Opcodes.F_NEW: + case Opcodes.F_FULL: + if (type == Opcodes.F_NEW) { + attrs.addAttribute("", "type", "type", "", "NEW"); + } else { + attrs.addAttribute("", "type", "type", "", "FULL"); + } + sa.addStart("frame", attrs); + appendFrameTypes(true, nLocal, local); + appendFrameTypes(false, nStack, stack); + break; + case Opcodes.F_APPEND: + attrs.addAttribute("", "type", "type", "", "APPEND"); + sa.addStart("frame", attrs); + appendFrameTypes(true, nLocal, local); + break; + case Opcodes.F_CHOP: + attrs.addAttribute("", "type", "type", "", "CHOP"); + attrs.addAttribute("", "count", "count", "", + Integer.toString(nLocal)); + sa.addStart("frame", attrs); + break; + case Opcodes.F_SAME: + attrs.addAttribute("", "type", "type", "", "SAME"); + sa.addStart("frame", attrs); + break; + case Opcodes.F_SAME1: + attrs.addAttribute("", "type", "type", "", "SAME1"); + sa.addStart("frame", attrs); + appendFrameTypes(false, 1, stack); + break; + } + sa.addEnd("frame"); + } + + private void appendFrameTypes(final boolean local, final int n, + final Object[] types) { + for (int i = 0; i < n; ++i) { + Object type = types[i]; + AttributesImpl attrs = new AttributesImpl(); + if (type instanceof String) { + attrs.addAttribute("", "type", "type", "", (String) type); + } else if (type instanceof Integer) { + attrs.addAttribute("", "type", "type", "", + TYPES[((Integer) type).intValue()]); + } else { + attrs.addAttribute("", "type", "type", "", "uninitialized"); + attrs.addAttribute("", "label", "label", "", + getLabel((Label) type)); + } + sa.addElement(local ? "local" : "stack", attrs); + } + } + + @Override + public final void visitInsn(final int opcode) { + sa.addElement(Printer.OPCODES[opcode], new AttributesImpl()); + } + + @Override + public final void visitIntInsn(final int opcode, final int operand) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "value", "value", "", Integer.toString(operand)); + sa.addElement(Printer.OPCODES[opcode], attrs); + } + + @Override + public final void visitVarInsn(final int opcode, final int var) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "var", "var", "", Integer.toString(var)); + sa.addElement(Printer.OPCODES[opcode], attrs); + } + + @Override + public final void visitTypeInsn(final int opcode, final String type) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "desc", "desc", "", type); + sa.addElement(Printer.OPCODES[opcode], attrs); + } + + @Override + public final void visitFieldInsn(final int opcode, final String owner, + final String name, final String desc) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "owner", "owner", "", owner); + attrs.addAttribute("", "name", "name", "", name); + attrs.addAttribute("", "desc", "desc", "", desc); + sa.addElement(Printer.OPCODES[opcode], attrs); + } + + @Override + public final void visitMethodInsn(final int opcode, final String owner, + final String name, final String desc) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "owner", "owner", "", owner); + attrs.addAttribute("", "name", "name", "", name); + attrs.addAttribute("", "desc", "desc", "", desc); + sa.addElement(Printer.OPCODES[opcode], attrs); + } + + @Override + public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, + Object... bsmArgs) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "name", "name", "", name); + attrs.addAttribute("", "desc", "desc", "", desc); + attrs.addAttribute("", "bsm", "bsm", "", + SAXClassAdapter.encode(bsm.toString())); + sa.addStart("INVOKEDYNAMIC", attrs); + for (int i = 0; i < bsmArgs.length; i++) { + sa.addElement("bsmArg", getConstantAttribute(bsmArgs[i])); + } + sa.addEnd("INVOKEDYNAMIC"); + } + + @Override + public final void visitJumpInsn(final int opcode, final Label label) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "label", "label", "", getLabel(label)); + sa.addElement(Printer.OPCODES[opcode], attrs); + } + + @Override + public final void visitLabel(final Label label) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "name", "name", "", getLabel(label)); + sa.addElement("Label", attrs); + } + + @Override + public final void visitLdcInsn(final Object cst) { + sa.addElement(Printer.OPCODES[Opcodes.LDC], getConstantAttribute(cst)); + } + + private static AttributesImpl getConstantAttribute(final Object cst) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "cst", "cst", "", + SAXClassAdapter.encode(cst.toString())); + attrs.addAttribute("", "desc", "desc", "", + Type.getDescriptor(cst.getClass())); + return attrs; + } + + @Override + public final void visitIincInsn(final int var, final int increment) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "var", "var", "", Integer.toString(var)); + attrs.addAttribute("", "inc", "inc", "", Integer.toString(increment)); + sa.addElement(Printer.OPCODES[Opcodes.IINC], attrs); + } + + @Override + public final void visitTableSwitchInsn(final int min, final int max, + final Label dflt, final 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 = Printer.OPCODES[Opcodes.TABLESWITCH]; + sa.addStart(o, attrs); + for (int i = 0; i < labels.length; i++) { + AttributesImpl att2 = new AttributesImpl(); + att2.addAttribute("", "name", "name", "", getLabel(labels[i])); + sa.addElement("label", att2); + } + sa.addEnd(o); + } + + @Override + public final void visitLookupSwitchInsn(final Label dflt, final int[] keys, + final Label[] labels) { + AttributesImpl att = new AttributesImpl(); + att.addAttribute("", "dflt", "dflt", "", getLabel(dflt)); + String o = Printer.OPCODES[Opcodes.LOOKUPSWITCH]; + sa.addStart(o, att); + for (int i = 0; i < labels.length; i++) { + AttributesImpl att2 = new AttributesImpl(); + att2.addAttribute("", "name", "name", "", getLabel(labels[i])); + att2.addAttribute("", "key", "key", "", Integer.toString(keys[i])); + sa.addElement("label", att2); + } + sa.addEnd(o); + } + + @Override + public final void visitMultiANewArrayInsn(final String desc, final int dims) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "desc", "desc", "", desc); + attrs.addAttribute("", "dims", "dims", "", Integer.toString(dims)); + sa.addElement(Printer.OPCODES[Opcodes.MULTIANEWARRAY], attrs); + } + + @Override + public final void visitTryCatchBlock(final Label start, final Label end, + final Label handler, final 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); + } + sa.addElement("TryCatch", attrs); + } + + @Override + public final void visitMaxs(final int maxStack, final int maxLocals) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "maxStack", "maxStack", "", + Integer.toString(maxStack)); + attrs.addAttribute("", "maxLocals", "maxLocals", "", + Integer.toString(maxLocals)); + sa.addElement("Max", attrs); + + sa.addEnd("code"); + } + + @Override + public void visitLocalVariable(final String name, final String desc, + final String signature, final Label start, final Label end, + final 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)); + sa.addElement("LocalVar", attrs); + } + + @Override + public final void visitLineNumber(final int line, final Label start) { + AttributesImpl attrs = new AttributesImpl(); + attrs.addAttribute("", "line", "line", "", Integer.toString(line)); + attrs.addAttribute("", "start", "start", "", getLabel(start)); + sa.addElement("LineNumber", attrs); + } + + @Override + public AnnotationVisitor visitAnnotationDefault() { + return new SAXAnnotationAdapter(sa, "annotationDefault", 0, null, null); + } + + @Override + public AnnotationVisitor visitAnnotation(final String desc, + final boolean visible) { + return new SAXAnnotationAdapter(sa, "annotation", visible ? 1 : -1, + null, desc); + } + + @Override + public AnnotationVisitor visitParameterAnnotation(final int parameter, + final String desc, final boolean visible) { + return new SAXAnnotationAdapter(sa, "parameterAnnotation", visible ? 1 + : -1, parameter, desc); + } + + @Override + public void visitEnd() { + sa.addEnd("method"); + } + + private final String getLabel(final Label label) { + String name = labelNames.get(label); + if (name == null) { + name = Integer.toString(labelNames.size()); + labelNames.put(label, name); + } + return name; + } + +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXFieldAdapter.java ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXFieldAdapter.java b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXFieldAdapter.java new file mode 100644 index 0000000..9ff57ff --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/SAXFieldAdapter.java @@ -0,0 +1,63 @@ +/*** + * ASM XML Adapter + * Copyright (c) 2004-2011, 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.apache.tajo.org.objectweb.asm.xml; + +import org.apache.tajo.org.objectweb.asm.AnnotationVisitor; +import org.apache.tajo.org.objectweb.asm.FieldVisitor; +import org.apache.tajo.org.objectweb.asm.Opcodes; +import org.xml.sax.Attributes; + +/** + * SAXFieldAdapter + * + * @author Eugene Kuleshov + */ +public final class SAXFieldAdapter extends FieldVisitor { + + SAXAdapter sa; + + public SAXFieldAdapter(final SAXAdapter sa, final Attributes att) { + super(Opcodes.ASM4); + this.sa = sa; + sa.addStart("field", att); + } + + @Override + public AnnotationVisitor visitAnnotation(final String desc, + final boolean visible) { + return new SAXAnnotationAdapter(sa, "annotation", visible ? 1 : -1, + null, desc); + } + + @Override + public void visitEnd() { + sa.addEnd("field"); + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/asm-xml.dtd ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/asm-xml.dtd b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/asm-xml.dtd new file mode 100644 index 0000000..65e9959 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/asm-xml.dtd @@ -0,0 +1,367 @@ +<!--~ + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<!-- + ASM XML Adapter + Copyright (c) 2004-2011, 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 + 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 | SWAP | F2D | F2I | F2L | FADD | FALOAD | FASTORE | FCMPG | FCMPL | FCONST_0 | FCONST_1 | FCONST_2 | FDIV | FLOAD | FMUL | FNEG | FREM | 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 | IRETU RN | 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 SWAP 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 FREM 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 INVOKEDYNAMIC ( bsmArgs+ )> +<!ATTLIST INVOKEDYNAMIC desc CDATA #REQUIRED> +<!ATTLIST INVOKEDYNAMIC name CDATA #REQUIRED> +<!ATTLIST INVOKEDYNAMIC bsm CDATA #REQUIRED> +<!ELEMENT bsmArgs EMPTY> +<!ATTLIST bsmArgs cst CDATA #REQUIRED> +<!ATTLIST bsmArgs desc 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> + http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/package.html ---------------------------------------------------------------------- diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/package.html b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/package.html new file mode 100644 index 0000000..51ec208 --- /dev/null +++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/xml/package.html @@ -0,0 +1,114 @@ +<!--~ + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<html> +<!-- + * ASM XML Adapter + * Copyright (c) 2004-2011, 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> http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-yarn-pullserver/pom.xml ---------------------------------------------------------------------- diff --git a/tajo-yarn-pullserver/pom.xml b/tajo-yarn-pullserver/pom.xml index 2065b05..64b3a74 100644 --- a/tajo-yarn-pullserver/pom.xml +++ b/tajo-yarn-pullserver/pom.xml @@ -30,6 +30,23 @@ <name>Tajo Core PullServer</name> <artifactId>tajo-yarn-pullserver</artifactId> + <build> + <plugins> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> <dependency> <groupId>org.apache.tajo</groupId> http://git-wip-us.apache.org/repos/asf/tajo/blob/7603a3d4/tajo-yarn-pullserver/src/main/java/org/apache/tajo/storage/Tuple.java ---------------------------------------------------------------------- diff --git a/tajo-yarn-pullserver/src/main/java/org/apache/tajo/storage/Tuple.java b/tajo-yarn-pullserver/src/main/java/org/apache/tajo/storage/Tuple.java index f98e6f1..7b5d9c0 100644 --- a/tajo-yarn-pullserver/src/main/java/org/apache/tajo/storage/Tuple.java +++ b/tajo-yarn-pullserver/src/main/java/org/apache/tajo/storage/Tuple.java @@ -19,6 +19,7 @@ package org.apache.tajo.storage; import org.apache.tajo.datum.Datum; +import org.apache.tajo.datum.ProtobufDatum; public interface Tuple extends Cloneable { @@ -44,26 +45,38 @@ public interface Tuple extends Cloneable { public long getOffset(); + @SuppressWarnings("unused") public boolean getBool(int fieldId); + @SuppressWarnings("unused") public byte getByte(int fieldId); + @SuppressWarnings("unused") public char getChar(int fieldId); - + public byte [] getBytes(int fieldId); - + + @SuppressWarnings("unused") public short getInt2(int fieldId); - + + @SuppressWarnings("unused") public int getInt4(int fieldId); - + + @SuppressWarnings("unused") public long getInt8(int fieldId); - + + @SuppressWarnings("unused") public float getFloat4(int fieldId); - + + @SuppressWarnings("unused") public double getFloat8(int fieldId); - + + @SuppressWarnings("unused") public String getText(int fieldId); + @SuppressWarnings("unused") + public ProtobufDatum getProtobufDatum(int field); + public Tuple clone() throws CloneNotSupportedException; public Datum[] getValues();
