Package com.dotcms.repackage.org.apache.oro.text.regex

Examples of com.dotcms.repackage.org.apache.oro.text.regex.Perl5Matcher


    return newBody.toString();
  }

  public void updateParseContainerSyntax(Template template) {
    String tb = template.getBody();
    Perl5Matcher matcher = (Perl5Matcher) localP5Matcher.get();
    String oldParse;
    String newParse;
      while(matcher.contains(tb, parseContainerPattern)){
         MatchResult match = matcher.getMatch();
        int groups = match.groups();
         for(int g=0;g<groups;g++){
           oldParse = match.group(g);
           if(matcher.contains(oldParse, oldContainerPattern)){
             MatchResult matchOld = matcher.getMatch();
             newParse = matchOld.group(0).trim();
             newParse = containerTag + newParse + "')";
             tb = StringUtil.replace(tb,oldParse,newParse);
           }
         }
View Full Code Here


    public String getHostName ( String uri ) {
    return getHostname(stripMapping(uri));
  }

  public boolean isTempResource(String path){
    Perl5Matcher matcher = (Perl5Matcher) localP5Matcher.get();
    if(matcher.contains(path, tempResourcePattern))
      return true;
    return false;
  }
View Full Code Here

    }
   
    private String cleanKey(String key) {
      if(key.startsWith(ResourceManager.RESOURCE_TEMPLATE + ""))
        key=key.substring((ResourceManager.RESOURCE_TEMPLATE+"").length());
      Perl5Matcher matcher = (Perl5Matcher) localP5Matcher.get();
      if(matcher.contains(key, menuPattern)){
        MatchResult match = matcher.getMatch();
        key = match.group(0);
      }else{
        if(matcher.contains(key, assetPattern)){
          MatchResult match = matcher.getMatch();
            key = match.group(0);
        }
      }
      if (key.startsWith(File.separatorChar +"")) {
        key=key.substring(1);
View Full Code Here

    return true;
  }

  protected boolean matchFilter(Folder folder, String fileName) {
    // return value
    Perl5Matcher p5m = new Perl5Matcher();
    Perl5Compiler p5c = new Perl5Compiler();
    boolean match = false;
    try {
      // Obtain the filters
      String filesMasks = folder.getFilesMasks();
      filesMasks = (filesMasks != null ? filesMasks.trim() : filesMasks);

      if (UtilMethods.isSet(filesMasks)) {
        String[] filesMasksArray = filesMasks.split(",");
        int length = filesMasksArray.length;

        // Try to match de filters
        for (int i = 0; i < length; i++) {
          String regex = filesMasksArray[i];
          regex = regex.replace(".", "\\.");
          regex = regex.replace("*", ".*");
          regex = "^" + regex.trim() + "$";
          Pattern pattern = p5c.compile(regex, Perl5Compiler.CASE_INSENSITIVE_MASK);
          match = match || p5m.matches(fileName, pattern);
          if (match) {
            break;
          }
        }
      } else {
View Full Code Here

   * @return
   * @throws DotRuntimeException
   */
  public static boolean contains(String text, String regEx)throws DotRuntimeException{
    RegEX i = getInstance();
    Perl5Matcher matcher = i.localP5Matcher.get();
    Pattern pattern;
    try {
      pattern = i.getPattern(regEx);
    } catch (MalformedPatternException e) {
      Logger.error(RegEX.class, "Unable to compile pattern for regex", e);
      throw new DotRuntimeException("Unable to compile pattern for regex",e);
    }
    return matcher.contains(text, pattern);
  }
View Full Code Here

   */
  public static String replace(String original,String substitution,String regEx) throws DotRuntimeException{
    String result = original;
    RegEX i = getInstance();
    Perl5Substitution sub = i.localP5Sub.get();
    Perl5Matcher matcher = i.localP5Matcher.get();
    sub.setSubstitution(substitution);
    Pattern pattern;
    try {
      pattern = i.getPattern(regEx);
    } catch (MalformedPatternException e) {
      Logger.error(RegEX.class, "Unable to compile pattern for regex", e);
      throw new DotRuntimeException("Unable to compile pattern for regex",e);
    }
    if(matcher.contains(original, pattern)){
      result = Util.substitute(matcher, pattern, sub, original);
    }
    return result;
  }
View Full Code Here

   */
  public static String replaceAll(String original,String substitution,String regEx) throws DotRuntimeException{
    String result = original;
    RegEX i = getInstance();
    Perl5Substitution sub = i.localP5Sub.get();
    Perl5Matcher matcher = i.localP5Matcher.get();
    sub.setSubstitution(substitution);
    Pattern pattern;
    try {
      pattern = i.getPattern(regEx);
    } catch (MalformedPatternException e) {
      Logger.error(RegEX.class, "Unable to compile pattern for regex", e);
      throw new DotRuntimeException("Unable to compile pattern for regex",e);
    }
    if(matcher.contains(original, pattern)){
      result = Util.substitute(matcher, pattern, sub, original, Util.SUBSTITUTE_ALL);
    }
    return result;
  }
View Full Code Here

    return find(text, regEx, true);
  }
 
  private static List<RegExMatch> find(String text, String regEx, boolean isUrlMap) throws DotRuntimeException{
    RegEX i = getInstance();
    Perl5Matcher matcher = i.localP5Matcher.get();
    Pattern pattern;
    try {
      pattern = i.getPattern(regEx);
    } catch (MalformedPatternException e) {
      Logger.error(RegEX.class, "Unable to compile pattern for regex", e);
      throw new DotRuntimeException("Unable to compile pattern for regex",e);
    }
    List<RegExMatch> res = new ArrayList<RegExMatch>();
    MatchResult result;
    PatternMatcherInput input = new PatternMatcherInput(text);
    while (matcher.contains(input, pattern)) {
      RegExMatch rm = new RegExMatch();
      result = matcher.getMatch();
      if(!isUrlMap || result.beginOffset(0) == 0){
        rm.setMatch(result.group(0));
        rm.setBegin(result.beginOffset(0));
        rm.setEnd(result.endOffset(0));
        List<RegExMatch> r = new ArrayList<RegExMatch>();
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.apache.oro.text.regex.Perl5Matcher

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.