org.apache.commons.io.filefilter.FileFilterUtils Java Examples

The following examples show how to use org.apache.commons.io.filefilter.FileFilterUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectImpl.java    From japi with MIT License 6 votes vote down vote up
@Override
public List<IPackage> getPackages() {
    String masterProjectActionPath = JapiClient.getConfig().getPrefixPath() + JapiClient.getConfig().getProjectJavaPath() + JapiClient.getConfig().getPostfixPath() + "/" + JapiClient.getConfig().getActionReletivePath();
    File actionFold = new File(masterProjectActionPath);
    if (!actionFold.exists()) {
        throw new JapiException(masterProjectActionPath + " fold not exists.");
    }
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory();
        }
    });
    Collection<File> folds = FileUtils.listFilesAndDirs(actionFold, dirFilter, TrueFileFilter.INSTANCE);
    List<IPackage> packages = new ArrayList<>(folds.size());
    for (File fold : folds) {
        if (!fold.getAbsolutePath().equals(actionFold.getAbsolutePath())) {
            PackageImpl packageImpl = new PackageImpl();
            packageImpl.setPackageFold(fold);
            packages.add(packageImpl);
        }
    }
    return packages;
}
 
Example #2
Source File: ApplicationConfigMonitor.java    From canal with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    File confDir = Util.getConfDirPath();
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
                FileFilterUtils.prefixFileFilter("application"),
                FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example #3
Source File: RdbConfigMonitor.java    From canal with Apache License 2.0 6 votes vote down vote up
public void init(String key, RdbAdapter rdbAdapter, Properties envProperties) {
    this.key = key;
    this.rdbAdapter = rdbAdapter;
    this.envProperties = envProperties;
    File confDir = Util.getConfDirPath(adapterName);
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example #4
Source File: SvnWorkspaceProviderImpl.java    From proctor with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    try {
        if (!shutdown.get()) {
            LOGGER.info("Actively cleaning up directories older than " + TimeUnit.MILLISECONDS.toHours(cleanupAgeMillis) + " hours");
            final IOFileFilter olderThanFilter = FileFilterUtils.asFileFilter(olderThanFileFilter(cleanupAgeMillis));
            final IOFileFilter tempDirFilter =
                FileFilterUtils.prefixFileFilter(prefix);

            /*
             * Delete directories that are:
             * older than [clean up age millis]
             * starts with temp-dir-prefix
             */
            final IOFileFilter deleteAfterMillisFilter = FileFilterUtils.makeDirectoryOnly(
                FileFilterUtils.andFileFilter(olderThanFilter, tempDirFilter)
            );
            deleteUserDirectories(rootDirectory, deleteAfterMillisFilter);
        } else {
            LOGGER.info("Currently shutdown, skipping older-than directory cleanup");
        }
    } catch (Exception e) {
        LOGGER.error("Unhandled Exception during directory cleanup", e);
    }
}
 
Example #5
Source File: PatternStats.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected void runSummary(File dir) throws FileNotFoundException, IOException, SAXException {
	HashMap<DittedBitSequence, PatternAccumulate> hashMap =
		new HashMap<>();

	Iterator<File> iterator = FileUtils.iterateFiles(dir,
		FileFilterUtils.prefixFileFilter("pat_"), FalseFileFilter.INSTANCE);

	while (iterator.hasNext()) {
		File f = iterator.next();
		accumulateFile(hashMap, new ResourceFile(f));
	}

	println("     Total FalseWith   FalseNo  Pattern");
	for (PatternAccumulate accum : hashMap.values()) {
		StringBuffer buf = new StringBuffer();
		accum.displaySummary(buf);
		println(buf.toString());
	}
}
 
