Esempio n. 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;
   }
 }
  /** Implementation for getting the indices of this class. i.e. <code>$a->foo[0]</code> */
  public Value __get(Env env, Value indexV) {
    if (indexV.isString()) {
      String name = indexV.toString();

      SimpleXMLElement attr = getAttribute(name);

      if (attr != null) return wrapJava(env, _cls, attr);
      else return NullValue.NULL;
    } else if (indexV.isLongConvertible()) {
      int i = indexV.toInt();

      if (i < _attributes.size()) return wrapJava(env, _cls, _attributes.get(i));

      return NullValue.NULL;
    } else return NullValue.NULL;
  }
Esempio n. 3
0
 /**
  * Returns true if subvalue is a substring of the current StringVal, and false otherwise
  *
  * @return true is subvalue is a substring of the object, false otherwise
  */
 @Override
 public boolean contains(Value subvalue) {
   if (subvalue instanceof StringVal) {
     StringVal stringval = (StringVal) subvalue;
     if (stringval.template == null) {
       stringval.template = Template.create(stringval.str);
     }
     return stringval.template.partialmatch(str).isMatching();
   } else {
     return subvalue.toString().contains(str);
   }
 }