Examples of RegularExpression


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

        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

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

            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

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

    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

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

  }
 
  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

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

    // 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

Examples of org.apache.xerces.utils.regex.RegularExpression

                String key = (String) e.nextElement();
                if (key.equals(SchemaSymbols.ELT_PATTERN)) {
                    fFacetsDefined += DatatypeValidator.FACET_PATTERN;
                    fPattern = (String)facets.get(key);
                    if ( fPattern != null )
                        fRegex = new RegularExpression(fPattern, "X" );

                } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
                    fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
                    continue; //Treat the enumaration after this for loop
                } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
View Full Code Here

Examples of org.apache.xerces.utils.regex.RegularExpression

                    }
                } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
                    fFacetsDefined += DatatypeValidator.FACET_PATTERN;
                    fPattern = (String)facets.get(key);
                    if ( fPattern != null )
                        fRegex = new RegularExpression(fPattern, "X" );

                } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
                    fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
                    fEnumeration = (Vector)facets.get(key);
                } else {
View Full Code Here

Examples of org.apache.xerces.utils.regex.RegularExpression

                        throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
                    }
                } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
                    fFacetsDefined += DatatypeValidator.FACET_PATTERN;
                    fPattern = (String)facets.get(key);
                    fRegex   = new RegularExpression(fPattern, "X");
                } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
                    fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
                    fEnumeration = (Vector)facets.get(key);
                } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
                    fFacetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
View Full Code Here

Examples of org.apache.xerces.utils.regex.RegularExpression

                    if (key.equals(SchemaSymbols.ELT_PATTERN)) {
                        fFacetsDefined += DatatypeValidator.FACET_PATTERN;
                        fPattern = (String)facets.get(key);
                        if( fPattern != null )
                           fRegex = new RegularExpression(fPattern, "X" );
                    } else {
                        throw new
                           InvalidDatatypeFacetException(
                                "Only constraining facet in boolean datatype is PATTERN" );
                    }
View Full Code Here

Examples of org.apache.xerces.utils.regex.RegularExpression

    public Object validate(String content, Object state)
                                       throws InvalidDatatypeValueException{
        long normalizedValue;

        if ( fPattern != null ) {
            RegularExpression regex = new RegularExpression(fPattern, "X" );
            if ( regex.matches( content) == false )
                throw new InvalidDatatypeValueException("Value'"+content+
                            "does not match regular expression facet" + fPattern );
        }

        normalizedValue = normalizeDuration(content.toCharArray(), 0 );
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.