001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/datatypes/Code.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2008 by:
006 EXSE, Department of Geography, University of Bonn
007 http://www.giub.uni-bonn.de/deegree/
008 lat/lon GmbH
009 http://www.lat-lon.de
010
011 This library is free software; you can redistribute it and/or
012 modify it under the terms of the GNU Lesser General Public
013 License as published by the Free Software Foundation; either
014 version 2.1 of the License, or (at your option) any later version.
015
016 This library is distributed in the hope that it will be useful,
017 but WITHOUT ANY WARRANTY; without even the implied warranty of
018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019 Lesser General Public License for more details.
020
021 You should have received a copy of the GNU Lesser General Public
022 License along with this library; if not, write to the Free Software
023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024
025 Contact:
026
027 Andreas Poth
028 lat/lon GmbH
029 Aennchenstr. 19
030 53115 Bonn
031 Germany
032 E-Mail: poth@lat-lon.de
033
034 Prof. Dr. Klaus Greve
035 Department of Geography
036 University of Bonn
037 Meckenheimer Allee 166
038 53115 Bonn
039 Germany
040 E-Mail: greve@giub.uni-bonn.de
041
042 ---------------------------------------------------------------------------*/
043 package org.deegree.datatypes;
044
045 import java.io.Serializable;
046 import java.net.URI;
047
048 /**
049 *
050 *
051 * @version $Revision: 9337 $
052 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
053 * @author last edited by: $Author: apoth $
054 *
055 * @version 1.0. $Revision: 9337 $, $Date: 2007-12-27 13:31:11 +0100 (Do, 27 Dez 2007) $
056 *
057 * @since 2.0
058 */
059 public class Code implements Serializable {
060
061 /**
062 *
063 */
064 private static final long serialVersionUID = 1L;
065
066 private String code = null;
067
068 private URI codeSpace = null;
069
070 private int ordinal = Integer.MIN_VALUE;
071
072 /**
073 * @param code
074 */
075 public Code( String code ) {
076 this.code = code;
077 }
078
079 /**
080 * @param code
081 * @param codeSpace
082 */
083 public Code( String code, URI codeSpace ) {
084 this.code = code;
085 this.codeSpace = codeSpace;
086 }
087
088 /**
089 * @param code
090 * @param ordinal
091 */
092 public Code( String code, int ordinal ) {
093 this.code = code;
094 this.ordinal = ordinal;
095 }
096
097 /**
098 * @param code
099 * @param codeSpace
100 * @param ordinal
101 */
102 public Code( String code, URI codeSpace, int ordinal ) {
103 this.code = code;
104 this.codeSpace = codeSpace;
105 this.ordinal = ordinal;
106 }
107
108 /**
109 * @return Returns the code.
110 */
111 public String getCode() {
112 return code;
113 }
114
115 /**
116 * @param code
117 * The code to set.
118 *
119 */
120 public void setCode( String code ) {
121 this.code = code;
122 }
123
124 /**
125 * @return Returns the codeSpace.
126 *
127 */
128 public URI getCodeSpace() {
129 return codeSpace;
130 }
131
132 /**
133 * @param codeSpace
134 * The codeSpace to set.
135 *
136 */
137 public void setCodeSpace( URI codeSpace ) {
138 this.codeSpace = codeSpace;
139 }
140
141 /**
142 * @return Returns the ordinal.
143 *
144 */
145 public int getOrdinal() {
146 return ordinal;
147 }
148
149 /**
150 * @param ordinal
151 * The ordinal to set.
152 *
153 */
154 public void setOrdinal( int ordinal ) {
155 this.ordinal = ordinal;
156 }
157
158 /**
159 * Tests this Code for equality with another object.
160 *
161 * @param other
162 * object to compare
163 */
164 @Override
165 public boolean equals( Object other ) {
166 if ( other == null || !( other instanceof Code ) ) {
167 return false;
168 }
169 Code oc = (Code) other;
170 if ( ordinal != oc.ordinal ) {
171 return false;
172 }
173 if ( !code.equals( oc ) ) {
174 return false;
175 }
176 if ( !codeSpace.equals( oc ) ) {
177 return false;
178 }
179 return true;
180 }
181
182 @Override
183 public String toString() {
184 return ( ( codeSpace != null ) ? ( codeSpace.toASCIIString() + '/' ) : " " ) + code;
185 }
186
187 }