Example usage for org.apache.commons.io IOCase INSENSITIVE

List of usage examples for org.apache.commons.io IOCase INSENSITIVE

Introduction

In this page you can find the example usage for org.apache.commons.io IOCase INSENSITIVE.

Prototype

IOCase INSENSITIVE

To view the source code for org.apache.commons.io IOCase INSENSITIVE.

Click Source Link

Document

The constant for case insensitive regardless of operating system.

Usage

From source file:au.gov.ga.gocadprojector.gui.AddDirectoryDialog.java

public AddDirectoryDialog(Shell parent, String title, final List<Parameters> parameters, String sourceSRS,
        String targetSRS) {/*from   ww  w .ja va 2  s. c om*/
    this.display = parent.getDisplay();

    final int buttonWidth = 60;
    final int buttonHeight = 30;
    final Color validColor = new Color(display, 0, 128, 0);
    final Color invalidColor = new Color(display, 255, 0, 0);

    GridData data;
    Composite composite;
    Button button;

    shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
    shell.setText(title);
    shell.setLayout(new GridLayout(3, false));

    final Runnable validator = new Runnable() {
        @Override
        public void run() {
            boolean valid = iValid && oValid && sValid && tValid;
            if (okButton != null) {
                okButton.setEnabled(valid);
            }
        }
    };

    final Label inputLabel = new Label(shell, SWT.NONE);
    inputLabel.setText("Input directory:");
    inputLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

    final Text input = new Text(shell, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    data = new GridData(SWT.FILL, SWT.CENTER, true, false);
    data.widthHint = 400;
    input.setLayoutData(data);

    ModifyListener inputListener = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            iValid = input.getText().length() > 0 && new File(input.getText()).isDirectory();
            inputLabel.setForeground(iValid ? validColor : invalidColor);
            validator.run();
        }
    };
    input.addModifyListener(inputListener);
    inputListener.modifyText(null);

    button = new Button(shell, SWT.PUSH);
    button.setText("Browse...");
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
            if (!input.getText().isEmpty()) {
                dialog.setFilterPath(input.getText());
            }
            String selectedDirectory = dialog.open();
            if (selectedDirectory != null) {
                input.setText(selectedDirectory);
            }
        }
    });

    final Label filterLabel = new Label(shell, SWT.NONE);
    filterLabel.setText("Input filter:");
    filterLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    filterLabel.setForeground(validColor);

    final Text filter = new Text(shell, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    setTextText(filter, filterString);
    filter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    filter.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            filterString = filter.getText();
        }
    });

    Label label = new Label(shell, SWT.NONE);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

    final Label sourceLabel = new Label(shell, SWT.NONE);
    sourceLabel.setText("Source SRS:");
    sourceLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

    final Text source = new Text(shell, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    setTextText(source, sourceSRS);
    source.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final Label sourceValidLabel = new Label(shell, SWT.NONE);
    sourceValidLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

    ModifyListener sourceListener = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            SpatialReference sr = new SpatialReference();
            boolean valid;
            try {
                valid = sr.SetFromUserInput(source.getText()) == ogrConstants.OGRERR_NONE;
            } catch (RuntimeException re) {
                valid = false;
            }
            sourceValidLabel.setText(valid ? "Valid" : "Invalid");
            sourceValidLabel.setForeground(valid ? validColor : invalidColor);
            sourceLabel.setForeground(valid ? validColor : invalidColor);
            sValid = valid;
            validator.run();
        }
    };
    source.addModifyListener(sourceListener);
    sourceListener.modifyText(null);

    final Label outputLabel = new Label(shell, SWT.NONE);
    outputLabel.setText("Output directory:");
    outputLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

    final Text output = new Text(shell, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    output.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    ModifyListener outputListener = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            oValid = output.getText().length() > 0;
            outputLabel.setForeground(oValid ? validColor : invalidColor);
            validator.run();
        }
    };
    output.addModifyListener(outputListener);
    outputListener.modifyText(null);

    button = new Button(shell, SWT.PUSH);
    button.setText("Browse...");
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(shell, SWT.SAVE);
            if (!input.getText().isEmpty()) {
                dialog.setFilterPath(input.getText());
            }
            if (!output.getText().isEmpty()) {
                dialog.setFilterPath(output.getText());
            }
            String selectedDirectory = dialog.open();
            if (selectedDirectory != null) {
                output.setText(selectedDirectory);
            }
        }
    });

    final Label targetLabel = new Label(shell, SWT.NONE);
    targetLabel.setText("Target SRS:");
    targetLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

    final Text target = new Text(shell, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    setTextText(target, targetSRS);
    target.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    final Label targetValidLabel = new Label(shell, SWT.NONE);
    targetValidLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

    ModifyListener targetListener = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            SpatialReference sr = new SpatialReference();
            boolean valid;
            try {
                valid = sr.SetFromUserInput(target.getText()) == ogrConstants.OGRERR_NONE;
            } catch (RuntimeException re) {
                valid = false;
            }
            targetValidLabel.setText(valid ? "Valid" : "Invalid");
            targetLabel.setForeground(valid ? validColor : invalidColor);
            targetValidLabel.setForeground(valid ? validColor : invalidColor);
            tValid = valid;
            validator.run();
        }
    };
    target.addModifyListener(targetListener);
    targetListener.modifyText(null);

    final Label suffixLabel = new Label(shell, SWT.NONE);
    suffixLabel.setText("Output filename suffix:");
    suffixLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    suffixLabel.setForeground(validColor);

    final Text suffix = new Text(shell, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    setTextText(suffix, suffixString);
    suffix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    suffix.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            suffixString = suffix.getText();
        }
    });

    label = new Label(shell, SWT.NONE);
    label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

    Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(SWT.FILL, SWT.BOTTOM, true, false, 3, 1);
    data.verticalIndent = 10;
    separator.setLayoutData(data);

    composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    data = new GridData(SWT.END, SWT.CENTER, true, false, 3, 1);
    composite.setLayoutData(data);

    okButton = new Button(composite, SWT.PUSH);
    okButton.setText("OK");
    shell.setDefaultButton(okButton);
    data = new GridData(SWT.CENTER, SWT.CENTER, false, false);
    data.widthHint = buttonWidth;
    data.heightHint = buttonHeight;
    okButton.setLayoutData(data);
    okButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            result = SWT.OK;
            String[] wildcards = filter.getText().split("[;,]");
            for (int i = 0; i < wildcards.length; i++) {
                wildcards[i] = wildcards[i].trim();
            }
            File inputDirectory = new File(input.getText());
            WildcardFileFilter fileFilter = new WildcardFileFilter(wildcards, IOCase.INSENSITIVE);
            File[] files = inputDirectory.listFiles((FileFilter) fileFilter);
            for (File file : files) {
                Parameters p = new Parameters();
                p.inputFile = file.getAbsolutePath();
                p.sourceSRS = source.getText();
                p.targetSRS = target.getText();

                String filename = file.getName();
                int indexOfDot = filename.lastIndexOf('.');
                filename = indexOfDot >= 0
                        ? filename.substring(0, indexOfDot) + suffix.getText()
                                + filename.substring(indexOfDot, filename.length())
                        : filename + suffix;
                File outputFile = new File(output.getText(), filename);
                p.outputFile = outputFile.getAbsolutePath();

                parameters.add(p);
            }
            shell.dispose();
        }
    });

    Button cancelButton = new Button(composite, SWT.PUSH);
    cancelButton.setText("Cancel");
    data = new GridData(SWT.CENTER, SWT.CENTER, false, false);
    data.widthHint = buttonWidth;
    data.heightHint = buttonHeight;
    cancelButton.setLayoutData(data);
    cancelButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            shell.dispose();
        }
    });

    validator.run();

    shell.pack();
    int x = parent.getBounds().x + (parent.getBounds().width - shell.getBounds().width) / 2;
    int y = parent.getBounds().y + (parent.getBounds().height - shell.getBounds().height) / 2;
    shell.setLocation(x, y);
    shell.open();
}

