You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2015/08/14 21:07:37 UTC

[04/50] [abbrv] 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.

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/1e703f5c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1e703f5c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1e703f5c

Branch: refs/heads/rajith-codec
Commit: 1e703f5cdf3ea2be43bd152dcefd118ca97a2609
Parents: 9880768
Author: Rajith Attapattu <ra...@apache.org>
Authored: Thu Feb 5 16:50:43 2015 -0500
Committer: Rajith Attapattu <ra...@apache.org>
Committed: Thu Jul 9 09:12:37 2015 -0400

----------------------------------------------------------------------
 .../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/1e703f5c/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/1e703f5c/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/1e703f5c/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