1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.ui.console; 12 13 /** 14 * A pattern match listener is registered with a <code>TextConsole</code>, 15 * and is notified when its pattern has been matched to contents in 16 * that console. A pattern match listener can be registered with a console 17 * programmatically or via the <code>consolePatternMatchListeners</code> extension 18 * point. 19 * <p> 20 * Following is an example console pattern match listener extension definition. 21 * </pre> 22 * <extension point="org.eclipse.ui.console.consolePatternMatchListeners"> 23 * <consolePatternMatchListener 24 * id="com.example.ConsolePatternMatcher" 25 * regex=".*foo.*" 26 * class="com.example.ConsolePatternMatcher"> 27 * </consolePatternMatchListener> 28 * </extension> 29 * </pre> 30 * Attributes are specified as follows: 31 * <ul> 32 * <li><code>id</code> - a unique identifier for the pattern match listener</li> 33 * <li><code>regex</code> - regular expression to match</li> 34 * <li><code>class</code> - fully qualified name of the Java class implementing 35 * <code>org.eclipse.ui.console.IPatternMatchListenerDelegate</code></li> 36 * </ul> 37 * </p> 38 * <p> 39 * Optionally a <code>qualifier</code> attribute may be specified to improve performance 40 * of regular expression matching. A qualifier specifies a simple regular expression used to 41 * qualify lines for the search. Lines that do not contain the qualifier are not considered. 42 * </p> 43 * <p> 44 * Optionally an <code>enablement</code> expression may be provided to specify 45 * which console(s) a pattern matcher should be contributed to. 46 * </p> 47 * <p> 48 * Clients may implement this interface directly if registering a pattern match listener with 49 * a text console programmatically. Clients contributing a pattern match listener via an 50 * extension implement <code>IPatternMatchListenerDelegate</code> instead. 51 * </p> 52 * @see org.eclipse.ui.console.TextConsole 53 * @since 3.1 54 */ 55 public interface IPatternMatchListener extends IPatternMatchListenerDelegate { 56 /** 57 * Returns the pattern to be used for matching. The pattern is 58 * a string representing a regular expression. 59 * 60 * @return the regular expression to be used for matching 61 */ 62 public String getPattern(); 63 64 /** 65 * Returns the flags to use when compiling this pattern match listener's 66 * regular expression, as defined by by <code>Pattern.compile(String regex, int flags)</code> 67 * 68 * @return the flags to use when compiling this pattern match listener's 69 * regular expression 70 * @see java.util.regex.Pattern#compile(java.lang.String, int) 71 */ 72 public int getCompilerFlags(); 73 74 /** 75 * Returns a simple regular expression used to identify lines that may 76 * match this pattern matcher's complete pattern, or <code>null</code>. 77 * Use of this attribute can improve performance by disqualifying lines 78 * from the search. When a line is found containing a match for this expression, 79 * the line is searched from the beginning for this pattern matcher's 80 * complete pattern. Lines not containing this pattern are discarded. 81 * 82 * @return a simple regular expression used to identify lines that may 83 * match this pattern matcher's complete pattern, or <code>null</code> 84 */ 85 public String getLineQualifier(); 86 87 } 88