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 2010/07/29 04:07:57 UTC

svn commit: r980287 - /qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java

Author: rajith
Date: Thu Jul 29 02:07:57 2010
New Revision: 980287

URL: http://svn.apache.org/viewvc?rev=980287&view=rev
Log:
Removed an import (related to a work-in-progress) that got accidently included in the AddressHelper.java

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java?rev=980287&r1=980286&r2=980287&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java Thu Jul 29 02:07:57 2010
@@ -27,7 +27,6 @@ import java.util.Map;
 
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQDestination.Binding;
-import org.apache.qpid.client.messaging.address.Link.Reliability;
 import org.apache.qpid.client.messaging.address.Node.ExchangeNode;
 import org.apache.qpid.client.messaging.address.Node.QueueNode;
 import org.apache.qpid.client.messaging.address.Node.UnknownNodeType;
@@ -36,8 +35,7 @@ import org.apache.qpid.configuration.Acc
 import org.apache.qpid.messaging.Address;
 
 /**
- * Utility class for extracting information
- * from the address class  
+ * Utility class for extracting information from the address class
  */
 public class AddressHelper
 {
@@ -68,40 +66,45 @@ public class AddressHelper
     public static final String KEY = "key";
     public static final String ARGUMENTS = "arguments";
     public static final String RELIABILITY = "reliability";
-    
+
     private Address address;
     private Accessor addressProps;
     private Accessor nodeProps;
     private Accessor linkProps;
-    
+
     public AddressHelper(Address address)
     {
         this.address = address;
         addressProps = new MapAccessor(address.getOptions());
-        Map node_props = address.getOptions() == null || 
-                         address.getOptions().get(NODE) == null ?
-                               null : (Map)address.getOptions().get(NODE);
-        
-        if (node_props != null) { nodeProps = new MapAccessor(node_props); }
-        
-        
-        Map link_props = address.getOptions() == null || 
-                         address.getOptions().get(LINK) == null ?
-                              null : (Map)address.getOptions().get(LINK); 
-        
-        if (link_props != null) { linkProps = new MapAccessor(link_props); }
+        Map node_props = address.getOptions() == null
+                || address.getOptions().get(NODE) == null ? null
+                : (Map) address.getOptions().get(NODE);
+
+        if (node_props != null)
+        {
+            nodeProps = new MapAccessor(node_props);
+        }
+
+        Map link_props = address.getOptions() == null
+                || address.getOptions().get(LINK) == null ? null
+                : (Map) address.getOptions().get(LINK);
+
+        if (link_props != null)
+        {
+            linkProps = new MapAccessor(link_props);
+        }
     }
-    
+
     public String getCreate()
     {
         return addressProps.getString(CREATE);
     }
-    
+
     public String getAssert()
     {
         return addressProps.getString(ASSERT);
     }
-    
+
     public String getDelete()
     {
         return addressProps.getString(DELETE);
@@ -110,15 +113,15 @@ public class AddressHelper
     public boolean isNoLocal()
     {
         Boolean b = nodeProps.getBoolean(NO_LOCAL);
-        return b == null ? false : b ;
+        return b == null ? false : b;
     }
-   
+
     public boolean isBrowseOnly()
     {
         String mode = addressProps.getString(MODE);
-        return mode != null && mode.equals(BROWSE) ? true : false ;
+        return mode != null && mode.equals(BROWSE) ? true : false;
     }
-  
+
     public QpidQueueOptions getQpidQueueOptions(MapAccessor args)
     {
         QpidQueueOptions options = new QpidQueueOptions();
@@ -126,39 +129,42 @@ public class AddressHelper
         {
             options.setMaxCount(args.getInt(QpidQueueOptions.QPID_MAX_COUNT));
         }
-        
+
         if (args.getInt(QpidQueueOptions.QPID_MAX_SIZE) != null)
         {
             options.setMaxSize(args.getInt(QpidQueueOptions.QPID_MAX_SIZE));
-        }        
-        
+        }
+
         if (args.getString(QpidQueueOptions.QPID_POLICY_TYPE) != null)
         {
-            options.setPolicyType(args.getString(QpidQueueOptions.QPID_POLICY_TYPE));
+            options.setPolicyType(args
+                    .getString(QpidQueueOptions.QPID_POLICY_TYPE));
         }
-        
+
         if (args.getInt(QpidQueueOptions.QPID_PERSIST_LAST_NODE) != null)
         {
             options.setPersistLastNode();
-        }  
-        
+        }
+
         if (args.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE) != null)
         {
             options.setOrderingPolicy(QpidQueueOptions.QPID_LAST_VALUE_QUEUE);
-        }
-        else if (args.getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE) != null)
+        } else if (args
+                .getString(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE) != null)
         {
-            options.setOrderingPolicy(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE);
+            options
+                    .setOrderingPolicy(QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE);
         }