Example #6
Source File: RdbConfigMonitor.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
public void init(String key, RdbAdapter rdbAdapter, Properties envProperties) {
    this.key = key;
    this.rdbAdapter = rdbAdapter;
    this.envProperties = envProperties;
    File confDir = Util.getConfDirPath(adapterName);
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example #7
Source File: ESConfigMonitor.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
public void init(ESAdapter esAdapter, Properties envProperties) {
        this.esAdapter = esAdapter;
        this.envProperties = envProperties;
        File confDir = Util.getConfDirPath(adapterName);
        try {
            FileAlterationObserver observer = new FileAlterationObserver(confDir,
                FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
//            文件变化监听采用的common io的类库
            FileListener listener = new FileListener();
            observer.addListener(listener);
            fileMonitor = new FileAlterationMonitor(3000, observer);
            fileMonitor.start();

        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
 
Example #8
Source File: CompiledJavaccFile.java    From javaccPlugin with MIT License 6 votes vote down vote up
private File scanSourceFiles(String compiledJavaccFilePackage, Collection<File> sourceFiles) {
    for (File sourceFile : sourceFiles) {
        logger.debug("Scanning source file [{}] looking for a file named [{}] in package [{}]", sourceFile, compiledJavaccFile.getName(), compiledJavaccFilePackage);
        if (sourceFile.isDirectory()) {
            Collection<File> childFiles = FileUtils.listFiles(sourceFile, FileFilterUtils.suffixFileFilter(".java"), TrueFileFilter.TRUE);
            File matchingChildFile = scanSourceFiles(compiledJavaccFilePackage, childFiles);
            if (matchingChildFile != null) {
                return matchingChildFile;
            }
        } else {
            if (FilenameUtils.isExtension(sourceFile.getName(), "java") && compiledJavaccFile.getName().equals(sourceFile.getName())) {
                String packageName = getPackageName(sourceFile);

                if (compiledJavaccFilePackage.equals(packageName)) {
                    return sourceFile;
                }
            }
        }
    }

    return null;
}
 
Example #9
Source File: BatchFileLookupableHelperServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
protected IOFileFilter getPathBasedFileFilter() {
    List<File> selectedFiles = getSelectedDirectories(getSelectedPaths());
    if (selectedFiles.isEmpty()) {
        return null;
    }
    IOFileFilter fileFilter = null;
    for (File selectedFile : selectedFiles) {
        IOFileFilter subFilter = new SubDirectoryFileFilter(selectedFile);
        if (fileFilter == null) {
            fileFilter = subFilter;
        }
        else {
            fileFilter = FileFilterUtils.orFileFilter(fileFilter, subFilter);
        }
    }
    return fileFilter;
}
 
Example #10
Source File: ApplicationConfigMonitor.java    From canal-1.1.3 with Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void init() {
    File confDir = Util.getConfDirPath();
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
                FileFilterUtils.prefixFileFilter("application"),
                FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example #11
Source File: FilesetSplit.java    From tassal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	if (args.length < 7) {
		System.err
				.println("Usage fromDirectory toDirectory fileSuffix <<segmentName_i> <weight_i> ...>");
		System.exit(-1);
	}

	final File fromDirectory = new File(args[0]);
	final File toDirectory = new File(args[1]);

	final IOFileFilter fileFilter = FileFilterUtils
			.suffixFileFilter(args[2]);

	final Map<String, Double> segments = Maps.newHashMap();

	for (int i = 3; i < args.length; i += 2) {
		segments.put(args[i], Double.valueOf(args[i + 1]));
	}

	LOGGER.info("Splitting files in segments " + segments);
	splitFiles(fromDirectory, toDirectory, segments, fileFilter,
			UNIFORM_FILE_WEIGHT);
}
 
Example #12
Source File: HbaseConfigMonitor.java    From canal with Apache License 2.0 6 votes vote down vote up
public void init(HbaseAdapter hbaseAdapter, Properties envProperties) {
    this.hbaseAdapter = hbaseAdapter;
    this.envProperties = envProperties;
    File confDir = Util.getConfDirPath(adapterName);
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example #13
Source File: AntRunner.java    From CodeDefenders with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String compileCUT(GameClass cut) throws CompileException {
    AntProcessResult result = runAntTarget("compile-cut", null, null, cut, null, forceLocalExecution);

    logger.info("Compile New CUT, Compilation result: {}", result);

    String pathCompiledClassName = null;
    if (result.compiled()) {
        // If the input stream returned a 'successful build' message, the CUT compiled correctly
        logger.info("Compiled uploaded CUT successfully");
        File f = Paths.get(CUTS_DIR, cut.getAlias()).toFile();
        final String compiledClassName = FilenameUtils.getBaseName(cut.getJavaFile()) + Constants.JAVA_CLASS_EXT;
        LinkedList<File> matchingFiles = (LinkedList<File>) FileUtils.listFiles(f, FileFilterUtils.nameFileFilter(compiledClassName), FileFilterUtils.trueFileFilter());
        if (!matchingFiles.isEmpty())
            pathCompiledClassName = matchingFiles.get(0).getAbsolutePath();
    } else {
        // Otherwise the CUT failed to compile
        String message = result.getCompilerOutput();
        logger.error("Failed to compile uploaded CUT: {}", message);
        throw new CompileException(message);
    }
    return pathCompiledClassName;
}
 
Example #14
Source File: IOUtil.java    From celerio with Apache License 2.0 6 votes vote down vote up
/**
 * Recurse in the folder to get the list all files and folders
 * <ul>
 * <li>do not recurse in svn folder</li>
 * <li>do not recurse in cvs folder</li>
 * <li>do not match .bak files</li>
 * <li>do not match .old files</li>
 * </ul>
 *
 * @param folder       the folder to parse
 * @param ioFileFilter additionnal IOFilter
 */
@SuppressWarnings("unchecked")
public Collection<String> listFiles(File folder, IOFileFilter ioFileFilter) {
    if (ioFileFilter == null) {
        ioFileFilter = FileFilterUtils.fileFileFilter();
    }
    OrFileFilter oldFilesFilter = new OrFileFilter();
    for (String exclude : DEFAULT_EXCLUDES_SUFFIXES) {
        oldFilesFilter.addFileFilter(FileFilterUtils.suffixFileFilter(exclude));
    }
    IOFileFilter notOldFilesFilter = FileFilterUtils.notFileFilter(oldFilesFilter);

    Collection<File> files = FileUtils.listFiles(folder, FileFilterUtils.andFileFilter(ioFileFilter, notOldFilesFilter),
            FileFilterUtils.makeSVNAware(FileFilterUtils.makeCVSAware(null)));
    Collection<String> ret = newArrayList();
    for (File file : files) {
        ret.add(file.getAbsolutePath());
    }
    return ret;
}
 
Example #15
Source File: FilesetSplit.java    From api-mining with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	if (args.length < 7) {
		System.err
				.println("Usage fromDirectory toDirectory fileSuffix <<segmentName_i> <weight_i> ...>");
		System.exit(-1);
	}

	final File fromDirectory = new File(args[0]);
	final File toDirectory = new File(args[1]);

	final IOFileFilter fileFilter = FileFilterUtils
			.suffixFileFilter(args[2]);

	final Map<String, Double> segments = Maps.newHashMap();

	for (int i = 3; i < args.length; i += 2) {
		segments.put(args[i], Double.valueOf(args[i + 1]));
	}

	LOGGER.info("Splitting files in segments " + segments);
	splitFiles(fromDirectory, toDirectory, segments, fileFilter,
			UNIFORM_FILE_WEIGHT);
}
 
Example #16
Source File: TemplateWatcher.java    From roboconf-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart( final FileAlterationObserver observer ) {

	if( this.alreadyStarted.getAndSet( true ))
		return;

	this.logger.fine("Initial provisioning of templates...");
	final Collection<File> templateFiles = FileUtils.listFiles(
			this.templateDir,

			// Find readable template files.
			FileFilterUtils.and(
					FileFilterUtils.suffixFileFilter( ".tpl" ),
					CanReadFileFilter.CAN_READ),

			// Directory filter: go through the root template directory and its direct children.
			new TemplateDirectoryFileFilter( this.templateDir ));

	process( templateFiles );
}
 
Example #17
Source File: FileMonitor.java    From util4j with Apache License 2.0 6 votes vote down vote up
/**
 * 只监控文件发送变化,如果是子目录的文件改变,则目录会变,由于没有过滤目录发生变化,则目录下的文件改变不会监控到
 * @param dir
 * @throws Exception 
 */
public void check1(String dir) throws Exception
{
	File directory = new File(dir);
    // 轮询间隔 5 秒
    long interval = TimeUnit.SECONDS.toMillis(5);
    // 创建一个文件观察器用于处理文件的格式
    IOFileFilter filter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),
    		FileFilterUtils.suffixFileFilter(".jar"));
    FileAlterationObserver observer = new FileAlterationObserver(directory,filter);
    //设置文件变化监听器
    observer.addListener(new MyFileListener());
    FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
    monitor.addObserver(observer);//文件观察
    monitor.start();
}
 
Example #18
Source File: AbstractProctorMojo.java    From proctor with Apache License 2.0 6 votes vote down vote up
void createTotalSpecifications(final File dir, final String packageDirectory) throws MojoExecutionException {

        if (dir.equals(null)) {
            throw new MojoExecutionException("Could not read from directory " + dir.getPath());
        }
        final File[] files = dir.listFiles();
        if (files == null) {
            return;
        }
        final File[] providedContextFiles = dir.listFiles((java.io.FileFilter) FileFilterUtils.andFileFilter(FileFilterUtils.fileFileFilter(), FileFilterUtils.nameFileFilter("providedcontext.json")));
        if (providedContextFiles.length == 1) {
            final File parent = providedContextFiles[0].getParentFile();
            final File outputDir = new File(getSpecificationOutput() + File.separator + packageDirectory.substring(0,packageDirectory.lastIndexOf(File.separator)));
            outputDir.mkdirs();
            try {
                generateTotalSpecification(parent, outputDir);
            } catch (final CodeGenException e) {
                throw new MojoExecutionException("Couldn't create total specification",e);
            }
        }
        for (final File entry : dir.listFiles()) {
            if (entry.isDirectory()) {
                createTotalSpecifications(entry, (packageDirectory == null) ? entry.getName() : packageDirectory + File.separator + entry.getName());
            }
        }
    }
 
Example #19
Source File: PackageImpl.java    From japi with MIT License 6 votes vote down vote up
@Override
public List<IAction> getActions() {
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.getName().endsWith(".java") && !pathname.getName().equals("package-info.java");
        }
    });
    Collection<File> actionFiles = FileUtils.listFiles(packageFold, dirFilter, null);
    List<IAction> actions = new ArrayList<>();
    for (File actionFile : actionFiles) {
        ActionImpl action = new ActionImpl();
        action.setActionFile(actionFile);
        actions.add(action);
    }
    return actions;
}
 
