001/**
002The contents of this file are subject to the Mozilla Public License Version 1.1 
003(the "License"); you may not use this file except in compliance with the License. 
004You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
005Software distributed under the License is distributed on an "AS IS" basis, 
006WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
007specific language governing rights and limitations under the License. 
008
009The Original Code is "Version.java".  Description: 
010"An enumeration of supported HL7 versions" 
011
012The Initial Developer of the Original Code is University Health Network. Copyright (C) 
0132012.  All Rights Reserved. 
014
015Contributor(s): ______________________________________. 
016
017Alternatively, the contents of this file may be used under the terms of the 
018GNU General Public License (the  "GPL"), in which case the provisions of the GPL are 
019applicable instead of those above.  If you wish to allow use of your version of this 
020file only under the terms of the GPL and not to allow others to use your version 
021of this file under the MPL, indicate your decision by deleting  the provisions above 
022and replace  them with the notice and other provisions required by the GPL License.  
023If you do not delete the provisions above, a recipient may use your version of 
024this file under either the MPL or the GPL. 
025*/
026package ca.uhn.hl7v2;
027
028public enum Version {
029
030        V21("2.1"),
031        V22("2.2"),
032        V23("2.3"),
033        V231("2.3.1"),
034        V24("2.4"),
035        V25("2.5"),
036        V251("2.5.1"),
037        V26("2.6");
038        
039        private String version;
040        
041        Version(String version) {
042                this.version = version;
043        }
044
045        public String getVersion() {
046                return version;
047        }
048        
049        public String getPackageVersion() {
050                return "v" + version.replace(".", "");
051        }
052        
053        public static boolean supportsVersion(String version) {
054                return versionOf(version) != null;
055        }
056        
057        /**
058         * @param version The version string, e.g. "2.1" or "2.6"
059         */
060        public static Version versionOf(String version) {
061                for (Version v : Version.values()) {
062                        if (v.getVersion().equals(version)) {
063                                return v;
064                        }
065                }
066                return null;
067        }       
068        
069        /**
070         * Returns true if this version is greater than the
071         * specified version
072         */
073        public boolean isGreaterThan(Version theVersion) {
074                return compareTo(theVersion) > 0;
075        }
076        
077        public static Version latestVersion() {
078                Version[] versions = Version.values();
079                return versions[versions.length - 1];
080        }
081        
082        
083}