Examples of Perl5Compiler


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

  static {
    new Timer().schedule(new FileResourceCacheCleaner(), 1000  * 60 * Config.getIntProperty("WEBDAV_CLEAR_RESOURCE_CACHE_FRECUENCY", 10), 1000  * 60 * Config.getIntProperty("WEBDAV_CLEAR_RESOURCE_CACHE_FRECUENCY", 10));
  }

  public DotWebdavHelper() {
    Perl5Compiler c = new Perl5Compiler();
    try{
      tempResourcePattern = c.compile("/\\(.*\\)|/._\\(.*\\)|/\\.|^\\.|^\\(.*\\)",Perl5Compiler.READ_ONLY_MASK);
      }catch (MalformedPatternException mfe) {
        Logger.fatal(this,"Unable to instaniate webdav servlet : " + mfe.getMessage(),mfe);
      Logger.error(this,mfe.getMessage(),mfe);
    }

View Full Code Here

Examples of com.sun.star.tool.starjar.regex.Perl5Compiler

        }
        catch (MalformedPatternException e) {
            System.out.println("Fehler beim Parsen der Filterdatei :\n" + e);
        }

        PatternCompiler compiler = new Perl5Compiler();
        PatternMatcher matcher = new Perl5Matcher();
       
        while (fileList.hasMoreElements()) {
            FileListElement file = (FileListElement)fileList.nextElement();
            Enumeration filterEnum = filter.elements();
            Pattern pathPattern = null;
            Pattern filenamePattern = null;
           
            while (filterEnum.hasMoreElements()) {
                FilterElement filterElement = (FilterElement)filterEnum.nextElement();
                try {
                    pathPattern = compiler.compile(filterElement.getPathPattern());
                    filenamePattern = compiler.compile(filterElement.getFilenamePattern());
                } catch (MalformedPatternException e) {
                    System.out.println("Fehler im Pattern\n" + e);
                }
                if (matcher.matches(file.getPath(),pathPattern) && matcher.matches(file.getFilename(),filenamePattern))
                    file.setInclude(filterElement.isInclude());
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

    ArrayList<String> oRecipientsWithoutDuplicates;
    boolean bAllowed;

  Pattern oAllowPattern=null, oDenyPattern=null;
  Perl5Matcher oMatcher = new Perl5Matcher();
  Perl5Compiler oCompiler = new Perl5Compiler();
   
    if (aEMails!=null) {
      if (aEMails.length>0) {
        if (aRecipients==null) {
          aRecipients = aEMails;
        } else {
          aRecipients = concatArrays(aRecipients, aEMails);
        } // fi (aRecipients!=null)
        final int nRecipients = aRecipients.length;
        Arrays.sort(aRecipients, String.CASE_INSENSITIVE_ORDER);
   
    oRecipientsWithoutDuplicates = new ArrayList<String>(nRecipients);

      sAllowPattern = getAllowPattern();
      sDenyPattern = getDenyPattern();
     
      if (sAllowPattern.length()>0) {
        oAllowPattern = oCompiler.compile(sAllowPattern, Perl5Compiler.CASE_INSENSITIVE_MASK);
      }

      if (sDenyPattern.length()>0) {
        oDenyPattern = oCompiler.compile(sDenyPattern, Perl5Compiler.CASE_INSENSITIVE_MASK);
      }
       
      for (int r=0; r<nRecipients-1; r++) {
      bAllowed = true;
      try {
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

                                 String sTextBody, String sHtmlBody,
                                 String sId, String [] aAttachmentsPath,
                                 String sBasePath)
  throws IOException,MessagingException,IllegalArgumentException,SecurityException {

  PatternCompiler oCompiler = new Perl5Compiler();
  PatternMatcher oMatcher = new Perl5Matcher();
 
  String sContentType = (sHtmlBody==null ? "plain" : "html");
 
  if (DebugFile.trace) {
    DebugFile.writeln("Begin SessionHandler.composeMessage("+sSubject+","+sEncoding+",...,"+sId+","+sContentType+")");
    DebugFile.incIdent();
  }

  if (sEncoding==null) sEncoding = "ASCII";
  String sCharEnc = Charset.forName(sEncoding).name();
   
  SMTPMessage oSentMessage = new SMTPMessage(getSmtpSession());

  MimeBodyPart oMsgPlainText = new MimeBodyPart();
  MimeMultipart oSentMsgParts = new MimeMultipart("mixed");

  if (sContentType.equalsIgnoreCase("html")) {

    MimeMultipart oHtmlRelated  = new MimeMultipart("related");
    MimeMultipart oTextHtmlAlt  = new MimeMultipart("alternative");

    // ************************************************************************
    // Replace image CIDs

    HashMap oDocumentImages = new HashMap(23);

    StringSubstitution oSrcSubs = new StringSubstitution();

    Parser oPrsr = Parser.createParser(sHtmlBody, sEncoding);

    String sCid, sSrc;

    try {

      if (sTextBody==null) {
          // ****************************
          // Extract plain text from HTML
          if (DebugFile.trace) DebugFile.writeln("new StringBean()");

          StringBean oStrBn = new StringBean();

          try {
            oPrsr.visitAllNodesWith (oStrBn);
          } catch (ParserException pe) {
          throw new MessagingException(pe.getMessage(), pe);
          }

          sTextBody = oStrBn.getStrings();

          oStrBn = null;
      } // fi (sTextBody==null)

      // *******************************
      // Set plain text alternative part

      oMsgPlainText.setDisposition("inline");
      oMsgPlainText.setText(sTextBody, sCharEnc, "plain");
      // oMsgPlainText.setContent(sTextBody, "text/plain; charset="+sCharEnc);
      if (DebugFile.trace) DebugFile.writeln("MimeBodyPart(multipart/alternative).addBodyPart(text/plain)");
      oTextHtmlAlt.addBodyPart(oMsgPlainText);

      // *****************************************
      // Iterate images from HTML and replace CIDs

      NodeList oCollectionList = new NodeList();
      TagNameFilter oImgFilter = new TagNameFilter ("IMG");
      for (NodeIterator e = oPrsr.elements(); e.hasMoreNodes();)
        e.nextNode().collectInto(oCollectionList, oImgFilter);

      final int nImgs = oCollectionList.size();

      if (DebugFile.trace) DebugFile.writeln("NodeList.size() = " + String.valueOf(nImgs));

      for (int i=0; i<nImgs; i++) {

        sSrc = ((ImageTag) oCollectionList.elementAt(i)).extractImageLocn();

        // Keep a reference to every related image name so that the same image is not included twice in the message
        if (!oDocumentImages.containsKey(sSrc)) {

          // Find last slash from image url
          int iSlash = sSrc.lastIndexOf('/');

          // Take image name
          if (iSlash>=0) {
            while (sSrc.charAt(iSlash)=='/') { if (++iSlash==sSrc.length()) break; }
            sCid = sSrc.substring(iSlash);
          }
          else {
            sCid = sSrc;
          }

          //String sUid = Gadgets.generateUUID();
          //sCid = sUid.substring(0,12)+"$"+sUid.substring(12,20)+"$"+sUid.substring(20,28)+"@hipergate.org";

          if (DebugFile.trace) DebugFile.writeln("HashMap.put("+sSrc+","+sCid+")");

          oDocumentImages.put(sSrc, sCid);
        } // fi (!oDocumentImages.containsKey(sSrc))

        try {
          Pattern oPattern = oCompiler.compile(sSrc, Perl5Compiler.SINGLELINE_MASK);
          oSrcSubs.setSubstitution("cid:"+oDocumentImages.get(sSrc));
          if (DebugFile.trace) DebugFile.writeln("Util.substitute([PatternMatcher],"+ sSrc + ",cid:"+oDocumentImages.get(sSrc)+",...)");
          sHtmlBody = Util.substitute(oMatcher, oPattern, oSrcSubs, sHtmlBody);
        } catch (MalformedPatternException neverthrown) { }

View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

  public void setEmail(String sAttendantEmail)
    throws IllegalArgumentException {

    try {
    if (!new Perl5Matcher().matches(sAttendantEmail, new Perl5Compiler().compile("[\\w\\x2E_-]+@[\\w\\x2E_-]+\\x2E\\D{2,4}",Perl5Compiler.CASE_INSENSITIVE_MASK)))
      throw new IllegalArgumentException("Invalid e-mail syntax");
    } catch (MalformedPatternException neverthrown) { }

    if (sAttendantEmail.length()>100)
      throw new IllegalArgumentException("e-mail may not exceed 100 characters");
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

      if (oMatcher.contains(sBase, oPattern)) {
        MatchResult oMtrs = oMatcher.getMatch();
        if (oMtrs!=null) sMatch = oMtrs.toString();
        if (sMatch.length()==0) {
          oCompiler = new Perl5Compiler();
          oMatcher = new Perl5Matcher();
          oPattern = oCompiler.compile(sPattern, Perl5Compiler.SINGLELINE_MASK);
          if (oMatcher.contains(sBase, oPattern)) {
            oMtrs = oMatcher.getMatch();
            if (oMtrs!=nullsMatch = oMtrs.toString();
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

  public void setPattern(String pattern)
  {
    if (pattern != null) {
      try {
        Perl5Compiler compiler = new Perl5Compiler();
        _pattern = compiler.compile(pattern);
      } catch (MalformedPatternException mpe) {
        throw new ConfigurationError(mpe.toString());
      }
    } else {
      _pattern = null;
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

      int flags =
        Perl5Compiler.READ_ONLY_MASK |
        (ignoreCase ? Perl5Compiler.CASE_INSENSITIVE_MASK : 0) |
        (multiLine ? Perl5Compiler.MULTILINE_MASK : Perl5Compiler.SINGLELINE_MASK) |
        (extended ? Perl5Compiler.EXTENDED_MASK : 0);
      pat = new Perl5Compiler().compile(pattern, flags);
      _patterns.put(key, pat);
    }
   
    return pat;
  }
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

  boolean bAutoDetectEncoding = true;
  TreeSet<String> oFiles = new TreeSet<String>();
  TreeSet<String> oEntries = new TreeSet<String>();
    Perl5Matcher oMatcher = new Perl5Matcher();
    Perl5Matcher oReplacer = new Perl5Matcher();
    Perl5Compiler oCompiler = new Perl5Compiler();

    try {
      String sHtml = readfilestr(sBasePath+sFilePath,"ASCII");

    if (null==sHtml) {
      if (DebugFile.trace) {
        DebugFile.writeln("Could not read file "+sBasePath+sFilePath);
        DebugFile.decIdent();
        throw new IOException("Could not read file "+sBasePath+sFilePath);
      }
    }

    if (DebugFile.trace) {
      DebugFile.writeln(String.valueOf(sHtml.length())+" characters readed from file "+sBasePath+sFilePath);
    }
   
      if (oMatcher.contains(sHtml, oCompiler.compile("<meta\\x20+http-equiv=(\"|')?Content-Type(\"|')?\\x20+content=(\"|')?text/html;\\x20+charset=(\\w|-){3,32}(\"|')?>",Perl5Compiler.CASE_INSENSITIVE_MASK))) {
        if (DebugFile.trace) DebugFile.writeln("<meta http-equiv> tag found");
        String sHttpEquiv = oMatcher.getMatch().toString();
        int iCharset = Gadgets.indexOfIgnoreCase(sHttpEquiv,"charset=");
        if (iCharset>0) {
          int iQuoute = sHttpEquiv.indexOf('"', iCharset);
          if (iQuoute<0) iQuoute = sHttpEquiv.indexOf((char)39, iCharset);
          if (iQuoute<0) {
            bAutoDetectEncoding = true;
          } else {
            sEncoding = sHttpEquiv.substring(iCharset+8, iQuoute);
          if (DebugFile.trace) DebugFile.writeln("setting charset encoding to "+sEncoding);
            bAutoDetectEncoding = false;
            try {
              byte[] aTest = new String("Test").getBytes(sEncoding);
            } catch (UnsupportedEncodingException uex) {
              bAutoDetectEncoding = true;
            }
          }
        } else {
          bAutoDetectEncoding = true;
        }
      } else {
        bAutoDetectEncoding = true;     
      }
   
      if (bAutoDetectEncoding) {
        if (DebugFile.trace) DebugFile.writeln("Autodetecting encoding");
        ByteArrayInputStream oHtmlStrm = new ByteArrayInputStream(sHtml.getBytes("ASCII"));
        sEncoding = new CharacterSetDetector().detect(oHtmlStrm,"ASCII");
        oHtmlStrm.close();
        if (DebugFile.trace) DebugFile.writeln("Encoding set to "+sEncoding);
      }
     
      Pattern oPattern = oCompiler.compile("<base(\\x20)+href=(\"|')?([^'\"\\r\\n]+)(\"|')?(\\x20)*/?>", Perl5Compiler.CASE_INSENSITIVE_MASK);
    if (oMatcher.contains(sHtml, oPattern)) {
      sBaseHref = Gadgets.chomp(oMatcher.getMatch().group(3),"/");
      if (DebugFile.trace) DebugFile.writeln("<base href="+sBaseHref+">");
    }
 
      PatternMatcherInput oMatchInput = new PatternMatcherInput(sHtml);
    oPattern = oCompiler.compile("\\x20(src=|background=|background-image:url\\x28)(\"|')?([^'\"\\r\\n]+)(\"|')?(\\x20|\\x29|/|>)", Perl5Compiler.CASE_INSENSITIVE_MASK);
    StringSubstitution oSrcSubs = new StringSubstitution();
    int nMatches = 0;
    while (oMatcher.contains(oMatchInput, oPattern)) {
      nMatches++;
      String sMatch = oMatcher.getMatch().toString();
      String sAttr = oMatcher.getMatch().group(1);
      String sQuo = oMatcher.getMatch().group(2);
      if (sQuo==null) sQuo = "";
      String sSrc = oMatcher.getMatch().group(3);
      if (DebugFile.trace) DebugFile.writeln("Source file found at "+sSrc);
      String sEnd = oMatcher.getMatch().group(5);
      if (!oFiles.contains(sSrc)) oFiles.add(sSrc);
      String sFilename = sSrc.substring(sSrc.replace('\\','/').lastIndexOf('/')+1);
      if (DebugFile.trace)
        DebugFile.writeln("StringSubstitution.setSubstitution("+sMatch+" replace with "+sMatch.substring(0,sAttr.length()+1)+sQuo+sFilename+sQuo+sEnd+")");
      oSrcSubs.setSubstitution(sMatch.substring(0,sAttr.length()+1)+sQuo+sFilename+sQuo+sEnd);
        sHtml = Util.substitute(oReplacer, oCompiler.compile(sMatch), oSrcSubs, sHtml, Util.SUBSTITUTE_ALL);
    } //wend
   
    oMatchInput = new PatternMatcherInput(sHtml);
    oPattern = oCompiler.compile("<link\\x20+(rel=(\"|')?stylesheet(\"|')?\\x20+)?(type=(\"|')?text/css(\"|')?\\x20+)?href=(\"|')?([^'\"\\r\\n]+)(\"|')?");
    while (oMatcher.contains(oMatchInput, oPattern)) {
      nMatches++;
      String sMatch = oMatcher.getMatch().toString();
      String sSrc = oMatcher.getMatch().group(8);
      String sFilename = sSrc.substring(sSrc.replace('\\','/').lastIndexOf('/')+1);
      if (!oFiles.contains(sSrc)) oFiles.add(sSrc);
      if (DebugFile.trace)
        DebugFile.writeln("StringSubstitution.setSubstitution("+sMatch+" replace with "+Gadgets.replace(sMatch, sSrc, sFilename)+")");
      oSrcSubs.setSubstitution(Gadgets.replace(sMatch, sSrc, sFilename));
        sHtml = Util.substitute(oReplacer, oCompiler.compile(sMatch), oSrcSubs, sHtml);    
    } // wend   
   
    if (DebugFile.trace) {
      DebugFile.writeln(String.valueOf(nMatches)+" matches found");
      DebugFile.write("\n"+sHtml+"\n");
View Full Code Here

Examples of org.apache.oro.text.regex.Perl5Compiler

     */
    public void setMask(String mask)
            throws InvalidMaskException
    {
        /** perl5 compiler, needed for setting up the masks */
        Perl5Compiler patternCompiler = new Perl5Compiler();

        maskString = mask;

        // Fixme. We should make this configureable by the XML file -- hps
        int maskOptions = Perl5Compiler.DEFAULT_MASK;

        try
        {
            log.debug("Compiling pattern " + maskString);
            maskPattern = patternCompiler.compile(maskString, maskOptions);
        }
        catch (MalformedPatternException mpe)
        {
            throw new InvalidMaskException("Could not compile pattern " + maskString, mpe);
        }
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.