public Link getLink()

in client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java [221:321]


    public Link getLink()
    {
        Link link = new Link();
        link.setSubscription(new Subscription());
        link.setSubscriptionQueue(new SubscriptionQueue());
        if (_linkPropAccess != null)
        {
            link.setDurable(getBooleanProperty(_linkPropAccess,DURABLE,false));
            link.setName(_linkPropAccess.getString(NAME));

            String reliability = _linkPropAccess.getString(RELIABILITY);
            if ( reliability != null)
            {
                if (reliability.equalsIgnoreCase("unreliable"))
                {
                    link.setReliability(Reliability.UNRELIABLE);
                }
                else if (reliability.equalsIgnoreCase("at-least-once"))
                {
                    link.setReliability(Reliability.AT_LEAST_ONCE);
                }
                else
                {
                    throw new IllegalArgumentException("The reliability mode '" +
                            reliability + "' is not yet supported");
                }
            }
            Long delay = _linkPropAccess.getLong("delay");
            if(delay != null)
            {
                link.setDelay(delay);
            }
            String localAddress = _linkPropAccess.getString("localAddress");
            if(localAddress != null)
            {
                link.setLocalAddress(localAddress);
            }
            if (((Map) _address.getOptions().get(LINK)).get(CAPACITY) instanceof Map)
            {
                MapAccessor capacityProps = new MapAccessor((Map) ((Map) _address.getOptions().get(LINK)).get(CAPACITY));

                Integer sourceCapacity = capacityProps.getInt(CAPACITY_SOURCE);
                link.setConsumerCapacity(sourceCapacity == null ? -1 : sourceCapacity);

                Integer targetCapacity = capacityProps.getInt(CAPACITY_TARGET);
                link.setProducerCapacity(targetCapacity == null ? -1 : targetCapacity);
            } 
            else
            {
                int cap = _linkPropAccess.getInt(CAPACITY) == null ? -1 : _linkPropAccess.getInt(CAPACITY);
                link.setConsumerCapacity(cap);
                link.setProducerCapacity(cap);
            }
            link.setFilter(_linkPropAccess.getString(FILTER));
            // so far filter type not used
            
            Map linkMap = (Map) _address.getOptions().get(LINK);

            if (linkMap != null)
            {
                Map x_subscribe = null;

                if(linkMap.containsKey(X_SUBSCRIBE))
                {
                    x_subscribe = (Map)((Map) _address.getOptions().get(LINK)).get(X_SUBSCRIBE);
                }
                else if(linkMap.containsKey(X_SUBSCRIBES))
                {
                    // left in for backwards compatibility with old broken constant
                    x_subscribe = (Map)((Map) _address.getOptions().get(LINK)).get(X_SUBSCRIBES);
                }

                if(x_subscribe != null)
                {
                    if (x_subscribe.containsKey(ARGUMENTS))
                    {
                        link.getSubscription().setArgs((Map<String, Object>) x_subscribe.get(ARGUMENTS));
                    }

                    boolean exclusive = x_subscribe.containsKey(EXCLUSIVE) ?
                            Boolean.parseBoolean((String) x_subscribe.get(EXCLUSIVE)) : false;

                    link.getSubscription().setExclusive(exclusive);
                }
            }

            link.setBindings(getBindings(linkMap));
            Map xDeclareMap = getDeclareArgs(linkMap);
            SubscriptionQueue queue = link.getSubscriptionQueue();
            if (!xDeclareMap.isEmpty() && xDeclareMap.containsKey(ARGUMENTS))
            {
                MapAccessor xDeclareMapAccessor = new MapAccessor(xDeclareMap);
                queue.setAutoDelete(getBooleanProperty(xDeclareMapAccessor,AUTO_DELETE,true));
                queue.setExclusive(getBooleanProperty(xDeclareMapAccessor,EXCLUSIVE,true));
                queue.setAlternateExchange(xDeclareMapAccessor.getString(ALT_EXCHANGE));
                queue.setDeclareArgs((Map<String,Object>)xDeclareMap.get(ARGUMENTS));
            }
        }

        return link;
    }