001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.jetspeed.capabilities.impl;
019:
020: import org.apache.commons.collections.CollectionUtils;
021: import org.apache.jetspeed.capabilities.Client;
022:
023: import java.util.ArrayList;
024: import java.util.Collection;
025:
026: /**
027: * Simple implementation of the ClientRegistry interface.
028: *
029: * @author <a href="shesmer@raleigh.ibm.com">Stephan Hesmer</a>
030: * @author <a href="mailto:raphael@apache.org">Rapha\u00ebl Luta</a>
031: * @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
032: * @version $Id: ClientImpl.java 516448 2007-03-09 16:25:47Z ate $
033: */
034: public class ClientImpl implements Client, java.io.Serializable {
035: private String userAgentPattern = "";
036: private String manufacturer = "";
037: private String model = "";
038: private String version = "";
039: private String name;
040: private Collection mimetypes;
041: private Collection capabilities;
042: private int preferredMimeTypeId;
043:
044: private int clientId;
045: private int evalOrder = 0;
046:
047: public ClientImpl() {
048: }
049:
050: /**
051: * Implements the equals operation so that 2 elements are equal if
052: * all their member values are equal.
053: */
054: public boolean equals(Object object) {
055: if (object == this )
056: return true;
057:
058: if (object == null) {
059: return false;
060: }
061:
062: ClientImpl obj = (ClientImpl) object;
063:
064: if (name != null) {
065: if (!name.equals(obj.name)) {
066: return false;
067: }
068: } else {
069: if (obj.name != null) {
070: return false;
071: }
072: }
073:
074: if (userAgentPattern != null) {
075: if (!userAgentPattern.equals(obj.userAgentPattern)) {
076: return false;
077: }
078: } else {
079: if (obj.userAgentPattern != null) {
080: return false;
081: }
082: }
083:
084: if (manufacturer != null) {
085: if (!manufacturer.equals(obj.manufacturer)) {
086: return false;
087: }
088: } else {
089: if (obj.manufacturer != null) {
090: return false;
091: }
092: }
093:
094: if (model != null) {
095: if (!model.equals(obj.model)) {
096: return false;
097: }
098: } else {
099: if (obj.model != null) {
100: return false;
101: }
102: }
103:
104: if (version != null) {
105: if (!version.equals(obj.version)) {
106: return false;
107: }
108: } else {
109: if (obj.version != null) {
110: return false;
111: }
112: }
113: if (mimetypes != null) {
114: if (!CollectionUtils.isEqualCollection(mimetypes,
115: obj.mimetypes)) {
116: return false;
117: }
118: } else {
119: if (obj.mimetypes != null) {
120: return false;
121: }
122: }
123:
124: if (capabilities != null) {
125: if (!(CollectionUtils.isEqualCollection(capabilities,
126: obj.capabilities)))
127: return false;
128: } else {
129: if (obj.capabilities != null) {
130: return false;
131: }
132: }
133: return true;
134: }
135:
136: public String getUserAgentPattern() {
137: return userAgentPattern;
138: }
139:
140: public void setUserAgentPattern(String userAgentPattern) {
141: this .userAgentPattern = userAgentPattern;
142: }
143:
144: public String getManufacturer() {
145: return manufacturer;
146: }
147:
148: public void setManufacturer(String name) {
149: manufacturer = name;
150: }
151:
152: public String getModel() {
153: return model;
154: }
155:
156: public void setModel(String name) {
157: model = name;
158: }
159:
160: public String getVersion() {
161: return version;
162: }
163:
164: public void setVersion(String name) {
165: version = name;
166: }
167:
168: public Collection getMimetypes() {
169: if (this .mimetypes == null) {
170: this .mimetypes = new ArrayList();
171: }
172: return mimetypes;
173: }
174:
175: public void setMimetypes(Collection mimetypes) {
176: this .mimetypes = mimetypes;
177: }
178:
179: public Collection getCapabilities() {
180: if (capabilities == null) {
181: capabilities = new ArrayList();
182: }
183: return capabilities;
184: }
185:
186: public void setCapabilities(Collection capabilities) {
187: this .capabilities = capabilities;
188: }
189:
190: /**
191: * Set Client ID -- Assigns the Client ID
192: * @param id
193: */
194: public void setClientId(int id) {
195: this .clientId = id;
196: }
197:
198: /**
199: * Get Client ID
200: * @return Client ID
201: */
202: public int getClientId() {
203: return this .clientId;
204: }
205:
206: /**
207: * @return
208: */
209: public String getName() {
210: return name;
211: }
212:
213: /**
214: * @param string
215: */
216: public void setName(String string) {
217: name = string;
218: }
219:
220: /**
221: * @return Preferred MimeType ID for Client
222: */
223: public int getPreferredMimeTypeId() {
224: return this .preferredMimeTypeId;
225: }
226:
227: /**
228: * Set preferred Mimetype ID for Client
229: * @param mimeTypeId MimeTypeId
230: */
231: public void setPreferredMimeTypeId(int mimeTypeId) {
232: this .preferredMimeTypeId = mimeTypeId;
233: }
234:
235: /**
236: * @return Returns the evalOrder.
237: */
238: public int getEvalOrder() {
239: return evalOrder;
240: }
241:
242: /**
243: * @param evalOrder The evalOrder to set.
244: */
245: public void setEvalOrder(int evalOrder) {
246: this.evalOrder = evalOrder;
247: }
248: }
|