Java cleanup, use generics
Change-Id: I164e0f8386558641497258cc0a1d731e81a51c15
This commit is contained in:
@@ -26,7 +26,8 @@ public class GlobalFile {
|
||||
* @return If a temp directory is created, return a File Object, else
|
||||
* return null.
|
||||
*/
|
||||
public static File createTempDir(String prefix, String directory) throws IOException {
|
||||
public static File createTempDir(String prefix, String directory)
|
||||
throws IOException {
|
||||
File f = null;
|
||||
String tempDir;
|
||||
boolean isCreated = false;
|
||||
@@ -35,7 +36,8 @@ public class GlobalFile {
|
||||
counter = new Random().nextInt() & 0xffff;
|
||||
}
|
||||
counter++;
|
||||
if (prefix == null) throw new NullPointerException();
|
||||
if (prefix == null)
|
||||
throw new NullPointerException();
|
||||
if (prefix.length() < 3)
|
||||
throw new IllegalArgumentException("Prefix string too short");
|
||||
if (directory == null) {
|
||||
@@ -118,9 +120,9 @@ public class GlobalFile {
|
||||
/**
|
||||
* Load curve data from a specified file.
|
||||
* @param fileStr the name of the file to be loaded.
|
||||
* @return A Vector that include the curve data.
|
||||
* @return An ArrayList that include the curve data.
|
||||
*/
|
||||
public static Vector getCurveDataFromFile(String fileName) {
|
||||
public static ArrayList<ArrayList<Double>> getCurveDataFromFile(String fileName) {
|
||||
File file = new File(fileName);
|
||||
if(!file.exists()){
|
||||
//showMessage();
|
||||
@@ -136,8 +138,8 @@ public class GlobalFile {
|
||||
//showMessage();
|
||||
return null;//Data file open error.
|
||||
}
|
||||
Vector xaxes = new Vector(1,1);
|
||||
Vector yaxes = new Vector(1,1);
|
||||
ArrayList<Double> xaxes = new ArrayList<Double>(1);
|
||||
ArrayList<Double> yaxes = new ArrayList<Double>(1);
|
||||
try{
|
||||
StringTokenizer st;
|
||||
String s;
|
||||
@@ -163,8 +165,8 @@ public class GlobalFile {
|
||||
Double yaxis = null;
|
||||
try{
|
||||
xaxis = Double.valueOf(s);
|
||||
xaxes.addElement(xaxis);
|
||||
}catch(Exception e){
|
||||
xaxes.add(xaxis);
|
||||
}catch(NumberFormatException e){
|
||||
//showMessage();
|
||||
inReader.close();
|
||||
inStream.close();
|
||||
@@ -173,8 +175,8 @@ public class GlobalFile {
|
||||
s = st.nextToken();
|
||||
try{
|
||||
yaxis = Double.valueOf(s);
|
||||
yaxes.addElement(yaxis);
|
||||
}catch(Exception e){
|
||||
yaxes.add(yaxis);
|
||||
}catch(NumberFormatException e){
|
||||
//showMessage();
|
||||
inReader.close();
|
||||
inStream.close();
|
||||
@@ -186,10 +188,10 @@ public class GlobalFile {
|
||||
//showMessage();
|
||||
return null;//Uncertain data file error.
|
||||
}
|
||||
Vector curveData = new Vector();
|
||||
curveData.addElement(xaxes);
|
||||
curveData.addElement(yaxes);
|
||||
return(curveData);
|
||||
ArrayList<ArrayList<Double>> curveData = new ArrayList<ArrayList<Double>>(2);
|
||||
curveData.add(xaxes);
|
||||
curveData.add(yaxes);
|
||||
return curveData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -38,15 +38,11 @@ public class GlobalString {
|
||||
* divided by the tokenKey.
|
||||
*/
|
||||
public static String[] tokenize(String input , String tokenKey) {
|
||||
Vector v = new Vector();
|
||||
ArrayList<String> v = new ArrayList<String>();
|
||||
StringTokenizer t = new StringTokenizer(input, tokenKey);
|
||||
String cmd[];
|
||||
while (t.hasMoreTokens())
|
||||
v.addElement(t.nextToken());
|
||||
cmd = new String[v.size()];
|
||||
for (int i = 0; i < cmd.length; i++)
|
||||
cmd[i] = (String) v.elementAt(i);
|
||||
return cmd;
|
||||
v.add(t.nextToken());
|
||||
return v.toArray(new String[v.size()]);
|
||||
}
|
||||
|
||||
public static String[] getMeaningfulLines(String srcStr) throws Exception {
|
||||
|
Reference in New Issue
Block a user