ValueMap trackingPlan() {
   ValueMap plan = plan();
   if (plan == null) {
     return null;
   }
   return plan.getValueMap(TRACKING_PLAN_KEY);
 }
 public void addComponentInheritanceInfo(ValueMap valueMap) {
   JsArrayString keyArray = valueMap.getKeyArray();
   for (int i = 0; i < keyArray.length(); i++) {
     String key = keyArray.get(i);
     int value = valueMap.getInt(key);
     componentInheritanceMap.put(Integer.parseInt(key), value);
   }
 }
  public void addComponentMappings(ValueMap valueMap, WidgetSet widgetSet) {
    JsArrayString keyArray = valueMap.getKeyArray();
    for (int i = 0; i < keyArray.length(); i++) {
      String key = keyArray.get(i).intern();
      int value = valueMap.getInt(key);
      tagToServerSideClassName.put(value, key);
    }

    for (int i = 0; i < keyArray.length(); i++) {
      String key = keyArray.get(i).intern();
      int value = valueMap.getInt(key);
      widgetSet.ensureConnectorLoaded(value, this);
    }
  }
  @Test
  public void subString() {
    final SourceValue value = new SourceValue("value", true, true);

    final ValueMap map = new ValueMap();

    map.setSourceValues(Collections.singleton(value));
    map.setReturnValue("return");

    Set<StringAttributeValue> result = map.apply("elephant");

    Assert.assertTrue(result.isEmpty());

    result = map.apply("elephantvaluegiraffe");
    Assert.assertEquals(result.size(), 1);
    Assert.assertTrue(result.contains(new StringAttributeValue("return")));
  }
示例#5
0
  protected final Value decodeJsonObjectLazyFinalParse() {
    char[] array = charArray;

    if (__currentChar == '{') __index++;

    ValueMap map = useValues ? new ValueMapImpl() : new LazyValueMap(lazyChop);
    Value value = new ValueContainer(map);

    objectLoop:
    for (; __index < array.length; __index++) {
      skipWhiteSpace();
      switch (__currentChar) {
        case '"':
          Value key = decodeStringOverlay();
          skipWhiteSpace();

          if (__currentChar != ':') {

            complain("expecting current character to be " + charDescription(__currentChar) + "\n");
          }
          __index++;

          Value item = decodeValueOverlay();

          skipWhiteSpace();

          MapItemValue miv = new MapItemValue(key, item);

          map.add(miv);
      }

      switch (__currentChar) {
        case '}':
          __index++;
          break objectLoop;

        case ',':
          continue;

        default:
          complain("expecting '}' or ',' but got current char " + charDescription(__currentChar));
      }
    }
    return value;
  }
  @Test
  public void regexp() {
    final HashSet<SourceValue> sources = new HashSet<>(3);

    sources.add(new SourceValue("R(.+)", false, false));
    sources.add(new SourceValue("RE(.+)", true, false));
    final ValueMap map = new ValueMap();
    map.setSourceValues(sources);
    map.setReturnValue("foo$1");

    Set<StringAttributeValue> result = map.apply("elephant");
    Assert.assertTrue(result.isEmpty());

    result = map.apply("Recursion");
    Assert.assertEquals(result.size(), 2);
    Assert.assertTrue(result.contains(new StringAttributeValue("fooecursion")));
    Assert.assertTrue(result.contains(new StringAttributeValue("foocursion")));
  }
  @Test
  public void setterGetter() {
    final SourceValue value = new SourceValue("value", true, true);

    final ValueMap map = new ValueMap();

    map.setSourceValues(Collections.singleton(value));
    map.setReturnValue("return");

    Assert.assertEquals(map.getReturnValue(), "return");
    Assert.assertEquals(map.getSourceValues().size(), 1);
    Assert.assertTrue(map.getSourceValues().contains(value));
  }
示例#8
0
 private Map<String, Object> propsFromDraft(final Draft draft) {
   final Map<String, Object> props = Maps.newLinkedHashMap();
   props.put("id", draft.entityId());
   final ValueMap data = valueMapOf(draft.data());
   final boolean isBusiness = "2".equals(data.get("customer_type").asString());
   if (isBusiness) {
     props.put("name", data.getRaw("supplementary_name"));
     props.put("nameExtra", data.getRaw("representative"));
   } else {
     props.put(
         "name",
         Joiner.on(" ")
             .skipNulls()
             .join(data.get("surname").asStringOr(null), data.get("name").asStringOr(null)));
     props.put("nameExtra", "");
   }
   props.put(
       "addressStreet",
       streetAddress(
           data.getRaw("street"),
           data.getRaw("descriptive_number"),
           data.getRaw("orientation_number")));
   props.put("addressTown", data.getRaw("town"));
   props.put("addressPostalCode", data.getRaw("postal_code"));
   props.put("addressCountryId", data.get("country").asLong());
   props.put("contactName", data.getRaw("contact_name"));
   props.put("contactEmail", data.getRaw("email"));
   props.put("contactPhone", data.getRaw("phone"));
   props.put("publicId", data.getRaw("public_id"));
   if (isBusiness) {
     props.put(
         "taxId",
         data.get("dic")
             .asStringValueOr(
                 data.get("public_id").asStringValueOr("" + System.currentTimeMillis())));
   } else {
     props.put("taxId", "");
   }
   props.put("otherInfo", data.getRaw("info"));
   return Collections.unmodifiableMap(props);
 }
示例#9
0
  private Value decodeJsonObjectLax() {

    if (__currentChar == '{') this.nextChar();

    ValueMap map = useValues ? new ValueMapImpl() : new LazyValueMap(lazyChop);
    Value value = new ValueContainer(map);

    skipWhiteSpaceIfNeeded();
    int startIndexOfKey = __index;
    Value key;
    MapItemValue miv;
    Value item;

    done:
    for (; __index < this.charArray.length; __index++) {

      skipWhiteSpaceIfNeeded();

      switch (__currentChar) {
        case '/': /* */ //
          handleComment();
          startIndexOfKey = __index;
          break;

        case '#':
          handleBashComment();
          startIndexOfKey = __index;
          break;

        case '=':
          char startChar = charArray[startIndexOfKey];
          if (startChar == ';') {
            startIndexOfKey++;
          }

          key = extractLaxString(startIndexOfKey, __index - 1, false, false);
          __index++; // skip :

          item = decodeValuePlist();
          skipWhiteSpaceIfNeeded();

          miv = new MapItemValue(key, item);

          map.add(miv);

          startIndexOfKey = __index;
          if (__currentChar == '}') {
            __index++;
            break done;
          }

          break;

        case '"':
          key = decodeStringPlist();

          skipWhiteSpaceIfNeeded();

          if (__currentChar != '=') {

            complain(
                "expecting current character to be '='  but got "
                    + charDescription(__currentChar)
                    + "\n");
          }
          __index++;
          item = decodeValuePlist();

          skipWhiteSpaceIfNeeded();
          miv = new MapItemValue(key, item);

          map.add(miv);

          startIndexOfKey = __index;
          if (__currentChar == '}') {
            __index++;
            if (hasMore()) {
              if (charArray[__index] == ';') {
                __index++;
              }
            }
            break done;
          }

          break;

        case '}':
          __index++;
          if (hasMore()) {
            if (charArray[__index] == ';') {
              __index++;
            }
          }
          break done;
      }
    }

    return value;
  }