예제 #1
0
 /**
  * Performs unit analysis of a given infix operation. The first unit (non-scalar token)
  * encountered is returned, except with division. In that case, scalar is returned if both units
  * are the same and points is returned when dividing inches and points.
  *
  * @param u1 left-hand unit
  * @param u2 right-hand unit
  * @param op operator
  * @return Token containing resultant unit.
  */
 public static ValueType evaluateUnits(ValueType u1, ValueType u2, Token op) {
   String unit = "SCALAR"; // default ValueType
   final String left = u1.toString();
   final String right = u2.toString();
   switch (op.text) {
     case "/":
       // In the case of division, we need only to be concerned in situations where
       // the final unit is not scalar
       if (!u1.toString().equals(right)) {
         if (left.equals("SCALAR")) {
           unit = right;
           break;
         }
         if (right.equals("SCALAR")) {
           unit = left;
           break;
         }
       }
       break;
     default:
       if (left.equals("SCALAR")) {
         unit = right;
         break;
       }
       if (right.equals("SCALAR")) {
         unit = left;
         break;
       }
       unit = left;
       break;
   }
   return ValueType.valueOf(unit);
 }
예제 #2
0
 @Override
 public String getText() {
   return value.toString();
 }
예제 #3
0
파일: Field.java 프로젝트: RG9/jira-client
 /**
  * Initialises the value tuple.
  *
  * @param type
  * @param value
  */
 public ValueTuple(ValueType type, Object value) {
   this(type.toString(), value);
 }