KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_web > deployment > api > TransportGuaranteeDesc


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Florent BENOIT
22  * --------------------------------------------------------------------------
23  * $Id: TransportGuaranteeDesc.java,v 1.2 2004/06/01 11:24:01 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas_web.deployment.api;
28
29 import java.util.ArrayList JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32
33 /**
34  * Defines a transport guarantee object.
35  * Several kind of tranport can be assigned.
36  * It could be : INTEGRAL, CONFIDENTIAL, NONE
37  * @author Florent Benoit
38  */

39 public class TransportGuaranteeDesc {
40
41     /**
42      * Constant for Confidential transport guarantee
43      */

44     public static final String JavaDoc CONFIDENTIAL_TRANSPORT = "CONFIDENTIAL";
45
46     /**
47      * Constant for Integral transport guarantee
48      */

49     public static final String JavaDoc INTEGRAL_TRANSPORT = "INTEGRAL";
50
51     /**
52      * Constant for None transport guarantee
53      */

54     public static final String JavaDoc NONE_TRANSPORT = "NONE";
55
56     /**
57      * Internal list of transports
58      */

59     private List JavaDoc transports = null;
60
61     /**
62      * Constructor : Build a new Guarantee object
63      */

64     public TransportGuaranteeDesc() {
65         transports = new ArrayList JavaDoc();
66     }
67
68
69     /**
70      * Add transport name
71      * No check is performed here on the name
72      * validation has to be done at XML parsing time
73      * @param name protocol value
74      */

75     public void addTransportValue(String JavaDoc name) {
76         if (name == null) {
77             name = NONE_TRANSPORT;
78         }
79         String JavaDoc upperCasename = name.toUpperCase();
80         if (!transports.contains(upperCasename)) {
81             transports.add(upperCasename);
82         }
83     }
84
85     /**
86      * Test if this transport Guarantee contains the INTEGRAL value
87      * @return true if it contains INTEGRAL
88      */

89     public boolean isIntegral() {
90         return transports.contains(INTEGRAL_TRANSPORT);
91     }
92
93     /**
94      * Test if this transport Guarantee contains the CONFIDENTIAL value
95      * @return true if it contains CONFIDENTIAL
96      */

97     public boolean isConfidential() {
98         return transports.contains(CONFIDENTIAL_TRANSPORT);
99     }
100
101     /**
102      * Test if this transport Guarantee contains the NONE value
103      * @return true if it contains NONE
104      */

105     public boolean hasNone() {
106         return transports.contains(NONE_TRANSPORT);
107     }
108
109
110     /**
111      * Gets the number of different transports.
112      * @return count of transports.
113      */

114     public int getNumber() {
115         return transports.size();
116     }
117
118
119     /**
120      * String representation
121      * @return string representation of the pattern
122      */

123     public String JavaDoc toString() {
124         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
125         sb.append("TransportGuarantee[values=");
126         for (Iterator JavaDoc it = transports.iterator(); it.hasNext();) {
127             String JavaDoc value = (String JavaDoc) it.next();
128             sb.append("(");
129             sb.append(value);
130             sb.append(")");
131         }
132         sb.append("]");
133         return sb.toString();
134     }
135
136 }
137
Popular Tags