Example #1
0
 /** Returns the concatenation of the two values. */
 @Override
 public Value concatenate(Value v) {
   if (v instanceof StringVal) {
     return ValueFactory.create(str + " " + v.toString());
   } else if (v instanceof DoubleVal) {
     return ValueFactory.create(str + " " + v.toString());
   } else if (v instanceof NoneVal) {
     return this;
   } else {
     log.warning("cannot concatenate " + this + " and " + v);
     return ValueFactory.noneValue;
   }
 }
Example #2
0
 public Value eval(RCvalue args) throws EvalException {
   if (args.size() != 2) throw new EvalException("usage: reduce(polygon, errtol])");
   PolygonValue pv1 = (PolygonValue) args.value(0);
   PolygonValue pv2 = (PolygonValue) args.value(1);
   boolean isContain = pv1.polygon().contains(pv2.polygon());
   double contain = 0;
   if (isContain) {
     contain = 1; // we don't have a boolean factory now.
   }
   return ValueFactory.create(contain);
 }
Example #3
0
 /** Returns a list of words */
 @Override
 public Collection<Value> getSubValues() {
   return Arrays.stream(str.split(" "))
       .map(w -> ValueFactory.create(w))
       .collect(Collectors.toList());
 }