Examples of MatchResult


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

            RegExp.compile("---([0-9][0-9])(Z|[+-][0-9][0-9]:[0-9][0-9])?");

    private GDayValue(){}

    public static ConversionResult makeGDayValue(CharSequence value) {
        MatchResult m = regex.exec(Whitespace.trimWhitespace(value).toString());
        if (m == null) {
            return new ValidationFailure("Cannot convert '" + value + "' to a gDay");
        }
        GDayValue g = new GDayValue();
        String base = m.getGroup(1);
        String tz = m.getGroup(2);
        String date = "2000-01-" + (base==null ? "" : base) + (tz==null ? "" : tz);
        g.typeLabel = BuiltInAtomicType.G_DAY;
        return setLexicalValue(g, date);
    }
View Full Code Here

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

            RegExp.compile("--([0-9][0-9]-[0-9][0-9])(Z|[+-][0-9][0-9]:[0-9][0-9])?");

    private GMonthDayValue(){}

    public static ConversionResult makeGMonthDayValue(CharSequence value) {
        MatchResult m = regex.exec(Whitespace.trimWhitespace(value).toString());
        if (m == null) {
            return new ValidationFailure("Cannot convert '" + value + "' to a gMonthDay");
        }
        GMonthDayValue g = new GMonthDayValue();
        String base = m.getGroup(1);
        String tz = m.getGroup(2);
        String date = "2000-" + (base==null ? "" : base) + (tz==null ? "" : tz);
        g.typeLabel = BuiltInAtomicType.G_MONTH_DAY;
        return setLexicalValue(g, date);
    }
