misc. utilities

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1034 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2007-05-01 03:10:31 +00:00
parent 8185a52d72
commit 2f5f87ce03
3 changed files with 32 additions and 2 deletions

View File

@ -113,6 +113,10 @@ public class StringStuff {
}
}
}
public static final TypeName parseForReturnTypeName(String desc) throws IllegalArgumentException {
return parseForReturnTypeName(ImmutableByteArray.make(desc));
}
/**
* Parse method descriptor to obtain description of method's return type.
@ -168,6 +172,10 @@ public class StringStuff {
return null;
}
}
public static final TypeName[] parseForParameterNames(String descriptor) throws IllegalArgumentException {
return parseForParameterNames(ImmutableByteArray.make(descriptor));
}
/**
* Parse method descriptor to obtain descriptions of method's parameters.
@ -578,4 +586,5 @@ public class StringStuff {
}
return dotForm.toString();
}
}

View File

@ -29,6 +29,11 @@ import com.ibm.wala.util.warnings.WalaException;
*/
public class FileUtil {
/**
* List all the files in a directory that match a regular expression
*
* @param recurse recurse to subdirectories?
*/
public static Collection<File> listFiles(String dir, String regex, boolean recurse) {
File d = new File(dir);
Pattern p = null;

View File

@ -12,7 +12,9 @@ package com.ibm.wala.util.tables;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.Properties;
@ -89,10 +91,24 @@ public class Table implements Cloneable {
* @throws WalaException
*/
private static Table readFromTextFile(File f) throws WalaException {
try {
return readFromStream(new FileInputStream(f));
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new WalaException("readFromTextFile failed");
}
}
/**
* @param s
* a stream containing a table in text format, whitespace delimited
* @throws WalaException
*/
public static Table readFromStream(InputStream s) throws WalaException {
try {
Table result = new Table();
LineNumberReader reader = new LineNumberReader(new InputStreamReader(new FileInputStream(f)));
LineNumberReader reader = new LineNumberReader(new InputStreamReader(s));
// LineNumberReader reader = new LineNumberReader(new
// InputStreamReader(new FileInputStream(f)));
@ -113,7 +129,7 @@ public class Table implements Cloneable {
return result;
} catch (IOException e) {
e.printStackTrace();
throw new WalaException("Table.readFromTextFile " + f.getName(), e);
throw new WalaException("readFromStream failed");
}
}