[Oregex-discuss] Pattern Info
Status: Pre-Alpha
Brought to you by:
mystifier
|
From: Rohit L. <ro...@ig...> - 2003-11-01 09:02:24
|
Hi Anthony, Patterns are the basic search definition. If you see the class implementing Pattern are all package scope and Pattern uses factory methods like exact(), or() .. to create the patterns. There is great advantage of having factory method. Tomorrow we can change the way patterns are handled, created without affecting the API. For Example: Pattern name(String name) in Pattern class This function now sets a sting private field and returns the 'this' pattern. Suppose later we would like to change the implementation of named patterns to having a list of named patterns as static Map, we can easily do so by overriding name factory method. Patterns are of 2 types : Basic Pattern and Operator Patterns. Basic Patterns are real patterns. They contain the Logic on how to apply them. They have static factory methods in the Pattern. Example: Exact Exact is a basic pattern which matches exactly the given Object with the Stream Object. This is normally equals method. Operator patterns are patterns that are made up of sub-patterns or operands. They contain the logic of carrying out the operation. They have a instance (non static) factory method. Example Or Or is a operator pattern that or's each of the composed patterns. It's apply method applies the given Stream to each operand(sub-pattern) and or's their result i.e. returns true if any one returns true. Operator patterns are of 2 types: Single and Multiple, indication number of operands. The respective Class implementations are SinglePatternWrapper and MultiplePatternWrapper. Not is a single where as or is multiple. hope this helps. Rohit Rohit Lodha New Delhi Mobile : +91-9811713235 **************************************************************************** ************** Sign of arrogance: My opinions may have changed but not the fact that I am right. **************************************************************************** ***************** |