activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r679095 [1/2] - in /activemq/sandbox/zookeeper: src/c/ zookeeper-all/ zookeeper-c/ zookeeper-core/ zookeeper-core/src/ zookeeper-core/src/main/ zookeeper-core/src/test/ zookeeper-jmx/ zookeeper-jmx/src/ zookeeper-jmx/src/main/ zookeeper-jmx...
Date Wed, 23 Jul 2008 14:48:07 GMT
Author: chirino
Date: Wed Jul 23 07:48:05 2008
New Revision: 679095

URL: http://svn.apache.org/viewvc?rev=679095&view=rev
Log:
reorganizing for maven build

Added:
    activemq/sandbox/zookeeper/zookeeper-all/
    activemq/sandbox/zookeeper/zookeeper-all/pom.xml
    activemq/sandbox/zookeeper/zookeeper-c/
      - copied from r679094, activemq/sandbox/zookeeper/src/c/
    activemq/sandbox/zookeeper/zookeeper-core/
    activemq/sandbox/zookeeper/zookeeper-core/pom.xml   (with props)
    activemq/sandbox/zookeeper/zookeeper-core/src/
    activemq/sandbox/zookeeper/zookeeper-core/src/main/
    activemq/sandbox/zookeeper/zookeeper-core/src/test/
    activemq/sandbox/zookeeper/zookeeper-jmx/
    activemq/sandbox/zookeeper/zookeeper-jmx/pom.xml   (with props)
    activemq/sandbox/zookeeper/zookeeper-jmx/src/
    activemq/sandbox/zookeeper/zookeeper-jmx/src/main/
    activemq/sandbox/zookeeper/zookeeper-jmx/src/test/
    activemq/sandbox/zookeeper/zookeeper-jmx/src/test/java/
    activemq/sandbox/zookeeper/zookeeper-jute/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/pom.xml
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CGenerator.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CppGenerator.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBoolean.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBuffer.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JByte.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JCompType.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JDouble.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JField.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFile.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFloat.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JInt.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JLong.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JMap.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JRecord.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JString.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JType.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JVector.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JavaGenerator.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JuteMojo.java
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/package.html
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/zookeeper/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/zookeeper/version/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/zookeeper/version/util/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/javacc/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/test/
    activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/test/java/
    activemq/sandbox/zookeeper/zookeeper-jute/pom.xml
    activemq/sandbox/zookeeper/zookeeper-jute/src/
    activemq/sandbox/zookeeper/zookeeper-jute/src/main/
    activemq/sandbox/zookeeper/zookeeper-jute/src/main/java/
    activemq/sandbox/zookeeper/zookeeper-jute/src/main/java/org/
    activemq/sandbox/zookeeper/zookeeper-jute/src/main/java/org/apache/
    activemq/sandbox/zookeeper/zookeeper-jute/src/main/javacc/
    activemq/sandbox/zookeeper/zookeeper-jute/src/test/
    activemq/sandbox/zookeeper/zookeeper-jute/src/test/java/
Removed:
    activemq/sandbox/zookeeper/src/c/

Added: activemq/sandbox/zookeeper/zookeeper-all/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-all/pom.xml?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-all/pom.xml (added)
+++ activemq/sandbox/zookeeper/zookeeper-all/pom.xml Wed Jul 23 07:48:05 2008
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.zookeeper</groupId>
+    <artifactId>zookeeper-pom</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.zookeeper</groupId>
+  <artifactId>zookeeper-all</artifactId>
+  <version>3.0.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>ZooKeeper :: All</name>
+  <description>An uber jar that includes all the jar dependencies needed to run a ZooKeeper server</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.zookeeper</groupId>
+      <artifactId>zookeeper-jute</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.zookeeper</groupId>
+      <artifactId>zookeeper-core</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.zookeeper</groupId>
+      <artifactId>zookeeper-jmx</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>1.0.1</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+
+              <artifactSet>
+                <includes>
+                  <include>org.apache.zookeeper:zookeeper-jute</include>
+                  <include>org.apache.zookeeper:zookeeper-core</include>
+                  <include>org.apache.zookeeper:zookeeper-jmx</include>
+                  <include>log4j:log4j</include>
+                </includes>
+              </artifactSet>
+
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
+                    <projectName>Apache ZooKeeper</projectName>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.geronimo.genesis.plugins</groupId>
+        <artifactId>tools-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>verify-legal-files</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>verify-legal-files</goal>
+            </goals>
+            <configuration>
+              <strict>false</strict>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+            
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: activemq/sandbox/zookeeper/zookeeper-core/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-core/pom.xml?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-core/pom.xml (added)
+++ activemq/sandbox/zookeeper/zookeeper-core/pom.xml Wed Jul 23 07:48:05 2008
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.zookeeper</groupId>
+    <artifactId>zookeeper-pom</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.zookeeper</groupId>
+  <artifactId>zookeeper-core</artifactId>
+  <version>3.0.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  
+  <name>ZooKeeper :: Core</name>
+  <description></description>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.zookeeper</groupId>
+      <artifactId>zookeeper-jute</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.zookeeper</groupId>
+        <artifactId>zookeeper-jute-compiler</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+		    <executions>
+          <execution>
+            <id>jute</id>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+            <configuration>
+              <sourceDirectory>${basedir}/..</sourceDirectory>
+              <language>java</language>
+            </configuration>
+          </execution>
+          <!-- Generates the Version Info File-->
+          <execution>
+            <id>version-gen</id>
+            <goals>
+              <goal>version-gen</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>

