import Sav.*; import java.io.*; class WordSearch { public static void main(String args[]) throws Exception { Association aSoft = new Association("Soft"); /** * The aJavaTool and aSoft associations share one area of memory due to * clone() */ Association aJavaTool = (Association) aSoft.clone(); /** * The following code line sets a pass through "Java tool " for aJavaTool. * By this means aJavaTool will an inassociation of aSoft. */ aJavaTool.con("Java tool "); aJavaTool.set("JDK").set("VisualJ++").set("JBuilder"); //aJavaTool = {"JDK", "VisualJ++", "JBuilder"} //aSoft = {"Java tool JDK", "Java tool VisualJ++", "Java tool JBuilder"} /** * The fix() method minds the initial route to value of the aJavaTool * association. */ aJavaTool.fix(); /** * The fragment declares "Article1.txt" file input for searching * a word token contained in aJavaTool association. */ String reference = "Article1.txt"; InputStream input = new FileInputStream(reference); StreamTokenizer tokens = new StreamTokenizer(input); Concept cCurrent= null; //For the additional control /** * The while loop inspects all the input tokens till end of file (EOF) * If concept of the current token string value (tokens.sval) is in * aJavaTool, file name is connected with this concept by * PN.RELATION connection. */ while (tokens.ttype != tokens.TT_EOF) { tokens.nextToken(); if (tokens.ttype != tokens.TT_WORD) continue; Concept c = aJavaTool.get(tokens.sval); if (c == null) continue; aJavaTool.con(c).con(PN.RELATION); aJavaTool.set(reference); /** * Restores the initial pass of the aJavaTool, we fixed by fix() method before. */ aJavaTool.regain(); /** * The following line stores memory content of the aSoft and respectively * aJavaTool. It is useful for keeping and freeing the operating memory. * Every association is saved in a file with a ".ass" extension and * a corresponding name ("Soft"), "Temporary.ass" by default if association * was created with a "new Association()" code text. If the operating * memory is enough, a save() method allows only to save. */ aSoft.store(); cCurrent= c; } /* Additional control of the current concept */ if (cCurrent!= null) { System.out.println("REFERENCE FOR " + cCurrent.getName() + ", ..."); aJavaTool.con(cCurrent).con(PN.RELATION); Concept cReference = aJavaTool.getFirst(); while (cReference != null) { System.out.println(cReference.getName()); cReference = aJavaTool.getNext(); } aJavaTool.regain(); System.out.println("\nPress ENTER to finish."); System.in.read(); } }//main() }//WordSearch