zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [3/6] zookeeper git commit: ZOOKEEPER-3080: MAVEN MIGRATION - Step 1.5 - move jute dir
Date Mon, 03 Sep 2018 09:57:59 GMT
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/OutputArchive.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/OutputArchive.java b/zookeeper-jute/src/main/java/org/apache/jute/OutputArchive.java
new file mode 100644
index 0000000..5f78ea9
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/OutputArchive.java
@@ -0,0 +1,47 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.TreeMap;
+
+/**
+ * Interface that all the serializers have to implement.
+ *
+ */
+public interface OutputArchive {
+    public void writeByte(byte b, String tag) throws IOException;
+    public void writeBool(boolean b, String tag) throws IOException;
+    public void writeInt(int i, String tag) throws IOException;
+    public void writeLong(long l, String tag) throws IOException;
+    public void writeFloat(float f, String tag) throws IOException;
+    public void writeDouble(double d, String tag) throws IOException;
+    public void writeString(String s, String tag) throws IOException;
+    public void writeBuffer(byte buf[], String tag)
+        throws IOException;
+    public void writeRecord(Record r, String tag) throws IOException;
+    public void startRecord(Record r, String tag) throws IOException;
+    public void endRecord(Record r, String tag) throws IOException;
+    public void startVector(List<?> v, String tag) throws IOException;
+    public void endVector(List<?> v, String tag) throws IOException;
+    public void startMap(TreeMap<?,?> v, String tag) throws IOException;
+    public void endMap(TreeMap<?,?> v, String tag) throws IOException;
+
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/Record.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/Record.java b/zookeeper-jute/src/main/java/org/apache/jute/Record.java
new file mode 100644
index 0000000..d955280
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/Record.java
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute;
+
+import org.apache.yetus.audience.InterfaceAudience;
+
+import java.io.IOException;
+
+/**
+ * Interface that is implemented by generated classes.
+ * 
+ */
+@InterfaceAudience.Public
+public interface Record {
+    public void serialize(OutputArchive archive, String tag)
+        throws IOException;
+    public void deserialize(InputArchive archive, String tag)
+        throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/RecordReader.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/RecordReader.java b/zookeeper-jute/src/main/java/org/apache/jute/RecordReader.java
new file mode 100644
index 0000000..5f24f56
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/RecordReader.java
@@ -0,0 +1,93 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+/**
+ * Front-end interface to deserializers. Also acts as a factory
+ * for deserializers.
+ *
+ */
+public class RecordReader {
+    
+    private InputArchive archive;
+
+    static private HashMap<String, Method> archiveFactory;
+    
+    static {
+        archiveFactory = new HashMap<String, Method>();
+
+        try {
+            archiveFactory.put("binary",
+                    BinaryInputArchive.class.getDeclaredMethod(
+                        "getArchive", new Class[]{ InputStream.class } ));
+            archiveFactory.put("csv",
+                    CsvInputArchive.class.getDeclaredMethod(
+                        "getArchive", new Class[]{ InputStream.class }));
+            archiveFactory.put("xml",
+                    XmlInputArchive.class.getDeclaredMethod(
+                        "getArchive", new Class[]{ InputStream.class }));
+        } catch (SecurityException ex) {
+            ex.printStackTrace();
+        } catch (NoSuchMethodException ex) {
+            ex.printStackTrace();
+        }
+    }
+    
+    static private InputArchive createArchive(InputStream in, String format)
+    throws IOException {
+        Method factory = (Method) archiveFactory.get(format);
+        if (factory != null) {
+            Object[] params = { in };
+            try {
+                return (InputArchive) factory.invoke(null, params);
+            } catch (IllegalArgumentException ex) {
+                ex.printStackTrace();
+            } catch (InvocationTargetException ex) {
+                ex.printStackTrace();
+            } catch (IllegalAccessException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return null;
+    }
+    /**
+     * Creates a new instance of RecordReader.
+     * @param in Stream from which to deserialize a record
+     * @param format Deserialization format ("binary", "xml", or "csv")
+     */
+    public RecordReader(InputStream in, String format)
+    throws IOException {
+        archive = createArchive(in, format);
+    }
+    
+    /**
+     * Deserialize a record
+     * @param r Record to be deserialized
+     */
+    public void read(Record r) throws IOException {
+        r.deserialize(archive, "");
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/RecordWriter.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/RecordWriter.java b/zookeeper-jute/src/main/java/org/apache/jute/RecordWriter.java
new file mode 100644
index 0000000..a400775
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/RecordWriter.java
@@ -0,0 +1,93 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+/**
+ * Front-end for serializers. Also serves as a factory for serializers.
+ *
+ */
+public class RecordWriter {
+    
+    private OutputArchive archive;
+    
+    static HashMap<String, Method> constructFactory() {
+        HashMap<String, Method> factory = new HashMap<String, Method>();
+
+        try {
+            factory.put("binary",
+                    BinaryOutputArchive.class.getDeclaredMethod(
+                        "getArchive", new Class[]{ OutputStream.class }));
+            factory.put("csv",
+                    CsvOutputArchive.class.getDeclaredMethod(
+                        "getArchive", new Class[]{ OutputStream.class }));
+            factory.put("xml",
+                    XmlOutputArchive.class.getDeclaredMethod(
+                        "getArchive", new Class[]{ OutputStream.class }));
+        } catch (SecurityException ex) {
+            ex.printStackTrace();
+        } catch (NoSuchMethodException ex) {
+            ex.printStackTrace();
+        }
+        return factory;
+    }
+    
+    static private HashMap<String, Method> archiveFactory = constructFactory();
+    
+    static private OutputArchive createArchive(OutputStream out,
+            String format)
+            throws IOException {
+        Method factory = (Method) archiveFactory.get(format);
+        if (factory != null) {
+            Object[] params = { out };
+            try {
+                return (OutputArchive) factory.invoke(null, params);
+            } catch (IllegalArgumentException ex) {
+                ex.printStackTrace();
+            } catch (InvocationTargetException ex) {
+                ex.printStackTrace();
+            } catch (IllegalAccessException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return null;
+    }
+    /**
+     * Creates a new instance of RecordWriter
+     * @param out Output stream where the records will be serialized
+     * @param format Serialization format ("binary", "xml", or "csv")
+     */
+    public RecordWriter(OutputStream out, String format)
+    throws IOException {
+        archive = createArchive(out, format);
+    }
+    
+    /**
+     * Serialize a record
+     * @param r record to be serialized
+     */
+    public void write(Record r) throws IOException {
+        r.serialize(archive, "");
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/Utils.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/Utils.java b/zookeeper-jute/src/main/java/org/apache/jute/Utils.java
new file mode 100644
index 0000000..1205fa2
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/Utils.java
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * Various utility functions for Hadoop record I/O runtime.
+ */
+public class Utils {
+    
+    /** Cannot create a new instance of Utils */
+    private Utils() {
+        super();
+    }
+   
+    /**
+     * equals function that actually compares two buffers.
+     *
+     * @param onearray First buffer
+     * @param twoarray Second buffer
+     * @return true if one and two contain exactly the same content, else false.
+     */
+    public static boolean bufEquals(byte onearray[], byte twoarray[] ) {
+    	if (onearray == twoarray) return true;
+        boolean ret = (onearray.length == twoarray.length);
+        if (!ret) {
+            return ret;
+        }
+        for (int idx = 0; idx < onearray.length; idx++) {
+            if (onearray[idx] != twoarray[idx]) {
+                return false;
+            }
+        }
+        return true;
+    }
+    
+    private static final char[] hexchars = { '0', '1', '2', '3', '4', '5',
+                                            '6', '7', '8', '9', 'A', 'B',
+                                            'C', 'D', 'E', 'F' };
+    /**
+     * 
+     * @param s 
+     * @return 
+     */
+    static String toXMLString(String s) {
+        if (s == null)
+            return "";
+
+        StringBuilder sb = new StringBuilder();
+        for (int idx = 0; idx < s.length(); idx++) {
+          char ch = s.charAt(idx);
+          if (ch == '<') {
+            sb.append("&lt;");
+          } else if (ch == '&') {
+            sb.append("&amp;");
+          } else if (ch == '%') {
+            sb.append("%25");
+          } else if (ch < 0x20) {
+            sb.append("%");
+            sb.append(hexchars[ch/16]);
+            sb.append(hexchars[ch%16]);
+          } else {
+            sb.append(ch);
+          }
+        }
+        return sb.toString();
+    }
+    
+    static private int h2c(char ch) {
+      if (ch >= '0' && ch <= '9') {
+        return ch - '0';
+      } else if (ch >= 'A' && ch <= 'F') {
+        return ch - 'A';
+      } else if (ch >= 'a' && ch <= 'f') {
+        return ch - 'a';
+      }
+      return 0;
+    }
+    
+    /**
+     * 
+     * @param s 
+     * @return 
+     */
+    static String fromXMLString(String s) {
+        StringBuilder sb = new StringBuilder();
+        for (int idx = 0; idx < s.length();) {
+          char ch = s.charAt(idx++);
+          if (ch == '%') {
+            char ch1 = s.charAt(idx++);
+            char ch2 = s.charAt(idx++);
+            char res = (char)(h2c(ch1)*16 + h2c(ch2));
+            sb.append(res);
+          } else {
+            sb.append(ch);
+          }
+        }
+        
+        return sb.toString();
+    }
+    
+    /**
+     * 
+     * @param s 
+     * @return 
+     */
+    static String toCSVString(String s) {
+        if (s == null)
+            return "";
+
+        StringBuilder sb = new StringBuilder(s.length()+1);
+        sb.append('\'');
+        int len = s.length();
+        for (int i = 0; i < len; i++) {
+            char c = s.charAt(i);
+            switch(c) {
+                case '\0':
+                    sb.append("%00");
+                    break;
+                case '\n':
+                    sb.append("%0A");
+                    break;
+                case '\r':
+                    sb.append("%0D");
+                    break;
+                case ',':
+                    sb.append("%2C");
+                    break;
+                case '}':
+                    sb.append("%7D");
+                    break;
+                case '%':
+                    sb.append("%25");
+                    break;
+                default:
+                    sb.append(c);
+            }
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * 
+     * @param s 
+     * @throws java.io.IOException 
+     * @return 
+     */
+    static String fromCSVString(String s) throws IOException {
+        if (s.charAt(0) != '\'') {
+            throw new IOException("Error deserializing string.");
+        }
+        int len = s.length();
+        StringBuilder sb = new StringBuilder(len-1);
+        for (int i = 1; i < len; i++) {
+            char c = s.charAt(i);
+            if (c == '%') {
+                char ch1 = s.charAt(i+1);
+                char ch2 = s.charAt(i+2);
+                i += 2;
+                if (ch1 == '0' && ch2 == '0') { sb.append('\0'); }
+                else if (ch1 == '0' && ch2 == 'A') { sb.append('\n'); }
+                else if (ch1 == '0' && ch2 == 'D') { sb.append('\r'); }
+                else if (ch1 == '2' && ch2 == 'C') { sb.append(','); }
+                else if (ch1 == '7' && ch2 == 'D') { sb.append('}'); }
+                else if (ch1 == '2' && ch2 == '5') { sb.append('%'); }
+                else {throw new IOException("Error deserializing string.");}
+            } else {
+                sb.append(c);
+            }
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * 
+     * @param s 
+     * @return 
+     */
+    static String toXMLBuffer(byte barr[]) {
+        if (barr == null || barr.length == 0) {
+            return "";
+        }
+        StringBuilder sb = new StringBuilder(2*barr.length);
+        for (int idx = 0; idx < barr.length; idx++) {
+            sb.append(Integer.toHexString(barr[idx]));
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * 
+     * @param s 
+     * @throws java.io.IOException 
+     * @return 
+     */
+    static byte[] fromXMLBuffer(String s)
+    throws IOException {
+        ByteArrayOutputStream stream =  new ByteArrayOutputStream();
+        if (s.length() == 0) { return stream.toByteArray(); }
+        int blen = s.length()/2;
+        byte[] barr = new byte[blen];
+        for (int idx = 0; idx < blen; idx++) {
+            char c1 = s.charAt(2*idx);
+            char c2 = s.charAt(2*idx+1);
+            barr[idx] = Byte.parseByte(""+c1+c2, 16);
+        }
+        stream.write(barr);
+        return stream.toByteArray();
+    }
+    
+    /**
+     * 
+     * @param buf 
+     * @return 
+     */
+    static String toCSVBuffer(byte barr[]) {
+        if (barr == null || barr.length == 0) {
+            return "";
+        }
+        StringBuilder sb = new StringBuilder(barr.length + 1);
+        sb.append('#');
+        for(int idx = 0; idx < barr.length; idx++) {
+            sb.append(Integer.toHexString(barr[idx]));
+        }
+        return sb.toString();
+    }
+    
+    /**
+     * Converts a CSV-serialized representation of buffer to a new
+     * ByteArrayOutputStream.
+     * @param s CSV-serialized representation of buffer
+     * @throws java.io.IOException 
+     * @return Deserialized ByteArrayOutputStream
+     */
+    static byte[] fromCSVBuffer(String s)
+    throws IOException {
+        if (s.charAt(0) != '#') {
+            throw new IOException("Error deserializing buffer.");
+        }
+        ByteArrayOutputStream stream =  new ByteArrayOutputStream();
+        if (s.length() == 1) { return stream.toByteArray(); }
+        int blen = (s.length()-1)/2;
+        byte[] barr = new byte[blen];
+        for (int idx = 0; idx < blen; idx++) {
+            char c1 = s.charAt(2*idx+1);
+            char c2 = s.charAt(2*idx+2);
+            barr[idx] = Byte.parseByte(""+c1+c2, 16);
+        }
+        stream.write(barr);
+        return stream.toByteArray();
+    }
+    public static int compareBytes(byte b1[], int off1, int len1, byte b2[], int off2, int len2) {
+        int i;
+        for(i=0; i < len1 && i < len2; i++) {
+            if (b1[off1+i] != b2[off2+i]) {
+                return b1[off1+i] < b2[off2+i] ? -1 : 1;
+            }
+        }
+        if (len1 != len2) {
+            return len1 < len2 ? -1 : 1;
+        }
+        return 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/XmlInputArchive.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/XmlInputArchive.java b/zookeeper-jute/src/main/java/org/apache/jute/XmlInputArchive.java
new file mode 100644
index 0000000..99e11d1
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/XmlInputArchive.java
@@ -0,0 +1,251 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+/**
+ *
+ */
+class XmlInputArchive implements InputArchive {
+    
+    static private class Value {
+        private String type;
+        private StringBuffer sb;
+        
+        public Value(String t) {
+            type = t;
+            sb = new StringBuffer();
+        }
+        public void addChars(char[] buf, int offset, int len) {
+            sb.append(buf, offset, len);
+        }
+        public String getValue() { return sb.toString(); }
+        public String getType() { return type; }
+    }
+    
+    private static class XMLParser extends DefaultHandler {
+        private boolean charsValid = false;
+        
+        private ArrayList<Value> valList;
+        
+        private XMLParser(ArrayList<Value> vlist) {
+            valList = vlist;
+        }
+        
+        public void startDocument() throws SAXException {}
+        
+        public void endDocument() throws SAXException {}
+        
+        public void startElement(String ns,
+                String sname,
+                String qname,
+                Attributes attrs) throws SAXException {
+            charsValid = false;
+            if ("boolean".equals(qname) ||
+                    "i4".equals(qname) ||
+                    "int".equals(qname) ||
+                    "string".equals(qname) ||
+                    "double".equals(qname) ||
+                    "ex:i1".equals(qname) ||
+                    "ex:i8".equals(qname) ||
+                    "ex:float".equals(qname)) {
+                charsValid = true;
+                valList.add(new Value(qname));
+            } else if ("struct".equals(qname) ||
+                "array".equals(qname)) {
+                valList.add(new Value(qname));
+            }
+        }
+        
+        public void endElement(String ns,
+                String sname,
+                String qname) throws SAXException {
+            charsValid = false;
+            if ("struct".equals(qname) ||
+                    "array".equals(qname)) {
+                valList.add(new Value("/"+qname));
+            }
+        }
+        
+        public void characters(char buf[], int offset, int len)
+        throws SAXException {
+            if (charsValid) {
+                Value v = valList.get(valList.size()-1);
+                v.addChars(buf, offset,len);
+            }
+        }
+        
+    }
+    
+    private class XmlIndex implements Index {
+        public boolean done() {
+            Value v = valList.get(vIdx);
+            if ("/array".equals(v.getType())) {
+                valList.set(vIdx, null);
+                vIdx++;
+                return true;
+            } else {
+                return false;
+            }
+        }
+        public void incr() {}
+    }
+    
+    private ArrayList<Value> valList;
+    private int vLen;
+    private int vIdx;
+    
+    private Value next() throws IOException {
+        if (vIdx < vLen) {
+            Value v = valList.get(vIdx);
+            valList.set(vIdx, null);
+            vIdx++;
+            return v;
+        } else {
+            throw new IOException("Error in deserialization.");
+        }
+    }
+    
+    static XmlInputArchive getArchive(InputStream strm)
+    throws ParserConfigurationException, SAXException, IOException {
+        return new XmlInputArchive(strm);
+    }
+    
+    /** Creates a new instance of BinaryInputArchive */
+    public XmlInputArchive(InputStream in)
+    throws ParserConfigurationException, SAXException, IOException {
+        valList = new ArrayList<Value>();
+        DefaultHandler handler = new XMLParser(valList);
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        SAXParser parser = factory.newSAXParser();
+        parser.parse(in, handler);
+        vLen = valList.size();
+        vIdx = 0;
+    }
+    
+    public byte readByte(String tag) throws IOException {
+        Value v = next();
+        if (!"ex:i1".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return Byte.parseByte(v.getValue());
+    }
+    
+    public boolean readBool(String tag) throws IOException {
+        Value v = next();
+        if (!"boolean".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return "1".equals(v.getValue());
+    }
+    
+    public int readInt(String tag) throws IOException {
+        Value v = next();
+        if (!"i4".equals(v.getType()) &&
+                !"int".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return Integer.parseInt(v.getValue());
+    }
+    
+    public long readLong(String tag) throws IOException {
+        Value v = next();
+        if (!"ex:i8".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return Long.parseLong(v.getValue());
+    }
+    
+    public float readFloat(String tag) throws IOException {
+        Value v = next();
+        if (!"ex:float".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return Float.parseFloat(v.getValue());
+    }
+    
+    public double readDouble(String tag) throws IOException {
+        Value v = next();
+        if (!"double".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return Double.parseDouble(v.getValue());
+    }
+    
+    public String readString(String tag) throws IOException {
+        Value v = next();
+        if (!"string".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return Utils.fromXMLString(v.getValue());
+    }
+    
+    public byte[] readBuffer(String tag) throws IOException {
+        Value v = next();
+        if (!"string".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return Utils.fromXMLBuffer(v.getValue());
+    }
+    
+    public void readRecord(Record r, String tag) throws IOException {
+        r.deserialize(this, tag);
+    }
+    
+    public void startRecord(String tag) throws IOException {
+        Value v = next();
+        if (!"struct".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+    }
+    
+    public void endRecord(String tag) throws IOException {
+        Value v = next();
+        if (!"/struct".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+    }
+    
+    public Index startVector(String tag) throws IOException {
+        Value v = next();
+        if (!"array".equals(v.getType())) {
+            throw new IOException("Error deserializing "+tag+".");
+        }
+        return new XmlIndex();
+    }
+    
+    public void endVector(String tag) throws IOException {}
+    
+    public Index startMap(String tag) throws IOException {
+        return startVector(tag);
+    }
+    
+    public void endMap(String tag) throws IOException { endVector(tag); }
+
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/XmlOutputArchive.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/XmlOutputArchive.java b/zookeeper-jute/src/main/java/org/apache/jute/XmlOutputArchive.java
new file mode 100644
index 0000000..8c7afe4
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/XmlOutputArchive.java
@@ -0,0 +1,251 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.Stack;
+import java.util.TreeMap;
+
+/**
+ *
+ */
+class XmlOutputArchive implements OutputArchive {
+
+    private PrintStream stream;
+    
+    private int indent = 0;
+    
+    private Stack<String> compoundStack;
+    
+    private void putIndent() {
+        StringBuilder sb = new StringBuilder("");
+        for (int idx = 0; idx < indent; idx++) {
+            sb.append("  ");
+        }
+        stream.print(sb.toString());
+    }
+    
+    private void addIndent() {
+        indent++;
+    }
+    
+    private void closeIndent() {
+        indent--;
+    }
+    
+    private void printBeginEnvelope(String tag) {
+        if (!compoundStack.empty()) {
+            String s = compoundStack.peek();
+            if ("struct".equals(s)) {
+                putIndent();
+                stream.print("<member>\n");
+                addIndent();
+                putIndent();
+                stream.print("<name>"+tag+"</name>\n");
+                putIndent();
+                stream.print("<value>");
+            } else if ("vector".equals(s)) {
+                stream.print("<value>");
+            } else if ("map".equals(s)) {
+                stream.print("<value>");
+            }
+        } else {
+            stream.print("<value>");
+        }
+    }
+    
+    private void printEndEnvelope(String tag) {
+        if (!compoundStack.empty()) {
+            String s = compoundStack.peek();
+            if ("struct".equals(s)) {
+                stream.print("</value>\n");
+                closeIndent();
+                putIndent();
+                stream.print("</member>\n");
+            } else if ("vector".equals(s)) {
+                stream.print("</value>\n");
+            } else if ("map".equals(s)) {
+                stream.print("</value>\n");
+            }
+        } else {
+            stream.print("</value>\n");
+        }
+    }
+    
+    private void insideVector(String tag) {
+        printBeginEnvelope(tag);
+        compoundStack.push("vector");
+    }
+    
+    private void outsideVector(String tag) throws IOException {
+        String s = compoundStack.pop();
+        if (!"vector".equals(s)) {
+            throw new IOException("Error serializing vector.");
+        }
+        printEndEnvelope(tag);
+    }
+    
+    private void insideMap(String tag) {
+        printBeginEnvelope(tag);
+        compoundStack.push("map");
+    }
+    
+    private void outsideMap(String tag) throws IOException {
+        String s = compoundStack.pop();
+        if (!"map".equals(s)) {
+            throw new IOException("Error serializing map.");
+        }
+        printEndEnvelope(tag);
+    }
+    
+    private void insideRecord(String tag) {
+        printBeginEnvelope(tag);
+        compoundStack.push("struct");
+    }
+    
+    private void outsideRecord(String tag) throws IOException {
+        String s = compoundStack.pop();
+        if (!"struct".equals(s)) {
+            throw new IOException("Error serializing record.");
+        }
+        printEndEnvelope(tag);
+    }
+    
+    static XmlOutputArchive getArchive(OutputStream strm) {
+        return new XmlOutputArchive(strm);
+    }
+    
+    /** Creates a new instance of XmlOutputArchive */
+    public XmlOutputArchive(OutputStream out) {
+        stream = new PrintStream(out);
+        compoundStack = new Stack<String>();
+    }
+    
+    public void writeByte(byte b, String tag) throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<ex:i1>");
+        stream.print(Byte.toString(b));
+        stream.print("</ex:i1>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeBool(boolean b, String tag) throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<boolean>");
+        stream.print(b ? "1" : "0");
+        stream.print("</boolean>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeInt(int i, String tag) throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<i4>");
+        stream.print(Integer.toString(i));
+        stream.print("</i4>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeLong(long l, String tag) throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<ex:i8>");
+        stream.print(Long.toString(l));
+        stream.print("</ex:i8>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeFloat(float f, String tag) throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<ex:float>");
+        stream.print(Float.toString(f));
+        stream.print("</ex:float>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeDouble(double d, String tag) throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<double>");
+        stream.print(Double.toString(d));
+        stream.print("</double>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeString(String s, String tag) throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<string>");
+        stream.print(Utils.toXMLString(s));
+        stream.print("</string>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeBuffer(byte buf[], String tag)
+    throws IOException {
+        printBeginEnvelope(tag);
+        stream.print("<string>");
+        stream.print(Utils.toXMLBuffer(buf));
+        stream.print("</string>");
+        printEndEnvelope(tag);
+    }
+    
+    public void writeRecord(Record r, String tag) throws IOException {
+        r.serialize(this, tag);
+    }
+    
+    public void startRecord(Record r, String tag) throws IOException {
+        insideRecord(tag);
+        stream.print("<struct>\n");
+        addIndent();
+    }
+    
+    public void endRecord(Record r, String tag) throws IOException {
+        closeIndent();
+        putIndent();
+        stream.print("</struct>");
+        outsideRecord(tag);
+    }
+    
+    public void startVector(List<?> v, String tag) throws IOException {
+        insideVector(tag);
+        stream.print("<array>\n");
+        addIndent();
+    }
+    
+    public void endVector(List<?> v, String tag) throws IOException {
+        closeIndent();
+        putIndent();
+        stream.print("</array>");
+        outsideVector(tag);
+    }
+    
+    public void startMap(TreeMap<?,?> v, String tag) throws IOException {
+        insideMap(tag);
+        stream.print("<array>\n");
+        addIndent();
+    }
+    
+    public void endMap(TreeMap<?,?> v, String tag) throws IOException {
+        closeIndent();
+        putIndent();
+        stream.print("</array>");
+        outsideMap(tag);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/CGenerator.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/CGenerator.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/CGenerator.java
new file mode 100644
index 0000000..ef5dd54
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/CGenerator.java
@@ -0,0 +1,129 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * C++ Code generator front-end for Hadoop record I/O.
+ */
+class CGenerator {
+    private String mName;
+    private List<JFile> mInclFiles;
+    private List<JRecord> mRecList;
+    private final File outputDirectory;
+
+    /** Creates a new instance of CppGenerator
+     *
+     * @param name possibly full pathname to the file
+     * @param ilist included files (as JFile)
+     * @param rlist List of records defined within this file
+     * @param outputDirectory
+     */
+    CGenerator(String name, List<JFile> ilist, List<JRecord> rlist,
+            File outputDirectory)
+    {
+        this.outputDirectory = outputDirectory;
+        mName = (new File(name)).getName();
+        mInclFiles = ilist;
+        mRecList = rlist;
+    }
+
+    /**
+     * Generate C++ code. This method only creates the requested file(s)
+     * and spits-out file-level elements (such as include statements etc.)
+     * record-level code is generated by JRecord.
+     */
+    void genCode() throws IOException {
+        if (!outputDirectory.exists()) {
+            if (!outputDirectory.mkdirs()) {
+                throw new IOException("unable to create output directory "
+                        + outputDirectory);
+            }
+        }
+
+        try (FileWriter c = new FileWriter(new File(outputDirectory, mName + ".c"));
+             FileWriter h = new FileWriter(new File(outputDirectory, mName + ".h"));
+        ) {
+            h.write("/**\n");
+            h.write("* Licensed to the Apache Software Foundation (ASF) under one\n");
+            h.write("* or more contributor license agreements.  See the NOTICE file\n");
+            h.write("* distributed with this work for additional information\n");
+            h.write("* regarding copyright ownership.  The ASF licenses this file\n");
+            h.write("* to you under the Apache License, Version 2.0 (the\n");
+            h.write("* \"License\"); you may not use this file except in compliance\n");
+            h.write("* with the License.  You may obtain a copy of the License at\n");
+            h.write("*\n");
+            h.write("*     http://www.apache.org/licenses/LICENSE-2.0\n");
+            h.write("*\n");
+            h.write("* Unless required by applicable law or agreed to in writing, software\n");
+            h.write("* distributed under the License is distributed on an \"AS IS\" BASIS,\n");
+            h.write("* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
+            h.write("* See the License for the specific language governing permissions and\n");
+            h.write("* limitations under the License.\n");
+            h.write("*/\n");
+            h.write("\n");
+
+            c.write("/**\n");
+            c.write("* Licensed to the Apache Software Foundation (ASF) under one\n");
+            c.write("* or more contributor license agreements.  See the NOTICE file\n");
+            c.write("* distributed with this work for additional information\n");
+            c.write("* regarding copyright ownership.  The ASF licenses this file\n");
+            c.write("* to you under the Apache License, Version 2.0 (the\n");
+            c.write("* \"License\"); you may not use this file except in compliance\n");
+            c.write("* with the License.  You may obtain a copy of the License at\n");
+            c.write("*\n");
+            c.write("*     http://www.apache.org/licenses/LICENSE-2.0\n");
+            c.write("*\n");
+            c.write("* Unless required by applicable law or agreed to in writing, software\n");
+            c.write("* distributed under the License is distributed on an \"AS IS\" BASIS,\n");
+            c.write("* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
+            c.write("* See the License for the specific language governing permissions and\n");
+            c.write("* limitations under the License.\n");
+            c.write("*/\n");
+            c.write("\n");
+
+            h.write("#ifndef __" + mName.toUpperCase().replace('.', '_') + "__\n");
+            h.write("#define __" + mName.toUpperCase().replace('.', '_') + "__\n");
+
+            h.write("#include \"recordio.h\"\n");
+            for (Iterator<JFile> i = mInclFiles.iterator(); i.hasNext(); ) {
+                JFile f = i.next();
+                h.write("#include \"" + f.getName() + ".h\"\n");
+            }
+            // required for compilation from C++
+            h.write("\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
+
+            c.write("#include <stdlib.h>\n"); // need it for calloc() & free()
+            c.write("#include \"" + mName + ".h\"\n\n");
+
+            for (Iterator<JRecord> i = mRecList.iterator(); i.hasNext(); ) {
+                JRecord jr = i.next();
+                jr.genCCode(h, c);
+            }
+
+            h.write("\n#ifdef __cplusplus\n}\n#endif\n\n");
+            h.write("#endif //" + mName.toUpperCase().replace('.', '_') + "__\n");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/CSharpGenerator.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/CSharpGenerator.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/CSharpGenerator.java
new file mode 100644
index 0000000..f59cdb2
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/CSharpGenerator.java
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+public class CSharpGenerator {
+    private List<JRecord> mRecList;
+    private final File outputDirectory;
+
+    /** Creates a new instance of CSharpGenerator
+     *
+     * @param name possibly full pathname to the file
+     * @param ilist included files (as JFile)
+     * @param rlist List of records defined within this file
+     * @param outputDirectory
+     */
+    CSharpGenerator(String name, List<JFile> ilist, List<JRecord> rlist,
+            File outputDirectory)
+     {
+        this.outputDirectory = outputDirectory;
+        mRecList = rlist;
+    }
+
+    /**
+     * Generate C# code. This method only creates the requested file(s)
+     * and spits-out file-level elements (such as include statements etc.)
+     * record-level code is generated by JRecord.
+     */
+    void genCode() throws IOException {
+        for (JRecord rec : mRecList) {
+            rec.genCsharpCode(outputDirectory);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/CppGenerator.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/CppGenerator.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/CppGenerator.java
new file mode 100644
index 0000000..3f5ccb3
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/CppGenerator.java
@@ -0,0 +1,124 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * C++ Code generator front-end for Hadoop record I/O.
+ */
+class CppGenerator {
+    private String mName;
+    private List<JFile> mInclFiles;
+    private List<JRecord> mRecList;
+    private final File outputDirectory;
+
+    /** Creates a new instance of CppGenerator
+     *
+     * @param name possibly full pathname to the file
+     * @param ilist included files (as JFile)
+     * @param rlist List of records defined within this file
+     * @param outputDirectory
+     */
+    CppGenerator(String name, List<JFile> ilist, List<JRecord> rlist,
+            File outputDirectory)
+     {
+        this.outputDirectory = outputDirectory;
+        mName = (new File(name)).getName();
+        mInclFiles = ilist;
+        mRecList = rlist;
+    }
+
+    /**
+     * Generate C++ code. This method only creates the requested file(s)
+     * and spits-out file-level elements (such as include statements etc.)
+     * record-level code is generated by JRecord.
+     */
+    void genCode() throws IOException {
+        if (!outputDirectory.exists()) {
+            if (!outputDirectory.mkdirs()) {
+                throw new IOException("unable to create output directory "
+                        + outputDirectory);
+            }
+        }
+
+        try (FileWriter cc = new FileWriter(new File(outputDirectory, mName + ".cc"));
+             FileWriter hh = new FileWriter(new File(outputDirectory, mName + ".hh"));
+        ) {
+            hh.write("/**\n");
+            hh.write("* Licensed to the Apache Software Foundation (ASF) under one\n");
+            hh.write("* or more contributor license agreements.  See the NOTICE file\n");
+            hh.write("* distributed with this work for additional information\n");
+            hh.write("* regarding copyright ownership.  The ASF licenses this file\n");
+            hh.write("* to you under the Apache License, Version 2.0 (the\n");
+            hh.write("* \"License\"); you may not use this file except in compliance\n");
+            hh.write("* with the License.  You may obtain a copy of the License at\n");
+            hh.write("*\n");
+            hh.write("*     http://www.apache.org/licenses/LICENSE-2.0\n");
+            hh.write("*\n");
+            hh.write("* Unless required by applicable law or agreed to in writing, software\n");
+            hh.write("* distributed under the License is distributed on an \"AS IS\" BASIS,\n");
+            hh.write("* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
+            hh.write("* See the License for the specific language governing permissions and\n");
+            hh.write("* limitations under the License.\n");
+            hh.write("*/\n");
+            hh.write("\n");
+
+            cc.write("/**\n");
+            cc.write("* Licensed to the Apache Software Foundation (ASF) under one\n");
+            cc.write("* or more contributor license agreements.  See the NOTICE file\n");
+            cc.write("* distributed with this work for additional information\n");
+            cc.write("* regarding copyright ownership.  The ASF licenses this file\n");
+            cc.write("* to you under the Apache License, Version 2.0 (the\n");
+            cc.write("* \"License\"); you may not use this file except in compliance\n");
+            cc.write("* with the License.  You may obtain a copy of the License at\n");
+            cc.write("*\n");
+            cc.write("*     http://www.apache.org/licenses/LICENSE-2.0\n");
+            cc.write("*\n");
+            cc.write("* Unless required by applicable law or agreed to in writing, software\n");
+            cc.write("* distributed under the License is distributed on an \"AS IS\" BASIS,\n");
+            cc.write("* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
+            cc.write("* See the License for the specific language governing permissions and\n");
+            cc.write("* limitations under the License.\n");
+            cc.write("*/\n");
+            cc.write("\n");
+
+            hh.write("#ifndef __" + mName.toUpperCase().replace('.', '_') + "__\n");
+            hh.write("#define __" + mName.toUpperCase().replace('.', '_') + "__\n");
+
+            hh.write("#include \"recordio.hh\"\n");
+            for (Iterator<JFile> i = mInclFiles.iterator(); i.hasNext(); ) {
+                JFile f = i.next();
+                hh.write("#include \"" + f.getName() + ".hh\"\n");
+            }
+            cc.write("#include \"" + mName + ".hh\"\n");
+
+            for (Iterator<JRecord> i = mRecList.iterator(); i.hasNext(); ) {
+                JRecord jr = i.next();
+                jr.genCppCode(hh, cc);
+            }
+
+            hh.write("#endif //" + mName.toUpperCase().replace('.', '_') + "__\n");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBoolean.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBoolean.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBoolean.java
new file mode 100644
index 0000000..b45b161
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBoolean.java
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JBoolean extends JType {
+    
+    /** Creates a new instance of JBoolean */
+    public JBoolean() {
+        super("int32_t", "bool", "bool", "boolean", "Bool", "Boolean", "bool", "toBoolean");
+    }
+    
+    public String getSignature() {
+        return "z";
+    }
+    
+    public String genJavaCompareTo(String fname) {
+        return "    ret = ("+fname+" == peer."+fname+")? 0 : ("+fname+"?1:-1);\n";
+    }
+    
+    public String genJavaHashCode(String fname) {
+        return "     ret = ("+fname+")?0:1;\n";
+    }
+
+    String genCsharpHashCode(String fname) {
+        return "     ret = ("+capitalize(fname)+")?0:1;\n";
+    }
+
+    String genCsharpCompareTo(String name) {
+        return "    ret = ("+capitalize(name)+" == peer."+capitalize(name)+")? 0 : ("+capitalize(name)+"?1:-1);\n";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java
new file mode 100644
index 0000000..b2be5bd
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JBuffer.java
@@ -0,0 +1,106 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JBuffer extends JCompType {
+    
+    /** Creates a new instance of JBuffer */
+    public JBuffer() {
+        super("struct buffer", " ::std::string", "byte[]", "byte[]", "Buffer", "byte[]", "byte[]");
+    }
+    
+    public String genCppGetSet(String fname, int fIdx) {
+        String cgetFunc = "  virtual const "+getCppType()+"& get"+fname+"() const {\n";
+        cgetFunc += "    return m"+fname+";\n";
+        cgetFunc += "  }\n";
+        String getFunc = "  virtual "+getCppType()+"& get"+fname+"() {\n";
+        getFunc += "    bs_.set("+fIdx+");return m"+fname+";\n";
+        getFunc += "  }\n";
+        return cgetFunc + getFunc;
+    }
+    
+    public String getSignature() {
+        return "B";
+    }
+    
+    public String genJavaReadWrapper(String fname, String tag, boolean decl) {
+        String ret = "";
+        if (decl) {
+            ret = "    byte[] "+fname+";\n";
+        }
+        return ret + "        "+fname+"=a_.readBuffer(\""+tag+"\");\n";
+    }
+    
+    public String genJavaWriteWrapper(String fname, String tag) {
+        return "        a_.writeBuffer("+fname+",\""+tag+"\");\n";
+    }
+    
+    public String genJavaCompareTo(String fname, String other) {
+      StringBuilder sb = new StringBuilder();
+      sb.append("    {\n");
+      sb.append("      byte[] my = "+fname+";\n");
+      sb.append("      byte[] ur = "+other+";\n");
+      sb.append("      ret = org.apache.jute.Utils.compareBytes(my,0,my.length,ur,0,ur.length);\n");
+      sb.append("    }\n");
+      return sb.toString();
+    }
+    
+    public String genJavaCompareTo(String fname) {
+        return genJavaCompareTo(fname, "peer."+fname);
+    }
+    public String genJavaCompareToWrapper(String fname, String other) {
+      return "    "+genJavaCompareTo(fname, other);
+    }
+    
+    public String genJavaEquals(String fname, String peer) {
+        return "    ret = org.apache.jute.Utils.bufEquals("+fname+","+peer+");\n";
+    }
+    
+    public String genJavaHashCode(String fname) {
+        return "    ret = java.util.Arrays.toString("+fname+").hashCode();\n";
+    }
+    
+    public String genJavaSlurpBytes(String b, String s, String l) {
+      StringBuilder sb = new StringBuilder();
+      sb.append("        {\n");
+      sb.append("           int i = org.apache.jute.Utils.readVInt("+b+", "+s+");\n");
+      sb.append("           int z = WritableUtils.getVIntSize(i);\n");
+      sb.append("           "+s+" += z+i; "+l+" -= (z+i);\n");
+      sb.append("        }\n");
+      return sb.toString();
+    }
+    
+    public String genJavaCompareBytes() {
+      StringBuilder sb = new StringBuilder();
+      sb.append("        {\n");
+      sb.append("           int i1 = org.apache.jute.Utils.readVInt(b1, s1);\n");
+      sb.append("           int i2 = org.apache.jute.Utils.readVInt(b2, s2);\n");
+      sb.append("           int z1 = WritableUtils.getVIntSize(i1);\n");
+      sb.append("           int z2 = WritableUtils.getVIntSize(i2);\n");
+      sb.append("           s1+=z1; s2+=z2; l1-=z1; l2-=z2;\n");
+      sb.append("           int r1 = org.apache.jute.Utils.compareBytes(b1,s1,l1,b2,s2,l2);\n");
+      sb.append("           if (r1 != 0) { return (r1<0)?-1:0; }\n");
+      sb.append("           s1+=i1; s2+=i2; l1-=i1; l1-=i2;\n");
+      sb.append("        }\n");
+      return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JByte.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JByte.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JByte.java
new file mode 100644
index 0000000..4b1cea4
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JByte.java
@@ -0,0 +1,34 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JByte extends JType {
+    
+    /** Creates a new instance of JByte */
+    public JByte() {
+        super("char", "int8_t", "byte", "byte", "Byte", "Byte", "byte", "toByte");
+    }
+    
+    public String getSignature() {
+        return "b";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JCompType.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JCompType.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JCompType.java
new file mode 100644
index 0000000..d98658f
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JCompType.java
@@ -0,0 +1,66 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ * Abstract base class for all the "compound" types such as ustring,
+ * buffer, vector, map, and record.
+ */
+abstract class JCompType extends JType {
+    
+    /** Creates a new instance of JCompType */
+    JCompType(String cType, String cppType, String csharpType, String javaType, String suffix, String wrapper, String csharpWrapper) {
+        super(cType, cppType, csharpType, javaType, suffix, wrapper, csharpWrapper, null);
+    }
+    
+    String genCppGetSet(String fname, int fIdx) {
+        String cgetFunc = "  virtual const "+getCppType()+"& get"+fname+"() const {\n";
+        cgetFunc += "    return m"+fname+";\n";
+        cgetFunc += "  }\n";
+        String getFunc = "  virtual "+getCppType()+"& get"+fname+"() {\n";
+        getFunc += "    bs_.set("+fIdx+");return m"+fname+";\n";
+        getFunc += "  }\n";
+        return cgetFunc + getFunc;
+    }
+    
+    String genJavaCompareTo(String fname) {
+        return "    ret = "+fname+".compareTo(peer."+fname+");\n";
+    }
+    
+    String genJavaEquals(String fname, String peer) {
+        return "    ret = "+fname+".equals("+peer+");\n";
+    }
+    
+    String genJavaHashCode(String fname) {
+        return "    ret = "+fname+".hashCode();\n";
+    }
+
+    String genCsharpHashCode(String fname) {
+        return "    ret = "+capitalize(fname)+".GetHashCode();\n";
+    }
+
+    String genCsharpEquals(String name, String peer) {
+        String[] peerSplit = peer.split("\\.");
+        return "    ret = "+capitalize(name)+".Equals("+peerSplit[0] + "." + capitalize(peerSplit[1]) + ");\n";
+    }
+
+    String genCsharpCompareTo(String name) {
+        return "    ret = "+capitalize(name)+".CompareTo(peer."+capitalize(name)+");\n";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JDouble.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JDouble.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JDouble.java
new file mode 100644
index 0000000..21f9cc8
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JDouble.java
@@ -0,0 +1,40 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JDouble extends JType {
+    
+    /** Creates a new instance of JDouble */
+    public JDouble() {
+        super("double", "double", "double", "double", "Double", "Double", "double", "toDouble");
+    }
+    
+    public String getSignature() {
+        return "d";
+    }
+    
+    public String genJavaHashCode(String fname) {
+        String tmp = "Double.doubleToLongBits("+fname+")";
+        return "    ret = (int)("+tmp+"^("+tmp+">>>32));\n";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JField.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JField.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JField.java
new file mode 100644
index 0000000..50f9fc9
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JField.java
@@ -0,0 +1,140 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JField {
+    private JType mType;
+    private String mName;
+    /**
+     * Creates a new instance of JField
+     */
+    public JField(JType type, String name) {
+        mType = type;
+        mName = name;
+    }
+    
+    public String getSignature() {
+        return mType.getSignature();
+    }
+    
+    public String genCppDecl() {
+        return mType.genCppDecl(mName);
+    }
+    
+	public String genCDecl() {
+		return mType.genCDecl(mName);
+	}
+
+    public String genCsharpDecl() {
+        return mType.genCsharpDecl(mName);
+    }
+
+    public String genCsharpConstructorParam(String fname) {
+        return mType.genCsharpConstructorParam(fname);
+    }
+	
+    public String genJavaDecl() {
+        return mType.genJavaDecl(mName);
+    }
+    
+    public String genJavaConstructorParam(String fname) {
+        return mType.genJavaConstructorParam(fname);
+    }
+    
+    public String getName() {
+        return mName;
+    }
+
+    public String getCsharpName() {
+        return "Id".equals(mName) ? "ZKId" : mName;
+    }
+    
+    public String getTag() {
+        return mName;
+    }
+    
+    public JType getType() {
+        return mType;
+    }
+    
+    public String genCppGetSet(int fIdx) {
+        return mType.genCppGetSet(mName, fIdx);
+    }
+
+    public String genCsharpConstructorSet(String fname) {
+        return mType.genCsharpConstructorSet(mName, fname);
+    }
+
+    public String genCsharpGetSet(int fIdx) {
+        return mType.genCsharpGetSet(getCsharpName(), fIdx);
+    }
+
+    public String genCsharpWriteMethodName() {
+        return mType.genCsharpWriteMethod(getCsharpName(), getTag());
+    }
+
+    public String genCsharpReadMethodName() {
+        return mType.genCsharpReadMethod(getCsharpName(), getTag());
+    }
+
+    public String genCsharpCompareTo() {
+        return mType.genCsharpCompareTo(getCsharpName());
+    }
+
+    public String genCsharpEquals() {
+        return mType.genCsharpEquals(getCsharpName(), "peer."+getCsharpName());
+    }
+
+    public String genCsharpHashCode() {
+        return mType.genCsharpHashCode(getCsharpName());
+    }
+
+    
+    public String genJavaGetSet(int fIdx) {
+        return mType.genJavaGetSet(mName, fIdx);
+    }
+    
+    public String genJavaWriteMethodName() {
+        return mType.genJavaWriteMethod(getName(), getTag());
+    }
+    
+    public String genJavaReadMethodName() {
+        return mType.genJavaReadMethod(getName(), getTag());
+    }
+    
+    public String genJavaCompareTo() {
+        return mType.genJavaCompareTo(getName());
+    }
+    
+    public String genJavaEquals() {
+        return mType.genJavaEquals(getName(), "peer."+getName());
+    }
+    
+    public String genJavaHashCode() {
+        return mType.genJavaHashCode(getName());
+    }
+
+    public String genJavaConstructorSet(String fname) {
+        return mType.genJavaConstructorSet(mName, fname);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFile.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFile.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFile.java
new file mode 100644
index 0000000..ae59490
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFile.java
@@ -0,0 +1,85 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Container for the Hadoop Record DDL.
+ * The main components of the file are filename, list of included files,
+ * and records defined in that file.
+ *
+ */
+public class JFile {
+    
+    private String mName;
+    private List<JFile> mInclFiles;
+    private List<JRecord> mRecords;
+    
+    /** Creates a new instance of JFile
+     *
+     * @param name possibly full pathname to the file
+     * @param inclFiles included files (as JFile)
+     * @param recList List of records defined within this file
+     */
+    public JFile(String name, ArrayList<JFile> inclFiles,
+            ArrayList<JRecord> recList)
+    {
+        mName = name;
+        mInclFiles = inclFiles;
+        mRecords = recList;
+    }
+    
+    /** Strip the other pathname components and return the basename */
+    String getName() {
+        int idx = mName.lastIndexOf('/');
+        return (idx > 0) ? mName.substring(idx) : mName; 
+    }
+    
+    /** Generate record code in given language. Language should be all
+     *  lowercase.
+     * @param outputDirectory 
+     */
+    public void genCode(String language, File outputDirectory)
+        throws IOException
+    {
+        if ("c++".equals(language)) {
+            CppGenerator gen = new CppGenerator(mName, mInclFiles, mRecords,
+                    outputDirectory);
+            gen.genCode();
+        } else if ("java".equals(language)) {
+            JavaGenerator gen = new JavaGenerator(mName, mInclFiles, mRecords,
+                    outputDirectory);
+            gen.genCode();
+        } else if ("c".equals(language)) {
+        	CGenerator gen = new CGenerator(mName, mInclFiles, mRecords,
+        	        outputDirectory);
+        	gen.genCode();
+        } else if ("csharp".equals(language)) {
+        	CSharpGenerator gen = new CSharpGenerator(mName, mInclFiles, mRecords,
+        	        outputDirectory);
+        	gen.genCode();
+        } else {
+            throw new IOException("Cannnot recognize language:" + language);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFloat.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFloat.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFloat.java
new file mode 100644
index 0000000..a4be6ec
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JFloat.java
@@ -0,0 +1,39 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JFloat extends JType {
+    
+    /** Creates a new instance of JFloat */
+    public JFloat() {
+        super("float", "float", "float", "float", "Float", "Float", "float", "toFloat");
+    }
+    
+    public String getSignature() {
+        return "f";
+    }
+    
+    public String genJavaHashCode(String fname) {
+        return "    ret = Float.floatToIntBits("+fname+");\n";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JInt.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JInt.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JInt.java
new file mode 100644
index 0000000..23b902e
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JInt.java
@@ -0,0 +1,34 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JInt extends JType {
+    
+    /** Creates a new instance of JInt */
+    public JInt() {
+        super("int32_t", "int32_t", "int", "int", "Int", "Integer", "int", "toInt");
+    }
+    
+    public String getSignature() {
+        return "i";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JLong.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JLong.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JLong.java
new file mode 100644
index 0000000..342fd9a
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JLong.java
@@ -0,0 +1,38 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JLong extends JType {
+    
+    /** Creates a new instance of JLong */
+    public JLong() {
+        super("int64_t", "int64_t", "long", "long", "Long", "Long", "long", "toLong");
+    }
+    
+    public String getSignature() {
+        return "l";
+    }
+    
+    public String genJavaHashCode(String fname) {
+        return "    ret = (int) ("+fname+"^("+fname+">>>32));\n";
+    }
+}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/b7181d2c/zookeeper-jute/src/main/java/org/apache/jute/compiler/JMap.java
----------------------------------------------------------------------
diff --git a/zookeeper-jute/src/main/java/org/apache/jute/compiler/JMap.java b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JMap.java
new file mode 100644
index 0000000..cc503be
--- /dev/null
+++ b/zookeeper-jute/src/main/java/org/apache/jute/compiler/JMap.java
@@ -0,0 +1,149 @@
+/**
+ * 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.
+ */
+
+package org.apache.jute.compiler;
+
+/**
+ *
+ */
+public class JMap extends JCompType {
+   
+    static private int level = 0;
+    
+    static private String getLevel() { return Integer.toString(level); }
+    
+    static private void incrLevel() { level++; }
+    
+    static private void decrLevel() { level--; }
+    
+    static private String getId(String id) { return id+getLevel(); }
+    
+    private JType mKey;
+    private JType mValue;
+    
+    /** Creates a new instance of JMap */
+    public JMap(JType t1, JType t2) {
+        super("#error", " ::std::map<"+t1.getCppType()+","+t2.getCppType()+">",
+                "System.Collections.Generic.SortedDictionary<string, string>", "java.util.TreeMap", "Map", "System.Collections.Generic.SortedDictionary<string, string>", "java.util.TreeMap");
+        mKey = t1;
+        mValue = t2;
+    }
+    
+    public String getSignature() {
+        return "{" + mKey.getSignature() + mValue.getSignature() +"}";
+    }
+    
+    public String genJavaCompareTo(String fname) {
+        return "    throw new UnsupportedOperationException(\"comparing "
+            + fname + " is unimplemented\");\n";
+    }
+    
+    public String genJavaReadWrapper(String fname, String tag, boolean decl) {
+        StringBuilder ret = new StringBuilder("");
+        if (decl) {
+            ret.append("    java.util.TreeMap "+fname+";\n");
+        }
+        ret.append("    {\n");
+        incrLevel();
+        ret.append("      org.apache.jute.Index "+getId("midx")+" = a_.startMap(\""+tag+"\");\n");
+        ret.append("      "+fname+"=new java.util.TreeMap();\n");
+        ret.append("      for (; !"+getId("midx")+".done(); "+getId("midx")+".incr()) {\n");
+        ret.append(mKey.genJavaReadWrapper(getId("k"),getId("k"),true));
+        ret.append(mValue.genJavaReadWrapper(getId("v"),getId("v"),true));
+        ret.append("        "+fname+".put("+getId("k")+","+getId("v")+");\n");
+        ret.append("      }\n");
+        ret.append("    a_.endMap(\""+tag+"\");\n");
+        decrLevel();
+        ret.append("    }\n");
+        return ret.toString();
+    }
+    
+    public String genJavaReadMethod(String fname, String tag) {
+        return genJavaReadWrapper(fname, tag, false);
+    }
+    
+    public String genJavaWriteWrapper(String fname, String tag) {
+        StringBuilder ret = new StringBuilder("    {\n");
+        incrLevel();
+        ret.append("      a_.startMap("+fname+",\""+tag+"\");\n");
+        ret.append("      java.util.Set "+getId("es")+" = "+fname+".entrySet();\n");
+        ret.append("      for(java.util.Iterator "+getId("midx")+" = "+getId("es")+".iterator(); "+getId("midx")+".hasNext(); ) {\n");
+        ret.append("        java.util.Map.Entry "+getId("me")+" = (java.util.Map.Entry) "+getId("midx")+".next();\n");
+        ret.append("        "+mKey.getJavaWrapperType()+" "+getId("k")+" = ("+mKey.getJavaWrapperType()+") "+getId("me")+".getKey();\n");
+        ret.append("        "+mValue.getJavaWrapperType()+" "+getId("v")+" = ("+mValue.getJavaWrapperType()+") "+getId("me")+".getValue();\n");
+        ret.append(mKey.genJavaWriteWrapper(getId("k"),getId("k")));
+        ret.append(mValue.genJavaWriteWrapper(getId("v"),getId("v")));
+        ret.append("      }\n");
+        ret.append("      a_.endMap("+fname+",\""+tag+"\");\n");
+        ret.append("    }\n");
+        decrLevel();
+        return ret.toString();
+    }
+    
+    public String genJavaWriteMethod(String fname, String tag) {
+        return genJavaWriteWrapper(fname, tag);
+    }
+
+    public String genCsharpWriteWrapper(String fname, int tag) {
+        StringBuilder ret = new StringBuilder("    {\n");
+        incrLevel();
+        ret.append("      a_.StartMap("+fname+",\""+tag+"\");\n");
+        ret.append("      java.util.Set "+getId("es")+" = "+fname+".entrySet();\n");
+        ret.append("      for(java.util.Iterator "+getId("midx")+" = "+getId("es")+".iterator(); "+getId("midx")+".hasNext(); ) {\n");
+        ret.append("        java.util.Map.Entry "+getId("me")+" = (java.util.Map.Entry) "+getId("midx")+".next();\n");
+        ret.append("        "+mKey.getCsharpWrapperType()+" "+getId("k")+" = ("+mKey.getCsharpWrapperType()+") "+getId("me")+".getKey();\n");
+        ret.append("        "+mValue.getCsharpWrapperType()+" "+getId("v")+" = ("+mValue.getCsharpWrapperType()+") "+getId("me")+".getValue();\n");
+        ret.append(mKey.genCsharpWriteWrapper(getId("k"),getId("k")));
+        ret.append(mValue.genCsharpWriteWrapper(getId("v"),getId("v")));
+        ret.append("      }\n");
+        ret.append("      a_.EndMap("+fname+",\""+tag+"\");\n");
+        ret.append("    }\n");
+        decrLevel();
+        return ret.toString();
+    }
+
+    String genCsharpWriteMethod(String fname, int tag) {
+        return genCsharpWriteWrapper(fname, tag);
+    }
+
+    public String genCsharpReadWrapper(String fname, int tag, boolean decl) {
+        StringBuilder ret = new StringBuilder("");
+        if (decl) {
+            ret.append("    System.Collections.SortedDictionary<string,string> "+capitalize(fname)+";\n");
+        }
+        ret.append("    {\n");
+        incrLevel();
+        ret.append("      Org.Apache.Jute.IIndex "+getId("midx")+" = a_.StartMap(\""+tag+"\");\n");
+        ret.append("      "+fname+"= new System.Collections.SortedDictionary<string,string>();\n");
+        ret.append("      for (; !"+getId("midx")+".done(); "+getId("midx")+".incr()) {\n");
+        ret.append(mKey.genCsharpReadWrapper(getId("k"),getId("k"),true));
+        ret.append(mValue.genCsharpReadWrapper(getId("v"),getId("v"),true));
+        ret.append("        "+fname+".Add("+getId("k")+","+getId("v")+");\n");
+        ret.append("      }\n");
+        ret.append("    a_.EndMap(\""+tag+"\");\n");
+        decrLevel();
+        ret.append("    }\n");
+        return ret.toString();
+    }
+
+
+
+    String genCsharpReadMethod(String fname, int tag) {
+        return genCsharpReadWrapper(fname, tag, false);
+    }
+}


Mime
View raw message