Propchange: activemq/sandbox/zookeeper/zookeeper-core/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/zookeeper/zookeeper-jmx/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jmx/pom.xml?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jmx/pom.xml (added)
+++ activemq/sandbox/zookeeper/zookeeper-jmx/pom.xml Wed Jul 23 07:48:05 2008
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.zookeeper</groupId>
+    <artifactId>zookeeper-pom</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.zookeeper</groupId>
+  <artifactId>zookeeper-jmx</artifactId>
+  <version>3.0.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  
+  <name>ZooKeeper :: JMX</name>
+  <description></description>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.zookeeper</groupId>
+      <artifactId>zookeeper-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: activemq/sandbox/zookeeper/zookeeper-jmx/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/pom.xml?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/pom.xml (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/pom.xml Wed Jul 23 07:48:05 2008
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.zookeeper</groupId>
+    <artifactId>zookeeper-pom</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.zookeeper</groupId>
+  <artifactId>zookeeper-jute-compiler</artifactId>
+  <version>3.0.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>ZooKeeper :: Jute Compiler</name>
+  <description></description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.5.1</version>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>javacc-maven-plugin</artifactId>
+        <version>2.4.1</version>
+		    <executions>
+          <execution>
+            <id>javacc</id>
+            <goals>
+              <goal>javacc</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CGenerator.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CGenerator.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CGenerator.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CGenerator.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,88 @@
+/**
+ * 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.
+ *
+ * @author Milind Bhandarkar
+ */
+class CGenerator {
+    private String mFullName;
+    private String mName;
+    private ArrayList mInclFiles;
+    private ArrayList 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 ilist, ArrayList rlist, File outputDirectory) {
+        mFullName = name;
+        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 {
+        outputDirectory.mkdirs();
+        FileWriter c = new FileWriter(new File(outputDirectory, mName+".c"));
+        FileWriter h = new FileWriter(new File(outputDirectory, mName+".h"));
+        h.write("#ifndef __"+mName.toUpperCase().replace('.','_')+"__\n");
+        h.write("#define __"+mName.toUpperCase().replace('.','_')+"__\n");
+        
+        h.write("#include \"recordio.h\"\n");
+        for (Iterator i = mInclFiles.iterator(); i.hasNext();) {
+            JFile f = (JFile) 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 i = mRecList.iterator(); i.hasNext();) {
+            JRecord jr = (JRecord) i.next();
+            jr.genCCode(h, c);
+        }
+        
+        h.write("\n#ifdef __cplusplus\n}\n#endif\n\n");
+        h.write("#endif //"+mName.toUpperCase().replace('.','_')+"__\n");
+        
+        h.close();
+        c.close();
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CppGenerator.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CppGenerator.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CppGenerator.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/CppGenerator.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,83 @@
+/**
+ * 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.
+ *
+ * @author Milind Bhandarkar
+ */
+class CppGenerator {
+    private String mFullName;
+    private String mName;
+    private ArrayList mInclFiles;
+    private ArrayList 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, ArrayList ilist, ArrayList rlist, File outputDirectory) {
+        mFullName = name;
+        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 {
+        outputDirectory.mkdirs();
+        FileWriter cc = new FileWriter(new File(outputDirectory, mName+".cc"));
+        FileWriter hh = new FileWriter(new File(outputDirectory, mName+".hh"));
+        hh.write("#ifndef __"+mName.toUpperCase().replace('.','_')+"__\n");
+        hh.write("#define __"+mName.toUpperCase().replace('.','_')+"__\n");
+        
+        hh.write("#include \"recordio.hh\"\n");
+        for (Iterator i = mInclFiles.iterator(); i.hasNext();) {
+            JFile f = (JFile) i.next();
+            hh.write("#include \""+f.getName()+".hh\"\n");
+        }
+        cc.write("#include \""+mName+".hh\"\n");
+        
+        for (Iterator i = mRecList.iterator(); i.hasNext();) {
+            JRecord jr = (JRecord) i.next();
+            jr.genCppCode(hh, cc);
+        }
+        
+        hh.write("#endif //"+mName.toUpperCase().replace('.','_')+"__\n");
+        
+        hh.close();
+        cc.close();
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBoolean.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBoolean.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBoolean.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBoolean.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,43 @@
+/**
+ * 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;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JBoolean extends JType {
+    
+    /** Creates a new instance of JBoolean */
+    public JBoolean() {
+        super("int32_t", "bool", "boolean", "Bool", "Boolean", "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";
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBuffer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBuffer.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBuffer.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JBuffer.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,107 @@
+/**
+ * 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;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JBuffer extends JCompType {
+    
+    /** Creates a new instance of JBuffer */
+    public JBuffer() {
+        super("struct buffer", " ::std::string", "byte[]", "Buffer", "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) {
+      StringBuffer sb = new StringBuffer();
+      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 = "+fname+".toString().hashCode();\n";
+    }
+    
+    public String genJavaSlurpBytes(String b, String s, String l) {
+      StringBuffer sb = new StringBuffer();
+      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() {
+      StringBuffer sb = new StringBuffer();
+      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();
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JByte.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JByte.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JByte.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JByte.java Wed Jul 23 07:48:05 2008
@@ -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.compiler;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JByte extends JType {
+    
+    /** Creates a new instance of JByte */
+    public JByte() {
+        super("char", "int8_t", "byte", "Byte", "Byte", "toByte");
+    }
+    
+    public String getSignature() {
+        return "b";
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JCompType.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JCompType.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JCompType.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JCompType.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,55 @@
+/**
+ * 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.
+ *
+ * @author Milind Bhandarkar
+ */
+abstract class JCompType extends JType {
+    
+    /** Creates a new instance of JCompType */
+    JCompType(String cType, String cppType, String javaType, String suffix, String wrapper) {
+        super(cType, cppType, javaType, suffix, wrapper, 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";
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JDouble.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JDouble.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JDouble.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JDouble.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,41 @@
+/**
+ * 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;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JDouble extends JType {
+    
+    /** Creates a new instance of JDouble */
+    public JDouble() {
+        super("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";
+    }
+
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JField.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JField.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JField.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JField.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,99 @@
+/**
+ * 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;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+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 genJavaDecl() {
+        return mType.genJavaDecl(mName);
+    }
+    
+    public String genJavaConstructorParam(String fname) {
+        return mType.genJavaConstructorParam(fname);
+    }
+    
+    public String getName() {
+        return mName;
+    }
+    
+    public String getTag() {
+        return mName;
+    }
+    
+    public JType getType() {
+        return mType;
+    }
+    
+    public String genCppGetSet(int fIdx) {
+        return mType.genCppGetSet(mName, fIdx);
+    }
+    
+    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);
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFile.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFile.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFile.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFile.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,75 @@
+/**
+ * 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;
+
+/**
+ * Container for the Hadoop Record DDL.
+ * The main components of the file are filename, list of included files,
+ * and records defined in that file.
+ *
+ * @author Milind Bhandarkar
+ */
+public class JFile {
+    
+    private String mName;
+    private ArrayList mInclFiles;
+    private ArrayList 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 inclFiles, ArrayList 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 {
+            System.out.println("Cannnot recognize language:"+language);
+            System.exit(1);
+        }
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFloat.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFloat.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFloat.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JFloat.java Wed Jul 23 07:48:05 2008
@@ -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;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JFloat extends JType {
+    
+    /** Creates a new instance of JFloat */
+    public JFloat() {
+        super("float", "float", "float", "Float", "Float", "toFloat");
+    }
+    
+    public String getSignature() {
+        return "f";
+    }
+    
+    public String genJavaHashCode(String fname) {
+        return "    ret = Float.floatToIntBits("+fname+");\n";
+    }
+
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JInt.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JInt.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JInt.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JInt.java Wed Jul 23 07:48:05 2008
@@ -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.compiler;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JInt extends JType {
+    
+    /** Creates a new instance of JInt */
+    public JInt() {
+        super("int32_t", "int32_t", "int", "Int", "Integer", "toInt");
+    }
+    
+    public String getSignature() {
+        return "i";
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JLong.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JLong.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JLong.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JLong.java Wed Jul 23 07:48:05 2008
@@ -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;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JLong extends JType {
+    
+    /** Creates a new instance of JLong */
+    public JLong() {
+        super("int64_t", "int64_t", "long", "Long", "Long", "toLong");
+    }
+    
+    public String getSignature() {
+        return "l";
+    }
+    
+    public String genJavaHashCode(String fname) {
+        return "    ret = (int) ("+fname+"^("+fname+">>>32));\n";
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JMap.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JMap.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JMap.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JMap.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,101 @@
+/**
+ * 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;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+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()+">",
+                "java.util.TreeMap", "Map", "java.util.TreeMap");
+        mKey = t1;
+        mValue = t2;
+    }
+    
+    public String getSignature() {
+        return "{" + mKey.getSignature() + mValue.getSignature() +"}";
+    }
+    
+    public String genJavaCompareTo(String fname) {
+        return "";
+    }
+    
+    public String genJavaReadWrapper(String fname, String tag, boolean decl) {
+        StringBuffer ret = new StringBuffer("");
+        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) {
+        StringBuffer ret = new StringBuffer("    {\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);
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JRecord.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JRecord.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JRecord.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JRecord.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,508 @@
+/**
+ * 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.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JRecord extends JCompType {
+
+    private String mFQName;
+    private String mName;
+    private String mModule;
+    private ArrayList<JField> mFields;
+    
+    /**
+     * Creates a new instance of JRecord
+     */
+    public JRecord(String name, ArrayList flist) {
+        super("struct " + name.substring(name.lastIndexOf('.')+1), name.replaceAll("\\.","::"), name, "Record", name);
+        mFQName = name;
+        int idx = name.lastIndexOf('.');
+        mName = name.substring(idx+1);
+        mModule = name.substring(0, idx);
+        mFields = flist;
+    }
+    
+    public String getName() {
+        return mName;
+    }
+    
+    public String getJavaFQName() {
+        return mFQName;
+    }
+    
+    public String getCppFQName() {
+        return mFQName.replaceAll("\\.", "::");
+    }
+    
+    public String getJavaPackage() {
+        return mModule;
+    }
+    
+    public String getCppNameSpace() {
+        return mModule.replaceAll("\\.", "::");
+    }
+    
+    public ArrayList getFields() {
+        return mFields;
+    }
+    
+    public String getSignature() {
+        StringBuffer sb = new StringBuffer();
+        sb.append("L").append(mName).append("(");
+        for (Iterator i = mFields.iterator(); i.hasNext();) {
+            String s = ((JField) i.next()).getSignature();
+            sb.append(s);
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+    
+    public String genCppDecl(String fname) {
+        return "  "+mName+" "+fname+";\n";
+    }
+    
+    public String genJavaReadMethod(String fname, String tag) {
+        return genJavaReadWrapper(fname, tag, false);
+    }
+    
+    public String genJavaReadWrapper(String fname, String tag, boolean decl) {
+        StringBuffer ret = new StringBuffer("");
+        if (decl) {
+            ret.append("    "+getJavaFQName()+" "+fname+";\n");
+        }
+        ret.append("    "+fname+"= new "+getJavaFQName()+"();\n");
+        ret.append("    a_.readRecord("+fname+",\""+tag+"\");\n");
+        return ret.toString();
+    }
+    
+    public String genJavaWriteWrapper(String fname, String tag) {
+        return "    a_.writeRecord("+fname+",\""+tag+"\");\n";
+    }
+    
+    static HashMap<String, String> vectorStructs = new HashMap<String, String>();
+    public void genCCode(FileWriter h, FileWriter c) throws IOException {
+    	for (JField f : mFields) {
+    		if (f.getType() instanceof JVector) {
+    			JVector jv = (JVector)f.getType();
+				JType jvType = jv.getElementType();
+				String struct_name = JVector.extractVectorName(jvType);
+				if (vectorStructs.get(struct_name) == null) {
+					vectorStructs.put(struct_name, struct_name);
+					h.write("struct " + struct_name + " {\n    int32_t count;\n" + jv.getElementType().genCDecl("*data") + ";\n};\n");
+					h.write("int serialize_" + struct_name + "(struct oarchive *out, const char *tag, struct " + struct_name + " *v);\n");
+					h.write("int deserialize_" + struct_name + "(struct iarchive *in, const char *tag, struct " + struct_name + " *v);\n");
+					h.write("int allocate_" + struct_name + "(struct " + struct_name + " *v, int32_t len);\n");
+					h.write("int deallocate_" + struct_name + "(struct " + struct_name + " *v);\n");
+					c.write("int allocate_" + struct_name + "(struct " + struct_name + " *v, int32_t len) {\n");
+					c.write("    if (!len) {\n");
+					c.write("        v->count = 0;\n");
+					c.write("        v->data = 0;\n");
+					c.write("    } else {\n");
+					c.write("        v->count = len;\n");
+					c.write("        v->data = calloc(sizeof(*v->data), len);\n");
+					c.write("    }\n");
+					c.write("    return 0;\n");
+					c.write("}\n");
+					c.write("int deallocate_" + struct_name + "(struct " + struct_name + " *v) {\n");
+					c.write("    if (v->data) {\n");
+					c.write("        int32_t i;\n");
+					c.write("        for(i=0;i<v->count; i++) {\n");
+					c.write("            deallocate_"+JRecord.extractMethodSuffix(jvType)+"(&v->data[i]);\n");
+					c.write("        }\n");
+					c.write("        free(v->data);\n");
+					c.write("        v->data = 0;\n");
+					c.write("    }\n");
+					c.write("    return 0;\n");
+					c.write("}\n");
+					c.write("int serialize_" + struct_name + "(struct oarchive *out, const char *tag, struct " + struct_name + " *v)\n");
+					c.write("{\n");
+					c.write("    int32_t count = v->count;\n");
+					c.write("    int rc = 0;\n");
+					c.write("    int32_t i;\n");
+					c.write("    rc = out->start_vector(out, tag, &count);\n");
+					c.write("    for(i=0;i<v->count;i++) {\n");
+					genSerialize(c, jvType, "data", "data[i]");
+					c.write("    }\n");
+					c.write("    rc = rc ? : out->end_vector(out, tag);\n");
+					c.write("    return rc;\n");
+					c.write("}\n");
+					c.write("int deserialize_" + struct_name + "(struct iarchive *in, const char *tag, struct " + struct_name + " *v)\n");
+					c.write("{\n");
+					c.write("    int rc = 0;\n");
+					c.write("    int32_t i;\n");
+					c.write("    rc = in->start_vector(in, tag, &v->count);\n");
+					c.write("    v->data = calloc(v->count, sizeof(*v->data));\n");
+					c.write("    for(i=0;i<v->count;i++) {\n");
+					genDeserialize(c, jvType, "value", "data[i]");
+					c.write("    }\n");
+					c.write("    rc = in->end_vector(in, tag);\n");
+					c.write("    return rc;\n");
+					c.write("}\n");
+					
+    			}
+    		}
+    	}
+    	String rec_name = getName();
+		h.write("struct " + rec_name + " {\n");
+    	for (JField f : mFields) {
+			h.write(f.genCDecl());
+		}
+    	h.write("};\n");
+    	h.write("int serialize_" + rec_name + "(struct oarchive *out, const char *tag, struct " + rec_name + " *v);\n");
+    	h.write("int deserialize_" + rec_name + "(struct iarchive *in, const char *tag, struct " + rec_name + "*v);\n");
+    	h.write("void deallocate_" + rec_name + "(struct " + rec_name + "*);\n");
+    	c.write("int serialize_" + rec_name + "(struct oarchive *out, const char *tag, struct " + rec_name + " *v)");
+    	c.write("{\n");
+    	c.write("    int rc;\n");
+    	c.write("    rc = out->start_record(out, tag);\n");
+    	for(JField f : mFields) {
+    		genSerialize(c, f.getType(), f.getTag(), f.getName());
+    	}
+    	c.write("    rc = rc ? : out->end_record(out, tag);\n");
+    	c.write("    return rc;\n");
+    	c.write("}\n");
+    	c.write("int deserialize_" + rec_name + "(struct iarchive *in, const char *tag, struct " + rec_name + "*v)");
+    	c.write("{\n");
+    	c.write("    int rc;\n");
+    	c.write("    rc = in->start_record(in, tag);\n");
+    	for(JField f : mFields) {
+    		genDeserialize(c, f.getType(), f.getTag(), f.getName());
+    	}
+    	c.write("    rc = rc ? : in->end_record(in, tag);\n");
+    	c.write("    return rc;\n");
+    	c.write("}\n");
+    	c.write("void deallocate_" + rec_name + "(struct " + rec_name + "*v)");
+    	c.write("{\n");
+    	for(JField f : mFields) {
+    		if (f.getType() instanceof JRecord) {
+    			c.write("    deallocate_" + extractStructName(f.getType()) + "(&v->" + f.getName() + ");\n");
+    		} else if (f.getType() instanceof JVector) {
+    			JVector vt = (JVector)f.getType();
+    			c.write("    deallocate_" + JVector.extractVectorName(vt.getElementType())+ "(&v->"+f.getName()+");\n");
+    		} else if (f.getType() instanceof JCompType) {
+    			c.write("    deallocate_" + extractMethodSuffix(f.getType()) + "(&v->"+f.getName()+");\n");
+    		}
+    	}
+    	c.write("}\n");
+    }
+
+	private void genSerialize(FileWriter c, JType type, String tag, String name) throws IOException {
+		if (type instanceof JRecord) {
+			c.write("    rc = rc ? : serialize_" + extractStructName(type) + "(out, \"" + tag + "\", &v->" + name + ");\n");
+		} else if (type instanceof JVector) {
+			c.write("    rc = rc ? : serialize_" + JVector.extractVectorName(((JVector)type).getElementType()) + "(out, \"" + tag + "\", &v->" + name + ");\n");
+		} else {
+			c.write("    rc = rc ? : out->serialize_" + extractMethodSuffix(type) + "(out, \"" + tag + "\", &v->" + name + ");\n");
+		}
+	}
+
+	private void genDeserialize(FileWriter c, JType type, String tag, String name) throws IOException {
+		if (type instanceof JRecord) {
+			c.write("    rc = rc ? : deserialize_" + extractStructName(type) + "(in, \"" + tag + "\", &v->" + name + ");\n");
+		} else if (type instanceof JVector) {
+			c.write("    rc = rc ? : deserialize_" + JVector.extractVectorName(((JVector)type).getElementType()) + "(in, \"" + tag + "\", &v->" + name + ");\n");
+		} else {
+			c.write("    rc = rc ? : in->deserialize_" + extractMethodSuffix(type) + "(in, \"" + tag + "\", &v->" + name + ");\n");
+		}
+	}
+
+	static String extractMethodSuffix(JType t) {
+		if (t instanceof JRecord) {
+			return extractStructName(t);
+		}
+		return t.getMethodSuffix();
+	}
+
+	static private String extractStructName(JType t) {
+		String type = t.getCType();
+		if (!type.startsWith("struct ")) return type;
+		return type.substring("struct ".length());
+	}
+	
+    public void genCppCode(FileWriter hh, FileWriter cc)
+        throws IOException {
+        String[] ns = getCppNameSpace().split("::");
+        for (int i = 0; i < ns.length; i++) {
+            hh.write("namespace "+ns[i]+" {\n");
+        }
+        
+        hh.write("class "+getName()+" : public ::hadoop::Record {\n");
+        hh.write("private:\n");
+        
+        for (Iterator i = mFields.iterator(); i.hasNext();) {
+            JField jf = (JField) i.next();
+            hh.write(jf.genCppDecl());
+        }
+        hh.write("  mutable std::bitset<"+mFields.size()+"> bs_;\n");
+        hh.write("public:\n");
+        hh.write("  virtual void serialize(::hadoop::OArchive& a_, const char* tag) const;\n");
+        hh.write("  virtual void deserialize(::hadoop::IArchive& a_, const char* tag);\n");
+        hh.write("  virtual const ::std::string& type() const;\n");
+        hh.write("  virtual const ::std::string& signature() const;\n");
+        hh.write("  virtual bool validate() const;\n");
+        hh.write("  virtual bool operator<(const "+getName()+"& peer_) const;\n");
+        hh.write("  virtual bool operator==(const "+getName()+"& peer_) const;\n");
+        hh.write("  virtual ~"+getName()+"() {};\n");
+        int fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            hh.write(jf.genCppGetSet(fIdx));
+        }
+        hh.write("}; // end record "+getName()+"\n");
+        for (int i=ns.length-1; i>=0; i--) {
+            hh.write("} // end namespace "+ns[i]+"\n");
+        }
+        cc.write("void "+getCppFQName()+"::serialize(::hadoop::OArchive& a_, const char* tag) const {\n");
+        cc.write("  if (!validate()) throw new ::hadoop::IOException(\"All fields not set.\");\n");
+        cc.write("  a_.startRecord(*this,tag);\n");
+        fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            String name = jf.getName();
+            if (jf.getType() instanceof JBuffer) {
+                cc.write("  a_.serialize("+name+","+name+".length(),\""+jf.getTag()+"\");\n");
+            } else {
+                cc.write("  a_.serialize("+name+",\""+jf.getTag()+"\");\n");
+            }
+            cc.write("  bs_.reset("+fIdx+");\n");
+        }
+        cc.write("  a_.endRecord(*this,tag);\n");
+        cc.write("  return;\n");
+        cc.write("}\n");
+        
+        cc.write("void "+getCppFQName()+"::deserialize(::hadoop::IArchive& a_, const char* tag) {\n");
+        cc.write("  a_.startRecord(*this,tag);\n");
+        fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            String name = jf.getName();
+            if (jf.getType() instanceof JBuffer) {
+                cc.write("  { size_t len=0; a_.deserialize("+name+",len,\""+jf.getTag()+"\");}\n");
+            } else {
+                cc.write("  a_.deserialize("+name+",\""+jf.getTag()+"\");\n");
+            }
+            cc.write("  bs_.set("+fIdx+");\n");
+        }
+        cc.write("  a_.endRecord(*this,tag);\n");
+        cc.write("  return;\n");
+        cc.write("}\n");
+        
+        cc.write("bool "+getCppFQName()+"::validate() const {\n");
+        cc.write("  if (bs_.size() != bs_.count()) return false;\n");
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            JType type = jf.getType();
+            if (type instanceof JRecord) {
+                cc.write("  if (!"+jf.getName()+".validate()) return false;\n");
+            }
+        }
+        cc.write("  return true;\n");
+        cc.write("}\n");
+        
+        cc.write("bool "+getCppFQName()+"::operator< (const "+getCppFQName()+"& peer_) const {\n");
+        cc.write("  return (1\n");
+        for (Iterator i = mFields.iterator(); i.hasNext();) {
+            JField jf = (JField) i.next();
+            String name = jf.getName();
+            cc.write("    && ("+name+" < peer_."+name+")\n");
+        }
+        cc.write("  );\n");
+        cc.write("}\n");
+        
+        cc.write("bool "+getCppFQName()+"::operator== (const "+getCppFQName()+"& peer_) const {\n");
+        cc.write("  return (1\n");
+        for (Iterator i = mFields.iterator(); i.hasNext();) {
+            JField jf = (JField) i.next();
+            String name = jf.getName();
+            cc.write("    && ("+name+" == peer_."+name+")\n");
+        }
+        cc.write("  );\n");
+        cc.write("}\n");
+        
+        cc.write("const ::std::string&"+getCppFQName()+"::type() const {\n");
+        cc.write("  static const ::std::string type_(\""+mName+"\");\n");
+        cc.write("  return type_;\n");
+        cc.write("}\n");
+        
+        cc.write("const ::std::string&"+getCppFQName()+"::signature() const {\n");
+        cc.write("  static const ::std::string sig_(\""+getSignature()+"\");\n");
+        cc.write("  return sig_;\n");
+        cc.write("}\n");
+        
+    }
+    
+    public void genJavaCode(File outputDirectory) throws IOException {
+        String pkg = getJavaPackage();
+        String pkgpath = pkg.replaceAll("\\.", "/");
+        File pkgdir = new File(outputDirectory, pkgpath);
+        if (!pkgdir.exists()) {
+            // create the pkg directory
+            boolean ret = pkgdir.mkdirs();
+            if (!ret) {
+                System.out.println("Cannnot create directory: "+pkgpath);
+                System.exit(1);
+            }
+        } else if (!pkgdir.isDirectory()) {
+            // not a directory
+            System.out.println(pkgpath+" is not a directory.");
+            System.exit(1);
+        }
+        File jfile = new File(pkgdir, getName()+".java");
+        FileWriter jj = new FileWriter(jfile);
+        jj.write("// File generated by hadoop record compiler. Do not edit.\n");
+        jj.write("package "+getJavaPackage()+";\n\n");
+        jj.write("import org.apache.jute.*;\n");
+        jj.write("public class "+getName()+" implements Record {\n");
+        for (Iterator i = mFields.iterator(); i.hasNext();) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaDecl());
+        }
+        jj.write("  public "+getName()+"() {\n");
+        jj.write("  }\n");
+        
+        jj.write("  public "+getName()+"(\n");
+        int fIdx = 0;
+        int fLen = mFields.size();
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaConstructorParam(jf.getName()));
+            jj.write((fLen-1 == fIdx)?"":",\n");
+        }
+        jj.write(") {\n");
+        fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaConstructorSet(jf.getName()));
+        }
+        jj.write("  }\n");
+        fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaGetSet(fIdx));
+        }
+        jj.write("  public void serialize(OutputArchive a_, String tag) throws java.io.IOException {\n");
+        jj.write("    a_.startRecord(this,tag);\n");
+        fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaWriteMethodName());
+        }
+        jj.write("    a_.endRecord(this,tag);\n");
+        jj.write("  }\n");
+        
+        jj.write("  public void deserialize(InputArchive a_, String tag) throws java.io.IOException {\n");
+        jj.write("    a_.startRecord(tag);\n");
+        fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaReadMethodName());
+        }
+        jj.write("    a_.endRecord(tag);\n");
+        jj.write("}\n");
+        
+        jj.write("  public String toString() {\n");
+        jj.write("    try {\n");
+        jj.write("      java.io.ByteArrayOutputStream s =\n");
+        jj.write("        new java.io.ByteArrayOutputStream();\n");
+        jj.write("      CsvOutputArchive a_ = \n");
+        jj.write("        new CsvOutputArchive(s);\n");
+        jj.write("      a_.startRecord(this,\"\");\n");
+        fIdx = 0;
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaWriteMethodName());
+        }
+        jj.write("      a_.endRecord(this,\"\");\n");
+        jj.write("      return new String(s.toByteArray(), \"UTF-8\");\n");
+        jj.write("    } catch (Throwable ex) {\n");
+        jj.write("      ex.printStackTrace();\n");
+        jj.write("    }\n");
+        jj.write("    return \"ERROR\";\n");
+        jj.write("  }\n");
+        
+        jj.write("  public void write(java.io.DataOutput out) throws java.io.IOException {\n");
+        jj.write("    BinaryOutputArchive archive = new BinaryOutputArchive(out);\n");
+        jj.write("    serialize(archive, \"\");\n");
+        jj.write("  }\n");
+        
+        jj.write("  public void readFields(java.io.DataInput in) throws java.io.IOException {\n");
+        jj.write("    BinaryInputArchive archive = new BinaryInputArchive(in);\n");
+        jj.write("    deserialize(archive, \"\");\n");
+        jj.write("  }\n");
+        
+        jj.write("  public int compareTo (Object peer_) throws ClassCastException {\n");
+        jj.write("    if (!(peer_ instanceof "+getName()+")) {\n");
+        jj.write("      throw new ClassCastException(\"Comparing different types of records.\");\n");
+        jj.write("    }\n");
+        jj.write("    "+getName()+" peer = ("+getName()+") peer_;\n");
+        jj.write("    int ret = 0;\n");
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaCompareTo());
+            jj.write("    if (ret != 0) return ret;\n");
+        }
+        jj.write("     return ret;\n");
+        jj.write("  }\n");
+        
+        jj.write("  public boolean equals(Object peer_) {\n");
+        jj.write("    if (!(peer_ instanceof "+getName()+")) {\n");
+        jj.write("      return false;\n");
+        jj.write("    }\n");
+        jj.write("    if (peer_ == this) {\n");
+        jj.write("      return true;\n");
+        jj.write("    }\n");
+        jj.write("    "+getName()+" peer = ("+getName()+") peer_;\n");
+        jj.write("    boolean ret = false;\n");
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaEquals());
+            jj.write("    if (!ret) return ret;\n");
+        }
+        jj.write("     return ret;\n");
+        jj.write("  }\n");
+        
+        jj.write("  public int hashCode() {\n");
+        jj.write("    int result = 17;\n");
+        jj.write("    int ret;\n");
+        for (Iterator i = mFields.iterator(); i.hasNext(); fIdx++) {
+            JField jf = (JField) i.next();
+            jj.write(jf.genJavaHashCode());
+            jj.write("    result = 37*result + ret;\n");
+        }
+        jj.write("    return result;\n");
+        jj.write("  }\n");
+        jj.write("  public static String signature() {\n");
+        jj.write("    return \""+getSignature()+"\";\n");
+        jj.write("  }\n");
+        
+        jj.write("}\n");
+        
+        jj.close();
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JString.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JString.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JString.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JString.java Wed Jul 23 07:48:05 2008
@@ -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.compiler;
+
+/**
+ *
+ * @author Milind Bhandarkar
+ */
+public class JString extends JCompType {
+    
+    /** Creates a new instance of JString */
+    public JString() {
+        super("char *", " ::std::string", "String", "String", "String");
+    }
+    
+    public String getSignature() {
+        return "s";
+    }
+    
+    public String genJavaReadWrapper(String fname, String tag, boolean decl) {
+        String ret = "";
+        if (decl) {
+            ret = "    String "+fname+";\n";
+        }
+        return ret + "        "+fname+"=a_.readString(\""+tag+"\");\n";
+    }
+    
+    public String genJavaWriteWrapper(String fname, String tag) {
+        return "        a_.writeString("+fname+",\""+tag+"\");\n";
+    }
+}

Added: activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JType.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JType.java?rev=679095&view=auto
==============================================================================
--- activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JType.java (added)
+++ activemq/sandbox/zookeeper/zookeeper-jute-compiler/src/main/java/org/apache/jute/compiler/JType.java Wed Jul 23 07:48:05 2008
@@ -0,0 +1,142 @@
+/**
+ * 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 types supported by Hadoop Record I/O.
+ * 
+ * @author Milind Bhandarkar
+ */
+abstract public class JType {
+    
+	private String mCName;
+    private String mCppName;
+    private String mJavaName;
+    private String mMethodSuffix;
+    private String mWrapper;
+    private String mUnwrapMethod;
+    
+    /**
+     * Creates a new instance of JType
+     */
+    JType(String cname, String cppname, String javaname, String suffix, String wrapper, String unwrap) {
+    	mCName = cname;
+        mCppName = cppname;
+        mJavaName = javaname;
+        mMethodSuffix = suffix;
+        mWrapper = wrapper;
+        mUnwrapMethod = unwrap;
+    }
+    
+    abstract String getSignature();
+    
+    String genCppDecl(String fname) {
+        return "  "+mCppName+" m"+fname+";\n"; 
+    }
+    
+	String genCDecl(String name) {
+		return "    " + mCName + " "+name+";\n"; 
+	}
+    String genJavaDecl (String fname) {
+        return "  private "+mJavaName+" " +fname+";\n";
+    }
+    
+    String genJavaConstructorParam (String fname) {
+        return "        "+mJavaName+" "+fname;
+    }
+    
+    String genCppGetSet(String fname, int fIdx) {
+        String getFunc = "  virtual "+mCppName+" get"+fname+"() const {\n";
+        getFunc += "    return m"+fname+";\n";
+        getFunc += "  }\n";
+        String setFunc = "  virtual void set"+fname+"("+mCppName+" m_) {\n";
+        setFunc += "    m"+fname+"=m_; bs_.set("+fIdx+");\n";
+        setFunc += "  }\n";
+        return getFunc+setFunc;
+    }
+    
+    static String capitalize(String s) {
+        return s.substring(0,1).toUpperCase()+s.substring(1);
+    }
+    String genJavaGetSet(String fname, int fIdx) {
+        String getFunc = "  public "+mJavaName+" get"+capitalize(fname)+"() {\n";
+        getFunc += "    return "+fname+";\n";
+        getFunc += "  }\n";
+        String setFunc = "  public void set"+capitalize(fname)+"("+mJavaName+" m_) {\n";
+        setFunc += "    " + fname+"=m_;\n";
+        setFunc += "  }\n";
+        return getFunc+setFunc;
+    }
+    
+    String getCType() {
+    	return mCName;
+    }
+    String getCppType() {
+        return mCppName;
+    }
+    
+    String getJavaType() {
+        return mJavaName;
+    }
+   
+    String getJavaWrapperType() {
+        return mWrapper;
+    }
+    
+    String getMethodSuffix() {
+        return mMethodSuffix;
+    }
+    
+    String genJavaWriteMethod(String fname, String tag) {
+        return "    a_.write"+mMethodSuffix+"("+fname+",\""+tag+"\");\n";
+    }
+    
+    String genJavaReadMethod(String fname, String tag) {
+        return "    "+fname+"=a_.read"+mMethodSuffix+"(\""+tag+"\");\n";
+    }
+    
+    String genJavaReadWrapper(String fname, String tag, boolean decl) {
+        String ret = "";
+        if (decl) {
+            ret = "    "+mWrapper+" "+fname+";\n";
+        }
+        return ret + "    "+fname+"=new "+mWrapper+"(a_.read"+mMethodSuffix+"(\""+tag+"\"));\n";
+    }
+    
+    String genJavaWriteWrapper(String fname, String tag) {
+        return "        a_.write"+mMethodSuffix+"("+fname+"."+mUnwrapMethod+"(),\""+tag+"\");\n";
+    }
+    
+    String genJavaCompareTo(String fname) {
+        return "    ret = ("+fname+" == peer."+fname+")? 0 :(("+fname+"<peer."+fname+")?-1:1);\n";
+    }
+    
+    String genJavaEquals(String fname, String peer) {
+        return "    ret = ("+fname+"=="+peer+");\n";
+    }
+    
+    String genJavaHashCode(String fname) {
+        return "    ret = (int)"+fname+";\n";
+    }
+
+    String genJavaConstructorSet(String fname, String name) {
+        return "    this."+fname+"="+name+";\n";
+    }
+
+}



Mime
View raw message