Example #20
Source File: ImportWorker.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Merges top level "decks" folder only.
 * Does not import sub-folders (prebuilt, firemind, etc).
 * If file already exists then imported version takes precedence.
 */
private void importCustomDecks() throws IOException {
    setProgressNote(MText.get(_S7));
    final String directoryName = "decks";
    final Path sourcePath = importDataPath.resolve(directoryName);
    if (sourcePath.toFile().exists()) {
        final Path targetPath = MagicFileSystem.getDataPath().resolve(directoryName);
        final IOFileFilter deckSuffixFilter = FileFilterUtils.suffixFileFilter(DeckUtils.DECK_EXTENSION);
        FileUtils.copyDirectory(sourcePath.toFile(), targetPath.toFile(), deckSuffixFilter);
    }
    setProgressNote(OK_STRING);
}
 
Example #21
Source File: FileFilterHelper.java    From appassembler with MIT License 5 votes vote down vote up
/**
 * Make the given IOFileFilter aware of files.
 *
 * @param filter The filter to make aware of files.
 * @param fileName The file name which should be payed attention to.
 * @return The new generated filter.
 */
public static IOFileFilter makeFileNameAware( IOFileFilter filter, String fileName )
{
    IOFileFilter directoryAwareFilter =
        FileFilterUtils.notFileFilter( FileFilterUtils.andFileFilter( FileFilterUtils.fileFileFilter(),
                                                                      FileFilterUtils.nameFileFilter( fileName ) ) );

    return FileFilterUtils.andFileFilter( filter, directoryAwareFilter );
}
 
