Beispiel #1
0
  public GString plus(GString that) {
    List<String> stringList = new ArrayList<String>();
    List<Object> valueList = new ArrayList<Object>();

    stringList.addAll(Arrays.asList(getStrings()));
    valueList.addAll(Arrays.asList(getValues()));

    List<String> thatStrings = Arrays.asList(that.getStrings());
    if (stringList.size() > valueList.size()) {
      thatStrings = new ArrayList<String>(thatStrings);
      // merge onto end of previous GString to avoid an empty bridging value
      String s = stringList.get(stringList.size() - 1);
      s += thatStrings.get(0);
      thatStrings.remove(0);
      stringList.set(stringList.size() - 1, s);
    }

    stringList.addAll(thatStrings);
    valueList.addAll(Arrays.asList(that.getValues()));

    final String[] newStrings = new String[stringList.size()];
    stringList.toArray(newStrings);
    Object[] newValues = valueList.toArray();

    return new GString(newValues) {
      public String[] getStrings() {
        return newStrings;
      }
    };
  }
 @Whitelisted
 String quote(Object o) {
   if (o instanceof GString) {
     GString gs = (GString) o;
     Object[] values = gs.getValues();
     for (int i = 0; i < values.length; i++) {
       if (values[i] instanceof Special) {
         values[i] = ((Special) values[i]).o;
       } else {
         values[i] = quoteSingle(values[i]);
       }
     }
     return new GStringImpl(values, gs.getStrings()).toString();
   } else {
     return quoteSingle(o);
   }
 }
Beispiel #3
0
 public boolean equals(GString that) {
   return toString().equals(that.toString());
 }