import java.io.*; public class TestAat { // Copyleft Harvey Greenberg, UW hgreen@u.washington.edu // This calls Aat to load an ARC/INFO AAT 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 ELEV. // This can be called from the command line: e.g. java TestAat con300 ELEV // or from another class, such as CheckMany.java. // This program checks each arc to make certain that the given item matches // on connected arcs. // Exceptions are written to standard error. // Caveats: // Error handling is neither complete nor elegant // This class and class Arccheck assume a unix style "/" separator, which is // probably not portable. // This will not recognize AAT files which are not stored as "aat.adf". // Class Arccheck assumes a specific item list for the arcs being checked. // Although this is very fast on small files, it uses an n-squared search, // and is slower on larger files. // A commented-out block of code for writing to the AAT is included only for // your edification. // This was compiled and checked under JDK Beta3 under Solaris. public static void main (String args[]) throws IOException { int maxid,from,to,elv, indx; String covername,itemname; Aat conArc; System.out.println("starting arc attribute check, version 0.03"); 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{ conArc = new Aat(covername); } catch (AatError e){ System.out.print("Error loading AAT file:"); System.out.println(e.getMessage()); return; } System.out.println("AAT has " + conArc.nrecords + " records, " + conArc.nitems + " extra items, " + conArc.extrabytes + " extrabytes, isDoubleodd:" + conArc.isDouble + conArc.odd); /* for(int i = 0;i < nrecords;i++){ elv = conArc.ivalues[ind_elv][i]; from = arcs[i].fnode; to = arcs[i].tnode; for(int j = i + 1;j< maxid;j++){ if((arcs[j].tnode == to) || (arcs[j].tnode == from) || (arcs[j].fnode == to) || (arcs[j].fnode == from)){ if(arcs[j].elev != elv) System.err.println("arc-id " + arcs[i].id + " elevation of " + elv + " does not match connected arc-id " + arcs[j].id + " elevation of " + arcs[j].elev); } } } */ conArc.report(); conArc.report(1); indx = conArc.findItem(itemname); System.out.println(itemname + " is the " + indx + "extra item of " + conArc.nitems + ", it has " + conArc.itemLength[indx] + " bytes"); /* No need to write to AAT // DataOutputStream t = new DataOutputStream(new FileOutputStream(f)); // Caution: this rewrites the actual file System.err.println("Writing to to the AAT file."); conArc.writeAat(); */ } }