Add additional NotNull and Nullable annotations

This commit is contained in:
Sam Harwell 2014-09-28 12:11:50 -05:00
parent 90071c69b8
commit 065c3e68b8
3 changed files with 12 additions and 10 deletions

View File

@ -29,6 +29,8 @@
*/
package org.antlr.v4.runtime;
import org.antlr.v4.runtime.misc.NotNull;
import org.antlr.v4.runtime.misc.Nullable;
import org.antlr.v4.runtime.misc.Utils;
import java.io.IOException;
@ -40,16 +42,16 @@ import java.io.IOException;
public class ANTLRFileStream extends ANTLRInputStream {
protected String fileName;
public ANTLRFileStream(String fileName) throws IOException {
public ANTLRFileStream(@NotNull String fileName) throws IOException {
this(fileName, null);
}
public ANTLRFileStream(String fileName, String encoding) throws IOException {
public ANTLRFileStream(@NotNull String fileName, String encoding) throws IOException {
this.fileName = fileName;
load(fileName, encoding);
}
public void load(String fileName, String encoding)
public void load(@NotNull String fileName, @Nullable String encoding)
throws IOException
{
data = Utils.readFile(fileName, encoding);

View File

@ -91,6 +91,7 @@ public interface TokenSource {
* non-null, non-empty string. If such a name is not known, this method
* returns {@link IntStream#UNKNOWN_SOURCE_NAME}.
*/
@NotNull
public String getSourceName();
/**

View File

@ -96,11 +96,11 @@ public class Utils {
return buf.toString();
}
public static void writeFile(String fileName, String content) throws IOException {
public static void writeFile(@NotNull String fileName, @NotNull String content) throws IOException {
writeFile(fileName, content, null);
}
public static void writeFile(String fileName, String content, String encoding) throws IOException {
public static void writeFile(@NotNull String fileName, @NotNull String content, @Nullable String encoding) throws IOException {
File f = new File(fileName);
FileOutputStream fos = new FileOutputStream(f);
OutputStreamWriter osw;
@ -119,14 +119,13 @@ public class Utils {
}
}
public static char[] readFile(String fileName) throws IOException {
@NotNull
public static char[] readFile(@NotNull String fileName) throws IOException {
return readFile(fileName, null);
}
public static char[] readFile(String fileName, String encoding) throws IOException {
if ( fileName==null ) {
return null;
}
@NotNull
public static char[] readFile(@NotNull String fileName, @Nullable String encoding) throws IOException {
File f = new File(fileName);
int size = (int)f.length();
InputStreamReader isr;