Debian Codegraph @

src/org/apache/commons/io/comparator/package-info.java

raw symbols SCIP
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /**
19 * Provides various {@link java.util.Comparator} implementations
20 * for {@link java.io.File}s and {@link java.nio.file.Path}.
21 * <h2>Sorting</h2>
22 * <p>
23 * All the comparators include <em>convenience</em> utility <code>sort(File...)</code> and
24 * <code>sort(List)</code> methods.
25 * </p>
26 * <p>
27 * For example, to sort the files in a directory by name:
28 * </p>
29 * <pre>
30 * File[] files = dir.listFiles();
31 * NameFileComparator.NAME_COMPARATOR.sort(files);
32 * </pre>
33 * <p>
34 * ...alternatively you can do this in one line:
35 * </p>
36 * <pre>
37 * File[] files = NameFileComparator.NAME_COMPARATOR.sort(dir.listFiles());
38 * </pre>
39 * <h2>Composite Comparator</h2>
40 * <p>
41 * The <a href="CompositeFileComparator.html">CompositeFileComparator</a> can be used
42 * to compare (and sort lists or arrays of files) by combining a number of other comparators.
43 * </p>
44 * <p>
45 * For example, to sort an array of files by type (directory or file)
46 * and then by name:
47 * </p>
48 * <pre>
49 * CompositeFileComparator comparator =
50 * new CompositeFileComparator(
51 * DirectoryFileComparator.DIRECTORY_COMPARATOR,
52 * NameFileComparator.NAME_COMPARATOR);
53 * File[] files = dir.listFiles();
54 * comparator.sort(files);
55 * </pre>
56 * <h2>Singleton Instances (thread-safe)</h2>
57 * <p>
58 * The {@link java.util.Comparator} implementations have some <em>convenience</em>
59 * singleton(<em>thread-safe</em>) instances ready to use:
60 * </p>
61 * <ul>
62 * <li><a href="DefaultFileComparator.html">DefaultFileComparator</a> - default file compare:
63 * <ul>
64 * <li><a href="DefaultFileComparator.html#DEFAULT_COMPARATOR">DEFAULT_COMPARATOR</a>
65 * - Compare using <code>File.compareTo(File)</code> method.
66 * </li>
67 * <li><a href="DefaultFileComparator.html#DEFAULT_REVERSE">DEFAULT_REVERSE</a>
68 * - Reverse compare of <code>File.compareTo(File)</code> method.
69 * </li>
70 * </ul>
71 * </li>
72 * <li><a href="DirectoryFileComparator.html">DirectoryFileComparator</a> - compare by type (directory or file):
73 * <ul>
74 * <li><a href="DirectoryFileComparator.html#DIRECTORY_COMPARATOR">DIRECTORY_COMPARATOR</a>
75 * - Compare using <code>File.isDirectory()</code> method (directories &lt; files).
76 * </li>
77 * <li><a href="DirectoryFileComparator.html#DIRECTORY_REVERSE">DIRECTORY_REVERSE</a>
78 * - Reverse compare of <code>File.isDirectory()</code> method (directories &gt;files).
79 * </li>
80 * </ul>
81 * </li>
82 * <li><a href="ExtensionFileComparator.html">ExtensionFileComparator</a> - compare file extensions:
83 * <ul>
84 * <li><a href="ExtensionFileComparator.html#EXTENSION_COMPARATOR">EXTENSION_COMPARATOR</a>
85 * - Compare using <code>FilenameUtils.getExtension(String)</code> method.
86 * </li>
87 * <li><a href="ExtensionFileComparator.html#EXTENSION_REVERSE">EXTENSION_REVERSE</a>
88 * - Reverse compare of <code>FilenameUtils.getExtension(String)</code> method.
89 * </li>
90 * <li><a href="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_COMPARATOR">EXTENSION_INSENSITIVE_COMPARATOR</a>
91 * - Case-insensitive compare using <code>FilenameUtils.getExtension(String)</code> method.
92 * </li>
93 * <li><a href="ExtensionFileComparator.html#EXTENSION_INSENSITIVE_REVERSE">EXTENSION_INSENSITIVE_REVERSE</a>
94 * - Reverse case-insensitive compare of <code>FilenameUtils.getExtension(String)</code> method.
95 * </li>
96 * <li><a href="ExtensionFileComparator.html#EXTENSION_SYSTEM_COMPARATOR">EXTENSION_SYSTEM_COMPARATOR</a>
97 * - System sensitive compare using <code>FilenameUtils.getExtension(String)</code> method.
98 * </li>
99 * <li><a href="ExtensionFileComparator.html#EXTENSION_SYSTEM_REVERSE">EXTENSION_SYSTEM_REVERSE</a>
100 * - Reverse system sensitive compare of <code>FilenameUtils.getExtension(String)</code> method.
101 * </li>
102 * </ul>
103 * </li>
104 * <li><a href="LastModifiedFileComparator.html">LastModifiedFileComparator</a>
105 * - compare the file's last modified date/time:
106 * <ul>
107 * <li><a href="LastModifiedFileComparator.html#LASTMODIFIED_COMPARATOR">LASTMODIFIED_COMPARATOR</a>
108 * - Compare using <code>File.lastModified()</code> method.
109 * </li>
110 * <li><a href="LastModifiedFileComparator.html#LASTMODIFIED_REVERSE">LASTMODIFIED_REVERSE</a>
111 * - Reverse compare of <code>File.lastModified()</code> method.
112 * </li>
113 * </ul>
114 * </li>
115 * <li><a href="NameFileComparator.html">NameFileComparator</a> - compare file names:
116 * <ul>
117 * <li><a href="NameFileComparator.html#NAME_COMPARATOR">NAME_COMPARATOR</a>
118 * - Compare using <code>File.getName()</code> method.
119 * </li>
120 * <li><a href="NameFileComparator.html#NAME_REVERSE">NAME_REVERSE</a>
121 * - Reverse compare of <code>File.getName()</code> method.
122 * </li>
123 * <li><a href="NameFileComparator.html#NAME_INSENSITIVE_COMPARATOR">NAME_INSENSITIVE_COMPARATOR</a>
124 * - Case-insensitive compare using <code>File.getName()</code> method.
125 * </li>
126 * <li><a href="NameFileComparator.html#NAME_INSENSITIVE_REVERSE">NAME_INSENSITIVE_REVERSE</a>
127 * - Reverse case-insensitive compare of <code>File.getName()</code> method.
128 * </li>
129 * <li><a href="NameFileComparator.html#NAME_SYSTEM_COMPARATOR">NAME_SYSTEM_COMPARATOR</a>
130 * - System sensitive compare using <code>File.getName()</code> method.
131 * </li>
132 * <li><a href="NameFileComparator.html#NAME_SYSTEM_REVERSE">NAME_SYSTEM_REVERSE</a>
133 * - Reverse system sensitive compare of <code>File.getName()</code> method.
134 * </li>
135 * </ul>
136 * </li>
137 * <li><a href="PathFileComparator.html">PathFileComparator</a> - compare file paths:
138 * <ul>
139 * <li><a href="PathFileComparator.html#PATH_COMPARATOR">PATH_COMPARATOR</a>
140 * - Compare using <code>File.getPath()</code> method.
141 * </li>
142 * <li><a href="PathFileComparator.html#PATH_REVERSE">PATH_REVERSE</a>
143 * - Reverse compare of <code>File.getPath()</code> method.
144 * </li>
145 * <li><a href="PathFileComparator.html#PATH_INSENSITIVE_COMPARATOR">PATH_INSENSITIVE_COMPARATOR</a>
146 * - Case-insensitive compare using <code>File.getPath()</code> method.
147 * </li>
148 * <li><a href="PathFileComparator.html#PATH_INSENSITIVE_REVERSE">PATH_INSENSITIVE_REVERSE</a>
149 * - Reverse case-insensitive compare of <code>File.getPath()</code> method.
150 * </li>
151 * <li><a href="PathFileComparator.html#PATH_SYSTEM_COMPARATOR">PATH_SYSTEM_COMPARATOR</a>
152 * - System sensitive compare using <code>File.getPath()</code> method.
153 * </li>
154 * <li><a href="PathFileComparator.html#PATH_SYSTEM_REVERSE">PATH_SYSTEM_REVERSE</a>
155 * - Reverse system sensitive compare of <code>File.getPath()</code> method.
156 * </li>
157 * </ul>
158 * </li>
159 * <li><a href="SizeFileComparator.html">SizeFileComparator</a> - compare the file's size:
160 * <ul>
161 * <li><a href="SizeFileComparator.html#SIZE_COMPARATOR">SIZE_COMPARATOR</a>
162 * - Compare using <code>File.length()</code> method (directories treated as zero length).
163 * </li>
164 * <li><a href="SizeFileComparator.html#SIZE_REVERSE">LASTMODIFIED_REVERSE</a>
165 * - Reverse compare of <code>File.length()</code> method (directories treated as zero length).
166 * </li>
167 * <li><a href="SizeFileComparator.html#SIZE_SUMDIR_COMPARATOR">SIZE_SUMDIR_COMPARATOR</a>
168 * - Compare using <code>FileUtils.sizeOfDirectory(File)</code> method
169 * (sums the size of a directory's contents).
170 * </li>
171 * <li><a href="SizeFileComparator.html#SIZE_SUMDIR_REVERSE">SIZE_SUMDIR_REVERSE</a>
172 * - Reverse compare of <code>FileUtils.sizeOfDirectory(File)</code> method
173 * (sums the size of a directory's contents).
174 * </li>
175 * </ul>
176 * </li>
177 * </ul>
178 */
179 package org.apache.commons.io.comparator;