本文整理汇总了Java中org.apache.oro.text.GlobCompiler类的典型用法代码示例。如果您正苦于以下问题:Java GlobCompiler类的具体用法?Java GlobCompiler怎么用?Java GlobCompiler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GlobCompiler类属于org.apache.oro.text包,在下文中一共展示了GlobCompiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandGlob
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
private String[] expandGlob(String filePath, String fileNamePattern, File dir) {
boolean recurse = (fileNamePattern.matches("\\*\\*.*")) ? true : false;
FilenameFilter fileFilter = new GlobFilenameFilter(fileNamePattern,
GlobCompiler.DEFAULT_MASK | GlobCompiler.CASE_INSENSITIVE_MASK);
String[] filteredFiles = getFiles(dir, fileFilter, recurse, "").toArray(new String[0]);
if (filteredFiles == null || filteredFiles.length == 0) {
try {
String error = "The patterns/paths "
+ filePath + " (" + dir + ") "
+ " used in the configuration"
+ " file didn't match any file, the files patterns/paths need to"
+ " be relative " + basePath.getCanonicalPath();
throw new IllegalArgumentException(error);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Arrays.sort(filteredFiles, String.CASE_INSENSITIVE_ORDER);
return filteredFiles;
}
示例2: matchesHost
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public boolean matchesHost(InetAddress a) throws MalformedPatternException {
Perl5Matcher m = new Perl5Matcher();
GlobCompiler c = new GlobCompiler();
Pattern p = c.compile(getHostMask());
return (m.matches(a.getHostAddress(), p) || m.matches(a.getHostName(),
p));
}
示例3: matchesIdent
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public boolean matchesIdent(String ident) throws MalformedPatternException {
Perl5Matcher m = new Perl5Matcher();
GlobCompiler c = new GlobCompiler();
if (ident == null) {
ident = "";
}
return !isIdentMaskSignificant()
|| m.matches(ident, c.compile(getIdentMask()));
}
示例4: MatchdirFilter
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public MatchdirFilter(DiskSelectionFilter diskSelection, Properties p, Integer i) {
super(diskSelection, p, i);
_assignList = AssignRoot.parseAssign(this, PropertyHelper.getProperty(p, i+ ".assign"));
boolean assumeRemove = PropertyHelper.getProperty(p, i + ".assume.remove", "false").
equalsIgnoreCase("true");
// If assume.remove=true, add all roots not assigned a score to be removed
if (assumeRemove) {
int roots = diskSelection.getRootCollection().getRootList().size();
for (int j = 1; j <= roots; j++) {
boolean assigned = false;
for (AssignParser ap : _assignList) {
if (j == ap.getRoot()) {
// Score added to root already, skip
assigned = true;
break;
}
}
if (!assigned) {
// Add root to be remove
_assignList.add(new AssignParser(j+"+remove"));
}
}
}
_negateExpr = PropertyHelper.getProperty(p, i + ".negate.expression", "false").
equalsIgnoreCase("true");
try {
_p = new GlobCompiler().compile(PropertyHelper.getProperty(p, i + ".match"),
GlobCompiler.CASE_INSENSITIVE_MASK);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例5: MatchdirFilter
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public MatchdirFilter(int i, Properties p) {
super(i, p);
try {
_assigns = AssignSlave.parseAssign(PropertyHelper.getProperty(p, i + ".assign"));
boolean assumeRemove = PropertyHelper.getProperty(p, i + ".assume.remove", "false").
equalsIgnoreCase("true");
// If assume.remove=true, add all slaves not assigned a score to be removed
if (assumeRemove) {
for (RemoteSlave slave : GlobalContext.getGlobalContext().getSlaveManager().getSlaves()) {
boolean assigned = false;
for (AssignParser ap : _assigns) {
if (slave.equals(ap.getRSlave())) {
// Score added to slave already, skip
assigned = true;
break;
}
}
if (!assigned) {
// Add slave to be remove
_assigns.add(new AssignParser(slave.getName()+"+remove"));
}
}
}
_p = new GlobCompiler().compile(PropertyHelper.getProperty(p, i + ".match"),Perl5Compiler.READ_ONLY_MASK);
_negateExpr = PropertyHelper.getProperty(p, i + ".negate.expression", "false").
equalsIgnoreCase("true");
} catch (Exception e) {
throw new FatalException(e);
}
}
示例6: toPatterns
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
@Nonnull
private static Iterable<Pattern> toPatterns(@Nonnull Iterable<? extends String>... patterns) throws MalformedPatternException {
GlobCompiler compiler = new GlobCompiler();
List<Pattern> out = new ArrayList<Pattern>();
for (Iterable<? extends String> in : patterns)
for (String pattern : in)
out.add(compiler.compile(pattern));
return out;
}
示例7: matchFileNamesWithPattern
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
/**
* compiles fileNameRegExp into a regular expression and pattern matches on
* each file's name, and returns those that match.
*
* @param files
* @param fileNameRegExp
*
* @return String[] of files that match the expresion.
*/
public String[] matchFileNamesWithPattern(File[] files,
String fileNameRegExp) throws SshException {
// set up variables for regexp matching
Pattern mpattern = null;
PatternCompiler aGCompiler = new GlobCompiler();
PatternMatcher aPerl5Matcher = new Perl5Matcher();
// Attempt to compile the pattern. If the pattern is not valid,
// throw exception
try {
mpattern = aGCompiler.compile(fileNameRegExp);
} catch (MalformedPatternException e) {
throw new SshException("Invalid regular expression:"
+ e.getMessage(), SshException.BAD_API_USAGE);
}
Vector<String> matchedNames = new Vector<String>();
for (int i = 0; i < files.length; i++) {
if ((!files[i].getName().equals("."))
&& (!files[i].getName().equals(".."))) {
if (aPerl5Matcher.matches(files[i].getName(), mpattern)) {
// call get for each match, passing true, so that it doesnt
// repeat the search
matchedNames.addElement(files[i].getAbsolutePath());
}
}
}
// return (String[]) matchedNames.toArray(new String[0]);
String[] matchedNamesStrings = new String[matchedNames.size()];
matchedNames.copyInto(matchedNamesStrings);
return matchedNamesStrings;
}
示例8: matchFilesWithPattern
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
/**
* compiles fileNameRegExp into a regular expression and pattern matches on
* each file's name, and returns those that match.
*
* @param files
* @param fileNameRegExp
*
* @return SftpFile[] of files that match the expresion.
*/
public SftpFile[] matchFilesWithPattern(SftpFile[] files,
String fileNameRegExp) throws SftpStatusException, SshException {
// set up variables for regexp matching
Pattern mpattern = null;
PatternCompiler aGCompiler = new GlobCompiler();
PatternMatcher aPerl5Matcher = new Perl5Matcher();
// Attempt to compile the pattern. If the pattern is not valid,
// throw exception
try {
mpattern = aGCompiler.compile(fileNameRegExp);
} catch (MalformedPatternException e) {
throw new SshException("Invalid regular expression:"
+ e.getMessage(), SshException.BAD_API_USAGE);
}
Vector<SftpFile> matchedNames = new Vector<SftpFile>();
for (int i = 0; i < files.length; i++) {
if ((!files[i].getFilename().equals("."))
&& (!files[i].getFilename().equals(".."))
&& (!files[i].isDirectory())) {
if (aPerl5Matcher.matches(files[i].getFilename(), mpattern)) {
// call get for each match, passing true, so that it doesnt
// repeat the search
matchedNames.addElement(files[i]);
}
}
}
// return (SftpFile[]) matchedNames.toArray(new SftpFile[0]);
SftpFile[] matchedNamesSftpFiles = new SftpFile[matchedNames.size()];
matchedNames.copyInto(matchedNamesSftpFiles);
return matchedNamesSftpFiles;
}
示例9: GlobMatcher
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public GlobMatcher(String expression) throws PatternSyntaxException {
this.expression = expression;
try {
pattern = new GlobCompiler().compile(expression);
} catch (MalformedPatternException e) {
throw new PatternSyntaxException(e.getMessage(), expression, 0);
}
}
示例10: compilePattern
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public Pattern compilePattern(String patternStr) throws MalformedPatternException {
int globOptions = GlobCompiler.DEFAULT_MASK | GlobCompiler.QUESTION_MATCHES_ZERO_OR_ONE_MASK;
char [] patternCh = patternStr.toCharArray();
String perl5PatternStr = GlobCompiler.globToPerl5(patternCh, globOptions);
return super.compilePattern(perl5PatternStr);
}
示例11: Recurser
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public Recurser(Connection connection) {
super(connection);
this.globCompiler = new GlobCompiler();
this.matcher = new Perl5Matcher();
}
示例12: GlobPathPermission
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public GlobPathPermission(String pattern, Collection<String> users) throws MalformedPatternException {
super(users);
_pat = new GlobCompiler().compile(pattern);
}
示例13: GlobPathMatcher
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public GlobPathMatcher(String pathPattern) throws MalformedPatternException {
_pat = new GlobCompiler().compile(pathPattern);
_pathPattern = pathPattern;
}
示例14: initialize
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public void initialize(StandardCommandManager cManager) {
Properties cfg = GlobalContext.getGlobalContext().getPluginsConfig().
getPropertiesForPlugin("zipscript.conf");
if (cfg == null) {
logger.fatal("conf/zipscript.conf not found");
throw new FatalException("conf/zipscript.conf not found");
}
// SFV First PathPermissions
String sfvFirstUsers = cfg.getProperty("sfvfirst.users", "");
_sfvFirstRequired = cfg.getProperty("sfvfirst.required", "false").equals("true");
_sfvFirstAllowNoExt = cfg.getProperty("sfvfirst.allownoext", "false").equals("true");
_sfvDenySubDir = cfg.getProperty("sfvdeny.subdir", "false").equals("true");
_sfvDenySubDirInclude = cfg.getProperty("sfvdeny.subdir.include", ".*");
_sfvDenySubDirExclude = cfg.getProperty("sfvdeny.subdir.exclude", ".*");
if (_sfvFirstRequired) {
try {
// this one gets perms defined in sfvfirst.users
StringTokenizer st = new StringTokenizer(cfg
.getProperty("sfvfirst.pathcheck", ""));
while (st.hasMoreTokens()) {
GlobalContext.getConfig().addPathPermission(
"sfvfirst.pathcheck",
new GlobPathPermission(new GlobCompiler()
.compile(st.nextToken()), Permission
.makeUsers(new StringTokenizer(
sfvFirstUsers, " "))));
}
st = new StringTokenizer(cfg
.getProperty("sfvfirst.pathignore", ""));
while (st.hasMoreTokens()) {
GlobalContext.getConfig().addPathPermission(
"sfvfirst.pathignore",
new GlobPathPermission(new GlobCompiler()
.compile(st.nextToken()), Permission
.makeUsers(new StringTokenizer("*", " "))));
}
} catch (MalformedPatternException e) {
logger.warn("Exception when reading conf/plugins/zipscript.conf", e);
}
}
}
示例15: resolveFiles
import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
private Set<FileInfo> resolveFiles(List<String> files, boolean serveOnly) {
if (files != null) {
Set<FileInfo> resolvedFiles = new LinkedHashSet<FileInfo>();
for (String f : files) {
f = pathRewriter.rewrite(f);
boolean isPatch = f.startsWith("patch");
if (isPatch) {
String[] tokens = f.split(" ", 2);
f = tokens[1].trim();
}
if (f.startsWith("http://") || f.startsWith("https://")) {
resolvedFiles.add(new FileInfo(f, -1, -1, false, false, null, f));
} else {
File file = basePath != null ? new File(basePath.getAbsoluteFile(), f) : new File(f);
File testFile = file.getAbsoluteFile();
File dir = testFile.getParentFile().getAbsoluteFile();
final String pattern = file.getName();
String[] filteredFiles = dir.list(new GlobFilenameFilter(pattern,
GlobCompiler.DEFAULT_MASK | GlobCompiler.CASE_INSENSITIVE_MASK));
if (filteredFiles == null || filteredFiles.length == 0) {
String error = "The patterns/paths " + f + " used in the configuration"
+ " file didn't match any file, the files patterns/paths need to be relative to"
+ " the configuration file.";
System.err.println(error);
throw new RuntimeException(error);
}
Arrays.sort(filteredFiles, String.CASE_INSENSITIVE_ORDER);
for (String filteredFile : filteredFiles) {
File resolvedFile =
pathResolver.resolvePath(dir.getPath() + File.separator + filteredFile);
resolvedFiles.add(new FileInfo(resolvedFile.getAbsolutePath(), resolvedFile.lastModified(), -1,
isPatch, serveOnly, null, filteredFile));
}
}
}
return resolvedFiles;
}
return Collections.emptySet();
}