001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2004 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * Initial developer: Florent BENOIT
022: * --------------------------------------------------------------------------
023: * $Id: TransportGuaranteeDesc.java 4854 2004-06-01 11:24:01Z benoitf $
024: * --------------------------------------------------------------------------
025: */package org.objectweb.jonas_web.deployment.api;
026:
027: import java.util.ArrayList;
028: import java.util.Iterator;
029: import java.util.List;
030:
031: /**
032: * Defines a transport guarantee object.
033: * Several kind of tranport can be assigned.
034: * It could be : INTEGRAL, CONFIDENTIAL, NONE
035: * @author Florent Benoit
036: */
037: public class TransportGuaranteeDesc {
038:
039: /**
040: * Constant for Confidential transport guarantee
041: */
042: public static final String CONFIDENTIAL_TRANSPORT = "CONFIDENTIAL";
043:
044: /**
045: * Constant for Integral transport guarantee
046: */
047: public static final String INTEGRAL_TRANSPORT = "INTEGRAL";
048:
049: /**
050: * Constant for None transport guarantee
051: */
052: public static final String NONE_TRANSPORT = "NONE";
053:
054: /**
055: * Internal list of transports
056: */
057: private List transports = null;
058:
059: /**
060: * Constructor : Build a new Guarantee object
061: */
062: public TransportGuaranteeDesc() {
063: transports = new ArrayList();
064: }
065:
066: /**
067: * Add transport name
068: * No check is performed here on the name
069: * validation has to be done at XML parsing time
070: * @param name protocol value
071: */
072: public void addTransportValue(String name) {
073: if (name == null) {
074: name = NONE_TRANSPORT;
075: }
076: String upperCasename = name.toUpperCase();
077: if (!transports.contains(upperCasename)) {
078: transports.add(upperCasename);
079: }
080: }
081:
082: /**
083: * Test if this transport Guarantee contains the INTEGRAL value
084: * @return true if it contains INTEGRAL
085: */
086: public boolean isIntegral() {
087: return transports.contains(INTEGRAL_TRANSPORT);
088: }
089:
090: /**
091: * Test if this transport Guarantee contains the CONFIDENTIAL value
092: * @return true if it contains CONFIDENTIAL
093: */
094: public boolean isConfidential() {
095: return transports.contains(CONFIDENTIAL_TRANSPORT);
096: }
097:
098: /**
099: * Test if this transport Guarantee contains the NONE value
100: * @return true if it contains NONE
101: */
102: public boolean hasNone() {
103: return transports.contains(NONE_TRANSPORT);
104: }
105:
106: /**
107: * Gets the number of different transports.
108: * @return count of transports.
109: */
110: public int getNumber() {
111: return transports.size();
112: }
113:
114: /**
115: * String representation
116: * @return string representation of the pattern
117: */
118: public String toString() {
119: StringBuffer sb = new StringBuffer();
120: sb.append("TransportGuarantee[values=");
121: for (Iterator it = transports.iterator(); it.hasNext();) {
122: String value = (String) it.next();
123: sb.append("(");
124: sb.append(value);
125: sb.append(")");
126: }
127: sb.append("]");
128: return sb.toString();
129: }
130:
131: }
|