001/* An abstraction for Unit constraints. 002 003 Copyright (c) 2003-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_3 025 COPYRIGHTENDKEY 026 */ 027package ptolemy.moml.unit; 028 029import ptolemy.kernel.util.NamedObj; 030 031/////////////////////////////////////////////////////////////////// 032//// UnitConstraint 033 034/** 035 @author Rowland R Johnson 036 @version $Id$ 037 @since Ptolemy II 8.0 038 @Pt.ProposedRating Red (rowland) 039 @Pt.AcceptedRating Red (rowland) 040 */ 041public abstract class UnitConstraint { 042 /** 043 * @param string 044 */ 045 public UnitConstraint(String string) { 046 // TODO Auto-generated constructor stub 047 } 048 049 /** 050 * @param lhs 051 * @param operator 052 * @param rhs 053 */ 054 public UnitConstraint(UnitExpr lhs, String operator, UnitExpr rhs) { 055 _lhs = lhs; 056 _operator = operator; 057 _rhs = rhs; 058 } 059 060 /////////////////////////////////////////////////////////////////// 061 //// public methods //// 062 063 /* (non-Javadoc) 064 * @see ptolemy.moml.unit.UnitPresentation#commonDesc() 065 */ 066 public String descriptiveForm() { 067 return _lhs.descriptiveForm() + _operator + _rhs.descriptiveForm(); 068 } 069 070 /** Get the left hand side. 071 * @return The left hand side. 072 */ 073 public UnitExpr getLhs() { 074 return _lhs; 075 } 076 077 /** 078 * @return The operator. 079 */ 080 public String getOperator() { 081 return _operator; 082 } 083 084 /** Get the right hand side. 085 * @return The right hand side. 086 */ 087 public UnitExpr getRhs() { 088 return _rhs; 089 } 090 091 /** Get the source of this equation. 092 * @return The source of this equation. 093 */ 094 public NamedObj getSource() { 095 return _source; 096 } 097 098 public void setLhs(UnitExpr expr) { 099 _lhs = expr; 100 } 101 102 public void setRhs(UnitExpr expr) { 103 _rhs = expr; 104 } 105 106 public void setSource(NamedObj source) { 107 _source = source; 108 } 109 110 @Override 111 public String toString() { 112 return _lhs.toString() + _operator + _rhs.toString(); 113 } 114 115 /////////////////////////////////////////////////////////////////// 116 //// private variables //// 117 UnitExpr _lhs; 118 119 /////////////////////////////////////////////////////////////////// 120 //// private variables //// 121 UnitExpr _rhs; 122 123 String _operator; 124 125 NamedObj _source = null; 126}