Examples of PatternCompiler


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

  public static Outlink[] getOutlinks(final String plainText, String anchor) {

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

    }

    public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
        PatternMatcher pm = JMeterUtils.getMatcher();
        Pattern pattern = null;
        PatternCompiler compiler = new Perl5Compiler();
        String input = prop.getStringValue();
        for(Entry<String, String> entry : getVariables().entrySet()){
            String key = entry.getKey();
            String value = entry.getValue();
            if (regexMatch) {
                try {
                    pattern = compiler.compile(value);
                    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

            if( value != null && 0 < value.length() && !STR_GLOBSTAR.equals( value ) )
            {
                try
                {
                    PatternCompiler pc = new GlobCompiler();

                    String[] ptrns = StringUtils.split( value, STR_COMMA );

                    result = new Pattern[ptrns.length];

                    for( int n = 0; n < ptrns.length; n++ )
                    {
                        result[n] = pc.compile( ptrns[n] );
                    }
                }
                catch( MalformedPatternException e )
                {
                    throw new PluginException( "Parameter " + name + " has a malformed pattern: " + e.getMessage() );
View Full Code Here

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

        //  The default packages are always added.
        //
        m_searchPath.add( DEFAULT_PACKAGE );
        m_searchPath.add( DEFAULT_FORMS_PACKAGE );

        PatternCompiler compiler = new Perl5Compiler();

        try {
            m_pluginPattern = compiler.compile( PLUGIN_INSERT_PATTERN );
        } catch( MalformedPatternException e ) {
            log.fatal( "Internal error: someone messed with pluginmanager patterns.", e );
            throw new InternalWikiException( "PluginManager patterns are broken" );
        }
View Full Code Here

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

        if( s != null )
        {
            try
            {
                PatternCompiler pc = new GlobCompiler();

                String[] ptrns = StringUtils.split( s, "," );

                m_exclude = new Pattern[ptrns.length];

                for( int i = 0; i < ptrns.length; i++ )
                {
                    m_exclude[i] = pc.compile( ptrns[i] );
                }
            }
            catch( MalformedPatternException e )
            {
                throw new PluginException("Exclude-parameter has a malformed pattern: "+e.getMessage());
            }
        }

        // TODO: Cut-n-paste, refactor
        s = params.get( PARAM_INCLUDE );

        if( s != null )
        {
            try
            {
                PatternCompiler pc = new GlobCompiler();

                String[] ptrns = StringUtils.split( s, "," );

                m_include = new Pattern[ptrns.length];

                for( int i = 0; i < ptrns.length; i++ )
                {
                    m_include[i] = pc.compile( ptrns[i] );
                }
            }
            catch( MalformedPatternException e )
            {
                throw new PluginException("Include-parameter has a malformed pattern: "+e.getMessage());
View Full Code Here

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

    // FIXME: parsers should be pooled for better performance.
    @SuppressWarnings("unchecked")
    private void initialize()
    {
        PatternCompiler compiler         = new GlobCompiler();
        List<Pattern>   compiledpatterns;

        //
        //  We cache compiled patterns in the engine, since their creation is
        //  really expensive
        //
        compiledpatterns = (List<Pattern>)m_engine.getAttribute( INLINE_IMAGE_PATTERNS );

        if( compiledpatterns == null )
        {
            compiledpatterns = new ArrayList<Pattern>(20);
            Collection< String > ptrns = m_engine.getAllInlinedImagePatterns();

            //
            //  Make them into Regexp Patterns.  Unknown patterns
            //  are ignored.
            //
            for( Iterator< String > i = ptrns.iterator(); i.hasNext(); )
            {
                try
                {
                    compiledpatterns.add( compiler.compile( i.next(),
                                                            GlobCompiler.DEFAULT_MASK|GlobCompiler.READ_ONLY_MASK ) );
                }
                catch( MalformedPatternException e )
                {
                    log.error("Malformed pattern in properties: ", e );
View Full Code Here

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

        super(platform);
        setDefaultCatalogPattern(null);
        setDefaultSchemaPattern(null);
        setDefaultTablePattern("%");

        PatternCompiler compiler = new Perl5Compiler();

      try
      {
            _isoDatePattern = compiler.compile("'(\\d{4}\\-\\d{2}\\-\\d{2})'");
            _isoTimePattern = compiler.compile("'(\\d{2}:\\d{2}:\\d{2})'");
        }
      catch (MalformedPatternException ex)
        {
          throw new DdlUtilsException(ex);
        }
View Full Code Here

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

  /**
   * Creates a new date converter object.
   */
  public DateConverter()
  {
        PatternCompiler compiler = new Perl5Compiler();

        try
        {
            _datePattern = compiler.compile("(\\d{2,4})(?:\\-(\\d{2}))?(?:\\-(\\d{2}))?.*");
        }
        catch (MalformedPatternException ex)
        {
            throw new DdlUtilsException(ex);
        }
View Full Code Here

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

  /**
   * Creates a new time converter object.
   */
  public TimeConverter()
  {
        PatternCompiler compiler = new Perl5Compiler();

        try
        {
            _timePattern = compiler.compile("(?:\\d{4}\\-\\d{2}\\-\\d{2}\\s)?(\\d{2})(?::(\\d{2}))?(?::(\\d{2}))?(?:\\..*)?");
        }
        catch (MalformedPatternException ex)
        {
            throw new DdlUtilsException(ex);
        }
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.