Example #22
Source File: ImportWorker.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Copies H2 game stats database file BUT ONLY if the stats folder
 * has been not yet been created (ie. post-install, not if you re-run
 * the import process via the "Reset & restart" option).
 */
private void importGameStats() throws IOException {
    setProgressNote(MText.get(_S14));
    String directoryName = "stats";
    Path sourcePath = importDataPath.resolve(directoryName);
    Path targetPath = MagicFileSystem.getDataPath().resolve(directoryName);
    if (sourcePath.toFile().exists() && MagicFileSystem.isMissingOrEmpty(targetPath)) {
        IOFileFilter dbSuffixFilter = FileFilterUtils.suffixFileFilter(".db");
        FileUtils.copyDirectory(sourcePath.toFile(), targetPath.toFile(), dbSuffixFilter);
    }
    setProgressNote(OK_STRING);
}
 
Example #23
Source File: AssetTest.java    From jbake with MIT License 5 votes vote down vote up
private Integer countFiles(File path) {
    int total = 0;
    FileFilter filesOnly = FileFilterUtils.fileFileFilter();
    FileFilter dirsOnly = FileFilterUtils.directoryFileFilter();
    File[] files = path.listFiles(filesOnly);
    System.out.println(files);
    total += files.length;
    for (File file : path.listFiles(dirsOnly)) {
        total += countFiles(file);
    }
    return total;
}
 
Example #24
Source File: MapUtils.java    From tankbattle with MIT License 5 votes vote down vote up
public static List<String> getCustomFileList() {
    Collection<File> listFiles = FileUtils.listFiles(new File(System.getProperty("user.home") + File.separator +
            ".tankBattle" + File.separator + "custom"), FileFilterUtils.suffixFileFilter("xml"), DirectoryFileFilter
            .INSTANCE);
    List<String> list = new ArrayList<>();
    for (File file : listFiles) {
        list.add(file.getName().substring(0, file.getName().lastIndexOf(".")));
        System.out.println(file.getName());
    }
    return list;
}
 
