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.List;
016
017public class Canonical {
018
019        public static class CanonicalUnit {
020    private BaseUnit base;
021    private int exponent;
022                protected CanonicalUnit(BaseUnit base, int exponent) {
023            super();
024            this.base = base;
025            this.exponent = exponent;
026    }
027                public BaseUnit getBase() {
028                        return base;
029                }
030                public int getExponent() {
031                        return exponent;
032                }
033                public void setExponent(int exponent) {
034                        this.exponent = exponent;
035                }
036    
037    
038  }
039
040        private Decimal value;
041        private List<CanonicalUnit> units = new ArrayList<CanonicalUnit>();
042        
043        /**
044         * @param value
045         * @param unit
046         */
047        public Canonical(Decimal value) {
048                super();
049                this.value = value;
050        }
051
052        /**
053         * @return the value
054         */
055        public Decimal getValue() {
056                return value;
057        }
058
059        /**
060         * @return the unit
061         */
062        public List<CanonicalUnit> getUnits() {
063                return units;
064        }
065
066        /**
067         * @param value the value to set
068         */
069        public void setValue(Decimal value) {
070                this.value = value;
071        }
072
073        public void multiplyValue(Decimal multiplicand) {
074                value = value.multiply(multiplicand);           
075        }
076
077        public void multiplyValue(int multiplicand) {
078                value = value.multiply(new Decimal(multiplicand));              
079        }
080
081        
082        public void divideValue(Decimal divisor) throws UcumException  {
083                value = value.divide(divisor);          
084        }
085        
086        public void divideValue(int divisor) throws UcumException  {
087                value = value.divide(new Decimal(divisor));             
088        }
089
090        
091}