All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.topologi.diffx.util.XMLFilenameFilter Maven / Gradle / Ivy

Go to download

docx4j is a library which helps you to work with the Office Open XML file format as used in docx documents, pptx presentations, and xlsx spreadsheets.

There is a newer version: 6.1.2
Show newest version
package com.topologi.diffx.util;

import java.io.FileFilter;
import java.io.File;

/**
 * Filename filter for XML files.
 * 
 * 

This filter assumes that an file simply as the .xml file extension. * * @author Christophe Lauret * @version 4 April 2005 */ public final class XMLFilenameFilter implements FileFilter { /** * The XML extension to be used for filtering the files. */ public final String ext = "xml"; /** * Set to true to ignore the case of the extension. */ public final boolean ignoreCase; /** * Creates a new case-insensitive XML file filter. */ public XMLFilenameFilter() { this.ignoreCase = false; } /** * Creates a new XML file filter. * * @param ignoreCase true to ignore the case of the extension. */ public XMLFilenameFilter(boolean ignoreCase) { this.ignoreCase = ignoreCase; } /** * Tests whether or not the specified abstract pathname should be included in a pathname * list. * *

A file is accepted if its name has a file extension matching the "xml". * * @param pathname The abstract pathname to be tested; * * @return true if and only if pathname has an extension matching "xml". * * @throws NullPointerException If the path name is null. */ public boolean accept(File pathname) throws NullPointerException { if (pathname == null) throw new NullPointerException("The specified file is null."); String name = pathname.getName(); int dot = name.lastIndexOf('.'); if (dot == -1) return false; String local = name.substring(dot+1); return (this.ignoreCase)? ext.equalsIgnoreCase(local) : ext.equals(local); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy