1 package org.myoodb.mi; 25 26 public class Client 27 { 28 public static int PORT = 54321; 29 public static String USERNAME = "admin"; 30 public static String PASSWORD = "admin"; 31 32 public static void main(String args[]) throws Exception 33 { 34 org.myoodb.MyOodbDatabase db = org.myoodb.MyOodbDatabase.open("myoodb://localhost:" + PORT, USERNAME, PASSWORD); 35 36 org.myoodb.collectable.LinkedList root = (org.myoodb.collectable.LinkedList) db.getRoot("Gozillas"); 37 38 if (root == null) 39 { 40 root = (org.myoodb.collectable.LinkedList) db.createRoot(org.myoodb.collectable.LinkedListDbImpl.class, "Gozillas"); 41 } 42 43 50 Gozilla gozilla = (Gozilla) db.createObject(new Class [] {org.myoodb.mi.GozillaDbImpl.class, org.myoodb.mi.FrogDbImpl.class}); 51 if ((root.size() & 1) == 1) 53 { 54 gozilla.setType(Gozilla.Type.BAD_MONSTER); 55 gozilla.setPoisonousFlag(true); 56 gozilla.setDangerousFlag(true); 57 } 58 else 59 { 60 gozilla.setType(Gozilla.Type.GOOD_MONSTER); 61 gozilla.setPoisonousFlag(false); 62 gozilla.setDangerousFlag(false); 63 } 64 65 root.add(gozilla); 66 67 System.out.println("New Gozilla:"); 68 System.out.println(" Type of gozilla: " + gozilla.getType()); 69 System.out.println(" Is poisonous: " + gozilla.getPoisonousFlag()); 70 System.out.println(" Is dangerous: " + gozilla.getDangerousFlag()); 71 System.out.println(" Eye Color of gozilla: " + gozilla.getEyeColor()); 72 73 System.out.println("\nList Exiting Gozilla(s):"); 74 java.util.Iterator iter = root.toArrayList().iterator(); 75 while (iter.hasNext()) 76 { 77 gozilla = (Gozilla) iter.next(); 78 79 System.out.println("Gozilla: " + gozilla.getType() + " " + gozilla.getEyeColor()); 80 } 81 } 82 } 83 | Popular Tags |