-        
+
         if (args.getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION) != null)
         {
-            options.setQueueEvents(args.getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION));
+            options.setQueueEvents(args
+                    .getString(QpidQueueOptions.QPID_QUEUE_EVENT_GENERATION));
         }
-        
+
         return options;
     }
-    
+
     public QpidExchangeOptions getQpidExchangeOptions(MapAccessor args)
     {
         QpidExchangeOptions options = new QpidExchangeOptions();
@@ -166,177 +172,180 @@ public class AddressHelper
         {
             options.setExclusiveBinding();
         }
-        
+
         if (args.getInt(QpidExchangeOptions.QPID_INITIAL_VALUE_EXCHANGE) != null)
         {
             options.setInitialValueExchange();
-        }        
-        
+        }
+
         if (args.getInt(QpidExchangeOptions.QPID_MSG_SEQUENCE) != null)
         {
             options.setMessageSequencing();
         }
         return options;
     }
-    
+
     @SuppressWarnings("unchecked")
     public List<Binding> getBindings(Map props)
     {
-        List<Binding> bindings = new ArrayList<Binding>();        
-        List<Map> bindingList = (List<Map>)props.get(X_BINDINGS);         
+        List<Binding> bindings = new ArrayList<Binding>();
+        List<Map> bindingList = (List<Map>) props.get(X_BINDINGS);
         if (bindingList != null)
         {
-            for (Map bindingMap: bindingList)
+            for (Map bindingMap : bindingList)
             {
-                Binding binding = new Binding((String)bindingMap.get(EXCHANGE),
-                                              (String)bindingMap.get(QUEUE),
-                                              (String)bindingMap.get(KEY),
-                                              bindingMap.get(ARGUMENTS) == null ?
-                                                  Collections.EMPTY_MAP:
-                                                  (Map<String,Object>)bindingMap.get(ARGUMENTS));
+                Binding binding = new Binding(
+                        (String) bindingMap.get(EXCHANGE),
+                        (String) bindingMap.get(QUEUE),
+                        (String) bindingMap.get(KEY),
+                        bindingMap.get(ARGUMENTS) == null ? Collections.EMPTY_MAP
+                                : (Map<String, Object>) bindingMap
+                                        .get(ARGUMENTS));
                 bindings.add(binding);
             }
         }
         return bindings;
     }
-    
+
     public Map getDeclareArgs(Map props)
     {
         if (props != null)
         {
-            return (Map)props.get(X_DECLARE);
-        }
-        else
+            return (Map) props.get(X_DECLARE);
+        } else
         {
             return Collections.EMPTY_MAP;
         }
     }
-    
+
     public int getTargetNodeType() throws Exception
     {
         if (nodeProps == null || nodeProps.getString(TYPE) == null)
         {
             // need to query and figure out
-            return AMQDestination.UNKNOWN_TYPE;    
-        }
-        else if (nodeProps.getString(TYPE).equals("queue"))
+            return AMQDestination.UNKNOWN_TYPE;
+        } else if (nodeProps.getString(TYPE).equals("queue"))
         {
             return AMQDestination.QUEUE_TYPE;
-        }
-        else if (nodeProps.getString(TYPE).equals("topic"))
+        } else if (nodeProps.getString(TYPE).equals("topic"))
         {
             return AMQDestination.TOPIC_TYPE;
-        }
-        else
+        } else
         {
             throw new Exception("unkown exchange type");
         }
     }
- 
+
     public Node getTargetNode(int addressType)
     {
         // target node here is the default exchange
         if (nodeProps == null || addressType == AMQDestination.QUEUE_TYPE)
         {
             return new ExchangeNode();
-        }
-        else if (addressType == AMQDestination.TOPIC_TYPE)
+        } else if (addressType == AMQDestination.TOPIC_TYPE)
         {
-            Map node = (Map)address.getOptions().get(NODE);
+            Map node = (Map) address.getOptions().get(NODE);
             return createExchangeNode(node);
-        }
-        else
+        } else
         {
             // don't know yet
             return null;
         }
     }
-    
+
     private Node createExchangeNode(Map parent)
     {
         Map declareArgs = getDeclareArgs(parent);
         MapAccessor argsMap = new MapAccessor(declareArgs);
         ExchangeNode node = new ExchangeNode();
-        node.setExchangeType(argsMap.getString(TYPE) == null?
-                             null:argsMap.getString(TYPE));
+        node.setExchangeType(argsMap.getString(TYPE) == null ? null : argsMap
+                .getString(TYPE));
         node.setDeclareArgs(getQpidExchangeOptions(argsMap));
-        fillInCommonNodeArgs(node,parent,argsMap);
+        fillInCommonNodeArgs(node, parent, argsMap);
         return node;
     }
