当前位置: 首页>>代码示例>>Java>>正文


Java GlobCompiler类代码示例

本文整理汇总了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;
}
 
开发者ID:BladeRunnerJS,项目名称:brjs-JsTestDriver,代码行数:24,代码来源:PathResolver.java

示例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));
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:9,代码来源:HostMask.java

示例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()));
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:12,代码来源:HostMask.java

示例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);
	}
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:36,代码来源:MatchdirFilter.java

示例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);
	}
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:34,代码来源:MatchdirFilter.java

示例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;
}
 
开发者ID:shevek,项目名称:jarjar,代码行数:10,代码来源:JarjarTask.java

示例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;
}
 
开发者ID:sshtools,项目名称:j2ssh-maverick,代码行数:42,代码来源:GlobRegExpMatching.java

示例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;
}
 
开发者ID:sshtools,项目名称:j2ssh-maverick,代码行数:44,代码来源:GlobRegExpMatching.java

示例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);
    }
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:9,代码来源:GlobPatternMatcher.java

示例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);
}
 
开发者ID:cverges,项目名称:expect4j,代码行数:8,代码来源:GlobMatch.java

示例11: Recurser

import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public Recurser(Connection connection) {
    super(connection);

    this.globCompiler = new GlobCompiler();
    this.matcher = new Perl5Matcher();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:7,代码来源:Recurser.java

示例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);		
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:5,代码来源:GlobPathPermission.java

示例13: GlobPathMatcher

import org.apache.oro.text.GlobCompiler; //导入依赖的package包/类
public GlobPathMatcher(String pathPattern) throws MalformedPatternException {
	_pat = new GlobCompiler().compile(pathPattern);
	_pathPattern = pathPattern;
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:5,代码来源:GlobPathMatcher.java

示例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);
		}
	}
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:42,代码来源:ZipscriptPreHook.java

示例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();
}
 
开发者ID:BladeRunnerJS,项目名称:brjs-JsTestDriver,代码行数:47,代码来源:ConfigurationParser.java


注:本文中的org.apache.oro.text.GlobCompiler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。