001/******************************************************************************* 002 * Crown Copyright (c) 2006 - 2014, Copyright (c) 2006 - 2014 Kestral Computing P/L. 003 * All rights reserved. This program and the accompanying materials 004 * are made available under the terms of the Eclipse Public License v1.0 005 * which accompanies this distribution, and is available at 006 * http://www.eclipse.org/legal/epl-v10.html 007 * 008 * Contributors: 009 * Kestral Computing P/L - initial implementation 010 *******************************************************************************/ 011 012package org.fhir.ucum; 013 014import java.util.ArrayList; 015import java.util.Date; 016import java.util.List; 017 018public class UcumModel { 019 020 /** 021 * version="1.7" 022 */ 023 private String version; 024 025 /** 026 * revision="$Revision: 1.1 $" 027 */ 028 private String revision; 029 030 /** 031 * date this revision was made public 032 */ 033 private Date revisionDate; 034 035 private List<Prefix> prefixes = new ArrayList<Prefix>(); 036 private List<BaseUnit> baseUnits = new ArrayList<BaseUnit>(); 037 private List<DefinedUnit> definedUnits = new ArrayList<DefinedUnit>(); 038 039 040 /** 041 * @param revision 042 * @param revisionDate 043 */ 044 public UcumModel(String version, String revision, Date revisionDate) { 045 super(); 046 this.version = version; 047 this.revision = revision; 048 this.revisionDate = revisionDate; 049 } 050 /** 051 * @return the prefixes 052 */ 053 public List<Prefix> getPrefixes() { 054 return prefixes; 055 } 056 /** 057 * @return the baseUnits 058 */ 059 public List<BaseUnit> getBaseUnits() { 060 return baseUnits; 061 } 062 /** 063 * @return the units 064 */ 065 public List<DefinedUnit> getDefinedUnits() { 066 return definedUnits; 067 } 068 /** 069 * @return the revision 070 */ 071 public String getRevision() { 072 return revision; 073 } 074 /** 075 * @param revision the revision to set 076 */ 077 public void setRevision(String revision) { 078 this.revision = revision; 079 } 080 /** 081 * @return the revisionDate 082 */ 083 public Date getRevisionDate() { 084 return revisionDate; 085 } 086 /** 087 * @param revisionDate the revisionDate to set 088 */ 089 public void setRevisionDate(Date revisionDate) { 090 this.revisionDate = revisionDate; 091 } 092 /** 093 * @return the version 094 */ 095 public String getVersion() { 096 return version; 097 } 098 /** 099 * @param version the version to set 100 */ 101 public void setVersion(String version) { 102 this.version = version; 103 } 104 105 public Unit getUnit(String code) { 106 for (Unit unit : getBaseUnits()) { 107 if (unit.getCode().equals(code)) 108 return unit; 109 } 110 for (Unit unit : getDefinedUnits()) { 111 if (unit.getCode().equals(code)) 112 return unit; 113 } 114 return null; 115 } 116 117 public BaseUnit getBaseUnit(String code) { 118 for (BaseUnit unit : getBaseUnits()) { 119 if (unit.getCode().equals(code)) 120 return unit; 121 } 122 return null; 123 } 124 125 126}