-    
+
     private Node createQueueNode(Map parent)
     {
         Map declareArgs = getDeclareArgs(parent);
         MapAccessor argsMap = new MapAccessor(declareArgs);
         QueueNode node = new QueueNode();
         node.setAlternateExchange(argsMap.getString(ALT_EXCHANGE));
-        node.setExclusive(argsMap.getBoolean(EXCLUSIVE) == null? false : argsMap.getBoolean(EXCLUSIVE));
+        node.setExclusive(argsMap.getBoolean(EXCLUSIVE) == null ? false
+                : argsMap.getBoolean(EXCLUSIVE));
         node.setDeclareArgs(getQpidQueueOptions(argsMap));
-        fillInCommonNodeArgs(node,parent,argsMap);
-        
+        fillInCommonNodeArgs(node, parent, argsMap);
+
         return node;
     }
-    
-    private void fillInCommonNodeArgs(Node node,Map parent,MapAccessor argsMap)
+
+    private void fillInCommonNodeArgs(Node node, Map parent, MapAccessor argsMap)
     {
         if (nodeProps != null)
         {
-            node.setDurable(nodeProps.getBoolean(DURABLE) == null? false : nodeProps.getBoolean(DURABLE));
+            node.setDurable(nodeProps.getBoolean(DURABLE) == null ? false
+                    : nodeProps.getBoolean(DURABLE));
         }
-        node.setAutoDelete(argsMap.getBoolean(AUTO_DELETE) == null? false : argsMap.getBoolean(AUTO_DELETE));
+        node.setAutoDelete(argsMap.getBoolean(AUTO_DELETE) == null ? false
+                : argsMap.getBoolean(AUTO_DELETE));
         node.setAlternateExchange(argsMap.getString(ALT_EXCHANGE));
         node.setBindings(getBindings(parent));
     }
-    
+
     /**
-     * if the type == queue x-declare args from the node props is used.
-     * if the type == exchange x-declare args from the link props is used
-     * else just create a default temp queue.
+     * if the type == queue x-declare args from the node props is used. if the
+     * type == exchange x-declare args from the link props is used else just
+     * create a default temp queue.
      */
     public Node getSourceNode(int addressType)
     {
         if (addressType == AMQDestination.QUEUE_TYPE && nodeProps != null)
         {
-            return createQueueNode((Map)address.getOptions().get(NODE));
-        }    
+            return createQueueNode((Map) address.getOptions().get(NODE));
+        }
         if (addressType == AMQDestination.TOPIC_TYPE && linkProps != null)
         {
-            return createQueueNode((Map)address.getOptions().get(LINK));
-        }
-        else
+            return createQueueNode((Map) address.getOptions().get(LINK));
+        } else
         {
             // need to query the info
             return new QueueNode();
         }
     }
-    
+
     public Link getLink()
     {
         Link link = new Link();
         if (linkProps != null)
-        {            
-            link.setDurable(linkProps.getBoolean(DURABLE)== null? false : linkProps.getBoolean(DURABLE));
+        {
+            link.setDurable(linkProps.getBoolean(DURABLE) == null ? false
+                    : linkProps.getBoolean(DURABLE));
             link.setName(linkProps.getString(NAME));
-           
-            if (((Map)address.getOptions().get(LINK)).get(CAPACITY) instanceof Map)
-            { 
+
+            if (((Map) address.getOptions().get(LINK)).get(CAPACITY) instanceof Map)
+            {
                 MapAccessor capacityProps = new MapAccessor(
-                        (Map)((Map)address.getOptions().get(LINK)).get(CAPACITY));
-                link.setConsumerCapacity(capacityProps.getInt(CAPACITY_SOURCE) == null ?
-                                         0 : capacityProps.getInt(CAPACITY_SOURCE));
-                link.setProducerCapacity(capacityProps.getInt(CAPACITY_TARGET) == null ?
-                                         0 : capacityProps.getInt(CAPACITY_TARGET));
-            }
-            else
+                        (Map) ((Map) address.getOptions().get(LINK))
+                                .get(CAPACITY));
+                link
+                        .setConsumerCapacity(capacityProps
+                                .getInt(CAPACITY_SOURCE) == null ? 0
+                                : capacityProps.getInt(CAPACITY_SOURCE));
+                link
+                        .setProducerCapacity(capacityProps
+                                .getInt(CAPACITY_TARGET) == null ? 0
+                                : capacityProps.getInt(CAPACITY_TARGET));
+            } else
             {
-                int cap = linkProps.getInt(CAPACITY) == null ? 0 : linkProps.getInt(CAPACITY);
-                link.setConsumerCapacity(cap);  
+                int cap = linkProps.getInt(CAPACITY) == null ? 0 : linkProps
+                        .getInt(CAPACITY);
+                link.setConsumerCapacity(cap);
                 link.setProducerCapacity(cap);
             }
             link.setFilter(linkProps.getString(FILTER));
             // so far filter type not used
         }
-        
+
         return link;
     }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org