Thanks for the reply, but it's not an inner class. I can't even break in
the first line of the constructor. But since I'm still in the learning
phase of Java, here's the file in question.
Best,
Kerry
--
Kerry Alt
New Mexico State University / Dept CS
New Science Hall, Room 123
Las Cruces, NM 88003-0001
phone: 505/646-3645
fax: 505/646-1002
package cm.physicsmodels.interfaces;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import cm.physicsmodels.core.PhysicsModel;
import cm.utils.misc.App;
import cm.utils.misc.Grid;
public class HazModel extends PhysicsModel {
/**
* JNI interface for hazard calculations.
*<P>
* @param inputFile The input file to the hazard model.
* @param outputFile The data output file.
*/
protected native void calculate(String inputFile, String outputFile);
/**
* Construct a HazModel with no attributes.
*<P>
*/
public HazModel() {
App.debug.println("HazModel:constructor with NO params");
}
/**
* Construct a HazModel with attributes.
*<P>
* @param inputFile The name of the input file.
* @param outputFile The name of the output file.
* @param library The name of the physics model library.
*/
public HazModel(File inputFile, File outputFile, File library) {
super(inputFile, outputFile, library);
App.debug.println("HazModel:constructor with params");
App.debug.println(" inputFile="+inputFile);
App.debug.println(" outputFile="+outputFile);
App.debug.println(" library="+library);
}
public void writeInputFile() {
try {
FileWriter fileWriter = new FileWriter(getInputFile());
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
PrintWriter printWriter = new PrintWriter(bufferedWriter);
printWriter.close();
bufferedWriter.close();
fileWriter.close();
} catch (Exception e) {
System.out.println("HazModel:writeInputFile:Exception -> " + e);
}
}
/**
* Perform an hazard calculation using the specified attributes.
*<P>
*/
public void calculate() {
App.debug.println("HazModel:calculate(no params)");
try {
calculate(getInputFile().getAbsolutePath(),
getOutputFile().getAbsolutePath());
} catch (NullPointerException exception) {
String msg = new String("Exception in HazModel.calculate(): ");
msg += "unspecified attribute(s).";
System.out.println(msg);
}
}
/**
* Read the output file into a Grid object.
*<P>
*/
public Grid readGrid(File filename, int numx, int numy) {
App.debug.println("HazModel:readGrid() filename=["+filename+"] numx=["+numx+"]
numy=["+numy+"]");
Grid g = new Grid(numx, numy);
double data[] = new double[numx*numy];
try {
RandomAccessFile fp = new RandomAccessFile(filename, "r");
String gstring = new String();
int count = 0;
for(int i=0; i<numx; i++) {
for(int j=0; j<numy; j++) {
gstring = fp.readLine();
data[count]=Double.parseDouble(gstring);
count++;
}
}
fp.close();
} catch (Exception e) {
System.out.println("HazModel:readGrid: Error: " + e.toString());
}
g.setRawGrid(data);
return g;
}
}