1 28 29 package com.caucho.jms.selector; 30 31 import javax.jms.DeliveryMode ; 32 import javax.jms.JMSException ; 33 import javax.jms.Message ; 34 35 38 public class SpecialIdentifierSelector extends Selector { 39 final static int JMS_DELIVERY_MODE = 1; 40 final static int JMS_PRIORITY = 2; 41 final static int JMS_MESSAGE_ID = 3; 42 final static int JMS_TIMESTAMP = 4; 43 final static int JMS_CORRELATION_ID = 5; 44 final static int JMS_TYPE = 6; 45 46 private int _type; 47 48 SpecialIdentifierSelector(int type) 49 { 50 _type = type; 51 } 52 53 56 boolean isUnknown() 57 { 58 return false; 59 } 60 61 64 boolean isNumber() 65 { 66 switch (_type) { 67 case JMS_PRIORITY: 68 case JMS_TIMESTAMP: 69 return true; 70 default: 71 return false; 72 } 73 } 74 75 78 boolean isString() 79 { 80 switch (_type) { 81 case JMS_MESSAGE_ID: 82 case JMS_CORRELATION_ID: 83 case JMS_TYPE: 84 case JMS_DELIVERY_MODE: 85 return true; 86 default: 87 return false; 88 } 89 } 90 91 95 Object evaluate(Message message) 96 throws JMSException 97 { 98 switch (_type) { 99 case JMS_DELIVERY_MODE: 100 if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) 101 return "PERSISTENT"; 102 else 103 return "NON_PERSISTENT"; 104 case JMS_PRIORITY: 105 return new Integer (message.getJMSPriority()); 106 case JMS_MESSAGE_ID: 107 return message.getJMSMessageID(); 108 case JMS_TIMESTAMP: 109 return new Long (message.getJMSTimestamp()); 110 case JMS_CORRELATION_ID: 111 return message.getJMSCorrelationID(); 112 case JMS_TYPE: 113 return message.getJMSType(); 114 default: 115 throw new UnsupportedOperationException (); 116 } 117 } 118 119 public String toString() 120 { 121 switch (_type) { 122 case JMS_DELIVERY_MODE: 123 return "JMSDeliveryMode"; 124 case JMS_PRIORITY: 125 return "JMSPriority"; 126 case JMS_MESSAGE_ID: 127 return "JMSMessageID"; 128 case JMS_TIMESTAMP: 129 return "JMSTimestamp"; 130 case JMS_CORRELATION_ID: 131 return "JMSCorrelationID"; 132 case JMS_TYPE: 133 return "JMSType"; 134 default: 135 return "Special[" + _type + "]"; 136 } 137 } 138 } 139 | Popular Tags |