Skip to content

Commit 1e8155f

Browse files
author
Gary Gregory
committed
Sort members.
1 parent 7c6b855 commit 1e8155f

8 files changed

Lines changed: 273 additions & 273 deletions

File tree

src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,46 @@ public MagicNumberFileFilter(final byte[] magicNumber) {
112112
this(magicNumber, 0);
113113
}
114114

115+
/**
116+
* <p>
117+
* Constructs a new MagicNumberFileFilter and associates it with the magic
118+
* number to test for in files and the byte offset location in the file to
119+
* to look for that magic number.
120+
* </p>
121+
*
122+
* <pre>
123+
* MagicNumberFileFilter tarFileFilter =
124+
* MagicNumberFileFilter(new byte[] {0x75, 0x73, 0x74, 0x61, 0x72}, 257);
125+
* </pre>
126+
*
127+
* <pre>
128+
* MagicNumberFileFilter javaClassFileFilter =
129+
* MagicNumberFileFilter(new byte[] {0xCA, 0xFE, 0xBA, 0xBE}, 0);
130+
* </pre>
131+
*
132+
* @param magicNumber the magic number to look for in the file.
133+
* @param offset the byte offset in the file to start comparing bytes.
134+
*
135+
* @throws IllegalArgumentException if <code>magicNumber</code> is
136+
* {@code null}, or contains no bytes, or <code>offset</code>
137+
* is a negative number.
138+
*/
139+
public MagicNumberFileFilter(final byte[] magicNumber, final long offset) {
140+
if (magicNumber == null) {
141+
throw new IllegalArgumentException("The magic number cannot be null");
142+
}
143+
if (magicNumber.length == 0) {
144+
throw new IllegalArgumentException("The magic number must contain at least one byte");
145+
}
146+
if (offset < 0) {
147+
throw new IllegalArgumentException("The offset cannot be negative");
148+
}
149+
150+
this.magicNumbers = new byte[magicNumber.length];
151+
System.arraycopy(magicNumber, 0, this.magicNumbers, 0, magicNumber.length);
152+
this.byteOffset = offset;
153+
}
154+
115155
/**
116156
* <p>
117157
* Constructs a new MagicNumberFileFilter and associates it with the magic
@@ -173,46 +213,6 @@ public MagicNumberFileFilter(final String magicNumber, final long offset) {
173213
this.byteOffset = offset;
174214
}
175215

176-
/**
177-
* <p>
178-
* Constructs a new MagicNumberFileFilter and associates it with the magic
179-
* number to test for in files and the byte offset location in the file to
180-
* to look for that magic number.
181-
* </p>
182-
*
183-
* <pre>
184-
* MagicNumberFileFilter tarFileFilter =
185-
* MagicNumberFileFilter(new byte[] {0x75, 0x73, 0x74, 0x61, 0x72}, 257);
186-
* </pre>
187-
*
188-
* <pre>
189-
* MagicNumberFileFilter javaClassFileFilter =
190-
* MagicNumberFileFilter(new byte[] {0xCA, 0xFE, 0xBA, 0xBE}, 0);
191-
* </pre>
192-
*
193-
* @param magicNumber the magic number to look for in the file.
194-
* @param offset the byte offset in the file to start comparing bytes.
195-
*
196-
* @throws IllegalArgumentException if <code>magicNumber</code> is
197-
* {@code null}, or contains no bytes, or <code>offset</code>
198-
* is a negative number.
199-
*/
200-
public MagicNumberFileFilter(final byte[] magicNumber, final long offset) {
201-
if (magicNumber == null) {
202-
throw new IllegalArgumentException("The magic number cannot be null");
203-
}
204-
if (magicNumber.length == 0) {
205-
throw new IllegalArgumentException("The magic number must contain at least one byte");
206-
}
207-
if (offset < 0) {
208-
throw new IllegalArgumentException("The offset cannot be negative");
209-
}
210-
211-
this.magicNumbers = new byte[magicNumber.length];
212-
System.arraycopy(magicNumber, 0, this.magicNumbers, 0, magicNumber.length);
213-
this.byteOffset = offset;
214-
}
215-
216216
/**
217217
* <p>
218218
* Accepts the provided file if the file contains the file filter's magic

src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,42 @@ public class NameFileFilter extends AbstractFileFilter implements Serializable {
5050
private final IOCase caseSensitivity;
5151

5252
/**
53-
* Constructs a new case-sensitive name file filter for a single name.
53+
* Constructs a new case-sensitive name file filter for a list of names.
5454
*
55-
* @param name the name to allow, must not be null
56-
* @throws IllegalArgumentException if the name is null
55+
* @param names the names to allow, must not be null
56+
* @throws IllegalArgumentException if the name list is null
57+
* @throws ClassCastException if the list does not contain Strings
5758
*/
58-
public NameFileFilter(final String name) {
59-
this(name, null);
59+
public NameFileFilter(final List<String> names) {
60+
this(names, null);
6061
}
6162

6263
/**
63-
* Construct a new name file filter specifying case-sensitivity.
64+
* Constructs a new name file filter for a list of names specifying case-sensitivity.
6465
*
65-
* @param name the name to allow, must not be null
66+
* @param names the names to allow, must not be null
6667
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
67-
* @throws IllegalArgumentException if the name is null
68+
* @throws IllegalArgumentException if the name list is null
69+
* @throws ClassCastException if the list does not contain Strings
6870
*/
69-
public NameFileFilter(final String name, final IOCase caseSensitivity) {
70-
if (name == null) {
71-
throw new IllegalArgumentException("The wildcard must not be null");
71+
public NameFileFilter(final List<String> names, final IOCase caseSensitivity) {
72+
if (names == null) {
73+
throw new IllegalArgumentException("The list of names must not be null");
7274
}
73-
this.names = new String[] {name};
75+
this.names = names.toArray(EMPTY_STRING_ARRAY);
7476
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
7577
}
7678

79+
/**
80+
* Constructs a new case-sensitive name file filter for a single name.
81+
*
82+
* @param name the name to allow, must not be null
83+
* @throws IllegalArgumentException if the name is null
84+
*/
85+
public NameFileFilter(final String name) {
86+
this(name, null);
87+
}
88+
7789
/**
7890
* Constructs a new case-sensitive name file filter for an array of names.
7991
* <p>
@@ -88,45 +100,33 @@ public NameFileFilter(final String... names) {
88100
}
89101

90102
/**
91-
* Constructs a new name file filter for an array of names specifying case-sensitivity.
103+
* Construct a new name file filter specifying case-sensitivity.
92104
*
93-
* @param names the names to allow, must not be null
105+
* @param name the name to allow, must not be null
94106
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
95-
* @throws IllegalArgumentException if the names array is null
107+
* @throws IllegalArgumentException if the name is null
96108
*/
97-
public NameFileFilter(final String[] names, final IOCase caseSensitivity) {
98-
if (names == null) {
99-
throw new IllegalArgumentException("The array of names must not be null");
109+
public NameFileFilter(final String name, final IOCase caseSensitivity) {
110+
if (name == null) {
111+
throw new IllegalArgumentException("The wildcard must not be null");
100112
}
101-
this.names = new String[names.length];
102-
System.arraycopy(names, 0, this.names, 0, names.length);
113+
this.names = new String[] {name};
103114
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
104115
}
105116

106117
/**
107-
* Constructs a new case-sensitive name file filter for a list of names.
108-
*
109-
* @param names the names to allow, must not be null
110-
* @throws IllegalArgumentException if the name list is null
111-
* @throws ClassCastException if the list does not contain Strings
112-
*/
113-
public NameFileFilter(final List<String> names) {
114-
this(names, null);
115-
}
116-
117-
/**
118-
* Constructs a new name file filter for a list of names specifying case-sensitivity.
118+
* Constructs a new name file filter for an array of names specifying case-sensitivity.
119119
*
120120
* @param names the names to allow, must not be null
121121
* @param caseSensitivity how to handle case sensitivity, null means case-sensitive
122-
* @throws IllegalArgumentException if the name list is null
123-
* @throws ClassCastException if the list does not contain Strings
122+
* @throws IllegalArgumentException if the names array is null
124123
*/
125-
public NameFileFilter(final List<String> names, final IOCase caseSensitivity) {
124+
public NameFileFilter(final String[] names, final IOCase caseSensitivity) {
126125
if (names == null) {
127-
throw new IllegalArgumentException("The list of names must not be null");
126+
throw new IllegalArgumentException("The array of names must not be null");
128127
}
129-
this.names = names.toArray(EMPTY_STRING_ARRAY);
128+
this.names = new String[names.length];
129+
System.arraycopy(names, 0, this.names, 0, names.length);
130130
this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity;
131131
}
132132

src/main/java/org/apache/commons/io/filefilter/OrFileFilter.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ public OrFileFilter() {
5050
this.fileFilters = new ArrayList<>();
5151
}
5252

53+
/**
54+
* Constructs a new file filter that ORs the result of two other filters.
55+
*
56+
* @param filter1 the first filter, must not be null
57+
* @param filter2 the second filter, must not be null
58+
* @throws IllegalArgumentException if either filter is null
59+
*/
60+
public OrFileFilter(final IOFileFilter filter1, final IOFileFilter filter2) {
61+
if (filter1 == null || filter2 == null) {
62+
throw new IllegalArgumentException("The filters must not be null");
63+
}
64+
this.fileFilters = new ArrayList<>(2);
65+
addFileFilter(filter1);
66+
addFileFilter(filter2);
67+
}
68+
5369
/**
5470
* Constructs a new instance of <code>OrFileFilter</code>
5571
* with the specified filters.
@@ -66,19 +82,29 @@ public OrFileFilter(final List<IOFileFilter> fileFilters) {
6682
}
6783

6884
/**
69-
* Constructs a new file filter that ORs the result of two other filters.
70-
*
71-
* @param filter1 the first filter, must not be null
72-
* @param filter2 the second filter, must not be null
73-
* @throws IllegalArgumentException if either filter is null
85+
* {@inheritDoc}
7486
*/
75-
public OrFileFilter(final IOFileFilter filter1, final IOFileFilter filter2) {
76-
if (filter1 == null || filter2 == null) {
77-
throw new IllegalArgumentException("The filters must not be null");
87+
@Override
88+
public boolean accept(final File file) {
89+
for (final IOFileFilter fileFilter : fileFilters) {
90+
if (fileFilter.accept(file)) {
91+
return true;
92+
}
7893
}
79-
this.fileFilters = new ArrayList<>(2);
80-
addFileFilter(filter1);
81-
addFileFilter(filter2);
94+
return false;
95+
}
96+
97+
/**
98+
* {@inheritDoc}
99+
*/
100+
@Override
101+
public boolean accept(final File file, final String name) {
102+
for (final IOFileFilter fileFilter : fileFilters) {
103+
if (fileFilter.accept(file, name)) {
104+
return true;
105+
}
106+
}
107+
return false;
82108
}
83109

84110
/**
@@ -114,32 +140,6 @@ public void setFileFilters(final List<IOFileFilter> fileFilters) {
114140
this.fileFilters.addAll(fileFilters);
115141
}
116142

117-
/**
118-
* {@inheritDoc}
119-
*/
120-
@Override
121-
public boolean accept(final File file) {
122-
for (final IOFileFilter fileFilter : fileFilters) {
123-
if (fileFilter.accept(file)) {
124-
return true;
125-
}
126-
}
127-
return false;
128-
}
129-
130-
/**
131-
* {@inheritDoc}
132-
*/
133-
@Override
134-
public boolean accept(final File file, final String name) {
135-
for (final IOFileFilter fileFilter : fileFilters) {
136-
if (fileFilter.accept(file, name)) {
137-
return true;
138-
}
139-
}
140-
return false;
141-
}
142-
143143
/**
144144
* Provide a String representation of this file filter.
145145
*

0 commit comments

Comments
 (0)