com.sapportals.wcm.util.regex

Class PathPatternMatcher

java.lang.Object
  extended bycom.sapportals.wcm.util.regex.PathPatternMatcher

public class PathPatternMatcher
extends Object

PathPatternMatcher matches single line strings against a given pattern. The pattern syntax resembles the path pattern syntax used by the open source make tool ant , at least to some degree. A pattern consists of 5 syntactical elements:

1. path separators '/' and '\' either slash or backslash 2. single character wildcard '?' question mark; matches any single non-whitespace char except for path separators 3. multiple character wildcard '*' asterisk, matches sequences of non-whitespace characters of any length greater or equal zero 4. multiple dir wildcard '**' matches any sequences of groups of nodes and path separators 5. node any sequence of non-whitespace characters not including separators

In addition, a path separator at the end of a strings serves as a convenience shortcut so that "string/" behaves like "string/**".

NOTE that PathPatternMatcher does reject some strings that the open source tools accepts. E.g., the ant manual pages state that the following two pairs of string and pattern do match.

String Pattern "CVS/Repository" "**/CVS/*" "org/apache/CVS/Entries" "org/apache/**/CVS/*"

PathPatternMatcher rejects those examples; the first one because the pattern contains 2 terminal symbols of type path separator while the string contains only 1; the second examples is rejected for almost the same reason: the pattern contains 2 path separators between the "apache" and the "CVS" part of the pattern while the string has only 1.

Copyright (c) SAP AG 2001-2002


Constructor Summary
PathPatternMatcher(String pattern)
          Creates a pattern matcher instance for pattern .
PathPatternMatcher(String[] pattern)
          Creates a pattern matcher instance that works on an array of pattern .
 
Method Summary
 boolean matches(String needle)
          Matches needle against the pattern of this pattern matcher.
 String toString()
          Returns a printable representation of this pattern matcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathPatternMatcher

public PathPatternMatcher(String pattern)
                   throws PatternSyntaxException
Creates a pattern matcher instance for pattern .

Parameters:
pattern - TBD: Description of the incoming method parameter
Throws:
PatternSyntaxException - Exception raised in failure situation

PathPatternMatcher

public PathPatternMatcher(String[] pattern)
                   throws PatternSyntaxException
Creates a pattern matcher instance that works on an array of pattern .

Parameters:
pattern - TBD: Description of the incoming method parameter
Throws:
PatternSyntaxException - Exception raised in failure situation
Method Detail

matches

public boolean matches(String needle)
Matches needle against the pattern of this pattern matcher.

Parameters:
needle - TBD: Description of the incoming method parameter
Returns:
TBD: Description of the outgoing return value

toString

public String toString()
Returns a printable representation of this pattern matcher.

Returns:
TBD: Description of the outgoing return value


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.