You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by an...@apache.org on 2018/09/04 14:02:32 UTC
[8/8] zookeeper git commit: ZOOKEEPER-3080_3.4: MAVEN MIGRATION -
Step 1.5 - move jute dir
ZOOKEEPER-3080_3.4: MAVEN MIGRATION - Step 1.5 - move jute dir
Author: Norbert Kalmar <nk...@yahoo.com>
Reviewers: andor@apache.org
Closes #616 from nkalmar/ZOOKEEPER-3080_3.4
Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/29cc5c1a
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/29cc5c1a
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/29cc5c1a
Branch: refs/heads/branch-3.4
Commit: 29cc5c1a7743cf126e3f9b7badb19cf3e80b69e6
Parents: 5694559
Author: Norbert Kalmar <nk...@yahoo.com>
Authored: Tue Sep 4 16:02:19 2018 +0200
Committer: Andor Molnar <an...@apache.org>
Committed: Tue Sep 4 16:02:19 2018 +0200
----------------------------------------------------------------------
build.xml | 36 +-
.../org/apache/jute/BinaryInputArchive.java | 130 ---
.../org/apache/jute/BinaryOutputArchive.java | 146 ----
.../main/org/apache/jute/CsvInputArchive.java | 208 -----
.../main/org/apache/jute/CsvOutputArchive.java | 150 ----
src/java/main/org/apache/jute/Index.java | 38 -
src/java/main/org/apache/jute/InputArchive.java | 43 -
.../main/org/apache/jute/OutputArchive.java | 47 --
src/java/main/org/apache/jute/Record.java | 35 -
src/java/main/org/apache/jute/RecordReader.java | 93 ---
src/java/main/org/apache/jute/RecordWriter.java | 113 ---
src/java/main/org/apache/jute/Utils.java | 282 -------
.../main/org/apache/jute/XmlInputArchive.java | 251 ------
.../main/org/apache/jute/XmlOutputArchive.java | 251 ------
.../org/apache/jute/compiler/CGenerator.java | 142 ----
.../apache/jute/compiler/CSharpGenerator.java | 53 --
.../org/apache/jute/compiler/CppGenerator.java | 136 ---
.../main/org/apache/jute/compiler/JBoolean.java | 50 --
.../main/org/apache/jute/compiler/JBuffer.java | 106 ---
.../main/org/apache/jute/compiler/JByte.java | 34 -
.../org/apache/jute/compiler/JCompType.java | 66 --
.../main/org/apache/jute/compiler/JDouble.java | 40 -
.../main/org/apache/jute/compiler/JField.java | 140 ----
.../main/org/apache/jute/compiler/JFile.java | 84 --
.../main/org/apache/jute/compiler/JFloat.java | 39 -
.../main/org/apache/jute/compiler/JInt.java | 34 -
.../main/org/apache/jute/compiler/JLong.java | 38 -
.../main/org/apache/jute/compiler/JMap.java | 149 ----
.../main/org/apache/jute/compiler/JRecord.java | 776 -----------------
.../main/org/apache/jute/compiler/JString.java | 46 -
.../main/org/apache/jute/compiler/JType.java | 204 -----
.../main/org/apache/jute/compiler/JVector.java | 153 ----
.../org/apache/jute/compiler/JavaGenerator.java | 57 --
.../jute/compiler/generated/ParseException.java | 210 -----
.../org/apache/jute/compiler/generated/Rcc.java | 525 ------------
.../jute/compiler/generated/RccConstants.java | 88 --
.../compiler/generated/RccTokenManager.java | 833 -------------------
.../compiler/generated/SimpleCharStream.java | 457 ----------
.../apache/jute/compiler/generated/Token.java | 99 ---
.../jute/compiler/generated/TokenMgrError.java | 151 ----
.../apache/jute/compiler/generated/package.html | 28 -
.../org/apache/jute/compiler/generated/rcc.jj | 374 ---------
.../main/org/apache/jute/compiler/package.html | 30 -
src/java/main/org/apache/jute/package.html | 801 ------------------
.../org/apache/jute/BinaryInputArchiveTest.java | 43 -
src/zookeeper.jute | 293 -------
.../org/apache/jute/BinaryInputArchive.java | 130 +++
.../org/apache/jute/BinaryOutputArchive.java | 146 ++++
.../java/org/apache/jute/CsvInputArchive.java | 208 +++++
.../java/org/apache/jute/CsvOutputArchive.java | 150 ++++
.../src/main/java/org/apache/jute/Index.java | 38 +
.../main/java/org/apache/jute/InputArchive.java | 43 +
.../java/org/apache/jute/OutputArchive.java | 47 ++
.../src/main/java/org/apache/jute/Record.java | 35 +
.../main/java/org/apache/jute/RecordReader.java | 93 +++
.../main/java/org/apache/jute/RecordWriter.java | 113 +++
.../src/main/java/org/apache/jute/Utils.java | 282 +++++++
.../java/org/apache/jute/XmlInputArchive.java | 251 ++++++
.../java/org/apache/jute/XmlOutputArchive.java | 251 ++++++
.../org/apache/jute/compiler/CGenerator.java | 142 ++++
.../apache/jute/compiler/CSharpGenerator.java | 53 ++
.../org/apache/jute/compiler/CppGenerator.java | 136 +++
.../java/org/apache/jute/compiler/JBoolean.java | 50 ++
.../java/org/apache/jute/compiler/JBuffer.java | 106 +++
.../java/org/apache/jute/compiler/JByte.java | 34 +
.../org/apache/jute/compiler/JCompType.java | 66 ++
.../java/org/apache/jute/compiler/JDouble.java | 40 +
.../java/org/apache/jute/compiler/JField.java | 140 ++++
.../java/org/apache/jute/compiler/JFile.java | 84 ++
.../java/org/apache/jute/compiler/JFloat.java | 39 +
.../java/org/apache/jute/compiler/JInt.java | 34 +
.../java/org/apache/jute/compiler/JLong.java | 38 +
.../java/org/apache/jute/compiler/JMap.java | 149 ++++
.../java/org/apache/jute/compiler/JRecord.java | 776 +++++++++++++++++
.../java/org/apache/jute/compiler/JString.java | 46 +
.../java/org/apache/jute/compiler/JType.java | 204 +++++
.../java/org/apache/jute/compiler/JVector.java | 153 ++++
.../org/apache/jute/compiler/JavaGenerator.java | 57 ++
.../jute/compiler/generated/ParseException.java | 210 +++++
.../org/apache/jute/compiler/generated/Rcc.java | 525 ++++++++++++
.../jute/compiler/generated/RccConstants.java | 88 ++
.../compiler/generated/RccTokenManager.java | 833 +++++++++++++++++++
.../compiler/generated/SimpleCharStream.java | 457 ++++++++++
.../apache/jute/compiler/generated/Token.java | 99 +++
.../jute/compiler/generated/TokenMgrError.java | 151 ++++
.../apache/jute/compiler/generated/package.html | 28 +
.../org/apache/jute/compiler/generated/rcc.jj | 374 +++++++++
.../java/org/apache/jute/compiler/package.html | 30 +
.../src/main/java/org/apache/jute/package.html | 801 ++++++++++++++++++
.../src/main/resources/zookeeper.jute | 293 +++++++
.../org/apache/jute/BinaryInputArchiveTest.java | 43 +
91 files changed, 8096 insertions(+), 8072 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 021c9b6..4618f5c 100644
--- a/build.xml
+++ b/build.xml
@@ -84,6 +84,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<property name="src.dir" value="${basedir}/src" />
<property name="java.src.dir" value="${src.dir}/java/main" />
+ <property name="jute.src.dir" value="${basedir}/zookeeper-jute/src/main/java" />
<property name="lib.dir" value="${src.dir}/java/lib" />
<property name="lib.dir.includes" value="**/*.jar" />
@@ -102,7 +103,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<property name="c.src.dir" value="${basedir}/zookeeper-client/zookeeper-client-c" />
<property name="csrc_generated.dir" value="${c.src.dir}/generated" />
- <property name="jute.file" value="${src.dir}/zookeeper.jute" />
+ <property name="jute.file" value="${basedir}/zookeeper-jute/src/main/resources/zookeeper.jute" />
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.docs" value="${build.dir}/docs" />
@@ -112,6 +113,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<property name="test.java.build.dir" value="${build.dir}/test"/>
<property name="test.java.classes" value="${test.java.build.dir}/classes"/>
<property name="test.src.dir" value="${src.dir}/java/test"/>
+ <property name="jute.test.src.dir" value="${basedir}/zookeeper-jute/src/test/java" />
<property name="systest.src.dir" value="${src.dir}/java/systest"/>
<property name="test.log.dir" value="${test.java.build.dir}/logs" />
<property name="test.data.dir" value="${test.java.build.dir}/data" />
@@ -311,7 +313,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
</target>
<target name="jute" depends="init">
- <javac srcdir="${java.src.dir}" destdir="${build.classes}" includeantruntime="false"
+ <javac srcdir="${jute.src.dir}" destdir="${build.classes}" includeantruntime="false"
target="${javac.target}" source="${javac.source}"
includes="org/apache/jute/**" debug="on" classpath="${ivy.lib}/audience-annotations-${audience-annotations.version}.jar" />
</target>
@@ -328,7 +330,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<java classname="org.apache.jute.compiler.generated.Rcc" fork="true" dir="${src_generated.dir}">
<arg value="-l" />
<arg value="java" />
- <arg value="../../zookeeper.jute" />
+ <arg value="../../../zookeeper-jute/src/main/resources/zookeeper.jute" />
<classpath>
<pathelement path="${build.classes}" />
</classpath>
@@ -337,7 +339,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<java classname="org.apache.jute.compiler.generated.Rcc" fork="true" dir="${csrc_generated.dir}">
<arg value="-l" />
<arg value="c" />
- <arg value="../../../src/zookeeper.jute" />
+ <arg value="../../../zookeeper-jute/src/main/resources/zookeeper.jute" />
<classpath>
<pathelement path="${build.classes}" />
</classpath>
@@ -454,8 +456,10 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
</target>
<target name="compile" depends="ivy-retrieve,clover,build-generated">
- <javac srcdir="${java.src.dir}" destdir="${build.classes}" includeantruntime="false"
+ <javac destdir="${build.classes}" includeantruntime="false"
target="${javac.target}" source="${javac.source}" debug="on">
+ <src path="${java.src.dir}"/>
+ <src path="${jute.src.dir}"/>
<classpath refid="java.classpath"/>
<compilerarg value="-Xlint:all"/>
<compilerarg value="-Xlint:-path"/>
@@ -464,8 +468,10 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<target name="compile-test" depends="ivy-retrieve-test,compile">
<mkdir dir="${test.java.classes}"/>
- <javac srcdir="${test.src.dir}" destdir="${test.java.classes}" includeantruntime="false"
+ <javac destdir="${test.java.classes}" includeantruntime="false"
target="${javac.target}" source="${javac.source}" debug="on">
+ <src path="${test.src.dir}"/>
+ <src path="${jute.test.src.dir}"/>
<classpath refid="test.java.classpath"/>
</javac>
<javac srcdir="${systest.src.dir}" destdir="${test.java.classes}" includeantruntime="false"
@@ -576,6 +582,9 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<include name="org/apache/**"/>
<exclude name="org/apache/zookeeper/server/**"/>
</packageset>
+ <packageset dir="${jute.src.dir}">
+ <include name="org/apache/**"/>
+ </packageset>
<packageset dir="${src_generated.dir}">
<include name="org/apache/**"/>
<exclude name="org/apache/zookeeper/proto"/>
@@ -610,6 +619,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<fileset file="LICENSE.txt" />
<fileset dir="${build.classes}" excludes="**/.generated"/>
<fileset dir="${java.src.dir}"/>
+ <fileset dir="${jute.src.dir}"/>
<fileset dir="${src_generated.dir}" excludes="**/.generated"/>
<manifest>
<attribute name="Main-Class" value="org.apache.zookeeper.server.quorum.QuorumPeerMain" />
@@ -684,6 +694,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<jar jarfile="${build.dir}/${final.name}-sources.jar">
<fileset file="LICENSE.txt" />
<fileset dir="${java.src.dir}"/>
+ <fileset dir="${jute.src.dir}"/>
<fileset dir="${src_generated.dir}" excludes="**/.generated"/>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
@@ -834,6 +845,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<include name="zookeeper-docs/**"/>
<include name="zookeeper-contrib/**"/>
<include name="zookeeper-client/**"/>
+ <include name="zookeeper-jute/**"/>
</fileset>
<fileset file="src/pom.template"/>
</copy>
@@ -1386,14 +1398,21 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<include name="**/*${test.category}Test.java"/>
<exclude name="**/*HammerTest.java"/>
</fileset>
+ <fileset dir="${jute.test.src.dir}">
+ <include name="**/*${test.category}Test.java" />
+ </fileset>
</batchtest>
<batchtest todir="${test.log.dir}" if="fulltest">
<fileset dir="${test.src.dir}">
<include name="**/*${test.category}Test.java"/>
</fileset>
+ <fileset dir="${jute.test.src.dir}">
+ <include name="**/*${test.category}Test.java" />
+ </fileset>
</batchtest>
<batchtest todir="${test.log.dir}" if="testcase">
<fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
+ <fileset dir="${jute.test.src.dir}" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<antcall target="fail.build.on.test.failure"/>
@@ -1709,6 +1728,9 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<fileset dir="${java.src.dir}">
<include name="**/*.java" />
</fileset>
+ <fileset dir="${jute.src.dir}">
+ <include name="**/*.java" />
+ </fileset>
<fileset dir="${src_generated.dir}">
<include name="**/*.java" />
</fileset>
@@ -1994,6 +2016,8 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
<classpath>
<source path="${java.src.dir}"
output="${build.dir.eclipse-main-classes}" />
+ <source path="${jute.src.dir}"
+ output="${build.dir.eclipse-main-classes}" />
<source path="${src_generated.dir}"
output="${build.dir.eclipse-main-classes}" />
<source path="${test.src.dir}"
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/BinaryInputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/BinaryInputArchive.java b/src/java/main/org/apache/jute/BinaryInputArchive.java
deleted file mode 100644
index 7722bff..0000000
--- a/src/java/main/org/apache/jute/BinaryInputArchive.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * 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.DataInput;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- *
- */
-public class BinaryInputArchive implements InputArchive {
- static public final String UNREASONBLE_LENGTH= "Unreasonable length = ";
- private DataInput in;
-
- static public BinaryInputArchive getArchive(InputStream strm) {
- return new BinaryInputArchive(new DataInputStream(strm));
- }
-
- static private class BinaryIndex implements Index {
- private int nelems;
- BinaryIndex(int nelems) {
- this.nelems = nelems;
- }
- public boolean done() {
- return (nelems <= 0);
- }
- public void incr() {
- nelems--;
- }
- }
- /** Creates a new instance of BinaryInputArchive */
- public BinaryInputArchive(DataInput in) {
- this.in = in;
- }
-
- public byte readByte(String tag) throws IOException {
- return in.readByte();
- }
-
- public boolean readBool(String tag) throws IOException {
- return in.readBoolean();
- }
-
- public int readInt(String tag) throws IOException {
- return in.readInt();
- }
-
- public long readLong(String tag) throws IOException {
- return in.readLong();
- }
-
- public float readFloat(String tag) throws IOException {
- return in.readFloat();
- }
-
- public double readDouble(String tag) throws IOException {
- return in.readDouble();
- }
-
- public String readString(String tag) throws IOException {
- int len = in.readInt();
- if (len == -1) return null;
- checkLength(len);
- byte b[] = new byte[len];
- in.readFully(b);
- return new String(b, "UTF8");
- }
-
- static public final int maxBuffer = Integer.getInteger("jute.maxbuffer", 0xfffff);
-
- public byte[] readBuffer(String tag) throws IOException {
- int len = readInt(tag);
- if (len == -1) return null;
- checkLength(len);
- byte[] arr = new byte[len];
- in.readFully(arr);
- return arr;
- }
-
- public void readRecord(Record r, String tag) throws IOException {
- r.deserialize(this, tag);
- }
-
- public void startRecord(String tag) throws IOException {}
-
- public void endRecord(String tag) throws IOException {}
-
- public Index startVector(String tag) throws IOException {
- int len = readInt(tag);
- if (len == -1) {
- return null;
- }
- return new BinaryIndex(len);
- }
-
- public void endVector(String tag) throws IOException {}
-
- public Index startMap(String tag) throws IOException {
- return new BinaryIndex(readInt(tag));
- }
-
- public void endMap(String tag) throws IOException {}
-
- // Since this is a rough sanity check, add some padding to maxBuffer to
- // make up for extra fields, etc. (otherwise e.g. clients may be able to
- // write buffers larger than we can read from disk!)
- private void checkLength(int len) throws IOException {
- if (len < 0 || len > maxBuffer + 1024) {
- throw new IOException(UNREASONBLE_LENGTH + len);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/BinaryOutputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/BinaryOutputArchive.java b/src/java/main/org/apache/jute/BinaryOutputArchive.java
deleted file mode 100644
index 213e203..0000000
--- a/src/java/main/org/apache/jute/BinaryOutputArchive.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * 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.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.TreeMap;
-
-/**
- *
- */
-public class BinaryOutputArchive implements OutputArchive {
- private ByteBuffer bb = ByteBuffer.allocate(1024);
-
- private DataOutput out;
-
- public static BinaryOutputArchive getArchive(OutputStream strm) {
- return new BinaryOutputArchive(new DataOutputStream(strm));
- }
-
- /** Creates a new instance of BinaryOutputArchive */
- public BinaryOutputArchive(DataOutput out) {
- this.out = out;
- }
-
- public void writeByte(byte b, String tag) throws IOException {
- out.writeByte(b);
- }
-
- public void writeBool(boolean b, String tag) throws IOException {
- out.writeBoolean(b);
- }
-
- public void writeInt(int i, String tag) throws IOException {
- out.writeInt(i);
- }
-
- public void writeLong(long l, String tag) throws IOException {
- out.writeLong(l);
- }
-
- public void writeFloat(float f, String tag) throws IOException {
- out.writeFloat(f);
- }
-
- public void writeDouble(double d, String tag) throws IOException {
- out.writeDouble(d);
- }
-
- /**
- * create our own char encoder to utf8. This is faster
- * then string.getbytes(UTF8).
- * @param s the string to encode into utf8
- * @return utf8 byte sequence.
- */
- final private ByteBuffer stringToByteBuffer(CharSequence s) {
- bb.clear();
- final int len = s.length();
- for (int i = 0; i < len; i++) {
- if (bb.remaining() < 3) {
- ByteBuffer n = ByteBuffer.allocate(bb.capacity() << 1);
- bb.flip();
- n.put(bb);
- bb = n;
- }
- char c = s.charAt(i);
- if (c < 0x80) {
- bb.put((byte) c);
- } else if (c < 0x800) {
- bb.put((byte) (0xc0 | (c >> 6)));
- bb.put((byte) (0x80 | (c & 0x3f)));
- } else {
- bb.put((byte) (0xe0 | (c >> 12)));
- bb.put((byte) (0x80 | ((c >> 6) & 0x3f)));
- bb.put((byte) (0x80 | (c & 0x3f)));
- }
- }
- bb.flip();
- return bb;
- }
-
- public void writeString(String s, String tag) throws IOException {
- if (s == null) {
- writeInt(-1, "len");
- return;
- }
- ByteBuffer bb = stringToByteBuffer(s);
- writeInt(bb.remaining(), "len");
- out.write(bb.array(), bb.position(), bb.limit());
- }
-
- public void writeBuffer(byte barr[], String tag)
- throws IOException {
- if (barr == null) {
- out.writeInt(-1);
- return;
- }
- out.writeInt(barr.length);
- out.write(barr);
- }
-
- public void writeRecord(Record r, String tag) throws IOException {
- r.serialize(this, tag);
- }
-
- 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 {
- if (v == null) {
- writeInt(-1, tag);
- return;
- }
- writeInt(v.size(), tag);
- }
-
- public void endVector(List v, String tag) throws IOException {}
-
- public void startMap(TreeMap v, String tag) throws IOException {
- writeInt(v.size(), tag);
- }
-
- public void endMap(TreeMap v, String tag) throws IOException {}
-
-}
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/CsvInputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/CsvInputArchive.java b/src/java/main/org/apache/jute/CsvInputArchive.java
deleted file mode 100644
index 3eb40ec..0000000
--- a/src/java/main/org/apache/jute/CsvInputArchive.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/**
- * 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.io.InputStreamReader;
-import java.io.PushbackReader;
-import java.io.UnsupportedEncodingException;
-
-/**
- *
- */
-class CsvInputArchive implements InputArchive {
-
- private PushbackReader stream;
-
- private class CsvIndex implements Index {
- public boolean done() {
- char c = '\0';
- try {
- c = (char) stream.read();
- stream.unread(c);
- } catch (IOException ex) {
- }
- return (c == '}') ? true : false;
- }
- public void incr() {}
- }
-
- private void throwExceptionOnError(String tag) throws IOException {
- throw new IOException("Error deserializing "+tag);
- }
-
- private String readField(String tag) throws IOException {
- try {
- StringBuilder buf = new StringBuilder();
- while (true) {
- char c = (char) stream.read();
- switch (c) {
- case ',':
- return buf.toString();
- case '}':
- case '\n':
- case '\r':
- stream.unread(c);
- return buf.toString();
- default:
- buf.append(c);
- }
- }
- } catch (IOException ex) {
- throw new IOException("Error reading "+tag);
- }
- }
-
- static CsvInputArchive getArchive(InputStream strm)
- throws UnsupportedEncodingException {
- return new CsvInputArchive(strm);
- }
-
- /** Creates a new instance of CsvInputArchive */
- public CsvInputArchive(InputStream in)
- throws UnsupportedEncodingException {
- stream = new PushbackReader(new InputStreamReader(in, "UTF-8"));
- }
-
- public byte readByte(String tag) throws IOException {
- return (byte) readLong(tag);
- }
-
- public boolean readBool(String tag) throws IOException {
- String sval = readField(tag);
- return "T".equals(sval) ? true : false;
- }
-
- public int readInt(String tag) throws IOException {
- return (int) readLong(tag);
- }
-
- public long readLong(String tag) throws IOException {
- String sval = readField(tag);
- try {
- long lval = Long.parseLong(sval);
- return lval;
- } catch (NumberFormatException ex) {
- throw new IOException("Error deserializing "+tag);
- }
- }
-
- public float readFloat(String tag) throws IOException {
- return (float) readDouble(tag);
- }
-
- public double readDouble(String tag) throws IOException {
- String sval = readField(tag);
- try {
- double dval = Double.parseDouble(sval);
- return dval;
- } catch (NumberFormatException ex) {
- throw new IOException("Error deserializing "+tag);
- }
- }
-
- public String readString(String tag) throws IOException {
- String sval = readField(tag);
- return Utils.fromCSVString(sval);
-
- }
-
- public byte[] readBuffer(String tag) throws IOException {
- String sval = readField(tag);
- return Utils.fromCSVBuffer(sval);
- }
-
- public void readRecord(Record r, String tag) throws IOException {
- r.deserialize(this, tag);
- }
-
- public void startRecord(String tag) throws IOException {
- if (tag != null && !"".equals(tag)) {
- char c1 = (char) stream.read();
- char c2 = (char) stream.read();
- if (c1 != 's' || c2 != '{') {
- throw new IOException("Error deserializing "+tag);
- }
- }
- }
-
- public void endRecord(String tag) throws IOException {
- char c = (char) stream.read();
- if (tag == null || "".equals(tag)) {
- if (c != '\n' && c != '\r') {
- throw new IOException("Error deserializing record.");
- } else {
- return;
- }
- }
-
- if (c != '}') {
- throw new IOException("Error deserializing "+tag);
- }
- c = (char) stream.read();
- if (c != ',') {
- stream.unread(c);
- }
-
- return;
- }
-
- public Index startVector(String tag) throws IOException {
- char c1 = (char) stream.read();
- char c2 = (char) stream.read();
- if (c1 != 'v' || c2 != '{') {
- throw new IOException("Error deserializing "+tag);
- }
- return new CsvIndex();
- }
-
- public void endVector(String tag) throws IOException {
- char c = (char) stream.read();
- if (c != '}') {
- throw new IOException("Error deserializing "+tag);
- }
- c = (char) stream.read();
- if (c != ',') {
- stream.unread(c);
- }
- return;
- }
-
- public Index startMap(String tag) throws IOException {
- char c1 = (char) stream.read();
- char c2 = (char) stream.read();
- if (c1 != 'm' || c2 != '{') {
- throw new IOException("Error deserializing "+tag);
- }
- return new CsvIndex();
- }
-
- public void endMap(String tag) throws IOException {
- char c = (char) stream.read();
- if (c != '}') {
- throw new IOException("Error deserializing "+tag);
- }
- c = (char) stream.read();
- if (c != ',') {
- stream.unread(c);
- }
- return;
- }
-}
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/CsvOutputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/CsvOutputArchive.java b/src/java/main/org/apache/jute/CsvOutputArchive.java
deleted file mode 100644
index f6d60d8..0000000
--- a/src/java/main/org/apache/jute/CsvOutputArchive.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * 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.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.TreeMap;
-
-/**
- *
- */
-public class CsvOutputArchive implements OutputArchive {
-
- private PrintStream stream;
- private boolean isFirst = true;
-
- static CsvOutputArchive getArchive(OutputStream strm)
- throws UnsupportedEncodingException {
- return new CsvOutputArchive(strm);
- }
-
- private void throwExceptionOnError(String tag) throws IOException {
- if (stream.checkError()) {
- throw new IOException("Error serializing "+tag);
- }
- }
-
- private void printCommaUnlessFirst() {
- if (!isFirst) {
- stream.print(",");
- }
- isFirst = false;
- }
-
- /** Creates a new instance of CsvOutputArchive */
- public CsvOutputArchive(OutputStream out)
- throws UnsupportedEncodingException {
- stream = new PrintStream(out, true, "UTF-8");
- }
-
- public void writeByte(byte b, String tag) throws IOException {
- writeLong((long)b, tag);
- }
-
- public void writeBool(boolean b, String tag) throws IOException {
- printCommaUnlessFirst();
- String val = b ? "T" : "F";
- stream.print(val);
- throwExceptionOnError(tag);
- }
-
- public void writeInt(int i, String tag) throws IOException {
- writeLong((long)i, tag);
- }
-
- public void writeLong(long l, String tag) throws IOException {
- printCommaUnlessFirst();
- stream.print(l);
- throwExceptionOnError(tag);
- }
-
- public void writeFloat(float f, String tag) throws IOException {
- writeDouble((double)f, tag);
- }
-
- public void writeDouble(double d, String tag) throws IOException {
- printCommaUnlessFirst();
- stream.print(d);
- throwExceptionOnError(tag);
- }
-
- public void writeString(String s, String tag) throws IOException {
- printCommaUnlessFirst();
- stream.print(Utils.toCSVString(s));
- throwExceptionOnError(tag);
- }
-
- public void writeBuffer(byte buf[], String tag)
- throws IOException {
- printCommaUnlessFirst();
- stream.print(Utils.toCSVBuffer(buf));
- throwExceptionOnError(tag);
- }
-
- public void writeRecord(Record r, String tag) throws IOException {
- if (r == null) {
- return;
- }
- r.serialize(this, tag);
- }
-
- public void startRecord(Record r, String tag) throws IOException {
- if (tag != null && !"".equals(tag)) {
- printCommaUnlessFirst();
- stream.print("s{");
- isFirst = true;
- }
- }
-
- public void endRecord(Record r, String tag) throws IOException {
- if (tag == null || "".equals(tag)) {
- stream.print("\n");
- isFirst = true;
- } else {
- stream.print("}");
- isFirst = false;
- }
- }
-
- public void startVector(List v, String tag) throws IOException {
- printCommaUnlessFirst();
- stream.print("v{");
- isFirst = true;
- }
-
- public void endVector(List v, String tag) throws IOException {
- stream.print("}");
- isFirst = false;
- }
-
- public void startMap(TreeMap v, String tag) throws IOException {
- printCommaUnlessFirst();
- stream.print("m{");
- isFirst = true;
- }
-
- public void endMap(TreeMap v, String tag) throws IOException {
- stream.print("}");
- isFirst = false;
- }
-}
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/Index.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/Index.java b/src/java/main/org/apache/jute/Index.java
deleted file mode 100644
index 258c6b5..0000000
--- a/src/java/main/org/apache/jute/Index.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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;
-
-/**
- * Interface that acts as an iterator for deserializing maps.
- * The deserializer returns an instance that the record uses to
- * read vectors and maps. An example of usage is as follows:
- *
- * <code>
- * Index idx = startVector(...);
- * while (!idx.done()) {
- * .... // read element of a vector
- * idx.incr();
- * }
- * </code>
- *
- */
-public interface Index {
- public boolean done();
- public void incr();
-}
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/InputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/InputArchive.java b/src/java/main/org/apache/jute/InputArchive.java
deleted file mode 100644
index b19ab3d..0000000
--- a/src/java/main/org/apache/jute/InputArchive.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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;
-
-/**
- * Interface that all the Deserializers have to implement.
- *
- */
-public interface InputArchive {
- public byte readByte(String tag) throws IOException;
- public boolean readBool(String tag) throws IOException;
- public int readInt(String tag) throws IOException;
- public long readLong(String tag) throws IOException;
- public float readFloat(String tag) throws IOException;
- public double readDouble(String tag) throws IOException;
- public String readString(String tag) throws IOException;
- public byte[] readBuffer(String tag) throws IOException;
- public void readRecord(Record r, String tag) throws IOException;
- public void startRecord(String tag) throws IOException;
- public void endRecord(String tag) throws IOException;
- public Index startVector(String tag) throws IOException;
- public void endVector(String tag) throws IOException;
- public Index startMap(String tag) throws IOException;
- public void endMap(String tag) throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/OutputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/OutputArchive.java b/src/java/main/org/apache/jute/OutputArchive.java
deleted file mode 100644
index 4e084e8..0000000
--- a/src/java/main/org/apache/jute/OutputArchive.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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 alll 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/29cc5c1a/src/java/main/org/apache/jute/Record.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/Record.java b/src/java/main/org/apache/jute/Record.java
deleted file mode 100644
index d955280..0000000
--- a/src/java/main/org/apache/jute/Record.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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/29cc5c1a/src/java/main/org/apache/jute/RecordReader.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/RecordReader.java b/src/java/main/org/apache/jute/RecordReader.java
deleted file mode 100644
index 2977d3f..0000000
--- a/src/java/main/org/apache/jute/RecordReader.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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 archiveFactory;
-
- static {
- archiveFactory = new HashMap();
- Class[] params = { InputStream.class };
- try {
- archiveFactory.put("binary",
- BinaryInputArchive.class.getDeclaredMethod(
- "getArchive", params));
- archiveFactory.put("csv",
- CsvInputArchive.class.getDeclaredMethod(
- "getArchive", params));
- archiveFactory.put("xml",
- XmlInputArchive.class.getDeclaredMethod(
- "getArchive", params));
- } 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/29cc5c1a/src/java/main/org/apache/jute/RecordWriter.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/RecordWriter.java b/src/java/main/org/apache/jute/RecordWriter.java
deleted file mode 100644
index 0adbd56..0000000
--- a/src/java/main/org/apache/jute/RecordWriter.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-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 private OutputArchive getBinaryArchive(OutputStream out) {
- return new BinaryOutputArchive(new DataOutputStream(out));
- }
-
- static private OutputArchive getCsvArchive(OutputStream out)
- throws IOException {
- try {
- return new CsvOutputArchive(out);
- } catch (UnsupportedEncodingException ex) {
- throw new IOException("Unsupported encoding UTF-8");
- }
- }
-
- static private OutputArchive getXmlArchive(OutputStream out)
- throws IOException {
- return new XmlOutputArchive(out);
- }
-
- static HashMap constructFactory() {
- HashMap factory = new HashMap();
- Class[] params = { OutputStream.class };
- try {
- factory.put("binary",
- BinaryOutputArchive.class.getDeclaredMethod(
- "getArchive", params));
- factory.put("csv",
- CsvOutputArchive.class.getDeclaredMethod(
- "getArchive", params));
- factory.put("xml",
- XmlOutputArchive.class.getDeclaredMethod(
- "getArchive", params));
- } catch (SecurityException ex) {
- ex.printStackTrace();
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return factory;
- }
-
- static private HashMap 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/29cc5c1a/src/java/main/org/apache/jute/Utils.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/Utils.java b/src/java/main/org/apache/jute/Utils.java
deleted file mode 100644
index 1205fa2..0000000
--- a/src/java/main/org/apache/jute/Utils.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/**
- * 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("<");
- } else if (ch == '&') {
- sb.append("&");
- } 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/29cc5c1a/src/java/main/org/apache/jute/XmlInputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/XmlInputArchive.java b/src/java/main/org/apache/jute/XmlInputArchive.java
deleted file mode 100644
index 99e11d1..0000000
--- a/src/java/main/org/apache/jute/XmlInputArchive.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/**
- * 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/29cc5c1a/src/java/main/org/apache/jute/XmlOutputArchive.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/XmlOutputArchive.java b/src/java/main/org/apache/jute/XmlOutputArchive.java
deleted file mode 100644
index b65e9a0..0000000
--- a/src/java/main/org/apache/jute/XmlOutputArchive.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/**
- * 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/29cc5c1a/src/java/main/org/apache/jute/compiler/CGenerator.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/compiler/CGenerator.java b/src/java/main/org/apache/jute/compiler/CGenerator.java
deleted file mode 100644
index 689ee21..0000000
--- a/src/java/main/org/apache/jute/compiler/CGenerator.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * 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.util.ArrayList;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Iterator;
-
-/**
- * C++ Code generator front-end for Hadoop record I/O.
- */
-class CGenerator {
- private String mName;
- private ArrayList<JFile> mInclFiles;
- private ArrayList<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, ArrayList<JFile> ilist, ArrayList<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);
- }
- }
-
- FileWriter c = null;
- FileWriter h = null;
- try {
- c = new FileWriter(new File(outputDirectory, mName+".c"));
- 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");
- } finally {
- try {
- if (h != null) {
- h.close();
- }
- } finally {
- if (c != null) {
- c.close();
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/29cc5c1a/src/java/main/org/apache/jute/compiler/CSharpGenerator.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/jute/compiler/CSharpGenerator.java b/src/java/main/org/apache/jute/compiler/CSharpGenerator.java
deleted file mode 100644
index c28751d..0000000
--- a/src/java/main/org/apache/jute/compiler/CSharpGenerator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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;
-
-public class CSharpGenerator {
- private ArrayList<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, ArrayList<JFile> ilist, ArrayList<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);
- }
- }
-}