Example #25
Source File: ThriftOutputConsumer.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
private void collectNewFiles(final FileGeneratedEvent msg) throws IOException {
  final Collection<File> files = FileUtils.listFiles(myTargetDir, FileFilterUtils.trueFileFilter(), FileFilterUtils.trueFileFilter());
  final URI baseUri = myTargetDir.toURI();
  for (File f : files) {
    msg.add(myTargetDir.toString(), baseUri.relativize(f.toURI()).getPath());
  }
}
 
Example #26
Source File: PrintPreviewDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected Object[] doInBackground()
{
	IOFileFilter pdfFilter = FileFilterUtils.asFileFilter(this);
	IOFileFilter suffixFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(".fo"));
	IOFileFilter sheetFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX);
	IOFileFilter fileFilter = FileFilterUtils.and(pdfFilter, suffixFilter, sheetFilter);

	IOFileFilter dirFilter = TrueFileFilter.INSTANCE;
	File dir = new File(ConfigurationSettings.getOutputSheetsDir());
	Collection<File> files = FileUtils.listFiles(dir, fileFilter, dirFilter);
	URI osPath = new File(ConfigurationSettings.getOutputSheetsDir()).toURI();
	return files.stream().map(v -> osPath.relativize(v.toURI())).toArray();
}
 
Example #27
Source File: KuduConfigMonitor.java    From canal with Apache License 2.0 5 votes vote down vote up
public void init(KuduAdapter kuduAdapter, Properties envProperties) {
    this.kuduAdapter = kuduAdapter;
    this.envProperties = envProperties;
    File confDir = Util.getConfDirPath(adapterName);
    try {
        FileAlterationObserver observer = new FileAlterationObserver(confDir,
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter("yml")));
        FileListener listener = new FileListener();
        observer.addListener(listener);
        fileMonitor = new FileAlterationMonitor(3000, observer);
        fileMonitor.start();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
Example #28
Source File: RequestCaseTest.java    From tcases with MIT License 5 votes vote down vote up
/**
 * Returns a filter that matches all test resources with the given base name.
 */
protected static FilenameFilter baseNameResources( String baseName)
  {
  return
    FileFilterUtils.and(
      FileFilterUtils.prefixFileFilter( baseName),
      FileFilterUtils.suffixFileFilter( testDefSuffix_));
  }
 
Example #29
Source File: LicenseHeaderUpdate.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void handleJSPStyleComments( String baseDir ) throws Exception {
    IOFileFilter sourceFileFilter = FileFilterUtils.orFileFilter(
            FileFilterUtils.suffixFileFilter("jsp"),
            FileFilterUtils.suffixFileFilter("tag") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("inc") );
    sourceFileFilter = FileFilterUtils.makeSVNAware(sourceFileFilter);
    sourceFileFilter = FileFilterUtils.makeFileOnly(sourceFileFilter);

    LicensableFileDirectoryWalker dw = new LicensableFileDirectoryWalker(sourceFileFilter, "<%--", "   - ", "--%>");
    Collection<String> results = dw.run( baseDir );
    System.out.println( results );
}
 
Example #30
Source File: Main.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	Options options = new Options();

	options.addOption(INSTANCE_OPTION, true, "Eclipse Instance path");
	options.addOption(REPO_OPTION, true, "Plugins and Features repo path");
	options.addOption(SITE_OPTION, true, "Output site path");
	options.addOption(LOCALIZATION_FRAGMENT_POSTFIX, true,
			"Localization fragment postfix");

	CommandLineParser parser = new PosixParser();
	CommandLine cmdLine = parser.parse(options, args);
	String repo = getAndValidateDirectoryOption(cmdLine, REPO_OPTION);
	String site = getAndValidateDirectoryOption(cmdLine, SITE_OPTION, true);
	String instance = getAndValidateDirectoryOption(cmdLine, INSTANCE_OPTION);
	if (repo == null || site == null || instance == null) {
		return;
	}
	
	String postfix = cmdLine.getOptionValue(LOCALIZATION_FRAGMENT_POSTFIX);
	
	InstanceInspector instanceInspector = new InstanceInspector();
	Map<String, BundleDescriptor> id2BundleDescriptor = instanceInspector
			.getBundleDescriptors(instance);
	
	Template velocityTemplate = initializeVelocityTemplate();

	File[] folders = new File(repo + "/features")
			.listFiles((FileFilter) FileFilterUtils.directoryFileFilter());
	for (File folder : folders) {
		System.out.println("Processing feature " + folder.getName() + " ...");
		processFeatureFolder(velocityTemplate, postfix, id2BundleDescriptor, folder, repo,
				site);
	}
	
	System.out.println("Site created");
}