1 23 24 31 package org.enhydra.dods.trans; 32 33 import java.util.*; 34 35 38 public class Table { 39 40 43 protected String pckg = null; 44 45 48 protected String author = DefaultTagValues.TABLE_AUTHOR; 49 50 53 protected String project_name = DefaultTagValues.TABLE_PROJECT_NAME; 54 55 58 protected String table_name = null; 59 60 63 protected String class_name = null; 64 65 68 protected String db_vendor = DefaultTagValues.TABLE_DB_VENDOR; 69 private static final String PARVALUE_COMPATIBLE = "Compatible"; 70 private static final String PARVALUE_DEPRECATE = "Deprecate"; 71 private static final String PARVALUE_OMIT = "Omit"; 72 73 76 protected String dirtyDOs = PARVALUE_COMPATIBLE; 77 78 81 public static final String [] caching_value = {"none", "partial", "full", 82 "lru"}; 83 public static final int NONE = 0; 84 public static final int PARTIAL = 1; 85 public static final int FULL = 2; 86 public static final int LRU = 3; 87 88 92 protected boolean do_is_oid_based = DefaultTagValues.DO_IS_OID_BASED; 93 94 97 protected boolean do_secure = DefaultTagValues.DO_SECURITY; 98 99 102 protected boolean do_insecure = DefaultTagValues.DO_NON_SECURITY; 103 104 107 protected boolean do_multidb = DefaultTagValues.DO_MULTIDB; 108 109 112 protected boolean is_abstract = false; 113 114 117 protected boolean delete_cascade = false; 118 119 122 protected boolean mass_updates = DefaultTagValues.MASS_UPDATES; 123 124 127 protected boolean mass_deletes = DefaultTagValues.MASS_DELETES; 128 129 132 protected ArrayList columns = new ArrayList(); 133 134 137 protected HashMap referrers = new HashMap(); 138 139 142 protected boolean isAnyColumnSecure = DefaultTagValues.IS_ANY_COLUMN_SECURE; 143 144 147 protected ArrayList indexes = new ArrayList(); 148 149 public Table(boolean genSecure, boolean genInsecure, String dirty) { 150 do_secure = genSecure; 151 do_insecure = genInsecure; 152 if (dirtyDOs != null) { 153 dirtyDOs = dirty; 154 } 155 } 156 157 public Table() {} 158 159 165 public String pckg() { 166 return pckg; 167 } 168 169 174 public String author() { 175 return author; 176 } 177 178 183 public String projectName() { 184 return project_name; 185 } 186 187 192 public String tableName() { 193 return table_name; 194 } 195 196 201 public String className() { 202 return class_name; 203 } 204 205 210 public String dbVendor() { 211 return db_vendor; 212 } 213 214 219 public boolean doIsOidBased() { 220 return do_is_oid_based; 221 } 222 223 228 public boolean doSecure() { 229 return do_secure; 230 } 231 232 237 public boolean doInSecure() { 238 return do_insecure; 239 } 240 241 246 public boolean doMultidb() { 247 return do_multidb; 248 } 249 250 255 public boolean doMassUpdates() { 256 return mass_updates; 257 } 258 259 264 public boolean doMassDeletes() { 265 return mass_deletes; 266 } 267 268 269 274 public boolean isAbstract() { 275 return is_abstract; 276 } 277 278 283 public boolean isAnyColumnSecure() { 284 return isAnyColumnSecure; 285 } 286 287 292 public boolean deleteCascade() { 293 return delete_cascade; 294 } 295 296 301 public ArrayList columns() { 302 return columns; 303 } 304 305 310 public int columnsSize() { 311 return columns.size(); 312 } 313 314 321 public Column column(int index) { 322 return (Column) columns.get(index); 323 } 324 325 330 public HashMap referrers() { 331 return referrers; 332 } 333 334 339 public int referrersSize() { 340 return referrers.size(); 341 } 342 343 348 public Iterator referrersIterator() { 349 return referrers.entrySet().iterator(); 350 } 351 352 357 public Iterator referrersKeyIterator() { 358 return referrers.keySet().iterator(); 359 } 360 361 366 public Iterator referrersValueIterator() { 367 return referrers.values().iterator(); 368 } 369 370 375 public Collection referrersValues() { 376 return referrers.values(); 377 } 378 379 384 public ArrayList indexes() { 385 return indexes; 386 } 387 388 393 public int indexesSize() { 394 return indexes.size(); 395 } 396 397 402 public Index index(int index) { 403 return (Index) indexes.get(index); 404 } 405 406 412 public void pckg(String pckg) { 413 this.pckg = pckg; 414 } 415 416 421 public void author(String author) { 422 this.author = author; 423 } 424 425 430 public void projectName(String project_name) { 431 this.project_name = project_name; 432 } 433 434 439 public void tableName(String table_name) { 440 this.table_name = table_name; 441 } 442 443 448 public void className(String class_name) { 449 this.class_name = class_name; 450 } 451 452 457 public void dbVendor(String db_vendor) { 458 this.db_vendor = db_vendor; 459 } 460 461 466 public void doIsOidBased(boolean do_is_oid_based) { 467 this.do_is_oid_based = do_is_oid_based; 468 } 469 470 475 public void doSecure(boolean do_secure) { 476 this.do_secure = do_secure; 477 } 478 479 484 public void doInSecure(boolean do_Insecure) { 485 this.do_insecure = do_Insecure; 486 } 487 488 493 public void doMassUpdates(boolean do_mass) { 494 this.mass_updates = do_mass; 495 } 496 497 502 public void doMassDeletes(boolean do_mass) { 503 this.mass_deletes = do_mass; 504 } 505 510 public void doMultidb(boolean do_Multidb) { 511 this.do_multidb = do_Multidb; 512 } 513 514 519 public void isAbstract(boolean is_abstract) { 520 this.is_abstract = is_abstract; 521 } 522 523 528 public void anyColumnSecure(boolean value) { 529 this.isAnyColumnSecure = value; 530 } 531 532 537 public void refConstarint(boolean delete_cascade) { 538 this.delete_cascade = delete_cascade; 539 } 540 541 546 public void columns(ArrayList columns) { 547 this.columns = columns; 548 } 549 550 555 public void addColumn(Column column) { 556 columns.add(column); 557 } 558 559 564 public void referrers(HashMap referrers) { 565 this.referrers = referrers; 566 } 567 568 573 public void addIndex(Index index) { 574 indexes.add(index); 575 } 576 577 582 public void indexes(ArrayList indexes) { 583 this.indexes = indexes; 584 } 585 586 593 public boolean addReferrer(Referrer referrer) { 594 String id = referrer.pckg() + "." + referrer.name(); 595 boolean inserted = !referrers.containsKey(id); 596 597 if (inserted) { 598 referrers.put(id, referrer); 599 } 600 return inserted; 601 } 602 603 608 public void setDirtyDOs(String howToGenerate)throws InvalidDomlException { 609 if ((0 != howToGenerate.compareTo(PARVALUE_COMPATIBLE)) 610 && (0 != howToGenerate.compareTo(PARVALUE_DEPRECATE)) 611 && (0 != howToGenerate.compareTo(PARVALUE_OMIT))) { 612 throw new InvalidDomlException ("DirtyDOs out of range!"); 613 } 614 dirtyDOs = howToGenerate; 615 } 616 617 620 public String getDirtyDOs() { 621 return dirtyDOs; 622 } 623 624 629 public String toString() { 630 StringBuffer ret = new StringBuffer ("package=").append(pckg).append(" author=").append(author); 631 632 ret.append(" project_name=").append(project_name).append(" table_name=").append(table_name); 633 ret.append(" class_name=").append(class_name).append(" db_vendor=").append(db_vendor); 634 ret.append(" do_is_oid_based=").append(do_is_oid_based).append(" is_abstract=").append(is_abstract); 635 ret.append(" delete_cascade=").append(delete_cascade); 636 ret.append(" do_secure=").append(do_secure); 637 ret.append(" do_insecure=").append(do_insecure); 638 ret.append("\ncolumns:\n"); 639 for (int i = 0; i < columns.size(); i++) { 640 ret.append(" column=").append(columns.get(i)).append("\n"); 641 } 642 ret.append(":referrers:\n"); 643 Iterator iter = referrers.values().iterator(); 644 645 while (iter.hasNext()) { 646 ret.append(" referrer=").append(iter.next()).append("\n"); 647 } 648 ret.append("\nindexess:\n"); 649 for (int i = 0; i < indexes.size(); i++) { 650 ret.append(" index=").append(indexes.get(i)).append("\n"); 651 } 652 return ret.toString(); 653 } 654 655 public static void main(String [] args) { 656 Table table = new Table(); 657 658 table.pckg("packag0.package1"); 659 table.tableName("Person"); 660 Column column1 = new Column(); 661 Column column2 = new Column(); 662 663 column1.name("name"); 664 column1.name("surname"); 665 table.addColumn(column1); 666 table.addColumn(column2); 667 Referrer referrer1 = new Referrer("package0.package1", "Person"); 668 669 referrer1.addAttribute("Manager", "package0.package1.Manager", false); 670 referrer1.addAttribute("Employee", "package0.package1.Employee", false); 671 Referrer referrer2 = new Referrer("package0.package1", "Manager"); 672 673 referrer2.addAttribute("Employee", "package0.package1.Employee", false); 674 table.addReferrer(referrer1); 675 table.addReferrer(referrer2); 676 System.out.println("Table: \n" + table); 677 } 678 } 679 | Popular Tags |