throw NullPointerException instead of IllegalArgumentException if appropriate

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150455 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Naber 2004-08-26 12:41:14 +00:00
parent 918bd1af86
commit ed7723dca0
1 changed files with 11 additions and 7 deletions

View File

@ -42,7 +42,7 @@ import java.io.IOException;
* *
* The fileCount integer indicates how many files are contained in this compound * The fileCount integer indicates how many files are contained in this compound
* file. The {directory} that follows has that many entries. Each directory entry * file. The {directory} that follows has that many entries. Each directory entry
* contains an encoding identifier, an long pointer to the start of this file's * contains an encoding identifier, a long pointer to the start of this file's
* data section, and a UTF String with that file's extension. * data section, and a UTF String with that file's extension.
* *
* @author Dmitry Serebrennikov * @author Dmitry Serebrennikov
@ -71,12 +71,13 @@ final class CompoundFileWriter {
/** Create the compound stream in the specified file. The file name is the /** Create the compound stream in the specified file. The file name is the
* entire name (no extensions are added). * entire name (no extensions are added).
* @throws NullPointerException if <code>dir</code> or <code>name</code> is null
*/ */
public CompoundFileWriter(Directory dir, String name) { public CompoundFileWriter(Directory dir, String name) {
if (dir == null) if (dir == null)
throw new IllegalArgumentException("Missing directory"); throw new NullPointerException("directory cannot be null");
if (name == null) if (name == null)
throw new IllegalArgumentException("Missing name"); throw new NullPointerException("name cannot be null");
directory = dir; directory = dir;
fileName = name; fileName = name;
@ -98,8 +99,9 @@ final class CompoundFileWriter {
* sub-stream will be known in the compound stream. * sub-stream will be known in the compound stream.
* *
* @throws IllegalStateException if this writer is closed * @throws IllegalStateException if this writer is closed
* @throws IllegalArgumentException if <code>file</code> is null * @throws NullPointerException if <code>file</code> is null
* or if a file with the same name has been added already * @throws IllegalArgumentException if a file with the same name
* has been added already
*/ */
public void addFile(String file) { public void addFile(String file) {
if (merged) if (merged)
@ -107,8 +109,8 @@ final class CompoundFileWriter {
"Can't add extensions after merge has been called"); "Can't add extensions after merge has been called");
if (file == null) if (file == null)
throw new IllegalArgumentException( throw new NullPointerException(
"Missing source file"); "file cannot be null");
if (! ids.add(file)) if (! ids.add(file))
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -123,6 +125,8 @@ final class CompoundFileWriter {
* All files with these extensions are combined sequentially into the * All files with these extensions are combined sequentially into the
* compound stream. After successful merge, the source files * compound stream. After successful merge, the source files
* are deleted. * are deleted.
* @throws IllegalStateException if close() had been called before or
* if no file has been added to this object
*/ */
public void close() throws IOException { public void close() throws IOException {
if (merged) if (merged)