import java.io.*; public class TestPat { // Copyleft Harvey Greenberg, UW hgreen@u.washington.edu // simple variant on TestAat.java // This calls Pat to load an ARC/INFO PAT file into an array of objects, // processes them, and writes a report. // The first argument is the name of an arc cover. // The second argument is the name of a data item, such as X-COORD // This can be called from the command line: e.g. java TestPat upolyb X-COORD // or from another class, such as // Exceptions are written to standard error. // Caveats: // Error handling is neither complete nor elegant // This will not recognize PAT files which are not stored as "pat.adf". // Class Arccheck assumes a specific item list for the arcs being checked. // A commented-out block of code for writing to the PAT is included only for // your edification. public static void main (String args[]) throws IOException { int maxid,from,to,elv, indx; String covername,itemname; Pat mypoints; System.out.println("starting pat attribute check, version 0.01"); if (args.length < 2){ System.err.println("The cover name and item name are required arguments."); return; } else{ covername = args[0]; itemname = args[1]; } System.err.println("Cover: " + covername + ", itemname: " + itemname ); try{ mypoints = new Pat(covername); } catch (AatError e){ System.out.print("Error loading PAT file:"); System.out.println(e.getMessage()); return; } System.out.println("PAT has " + mypoints.nrecords + " records, " + mypoints.nitems + " extra items, " + mypoints.extrabytes + " extrabytes, odd:" + mypoints.odd); mypoints.report(); mypoints.report(1); indx = mypoints.findItem(itemname); /* No need to write to PAT // DataOutputStream t = new DataOutputStream(new FileOutputStream(f)); // Caution: this rewrites the actual file System.err.println("Writing to to the PAT file."); mypoints.writePat(); */ } }