KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > api > jms > selector > syntax > Identifiers


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Coridan.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 package org.mr.api.jms.selector.syntax;
47
48
49 /**
50  * Utility methods for JMS message header identifiers
51  *
52  */

53 public final class Identifiers {
54
55     
56     /**
57      * Prefix for identifiers available via message methods
58      */

59     public static final String JavaDoc JMS_PREFIX = "JMS";
60
61     
62     /**
63      * Prefix for identifiers specified by the JMS standard
64      */

65     public static final String JavaDoc JMSX_PREFIX = "JMSX";
66
67     
68     /**
69      * Prefix for provider specific identifiers
70      */

71     public static final String JavaDoc JMS_PROVIDER_PREFIX = "JMS_";
72
73     
74     /**
75      * The JMSDeliveryMode identifier
76      */

77     public static final String JavaDoc JMS_DELIVERY_MODE = "JMSDeliveryMode";
78
79     /**
80      * The JMSPriority identifier
81      */

82     public static final String JavaDoc JMS_PRIORITY = "JMSPriority";
83
84     /**
85      * The JMSMessageID identifier
86      */

87     public static final String JavaDoc JMS_MESSAGE_ID = "JMSMessageID";
88
89     /**
90      * The JMSTimestamp identifier
91      */

92     public static final String JavaDoc JMS_TIMESTAMP = "JMSTimestamp";
93
94     /**
95      * The JMSCorrelationID identifier
96      */

97     public static final String JavaDoc JMS_CORRELATION_ID = "JMSCorrelationID";
98
99     /**
100      * The JMSType identifier
101      */

102     public static final String JavaDoc JMS_TYPE = "JMSType";
103
104     /**
105      * The persistent delivery mode
106      */

107     public static final String JavaDoc PERSISTENT = "PERSISTENT";
108
109     /**
110      * The non-persistent delivery mode
111      */

112     public static final String JavaDoc NON_PERSISTENT = "NON_PERSISTENT";
113
114
115     /**
116      * Private constructor,we don't want to create a new instance of Identifiers
117      */

118     private Identifiers() {
119     }//Identifiers
120

121     /**
122      * Determines if an identifier is a JMS identifier (not a JMSX or
123      * provider specific identifier)
124      *
125      * @param name the identifier name
126      * @return true if the identifier is a JMS identifier, otherwise false
127      */

128     public static boolean isJMSIdentifier(final String JavaDoc name) {
129         boolean result = false;
130
131         if (name.startsWith(JMS_PREFIX) && !(name.startsWith(JMSX_PREFIX) || name.startsWith(JMS_PROVIDER_PREFIX)))
132             result = true;
133
134         return result;
135     }//isJMSIdentifier
136

137     
138     /**
139      * Determines if a JMS identifier is valid in selectors
140      *
141      * @param name the identifier name
142      * @return true if the identifier may be selected upon, otherwise false
143      */

144     public static boolean isQueryableJMSIdentifier(final String JavaDoc name) {
145         return (name.equals(JMS_DELIVERY_MODE)
146                 || name.equals(JMS_PRIORITY)
147                 || name.equals(JMS_TIMESTAMP)
148                 || name.equals(JMS_MESSAGE_ID)
149                 || name.equals(JMS_CORRELATION_ID)
150                 || name.equals(JMS_TYPE));
151     }//isQueryableJMSIdentifier
152

153     
154     /**
155      * Determines if a JMS identifier is a string
156      *
157      * @param name the identifier name
158      * @return true if the identifier is a string, otherwise false
159      */

160     public static boolean isString(final String JavaDoc name) {
161         return (name.equals(JMS_MESSAGE_ID)
162                 || name.equals(JMS_CORRELATION_ID)
163                 || name.equals(JMS_TYPE)
164                 || name.equals(JMS_DELIVERY_MODE));
165         // delivery mode is an integer which must be mapped to a string
166
// (see '3.8.1.3 Special Notes' of the spec).
167
}//isString
168

169     
170     /**
171      * Determines if a JMS identifier is numeric
172      *
173      * @param name the identifier name
174      * @return true if the identifier is numeric, otherwise false
175      */

176     public static boolean isNumeric(final String JavaDoc name) {
177         return (name.equals(JMS_PRIORITY) || name.equals(JMS_TIMESTAMP));
178     }//isNumeric
179
}//Identifiers
180
Popular Tags