tweak propagation of exceptions
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1113 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
46eeca59af
commit
83ee60fe7e
|
@ -66,17 +66,18 @@ public class Table implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read from a direct (native) text file
|
* read from a direct (native) text file
|
||||||
* @param fileName
|
* @throws IOException
|
||||||
* @return
|
* @throws FileNotFoundException
|
||||||
* @throws WalaException
|
*
|
||||||
*/
|
*/
|
||||||
public static Table readFromDirectTextFile(String fileName) throws WalaException {
|
public static Table readFromDirectTextFile(String fileName) throws FileNotFoundException, IOException{
|
||||||
File f = new File(fileName);
|
File f = new File(fileName);
|
||||||
return readFromTextFile(f);
|
return readFromTextFile(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read from a text file obtained as a resource
|
* read from a text file obtained as a resource
|
||||||
|
*
|
||||||
* @param fileName
|
* @param fileName
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
@ -86,15 +87,16 @@ public class Table implements Cloneable {
|
||||||
File f = FileProvider.getFile(fileName);
|
File f = FileProvider.getFile(fileName);
|
||||||
return readFromTextFile(f);
|
return readFromTextFile(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read from a text file obtained as a resource
|
* read from a text file obtained as a resource
|
||||||
|
*
|
||||||
* @param fileName
|
* @param fileName
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws WalaException
|
* @throws WalaException
|
||||||
*/
|
*/
|
||||||
public static Table readFromTextFile(Plugin p, String fileName) throws IOException, WalaException {
|
public static Table readFromTextFile(Plugin p, String fileName) throws IOException {
|
||||||
File f = FileProvider.getFileFromPlugin(p, fileName);
|
File f = FileProvider.getFileFromPlugin(p, fileName);
|
||||||
return readFromTextFile(f);
|
return readFromTextFile(f);
|
||||||
}
|
}
|
||||||
|
@ -102,49 +104,40 @@ public class Table implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* @param f
|
* @param f
|
||||||
* a file containing a table in text format, whitespace delimited
|
* a file containing a table in text format, whitespace delimited
|
||||||
* @throws WalaException
|
* @throws IOException
|
||||||
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
private static Table readFromTextFile(File f) throws WalaException {
|
private static Table readFromTextFile(File f) throws FileNotFoundException, IOException {
|
||||||
try {
|
return readFromStream(new FileInputStream(f));
|
||||||
return readFromStream(new FileInputStream(f));
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new WalaException("readFromTextFile failed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param s
|
* @param s
|
||||||
* a stream containing a table in text format, whitespace delimited
|
* a stream containing a table in text format, whitespace delimited
|
||||||
* @throws WalaException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static Table readFromStream(InputStream s) throws WalaException {
|
public static Table readFromStream(InputStream s) throws IOException {
|
||||||
try {
|
Table result = new Table();
|
||||||
Table result = new Table();
|
|
||||||
|
|
||||||
LineNumberReader reader = new LineNumberReader(new InputStreamReader(s));
|
LineNumberReader reader = new LineNumberReader(new InputStreamReader(s));
|
||||||
|
|
||||||
// LineNumberReader reader = new LineNumberReader(new
|
// LineNumberReader reader = new LineNumberReader(new
|
||||||
// InputStreamReader(new FileInputStream(f)));
|
// InputStreamReader(new FileInputStream(f)));
|
||||||
String line = readNextNonCommentLine(reader);
|
String line = readNextNonCommentLine(reader);
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
throw new IOException("first line expected to be column headings");
|
throw new IOException("first line expected to be column headings");
|
||||||
}
|
|
||||||
result.populateColumnHeadings(line);
|
|
||||||
|
|
||||||
line = readNextNonCommentLine(reader);
|
|
||||||
int row = 0;
|
|
||||||
while (line != null) {
|
|
||||||
result.populateRow(row, line);
|
|
||||||
line = readNextNonCommentLine(reader);
|
|
||||||
row++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new WalaException("readFromStream failed");
|
|
||||||
}
|
}
|
||||||
|
result.populateColumnHeadings(line);
|
||||||
|
|
||||||
|
line = readNextNonCommentLine(reader);
|
||||||
|
int row = 0;
|
||||||
|
while (line != null) {
|
||||||
|
result.populateRow(row, line);
|
||||||
|
line = readNextNonCommentLine(reader);
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String readNextNonCommentLine(LineNumberReader reader) throws IOException {
|
public static String readNextNonCommentLine(LineNumberReader reader) throws IOException {
|
||||||
|
@ -180,7 +173,7 @@ public class Table implements Cloneable {
|
||||||
StringTokenizer st = new StringTokenizer(line);
|
StringTokenizer st = new StringTokenizer(line);
|
||||||
int nColumns = st.countTokens();
|
int nColumns = st.countTokens();
|
||||||
for (int i = 0; i < nColumns; i++) {
|
for (int i = 0; i < nColumns; i++) {
|
||||||
columnHeadings.set(i, (String)st.nextElement());
|
columnHeadings.set(i, (String) st.nextElement());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue