Package com.google.gwt.regexp.shared

Examples of com.google.gwt.regexp.shared.SplitResult


     * @return Formatted string.
     * @see <a href="http://stackoverflow.com/questions/3126232/string-formatter-in-gwt">Stack Overflow</a>
     */
    public static String format(final String format, final Object... args) {
        RegExp regex = RegExp.compile("%[a-z]");
        SplitResult split = regex.split(format);
        StringBuffer msg = new StringBuffer();

        for (int pos = 0; pos < split.length() - 1; pos += 1) {
            msg.append(split.get(pos));
            msg.append(args[pos].toString());
        }

        msg.append(split.get(split.length() - 1));
        return msg.toString();
    }
View Full Code Here


  }

  private void parseCurrentPropertyAndValues(String incompletePropertyAndValues) {
    incompletePropertyAndValues =
        incompletePropertyAndValues.substring(incompletePropertyAndValues.indexOf('{') + 1);
    SplitResult subParts = REGEXP_COLON.split(incompletePropertyAndValues);
    // subParts must have at least one element
    property = subParts.get(0).trim();
    if (subParts.length() > 1) {
      SplitResult valueParts = REGEXP_SPACES.split(subParts.get(1));

      if (subParts.get(1).endsWith(" ")) {
        for (int i = 0; i < valueParts.length(); i++) {
          String trimmed = valueParts.get(i).trim();
          if (!trimmed.isEmpty()) {
            valuesBefore.push(trimmed);
          }
        }
      } else {
        if (valueParts.length() == 1) {
          value = subParts.get(1).trim();
        } else {
          value = valueParts.get(valueParts.length() - 1).trim();
          for (int i = 0; i < valueParts.length() - 1; i++) {
            String trimmed = valueParts.get(i).trim();
            if (!trimmed.isEmpty()) {
              valuesBefore.push(trimmed);
            }
          }
        }
View Full Code Here

    }

    textBefore = textBefore.replaceAll("^\\s+", "");

    // Split first on ';'. The last one is the incomplete one.
    SplitResult parts = REGEXP_SEMICOLON.split(textBefore);

    if ((textBefore.endsWith(";")) || (!parts.get(parts.length() - 1).contains(":"))) {
      completionType = CompletionType.PROPERTY;
    } else {
      completionType = CompletionType.VALUE;
    }

    int highestCompleteIndex = parts.length() - 2;
    if (textBefore.endsWith(";")) {
      highestCompleteIndex = parts.length() - 1;
    } else {
      parseCurrentPropertyAndValues(parts.get(parts.length() - 1));
    }
    if (parts.length() > 1) {
      // Parse the completed properties, which we use for filtering.
      for (int i = 0; i <= highestCompleteIndex; i++) {
        String completePropertyAndValues = parts.get(i);
        SplitResult subParts = REGEXP_COLON.split(completePropertyAndValues);
        completedProperties.add(subParts.get(0).trim().toLowerCase());
      }
    }

    // Interpret textAfter
    // Everything up to the first ; will be interpreted as being part of the
View Full Code Here

      }
    }
  }

  private void addToCompletedProperties(String completedProps) {
    SplitResult completed = REGEXP_SEMICOLON.split(completedProps);
    for (int i = 0; i < completed.length(); i++) {
      int colonIndex = completed.get(i).indexOf(":");
      String trimmed;
      if (colonIndex != -1) {
        trimmed = completed.get(i).substring(0, colonIndex).trim();
      } else {
        trimmed = completed.get(i).trim();
      }
      if (!trimmed.isEmpty()) {
        completedProperties.add(trimmed.toLowerCase());
      }
    }
View Full Code Here

      }
    }
  }

  private void addToValuesAfter(String completedVals) {
    SplitResult completed = REGEXP_SPACES.split(completedVals);
    for (int i = 0; i < completed.length(); i++) {
      String trimmed = completed.get(i).trim();
      if (!trimmed.isEmpty()) {
        valuesAfter.push(trimmed);
      }
    }
  }
View Full Code Here

      Element textPath = element.childElement("textPath").cast();
      if (textPath != null) {
        TextMetrics.get().bind(textPath);
      }

      SplitResult split = newLineRegExp.split(sprite.getText());
      bbox = new PreciseRectangle();

      for (int i = 0; i < split.length(); i++) {
        double width = TextMetrics.get().getWidth(split.get(i));
        bbox.setWidth(Math.max(bbox.getWidth(), width));
      }
      bbox.setHeight(sprite.getFontSize() * split.length());

      PrecisePoint point = textRenderedPoints.get(sprite);
      TextBaseline baseline = textRenderedBaseline.get(sprite);
      bbox.setX(point.getX());
      bbox.setY(point.getY());
View Full Code Here

        parseItems();
    }

    private void parseItems() {
        idCounter = 0;
        SplitResult result = ITEMS.split(RESOURCES.auditLog().getText());
        for (int i = 0; i < result.length(); i++) {
            String nextResult = result.get(i);
            if (nextResult != null && nextResult.length() != 0) {
                String itemText = nextResult.trim() + "\n}";
                MatchResult match = ITEM.exec(itemText);
                if (match != null) {
                    store.add(parseItem(match));
View Full Code Here

    public List<String> getEntityBrowserText() {
        String enteredText = entityBrowserTextField.getText().trim();
        List<String> result = new ArrayList<String>();
        RegExp regExp = RegExp.compile("\n");
        SplitResult split = regExp.split(enteredText);
        for(int i = 0; i < split.length(); i++) {
            result.add(split.get(i));
        }
        return result;
    }
View Full Code Here

        parseItems();
    }

    private void parseItems() {
        idCounter = 0;
        SplitResult result = ITEMS.split(RESOURCES.auditLog().getText());
        for (int i = 0; i < result.length(); i++) {
            String nextResult = result.get(i);
            if (nextResult != null && nextResult.length() != 0) {
                String itemText = nextResult.trim() + "\n}";
                MatchResult match = ITEM.exec(itemText);
                if (match != null) {
                    store.add(parseItem(match));
View Full Code Here

        parseItems();
    }

    private void parseItems() {
        idCounter = 0;
        SplitResult result = ITEMS.split(RESOURCES.auditLog().getText());
        for (int i = 0; i < result.length(); i++) {
            String nextResult = result.get(i);
            if (nextResult != null && nextResult.length() != 0) {
                String itemText = nextResult.trim() + "\n}";
                MatchResult match = ITEM.exec(itemText);
                if (match != null) {
                    store.add(parseItem(match));
View Full Code Here

TOP

Related Classes of com.google.gwt.regexp.shared.SplitResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.