Package org.apache.xerces.impl.xpath.regex

Examples of org.apache.xerces.impl.xpath.regex.RegularExpression


        // pattern
        if ((presentFacet & FACET_PATTERN) != 0) {
            if ((allowedFacet & FACET_PATTERN) == 0) {
                reportError("cos-applicable-facets", new Object[]{"pattern"});
            } else {
                RegularExpression regex = null;
                try {
                    regex = new RegularExpression(facets.pattern, "X");
                } catch (Exception e) {
                    reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage()});
                }
                if (regex != null) {
                    fPattern = new Vector();
View Full Code Here


        } else {
            nvalue = content.toString();
        }

        if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
            RegularExpression regex;
            for (int idx = fPattern.size()-1; idx >= 0; idx--) {
                regex = (RegularExpression)fPattern.elementAt(idx);
                if (!regex.matches(nvalue)){
                    throw new InvalidDatatypeValueException("cvc-pattern-valid",
                                                            new Object[]{content, regex});
                }
            }
        }
View Full Code Here

        if ((presentFacet & FACET_PATTERN) != 0) {
            if ((allowedFacet & FACET_PATTERN) == 0) {
                reportError("cos-applicable-facets", new Object[]{"pattern", fTypeName});
            } else {
                patternAnnotations = facets.patternAnnotations;
                RegularExpression regex = null;
                try {
                    regex = new RegularExpression(facets.pattern, "X");
                } catch (Exception e) {
                    reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage()});
                }
                if (regex != null) {
                    fPattern = new Vector();
View Full Code Here

            nvalue = normalize(content, fWhiteSpace);
        } else {
            nvalue = content.toString();
        }
        if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
            RegularExpression regex;
            for (int idx = fPattern.size()-1; idx >= 0; idx--) {
                regex = (RegularExpression)fPattern.elementAt(idx);
                if (!regex.matches(nvalue)){
                    throw new InvalidDatatypeValueException("cvc-pattern-valid",
                                                            new Object[]{content,
                                                            fPatternStr.elementAt(idx),

                                                            fTypeName});
View Full Code Here

    return null;
  }

  public static boolean matchXerces(final String s, final String pattern,
      final String flags) {
    final RegularExpression regexPattern = makePatternXerces(pattern, flags);
    if (regexPattern == null)
      return false;
    else
      return regexPattern.matches(s);
  }
View Full Code Here

  }
 
  public static String replaceXerces(final String content, final String pattern,
      final String flags, final String replacement) {
    String s = content;
    final RegularExpression regexPattern = makePatternXerces(pattern, flags);
    if (regexPattern == null)
      return s;
    else {
      Match m = new Match();
      if(regexPattern.matches(s,m)){
        String result = "";
        while(regexPattern.matches(s,m)){
          int numberOfGroups = m.getNumberOfGroups();
          if(numberOfGroups>0){
            String interReplacement = new String(replacement);
            if(numberOfGroups>1){
              for(int i=numberOfGroups-1; i>0; i--){ // start at the end to not have problems that $1 is replaced for a string $10 but $10 should be replaced (the same leading prefixes!)
View Full Code Here

    // Check/modify flags.
    // Always "u", never patternStr
    // x: Remove whitespace characters (#x9, #xA, #xD and #x20) unless in []
    // classes
    try {
      return new RegularExpression(patternStr, flags);
    } catch (final Exception pEx) {
      System.err.println("Regex: Pattern exception: " + pEx);
      return null;
    }
  }
View Full Code Here

        // pattern
        if ((presentFacet & FACET_PATTERN) != 0) {
            if ((allowedFacet & FACET_PATTERN) == 0) {
                reportError("cos-applicable-facets", new Object[]{"pattern"});
            } else {
                RegularExpression regex = null;
                try {
                    regex = new RegularExpression(facets.pattern, "X");
                } catch (Exception e) {
                    reportError("InvalidRegex", new Object[]{facets.pattern, e.getLocalizedMessage()});
                }
                if (regex != null) {
                    fPattern = new Vector();
View Full Code Here

        } else {
            nvalue = content.toString();
        }

        if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
            RegularExpression regex;
            for (int idx = fPattern.size()-1; idx >= 0; idx--) {
                regex = (RegularExpression)fPattern.elementAt(idx);
                if (!regex.matches(nvalue)){
                    throw new InvalidDatatypeValueException("cvc-pattern-valid",
                                                            new Object[]{content,
                                                            fPatternStr.elementAt(idx)});
                }
            }
View Full Code Here

                                                            SPECIAL_TOKEN_STRING[fTokenType]);
                }
            }

            if ( (fFacetsDefined & FACET_PATTERN ) != 0 ) {
                RegularExpression regex;
                for (int idx = fPattern.size()-1; idx >= 0; idx--) {
                    regex = (RegularExpression)fPattern.elementAt(idx);
                    if (!regex.matches(nvalue)){
                        throw new InvalidDatatypeValueException("Value '"+content+
                                                                "' does not match regular expression facet '" + fPattern + "'" );
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.xpath.regex.RegularExpression

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.