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