qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [01/10] qpid-proton git commit: Addressing the comments made in the previous round of reviews. Moved the described class out of POJOBuilder and renamed classes appropriately.
Date Mon, 09 Feb 2015 16:49:53 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/rajith-codec 4c1c1eaa2 -> 45e86de42


Addressing the comments made in the previous round of reviews. Moved the described class out
of POJOBuilder and renamed classes appropriately.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cbaf991a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cbaf991a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cbaf991a

Branch: refs/heads/rajith-codec
Commit: cbaf991a552b6a89f2b68db686017101dcb8401a
Parents: 4c1c1ea
Author: Rajith Attapattu <rajith@apache.org>
Authored: Thu Feb 5 16:50:43 2015 -0500
Committer: Rajith Attapattu <rajith@apache.org>
Committed: Thu Feb 5 16:50:43 2015 -0500

----------------------------------------------------------------------
 .../apache/qpid/proton/codec2/Described.java    | 51 ++++++++++++++++
 .../proton/codec2/DescribedTypeFactory.java     | 26 ++++++++
 .../qpid/proton/codec2/DiscriptorRegistry.java  | 63 ++++++++++++++++++++
 3 files changed, 140 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbaf991a/proton-j/src/main/java/org/apache/qpid/proton/codec2/Described.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec2/Described.java b/proton-j/src/main/java/org/apache/qpid/proton/codec2/Described.java
new file mode 100644
index 0000000..49a939f
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec2/Described.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.qpid.proton.codec2;
+
+public class Described
+{
+
+    private Object descriptor;
+
+    private Object value;
+
+    public Described(Object descriptor, Object value)
+    {
+        this.descriptor = descriptor;
+        this.value = value;
+    }
+
+    public Object getDescriptor()
+    {
+        return descriptor;
+    }
+
+    public Object getValue()
+    {
+        return value;
+    }
+
+    public String toString()
+    {
+        return String.format("Described(%s, %s)", descriptor, value);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbaf991a/proton-j/src/main/java/org/apache/qpid/proton/codec2/DescribedTypeFactory.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec2/DescribedTypeFactory.java
b/proton-j/src/main/java/org/apache/qpid/proton/codec2/DescribedTypeFactory.java
new file mode 100644
index 0000000..4a2e784
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec2/DescribedTypeFactory.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.qpid.proton.codec2;
+
+public interface DescribedTypeFactory
+{
+    public Object create(Object in) throws DecodeException;
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cbaf991a/proton-j/src/main/java/org/apache/qpid/proton/codec2/DiscriptorRegistry.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec2/DiscriptorRegistry.java
b/proton-j/src/main/java/org/apache/qpid/proton/codec2/DiscriptorRegistry.java
new file mode 100644
index 0000000..2c28995
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec2/DiscriptorRegistry.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.qpid.proton.codec2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DiscriptorRegistry
+{
+    private static Map<String, DescribedTypeFactory> _typeRegByStrCode = new HashMap<String,
DescribedTypeFactory>();
+
+    private static Map<Long, DescribedTypeFactory> _typeRegByLongCode = new HashMap<Long,
DescribedTypeFactory>();
+
+    public static void registerType(long longCode, String strCode, DescribedTypeFactory factory)
+    {
+        _typeRegByStrCode.put(strCode, factory);
+        _typeRegByLongCode.put(longCode, factory);
+    }
+
+    public static DescribedTypeFactory lookup(Object code)
+    {
+        if (code instanceof Long)
+        {
+            return lookup((Long) code);
+        }
+        else if (code instanceof String)
+        {
+            return lookup((String) code);
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    static DescribedTypeFactory lookup(long code)
+    {
+        return _typeRegByLongCode.get(code);
+    }
+
+    static DescribedTypeFactory lookup(String code)
+    {
+        return _typeRegByStrCode.get(code);
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message