protected Object convertScheduled(String name, Object value) throws MessageFormatException { Object result = value; if (AMQ_SCHEDULED_DELAY.equals(name)){ result = TypeConversionSupport.convert(value, Long.class); } else if (AMQ_SCHEDULED_PERIOD.equals(name)){ result = TypeConversionSupport.convert(value, Long.class); } else if (AMQ_SCHEDULED_REPEAT.equals(name)){ result = TypeConversionSupport.convert(value, Integer.class); } return result; }
public static boolean isDestForcedDurable(final ActiveMQDestination destination) { boolean isForceDurable = false; if (destination != null) { final Map<String, String> options = destination.getOptions(); if (options != null) { isForceDurable = (boolean) TypeConversionSupport.convert(options.get("forceDurable"), boolean.class); } } return isForceDurable; } }
@Override public long getLongProperty(String name) throws JMSException { Object value = getObjectProperty(name); if (value == null) { throw new NumberFormatException("property " + name + " was null"); } Long rc = (Long) TypeConversionSupport.convert(value, Long.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a long"); } return rc.longValue(); }
@Override public short getShortProperty(String name) throws JMSException { Object value = getObjectProperty(name); if (value == null) { throw new NumberFormatException("property " + name + " was null"); } Short rc = (Short) TypeConversionSupport.convert(value, Short.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a short"); } return rc.shortValue(); }
@Override public int getIntProperty(String name) throws JMSException { Object value = getObjectProperty(name); if (value == null) { throw new NumberFormatException("property " + name + " was null"); } Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as an integer"); } return rc.intValue(); }
@Override public boolean getBooleanProperty(String name) throws JMSException { Object value = getObjectProperty(name); if (value == null) { return false; } Boolean rc = (Boolean) TypeConversionSupport.convert(value, Boolean.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a boolean"); } return rc.booleanValue(); }
@Override public byte getByteProperty(String name) throws JMSException { Object value = getObjectProperty(name); if (value == null) { throw new NumberFormatException("property " + name + " was null"); } Byte rc = (Byte) TypeConversionSupport.convert(value, Byte.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a byte"); } return rc.byteValue(); }
@Override public double getDoubleProperty(String name) throws JMSException { Object value = getObjectProperty(name); if (value == null) { throw new NullPointerException("property " + name + " was null"); } Double rc = (Double) TypeConversionSupport.convert(value, Double.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a double"); } return rc.doubleValue(); }
@Override public void set(Message message, Object value) throws MessageFormatException { Boolean rc = (Boolean) TypeConversionSupport.convert(value, Boolean.class); if (rc == null) { throw new MessageFormatException("Property JMSRedelivered cannot be set from a " + value.getClass().getName() + "."); } ((ActiveMQMessage) message).setJMSRedelivered(rc.booleanValue()); } });
@Override public float getFloatProperty(String name) throws JMSException { Object value = getObjectProperty(name); if (value == null) { throw new NullPointerException("property " + name + " was null"); } Float rc = (Float) TypeConversionSupport.convert(value, Float.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a float"); } return rc.floatValue(); }
@Override public void set(Message message, Object value) throws MessageFormatException { Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class); if (rc == null) { throw new MessageFormatException("Property JMSXDeliveryCount cannot be set from a " + value.getClass().getName() + "."); } message.setRedeliveryCounter(rc.intValue() - 1); } });
@Override public void set(Message message, Object value) throws MessageFormatException { Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class); if (rc == null) { throw new MessageFormatException("Property JMSPriority cannot be set from a " + value.getClass().getName() + "."); } ((ActiveMQMessage) message).setJMSPriority(rc.intValue()); } });
@Override public void set(Message message, Object value) throws MessageFormatException { String rc = (String) TypeConversionSupport.convert(value, String.class); if (rc == null) { throw new MessageFormatException("Property JMSType cannot be set from a " + value.getClass().getName() + "."); } ((ActiveMQMessage) message).setJMSType(rc); } });
@Override public void set(Message message, Object value) throws MessageFormatException { String rc = (String) TypeConversionSupport.convert(value, String.class); if (rc == null) { throw new MessageFormatException("Property JMSXGroupID cannot be set from a " + value.getClass().getName() + "."); } message.setGroupID(rc); } });
@Override public void set(Message message, Object value) throws MessageFormatException { Integer rc = (Integer) TypeConversionSupport.convert(value, Integer.class); if (rc == null) { throw new MessageFormatException("Property JMSXGroupSeq cannot be set from a " + value.getClass().getName() + "."); } message.setGroupSequence(rc.intValue()); } });
@Override public void set(Message message, Object value) throws MessageFormatException { Long rc = (Long) TypeConversionSupport.convert(value, Long.class); if (rc == null) { throw new MessageFormatException("Property JMSExpiration cannot be set from a " + value.getClass().getName() + "."); } ((ActiveMQMessage) message).setJMSExpiration(rc.longValue()); } });
@Override public void set(Message message, Object value) throws MessageFormatException { Long rc = (Long) TypeConversionSupport.convert(value, Long.class); if (rc == null) { throw new MessageFormatException("Property JMSTimestamp cannot be set from a " + value.getClass().getName() + "."); } ((ActiveMQMessage) message).setJMSTimestamp(rc.longValue()); } });
@Override public void set(Message message, Object value) throws MessageFormatException { String rc = (String) TypeConversionSupport.convert(value, String.class); if (rc == null) { throw new MessageFormatException("Property JMSCorrelationID cannot be set from a " + value.getClass().getName() + "."); } ((ActiveMQMessage) message).setJMSCorrelationID(rc); } });
@Override public void set(Message message, Object value) throws MessageFormatException { ActiveMQDestination rc = (ActiveMQDestination) TypeConversionSupport.convert(value, ActiveMQDestination.class); if (rc == null) { throw new MessageFormatException("Property JMSReplyTo cannot be set from a " + value.getClass().getName() + "."); } ((ActiveMQMessage) message).setReplyTo(rc); } });
@Override public String getStringProperty(String name) throws JMSException { Object value = null; if (name.equals("JMSXUserID")) { value = getUserID(); if (value == null) { value = getObjectProperty(name); } } else { value = getObjectProperty(name); } if (value == null) { return null; } String rc = (String) TypeConversionSupport.convert(value, String.class); if (rc == null) { throw new MessageFormatException("Property " + name + " was a " + value.getClass().getName() + " and cannot be read as a String"); } return rc; }