Package com.google.gwt.regexp.shared

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


    throws XPathException {
        boolean ignoreDate = (value instanceof TimeValue);
        boolean ignoreTime = (value instanceof DateValue);
        DateTimeValue dtvalue = value.toDateTime();

        MatchResult matcher = componentPattern.exec(specifier.toString());
        if (matcher == null) {
            XPathException error = new XPathException("Unrecognized date/time component [" + specifier + ']');
            error.setErrorCode("XTDE1340");
            error.setXPathContext(context);
            throw error;
        }
        String component = matcher.getGroup(1);
        if (component == null) {
            component = "";
        }
        String format = matcher.getGroup(2);
        if (format==null) {
            format = "";
        }
        boolean defaultFormat = false;
        if ("".equals(format) || format.startsWith(",")) {
View Full Code Here


            RegExp.compile("[0-9]+"); // was [0-9]* but this always returned a match - java: "\\p{Nd}*"
    private static CharSequence formatNumber(String component, int value,
                                             String format, boolean defaultFormat, Numberer numberer, XPathContext context)
    throws XPathException {
        MatchResult matcher = formatPattern.exec(format);
        if (matcher == null) {
            XPathException error = new XPathException("Unrecognized format picture [" + component + format + ']');
            error.setErrorCode("XTDE1340");
            error.setXPathContext(context);
            throw error;
        }
        //String primary = matcher.group(1);
        //String modifier = matcher.group(2);      
        String primary = matcher.getGroup(1);
        if (primary == null) {
            primary = "";
        }

        String modifier = null;
        if (primary.endsWith("t")) {
            primary = primary.substring(0, primary.length()-1);
            modifier = "t";
        } else if (primary.endsWith("o")) {
            primary = primary.substring(0, primary.length()-1);
            modifier = "o";
        }
        String letterValue = ("t".equals(modifier) ? "traditional" : null);
        String ordinal = ("o".equals(modifier) ? numberer.getOrdinalSuffixForDateTime(component) : null);
        String widths = matcher.getGroup(2);
        if (widths == null) {
            widths = "";
        }
        if (!alphanumericPattern.test(primary)) {
            XPathException error = new XPathException("In format picture at '" + primary +
View Full Code Here

        try {
            int min = -1;
            int max = -1;

            if (!"".equals(widths)) {
                MatchResult widthMatcher = widthPattern.exec(widths);
                if (widthMatcher != null) {
                    String smin = widthMatcher.getGroup(1);
                    if (smin==null || "".equals(smin) || "*".equals(smin)) {
                        min = 1;
                    } else {
                        min = Integer.parseInt(smin);
                    }
                    String smax = widthMatcher.getGroup(3);
                    if (smax==null || "".equals(smax) || "*".equals(smax)) {
                        max = Integer.MAX_VALUE;
                    } else {
                        max = Integer.parseInt(smax);
                    }
View Full Code Here

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

    protected static ConversionResult setLexicalValue(GDateValue dt, CharSequence s) {
        String str = s.toString();
        MatchResult match = datePattern.exec(str);
        if (match == null) {
            return badDate("wrong format", str);
        }
        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));
        String tz = match.getGroup(4);
        int tzmin = parseTimezone(tz);
        if (tzmin == BAD_TIMEZONE) {
            return badDate("invalid timezone", str);
        }
        dt.setTimezoneInMinutes(tzmin);
View Full Code Here

        if (zone==null || zone.isEmpty()) {
            return NO_TIMEZONE;
        } else if (zone.equals("Z")) {
            return 0;
        } else {
            MatchResult match = timezonePattern.exec(zone);
            if (match == null) {
                return BAD_TIMEZONE;
            }
            int h = DurationValue.simpleInteger(match.getGroup(1));
            int m = DurationValue.simpleInteger(match.getGroup(2));
            if (h > 14 || (h == 14 && m > 0)) {
                return BAD_TIMEZONE;
            }
            int tz = h*60 + m;
            if (zone.charAt(0) == '-') {
View Full Code Here

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

    public static ConversionResult makeTimeValue(CharSequence s) {
        String str = s.toString();
        MatchResult match = timePattern.exec(str);
        if (match == null) {
            return badTime("wrong format", str);
        }
        TimeValue dt = new TimeValue();
        dt.hour = DurationValue.simpleInteger(match.getGroup(1));
        dt.minute = DurationValue.simpleInteger(match.getGroup(2));
        dt.second = DurationValue.simpleInteger(match.getGroup(3));
        String frac = match.getGroup(4);
        if (frac != null && frac.length() > 0) {
            double fractionalSeconds = Double.parseDouble(frac);
            dt.microsecond = (int)(Math.round(fractionalSeconds * 1000000));
        }
        String tz = match.getGroup(5);
        int tzmin = parseTimezone(tz);
        if (tzmin == BAD_TIMEZONE) {
            return badTime("Invalid timezone", str);
        }
        dt.setTimezoneInMinutes(tzmin);
View Full Code Here

    private GYearValue(){}

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

    private GMonthValue(){}

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

            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

            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

TOP

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

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.