Posts

Showing posts with the label expression

Eclipse command framework core expression : Multiple handlers

Image
Eclipse platform command framework supports core expression to control commands behavior runtime. In this series of posts I have explained different ways of using core expressions . This post explains having multiple handler for same command but activate only one of it at runtime based on some of the condition. Eclipse command framework is based on MVC framework. Command declaration, handler declaration  and contributing command to workbench helps to keep declaration separate from presentation. You can have multiple handlers for same command, but only one will be active at one moment. Core expression provides “activeWhen” declarative clause to activate specific handler for given command based on specific condition. Here is how we use it . I have created a new eclipse plug-in project. I have extended “org.eclipse.ui.editors” extension point to define two simple text editors. Here I am going to define two different handlers for same commands but only one will be active based on e...

Pattern matching using java.util.regex

Image
java.util.regex library is available since Java 1.4. It can be used for matching character sequences against pattern specified by regular expression. It has two main classes Pattern and Matcher . An instance of the Pattern class represents a regular expression that is specified in string form in a syntax. Instances of the Matcher class are used to match character sequences against a given pattern. Input is provided to matchers via the CharSequence interface in order to support matching against characters from a wide variety of input sources. Here is the simple example, If you have to extract part of string based on the fixed pattern defined. For example the simple greeting string “Hello Yogesh, Welcome to Hyderabad.” In this sentence, we have to extract two info like name and location ( Yogesh & Hyderabad). First of all we need to define pattern to extract the same information. Java support regular expression for pattern matching, go through Java Pattern documentation to ...