Esempio n. 1
0
 /**
  * Make a shallow copy of this UnitTerm. That is, the underlying Unit or UnitExpr is not copied.
  *
  * @return The copy of this UnitTerm
  */
 public UnitTerm copy() {
   UnitTerm retv = new UnitTerm();
   retv.setVariable(_variable);
   retv.setExponent(getExponent());
   retv.setUnit(_unit);
   retv.setUnitExpr(_unitExpr);
   retv._setType(_type);
   return retv;
 }
Esempio n. 2
0
  /**
   * Invert this UnitTerm.
   *
   * @return The inverse of this UnitTerm.
   */
  public UnitTerm invert() {
    UnitTerm retv = copy();

    switch (_type) {
      case _VARIABLE:
      case _UNIT:
        {
          retv.setExponent(-getExponent());
          break;
        }

      case _UNITEXPR:
        {
          retv.setUnitExpr(_unitExpr.invert());
          break;
        }
    }

    return retv;
  }