|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--cug.ptree.TestPTree
static String fn = "PTreeTest.txt";
public static void main( String[] args ) {
if ( args.length > 0 )
fn = args[0];
try {
RStones rs = new RStones();
rs.build();
PrintWriter pw = new PrintWriter( new FileOutputStream( fn ) );
PTree.report( pw, rs );
pw.close();
String s = "not mick jagger";
PTree pt = rs.getNode( s );
Iterator it = pt.getPersonsBelowIt();
while ( it.hasNext() ) {
Person p = (Person)it.next();
System.err.println( p.toString() );
}
} catch ( Exception ex ) {
ex.printStackTrace();
System.exit( 1 );
}
}
}
class RStones extends PTree {
IDFactory idf = new IDFactory();
RStones() {
super( "rolling stones" );
}
public void build() throws Exception {
String idTemplate = "rs_1";
Person m = new Person( new Name_NL( "Mick Jagger" ) );
m.setPersonID( idf.createUniqueID( idTemplate ) );
Person k = new Person( new Name_NL( "Keith Richards" ) );
k.setPersonID( idf.createUniqueID( idTemplate ) );
Person b = new Person( new Name_NL( "Brian Jones" ) );
b.setPersonID( idf.createUniqueID( idTemplate ) );
Person c = new Person( new Name_NL( "Charlie Watts" ) );
c.setPersonID( idf.createUniqueID( idTemplate ) );
Person w = new Person( new Name_NL( "Bill Wyman" ) );
w.setPersonID( idf.createUniqueID( idTemplate ) );
PTree pt = createNode( "singers" );
pt.addPerson( m );
pt.addPerson( b );
addNode( pt );
pt = createNode( "rhythm" );
pt.addPerson( c );
pt.addPerson( w );
addNode( pt );
PTree branch = createNode( "not mick jagger" );
pt = branch.createNode( "string" );
pt.addPerson( k );
pt.addPerson( b );
pt.addPerson( w );
branch.addNode( pt );
pt = branch.createNode( "older" );
pt.addPerson( b );
pt.addPerson( c );
branch.addNode( pt );
addNode( branch );
}
}
| Field Summary | |
(package private) static java.lang.String |
fn
|
| Constructor Summary | |
TestPTree()
|
|
| Method Summary | |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
static java.lang.String fn
| Constructor Detail |
public TestPTree()
| Method Detail |
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||