From source file:betullam.xmlmodifier.XMLmodifier.java

private Set<File> getFilesToModify(String mdDirectory, String fileName, String condStructureType,
        String condMdName, String condMdValue) {

    Set<File> setFilesToModify = new HashSet<File>();

    // Iterate over all files in the given directory and it's subdirectories. Works with "FileUtils" in Apache "commons-io" library.
    //for (File mdFile : FileUtils.listFiles(new File(mdDirectory), new WildcardFileFilter(new String[]{"meta.xml", "meta_anchor.xml"}, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE)) {
    if (fileName.equals("meta") || fileName.equals("meta_anchor")) {

        for (File mdFile : FileUtils.listFiles(new File(mdDirectory),
                new WildcardFileFilter(fileName + ".xml", IOCase.INSENSITIVE), TrueFileFilter.INSTANCE)) {
            // DOM Parser:
            String filePath = mdFile.getAbsolutePath();
            DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder documentBuilder = null;
            Document xmlDoc = null;
            try {
                documentBuilder = documentFactory.newDocumentBuilder();
                xmlDoc = documentBuilder.parse(filePath);

                // Only get files that match a certain condition (e. g. "AccessLicense" of a "Monograph" is "OpenAccess"). Only they should be modified.
                boolean isFileToModify = checkCondition(condStructureType, condMdName, condMdValue, xmlDoc);
                if (isFileToModify) {
                    setFilesToModify.add(mdFile);
                }// w  w w.  j  a  v  a 2  s .  c  o  m
            } catch (ParserConfigurationException e) {
                e.printStackTrace();
            } catch (SAXException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (XPathExpressionException e) {
                e.printStackTrace();
            }
        }
    } else {
        System.err.println("Name of meta files can only be \"meta\" or \"meta_anchor\".");
    }

    return setFilesToModify;
}

From source file:com.silverpeas.util.FileUtil.java

public static Collection<File> listFiles(File directory, String[] extensions, boolean caseSensitive,
        boolean recursive) {
    if (caseSensitive) {
        return listFiles(directory, extensions, recursive);
    }/*ww w .j a  v a  2s. c o m*/
    IOFileFilter filter;
    if (extensions == null) {
        filter = TrueFileFilter.INSTANCE;
    } else {
        String[] suffixes = new String[extensions.length];
        for (int i = 0; i < extensions.length; i++) {
            suffixes[i] = "." + extensions[i];
        }
        filter = new SuffixFileFilter(suffixes, IOCase.INSENSITIVE);
    }
    return FileUtils.listFiles(directory, filter,
            (recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE));
}

From source file:de.lmu.ifi.dbs.jfeaturelib.utils.Extractor.java

/**
 * creates a list of image files in the specified directory and all subdirectories (if recursive is enabled)
 *
 * @param dir directory to start from/*  w  w  w.j a v  a  2  s.co m*/
 * @return a list of image files in this directory (possibly empty)
 */
Collection<File> createFileList(File dir) {
    if (dir == null) {
        log.debug("directory is null, returning empty list");
        return Collections.EMPTY_LIST;
    } else {
        SuffixFileFilter sff = new SuffixFileFilter(imageFormats, IOCase.INSENSITIVE);
        IOFileFilter recursiveFilter = recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE;
        return FileUtils.listFiles(dir, sff, recursiveFilter);
    }
}

From source file:betullam.xmlmodifier.XMLmodifier.java

private void makeBackupFiles(Set<File> filesToModify) {

    for (File fileToModify : filesToModify) {

        String fileToModifyName = fileToModify.getName();
        File backupDirectory = fileToModify.getParentFile();

        // Copy existing backup file to a new temporary file (add + 1 to number-suffix), so that nothing gets overwritten
        for (File existingBackupFile : FileUtils.listFiles(backupDirectory,
                new RegexFileFilter(fileToModifyName + "(\\.\\d+)"), TrueFileFilter.INSTANCE)) {
            String fileName = existingBackupFile.getName();

            // Get number-suffix from existing backup-files and add 1
            Pattern p = Pattern.compile("xml\\.\\d+");
            Matcher m = p.matcher(fileName);
            boolean b = m.find();
            int oldBackupNo = 0;
            int newBackupNo = 0;
            if (b) {
                oldBackupNo = Integer.parseInt(m.group(0).replace("xml.", ""));
                newBackupNo = oldBackupNo + 1;
            }//from w w w.j  a  v  a  2  s  . c  o m

            // Create temporary files:
            String newTempBackupFilename = "";
            File newTempBackupFile = null;

            if (fileName.matches(fileToModifyName + ".[\\d]*")) {
                newTempBackupFilename = fileToModifyName + "." + newBackupNo + ".temp";
                newTempBackupFile = new File(backupDirectory + File.separator + newTempBackupFilename);
            }

            try {
                // Copy existing file to temporary backup-file with new filename:
                FileUtils.copyFile(existingBackupFile, newTempBackupFile);
            } catch (IOException e) {
                e.printStackTrace();
            }

            // Delete the existing old backup file:
            existingBackupFile.delete();
        }

        // Remove the ".temp" suffix from the newly created temporary backup-files
        for (File tempBackupFile : FileUtils.listFiles(backupDirectory, new RegexFileFilter(".*\\.temp"),
                TrueFileFilter.INSTANCE)) {
            String newBackupFilename = tempBackupFile.getName().replace(".temp", "");
            File newBackupFile = new File(backupDirectory + File.separator + newBackupFilename);

            try {
                // Copy temporary file to real backup-file with new filename:
                FileUtils.copyFile(tempBackupFile, newBackupFile);
            } catch (IOException e) {
                e.printStackTrace();
            }

            // Delete temporary backup file:
            tempBackupFile.delete();
        }

        // Copy meta.xml and/or meta_anchor.xml and append the suffix ".1" to it, so that it becomes the newest backup file
        for (File productiveFile : FileUtils.listFiles(backupDirectory,
                new WildcardFileFilter(fileToModifyName, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE)) {
            // Copy current productive file and append ".1" so that it gets the newes backup-file: 
            File newBackupFile = new File(productiveFile.getAbsoluteFile() + ".1");
            try {
                FileUtils.copyFile(productiveFile, newBackupFile);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        // Remove all files with a suffix bigger than 9, because Goobi keeps only max. 9 backup files:
        for (File backupFileHigher9 : FileUtils.listFiles(backupDirectory,
                new RegexFileFilter(fileToModifyName + "(\\.\\d{2,})"), TrueFileFilter.INSTANCE)) {
            backupFileHigher9.delete();
        }
    }
}

From source file:com.github.aliteralmind.codelet.util.FilenameBlackWhiteList.java

/**
   <p>Creates a new white-or-blacklist from a set of string-variables as found in a configuration text file.</p>
        //from   w  ww .ja  v  a 2  s  .c  om
 * @param  black_white_off  Is this a {@linkplain com.github.aliteralmind.codelet.util.BlackOrWhite#BLACK blacklist}, {@linkplain com.github.aliteralmind.codelet.util.BlackOrWhite#WHITE whitelist}, or nothing? Must be {@code "black"}, {@code "white"}, or {@code "off"} (the case of this parameter's value is ignored). If {@code "off"}, this function <i><b>returns</b></i> a new {@code FilenameBlackWhiteList} that {@linkplain #newForAcceptAll(Appendable) accepts everything}.
 * @param  ignore_require_system  Should case be {@linkplain org.apache.commons.io.IOCase#INSENSITIVE ignored}, {@linkplain org.apache.commons.io.IOCase#SENSITIVE <i>not</i> ignored}, or determined by the operating {@linkplain org.apache.commons.io.IOCase#SYSTEM system}? Must be {@code "ignore"}, {@code "require"}, or {@code "system"} (the case of <i>this parameter's value</i> is ignored).
 * @param  separator  The character used to separate each proper and override value. Such as a comma ({@code ","}), {@linkplain com.github.xbn.lang.XbnConstants#LINE_SEP line-separator} ({@code "\r\n"}), or tab ({@code "\t"}). May not be {@code null}, empty, or contain any letters, digits, underscores ({@code '_'}), question-marks ({@code '?'}), or asterisks ({@code '*'}).
 * @param  separated_propers  The separated list of &quot;proper&quot; items. Must be separated by {@code separator}, and otherwise must conform to the restrictions for the {@link #FilenameBlackWhiteList(BlackOrWhite, IOCase, String[], String[], Appendable) proper_items} constructor parameter.
 * @param  separated_overrides  The separated list of override items. Must be non-{@code null} (if none, this must be the empty string: {@code ""}), separated by {@code separator}, and otherwise must conform to the restrictions for the {@code override_items} constructor parameter.
 * @see  #newFromProperties(Properties, String, String, String, String, String, Appendable, Appendable) newFromProperties
 */
public static final FilenameBlackWhiteList newFromConfigStringVars(String black_white_off,
        String ignore_require_system, String separator, String separated_propers, String separated_overrides,
        Appendable dbgLoading_ifNonNull, Appendable dbgAccept_ifNonNull) {
    TextAppenter dbgAptr = NewTextAppenterFor.appendableUnusableIfNull(dbgLoading_ifNonNull);

    if (dbgAptr.isUseable()) {
        dbgAptr.appentln("FilenameBlackWhiteList newFromConfigStringVars:");
    }

    try {
        if (black_white_off.toLowerCase().equals("off")) {
            if (dbgAptr.isUseable()) {
                dbgAptr.appentln(" - newForAcceptAll(dbgAccept_ifNonNull). DONE");
            }
            return newForAcceptAll(dbgAccept_ifNonNull);
        }
    } catch (RuntimeException rx) {
        throw CrashIfObject.nullOrReturnCause(black_white_off, "black_white_off", null, rx);
    }

    BlackOrWhite bw = EnumUtil.toValueWithNullDefault(black_white_off, "black_white_off", IgnoreCase.YES,
            DefaultValueFor.NOTHING, BlackOrWhite.BLACK);

    if (dbgAptr.isUseable()) {
        dbgAptr.appentln(" - BlackOrWhite." + bw);
    }

    IOCase ioc = null;
    try {
        switch (ignore_require_system.toUpperCase()) {
        case "IGNORE":
            ioc = IOCase.INSENSITIVE;
            break;
        case "REQUIRE":
            ioc = IOCase.SENSITIVE;
            break;
        case "SYSTEM":
            ioc = IOCase.SYSTEM;
            break;
        default:
            throw new IllegalArgumentException(
                    "ignore_require_system.toUpperCase() (\"" + ignore_require_system.toUpperCase()
                            + "\") does not equal \"IGNORE\", \"REQUIRE\", or \"SYSTEM\".");
        }
    } catch (RuntimeException rx) {
        throw CrashIfObject.nullOrReturnCause(ignore_require_system, "ignore_require_system", null, rx);
    }

    if (dbgAptr.isUseable()) {
        dbgAptr.appentln(" - IOCase." + ioc);
    }

    CrashIfString.nullEmpty(separator, "separator", null);
    if (Pattern.compile("[?*\\w]").matcher(separator).find()) {
        throw new IllegalArgumentException("separator (\"" + separator + "\") contains an illegal character.");
    }

    if (dbgAptr.isUseable()) {
        dbgAptr.appentln(" - separator valid: \"" + separator + "\"");
    }

    String[] propers = null;
    try {
        propers = separated_propers.split(separator);
    } catch (RuntimeException rx) {
        throw CrashIfObject.nullOrReturnCause(separated_propers, "separated_propers", null, rx);
    }

    if (dbgAptr.isUseable()) {
        dbgAptr.appentln(" - Propers: " + Arrays.toString(propers));
    }

    String[] overrides = null;
    try {
        if (separated_overrides.length() == 0) {
            overrides = EMPTY_STRING_ARRAY;
        } else {
            overrides = separated_overrides.split(separator);
        }
    } catch (RuntimeException rx) {
        throw CrashIfObject.nullOrReturnCause(separated_overrides, "separated_overrides", null, rx);
    }

    if (dbgAptr.isUseable()) {
        dbgAptr.appentln(" - Overrides: " + Arrays.toString(overrides) + "...DONE");
    }

    return new FilenameBlackWhiteList(bw, ioc, propers, overrides, dbgAccept_ifNonNull);
}

From source file:betullam.xmlmodifier.XMLmodifier.java

private Set<File> getFilesForInsertion(String condStructureElements, String mdDirectory) {
    Set<File> filesForInsertion = new HashSet<File>();
    List<String> lstStructureElements = Arrays.asList(condStructureElements.split("\\s*,\\s*"));
    // Iterate over all files in the given directory and it's subdirectories. Works with "FileUtils" in Apache "commons-io" library.

    //for (File mdFile : FileUtils.listFiles(new File(mdDirectory), new WildcardFileFilter(new String[]{"meta.xml", "meta_anchor.xml"}, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE)) {
    for (File mdFile : FileUtils.listFiles(new File(mdDirectory),
            new WildcardFileFilter("*.xml", IOCase.INSENSITIVE), TrueFileFilter.INSTANCE)) {
        // DOM Parser:
        String filePath = mdFile.getAbsolutePath();
        DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = null;
        Document xmlDoc = null;/*from  w  ww .  j av  a  2s .c  o  m*/
        try {
            documentBuilder = documentFactory.newDocumentBuilder();
            xmlDoc = documentBuilder.parse(filePath);

            // Only get files with a structure element that is listed in condStructureElements
            for (String structureElement : lstStructureElements) {

                String xPathString = "/mets/structMap[@TYPE='LOGICAL']//div[@TYPE='" + structureElement + "']";
                XPathFactory xPathFactory = XPathFactory.newInstance();
                XPath xPath = xPathFactory.newXPath();
                XPathExpression xPathExpr = xPath.compile(xPathString);
                NodeList nodeList = (NodeList) xPathExpr.evaluate(xmlDoc, XPathConstants.NODESET);

                if (nodeList.getLength() > 0) {
                    filesForInsertion.add(mdFile);
                } else {
                }
            }

        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XPathExpressionException e) {
            e.printStackTrace();
        }
    }
    return filesForInsertion;

}

From source file:com.github.aliteralmind.codelet.util.FilenameBlackWhiteList.java

/**
   <p>A new instance that accepts everything.</p>
        //from  w ww. j  ava 2 s.c o m
 * @return  <code>new {@link #FilenameBlackWhiteList(BlackOrWhite, IOCase, String[], String[], Appendable) FilenameBlackWhiteList}({@link com.github.aliteralmind.codelet.util.BlackOrWhite BlackOrWhite}.{@link com.github.aliteralmind.codelet.util.BlackOrWhite#WHITE WHITE}, {@link org.apache.commons.io.IOCase IOCase}.{@link org.apache.commons.io.IOCase#INSENSITIVE INSENSITIVE}, (new String[]{&quot;*&quot;}), (new String[]{}), dbgAccept_ifNonNull)</code>.
        
 */
public static final FilenameBlackWhiteList newForAcceptAll(Appendable dbgAccept_ifNonNull) {
    return (new FilenameBlackWhiteList(BlackOrWhite.WHITE, IOCase.INSENSITIVE, (new String[] { "*" }),
            EMPTY_STRING_ARRAY, dbgAccept_ifNonNull));
}

From source file:com.silverpeas.jobStartPagePeas.control.JobStartPagePeasSessionController.java

private void processSpaceWallpaper(List<FileItem> items, String path) throws Exception {
    FileItem file = FileUploadUtil.getFile(items, "wallPaper");
    if (file != null && StringUtil.isDefined(file.getName())) {
        String extension = FileRepositoryManager.getFileExtension(file.getName());
        if (extension != null && extension.equalsIgnoreCase("jpeg")) {
            extension = "jpg";
        }//from www  . j a  v a 2 s. c  o  m

        // Remove all wallpapers to ensure it is unique
        File dir = new File(path);
        Collection<File> wallpapers = FileUtils.listFiles(dir,
                FileFilterUtils.prefixFileFilter(SilverpeasLook.DEFAULT_WALLPAPER_PROPERTY, IOCase.INSENSITIVE),
                null);
        for (File wallpaper : wallpapers) {
            FileUtils.deleteQuietly(wallpaper);
        }

        file.write(new File(path + File.separator + "wallPaper." + extension.toLowerCase()));
    }
}

From source file:io.manasobi.utils.FileUtils.java

/**
 *  ? ?  ?? ?  .//from  w w w.j  a v a2s .  c  om
 * 
 * @param dir  
 * @param recursive  ?? ? ??   
 * @param extList ? ? 
 * @return  ? ?  ?? ? 
 */
public static List<String> listFilenamesExcludeExt(String dir, boolean recursive, String... extList) {

    IOFileFilter suffixFileFilters = new SuffixFileFilter(extList, IOCase.INSENSITIVE);
    IOFileFilter excludeExtFilter = FileFilterUtils.notFileFilter(FileFilterUtils.or(suffixFileFilters));

    List<File> resultFiles = (List<File>) org.apache.commons.io.FileUtils.listFiles(new File(dir),
            excludeExtFilter, TrueFileFilter.INSTANCE);

    List<String> resultList = new ArrayList<String>();

    for (File file : resultFiles) {
        resultList.add(file.getAbsolutePath());
    }

    return resultList;
}