Examples of PatternCompiler


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

        LOG.error("error assigning base URL", e);
      }
    }

    try {
      final PatternCompiler cp = new Perl5Compiler();
      final Pattern pattern = cp.compile(STRING_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
          | Perl5Compiler.MULTILINE_MASK);
      final Pattern pattern1 = cp.compile(URI_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
          | Perl5Compiler.MULTILINE_MASK);
      final PatternMatcher matcher = new Perl5Matcher();

      final PatternMatcher matcher1 = new Perl5Matcher();
View Full Code Here

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

  public Pattern getPattern(){ //laisy compilation of the regex.
    return this.regexPattern;
  }
  public void setRegex(String regex) {
    // would be better to get them from Avalon or so?
    PatternCompiler regexCompiler = new Perl5Compiler();
     if (regex != null){
      try {
        this.regexPattern = regexCompiler.compile(regex);
      } catch (MalformedPatternException e){
        this.regexPattern = null;
      }
    }
  }
View Full Code Here

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

      }
    }
  }
  public void setGlob(String mask) {
    // would be better to get them from Avalon or so?
   PatternCompiler globCompiler = new GlobCompiler();
    if (mask != null){
      try {
        this.regexPattern = globCompiler.compile(mask);
      } catch (MalformedPatternException e){
        this.regexPattern = null;
      }
    }
  }
View Full Code Here

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

            this.urlPattern = urlPattern;
            this.pattern = null;

            try
            {
                PatternCompiler compiler = new GlobCompiler();
                this.pattern = compiler.compile(this.urlPattern);
            }
            catch (Exception e)
            {
                log.error("Invalid url pattern: " + this.urlPattern);
            }
View Full Code Here

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

    }

    public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
        PatternMatcher pm = JMeterUtils.getMatcher();
        Pattern pattern = null;
        PatternCompiler compiler = new Perl5Compiler();
        String input = prop.getStringValue();
        if(input == null) {
            return prop;
        }
        for(Entry<String, String> entry : getVariables().entrySet()){
            String key = entry.getKey();
            String value = entry.getValue();
            if (regexMatch) {
                try {
                    pattern = compiler.compile("\\b("+value+")\\b");
                    input = Util.substitute(pm, pattern,
                            new StringSubstitution(FUNCTION_REF_PREFIX + key + FUNCTION_REF_SUFFIX),
                            input, Util.SUBSTITUTE_ALL);
                } catch (MalformedPatternException e) {
                    log.warn("Malformed pattern " + value);
View Full Code Here

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

        LOG.error("error assigning base URL", e);
      }
    }

    try {
      final PatternCompiler cp = new Perl5Compiler();
      final Pattern pattern = cp.compile(STRING_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
          | Perl5Compiler.MULTILINE_MASK);
      final Pattern pattern1 = cp.compile(URI_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
          | Perl5Compiler.MULTILINE_MASK);
      final PatternMatcher matcher = new Perl5Matcher();

      final PatternMatcher matcher1 = new Perl5Matcher();
View Full Code Here

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

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

          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);
      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();

      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;
          }

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

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

      } // next
View Full Code Here

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

    } catch (Exception e) {
      if (LOG.isErrorEnabled()) { LOG.error("getJSLinks", e); }
    }

    try {
      final PatternCompiler cp = new Perl5Compiler();
      final Pattern pattern = cp.compile(STRING_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
              | Perl5Compiler.MULTILINE_MASK);
      final Pattern pattern1 = cp.compile(URI_PATTERN,
              Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
                  | Perl5Compiler.MULTILINE_MASK);
      final PatternMatcher matcher = new Perl5Matcher();

      final PatternMatcher matcher1 = new Perl5Matcher();
View Full Code Here

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

  public static Outlink[] getOutlinks(final String plainText, String anchor, Configuration conf) {
    long start = System.currentTimeMillis();
    final List outlinks = new ArrayList();

    try {
      final PatternCompiler cp = new Perl5Compiler();
      final Pattern pattern = cp.compile(URL_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
              | Perl5Compiler.MULTILINE_MASK);
      final PatternMatcher matcher = new Perl5Matcher();

      final PatternMatcherInput input = new PatternMatcherInput(plainText);
View Full Code Here

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

  public static Outlink[] getOutlinks(final String plainText, String anchor, Configuration conf) {
    long start = System.currentTimeMillis();
    final List<Outlink> outlinks = new ArrayList<Outlink>();

    try {
      final PatternCompiler cp = new Perl5Compiler();
      final Pattern pattern = cp.compile(URL_PATTERN,
          Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK
              | Perl5Compiler.MULTILINE_MASK);
      final PatternMatcher matcher = new Perl5Matcher();

      final PatternMatcherInput input = new PatternMatcherInput(plainText);
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.