View Full Code Here

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

    private static RegExp dateTimePattern =
            RegExp.compile("\\-?([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])T([0-9][0-9]):([0-9][0-9]):([0-9][0-9])(\\.[0-9]*)?([-+Z].*)?");

    public static ConversionResult makeDateTimeValue(CharSequence s) {
        String str = s.toString();
        MatchResult match = dateTimePattern.exec(str);
        if (match == null) {
            return badDate("wrong format", str);
        }
        DateTimeValue dt = new DateTimeValue();
        dt.year = DurationValue.simpleInteger(match.getGroup(1));
        if (str.startsWith("-")) {
          dt.year = dt.year - 1; // no year zero in lexical space for XSD 1.0 - so -1 becomes 0 and -2 becomes -1 etc.
            dt.year = -dt.year;
        }
        dt.month = DurationValue.simpleInteger(match.getGroup(2));
        dt.day = DurationValue.simpleInteger(match.getGroup(3));
        dt.hour = DurationValue.simpleInteger(match.getGroup(4));
        dt.minute = DurationValue.simpleInteger(match.getGroup(5));
        dt.second = DurationValue.simpleInteger(match.getGroup(6));
        String frac = match.getGroup(7);
        if (frac != null && frac.length() > 0) {
            double fractionalSeconds = Double.parseDouble(frac);
            dt.microsecond = (int)(Math.round(fractionalSeconds * 1000000));
        }
        String tz = match.getGroup(8);
        int tzmin = parseTimezone(tz);
        if (tzmin == BAD_TIMEZONE) {
            return badDate("Invalid timezone", str);
        }
        dt.setTimezoneInMinutes(tzmin);
View Full Code Here

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

            RegExp.compile("(-?[0-9]+-[0-9][0-9])(Z|[+-][0-9][0-9]:[0-9][0-9])?");

    private GYearMonthValue(){}

    public static ConversionResult makeGYearMonthValue(CharSequence value) {
        MatchResult m = regex.exec(Whitespace.trimWhitespace(value).toString());
        if (m == null) {
            return new ValidationFailure("Cannot convert '" + value + "' to a gYearMonth");
        }
        GYearMonthValue g = new GYearMonthValue();
        String base = m.getGroup(1);
        String tz = m.getGroup(2);
        String date = (base==null ? "" : base) + "-01" + (tz==null ? "" : tz);
        g.typeLabel = BuiltInAtomicType.G_YEAR_MONTH;
        return setLexicalValue(g, date);
    }
View Full Code Here

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

      // we therefore don't expect non-quoted styles like <h1 style=color id="abc"...
      String value = getOuterHTML(elem);
     
      RegExp quotesPattern = RegExp.compile("(?:\".*?\"|\'.*?\'|[^\'\"]+|['\"])", "g"); // g=global: = all-matches
      RegExp stylePattern = RegExp.compile("[\\s]style\\s*="); // e.g. match: <h1 style=
      MatchResult m = quotesPattern.exec(value);

      int i = 0;
      boolean styleFound = false;
      String styleContent = "";
      String nonQ = "";
      while (quotesPattern.getLastIndex() > 0) {
        if (i % 2 == 0) {
          nonQ = m.getGroup(0); // not in quotes - so check
          MatchResult ms = stylePattern.exec(nonQ);
          styleFound = ms.getGroupCount() > 0;
          if (!styleFound && nonQ.indexOf('>') > -1) {
            break; // no more attributes
          }
        } else if (styleFound) {
          styleContent = m.getGroup(0);
View Full Code Here

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

      ArrayList<String> xmlnsNames = new ArrayList<String>();
      ArrayList<String> xmlnsUris = new ArrayList<String>();
      namespaceBindings = new ArrayList<NamespaceBinding>();
     
      RegExp quotesPattern = RegExp.compile("(?:\"(.|\n)*?\"|\'(.|\n)*?\'|[^\'\"]+|['\"])", "gm"); // g=global: = all-matches m=multiline
      MatchResult m = quotesPattern.exec(value);

      int i = 0;
      String nonQ = "";
      boolean awaitingXmlnsUri = false;
      while (quotesPattern.getLastIndex() > 0) {
       
        if (i % 2 == 0) {
          nonQ = m.getGroup(0); // not in quotes - so check
          StringBuffer sb = new StringBuffer();
          boolean endOfTag = false;
          boolean isName = !(i == 0);// first part is not a name: e.g. \r\n<H1 style="
          int start = 0;
          if (i == 0) {
            start = nonQ.indexOf('<') + 1;          
          }
          for (int x = start; x < nonQ.length(); x++) {
            int[] offsetChar = skipWhitespace(x, nonQ, false);
            int offset = offsetChar[0];
           
            if(offset > 0 && !(isName)) {
              // no whitespace allow in an unquoted value, so we're back on a name
              isName = true;
            }
            char ch = (char)offsetChar[1];
            if (ch == '\0') break;
            if (ch == '=') {
              // part after the '=' is the value, until next whitespace
              isName = false;
              String attName = sb.toString();
             
              if (attName.startsWith("xmlns")) {
                xmlnsNames.add(attName);
                awaitingXmlnsUri = true;
              } else if(attName.length() != 0) {
                nodeNames.add(attName);
                awaitingXmlnsUri = false;
              }

              sb = new StringBuffer();
              continue;
            } else if (ch == '>') {
              endOfTag = true;
              break;
            }
           
            if (isName) {
              sb.append(ch);
            }          
            x += offset;
          } // end for
          if (endOfTag) {
            break;
          }
        } else if (awaitingXmlnsUri) {// ends if i % 2
          xmlnsUris.add(m.getGroup(0));
        }
        i++;
        m = quotesPattern.exec(value);
      } // end while
     
View Full Code Here

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

                    + "\\[(\\d+)\\]");

    @Override
    public com.google.gwt.user.client.Element getSubPartElement(String subPart) {
        if (SUBPART_ROW_COL_REGEXP.test(subPart)) {
            MatchResult result = SUBPART_ROW_COL_REGEXP.exec(subPart);
            int rowIx = Integer.valueOf(result.getGroup(1));
            int colIx = Integer.valueOf(result.getGroup(2));
            VScrollTableRow row = scrollBody.getRowByRowIndex(rowIx);
            if (row != null) {
                Element rowElement = row.getElement();
                if (colIx < rowElement.getChildCount()) {
                    return rowElement.getChild(colIx).getFirstChild().cast();
                }
            }

        } else if (SUBPART_ROW_REGEXP.test(subPart)) {
            MatchResult result = SUBPART_ROW_REGEXP.exec(subPart);
            int rowIx = Integer.valueOf(result.getGroup(1));
            VScrollTableRow row = scrollBody.getRowByRowIndex(rowIx);
            if (row != null) {
                return row.getElement();
            }

        } else if (SUBPART_HEADER_REGEXP.test(subPart)) {
            MatchResult result = SUBPART_HEADER_REGEXP.exec(subPart);
            int headerIx = Integer.valueOf(result.getGroup(1));
            HeaderCell headerCell = tHead.getHeaderCell(headerIx);
            if (headerCell != null) {
                return headerCell.getElement();
            }

        } else if (SUBPART_FOOTER_REGEXP.test(subPart)) {
            MatchResult result = SUBPART_FOOTER_REGEXP.exec(subPart);
            int footerIx = Integer.valueOf(result.getGroup(1));
            FooterCell footerCell = tFoot.getFooterCell(footerIx);
            if (footerCell != null) {
                return footerCell.getElement();
            }
        }
View Full Code Here

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

    public CaptionPosition getCaptionPositionFromElement(
            com.google.gwt.user.client.Element captionWrap) {
        RegExp captionPositionRegexp = RegExp.compile("v-caption-on-(\\S+)");

        // Get caption position from the classname
        MatchResult matcher = captionPositionRegexp.exec(captionWrap
                .getClassName());
        if (matcher == null || matcher.getGroupCount() < 2) {
            return CaptionPosition.TOP;
        }
        String captionClass = matcher.getGroup(1);
        CaptionPosition captionPosition = CaptionPosition.valueOf(
                CaptionPosition.class, captionClass.toUpperCase());
        return captionPosition;
    }
View Full Code Here

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

            }

            float size = 0;
            Unit unit = null;

            MatchResult matcher = sizePattern.exec(s);
            if (matcher.getGroupCount() > 1) {

                size = Float.parseFloat(matcher.getGroup(1));
                if (size < 0) {
                    size = -1;
                    unit = Unit.PX;

                } else {
                    String symbol = matcher.getGroup(2);
                    unit = unitByType(symbol);
                }
            } else {
                throw new IllegalArgumentException("Invalid size argument: \""
                        + s + "\" (should match " + sizePattern.getSource()
View Full Code Here

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

                     * request and served non-UIDL content (for instance, a
                     * login page if the session has expired.) If the response
                     * contains a magic substring, do a synchronous refresh. See
                     * #8241.
                     */
                    MatchResult refreshToken = RegExp.compile(
                            UIDL_REFRESH_TOKEN + "(:\\s*(.*?))?(\\s|$)").exec(
                            response.getText());
                    if (refreshToken != null) {
                        redirect(refreshToken.getGroup(2));
                        return;
                    }
                }

                // for(;;);[realjson]
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.