01: package com.sun.portal.app.filesharing.util;
02:
03: import java.util.regex.Pattern;
04: import java.util.regex.Matcher;
05:
06: /**
07: * @author Alejandro Abdelnur
08: */
09: public class FilePattern {
10: private static final String[][] SWAPS = { { ".", "\\." },
11: { "*", ".*" }, { "?", "." } };
12:
13: private Pattern _pattern;
14: private Matcher _matcher;
15:
16: public FilePattern(String pattern) {
17: _pattern = Pattern.compile(MaskTranslator.translate(SWAPS,
18: pattern));
19: _matcher = _pattern.matcher("");
20: }
21:
22: public boolean matches(String name) {
23: _matcher.reset(name);
24: return _matcher.matches();
25: }
26:
27: }
|