1 64 65 package com.jcorporate.expresso.core.db.config; 66 67 import com.jcorporate.expresso.core.db.DefaultEscapeHandler; 68 import com.jcorporate.expresso.core.db.EscapeHandler; 69 import com.jcorporate.expresso.core.misc.StringUtil; 70 import com.jcorporate.expresso.core.misc.SystemMacros; 71 import com.jcorporate.expresso.kernel.util.ClassLocator; 72 73 import java.util.Vector ; 74 75 90 public class JDBCConfig { 91 92 public JDBCConfig() { 93 } 94 95 protected String driverType = null; 96 protected String driver = null; 97 protected String url = null; 98 protected String connectFormat = null; 99 protected String login = null; 100 protected String password = null; 101 protected String cache = null; 102 protected Vector wildCards = new Vector (); 103 protected String dateSelectFormat = null; 104 protected String dateSelectFunction = null; 105 protected String dateUpdateFormat = null; 106 protected String dateUpdateFunction = null; 107 protected String timeSelectFormat = null; 108 protected String timeSelectFunction = null; 109 protected String timeUpdateFormat = null; 110 protected String timeUpdateFunction = null; 111 protected String dateTimeSelectFormat = null; 112 protected String dateTimeSelectFunction = null; 113 protected String dateTimeUpdateFormat = null; 114 protected String dateTimeUpdateFunction = null; 115 protected String dbStats = "y"; 116 protected String dbTest = null; 117 protected String createTableIndicies = null; 118 protected String limitationSyntax = null; 119 protected String limitationPosition = null; 120 protected String uniqueRowKeyword = null; 121 protected String skipText = "n"; 122 protected String useNullOnCreate = "n"; 123 protected String nativeBool = "y"; 124 protected String transactionNotActive = "n"; 125 protected String stringNotTrim = "n"; 126 protected String checkZeroUpdate = null; 127 protected String escapeHandler = 128 com.jcorporate.expresso.core.db.DefaultEscapeHandler.class.getName(); 129 130 protected EscapeHandler escapeHandlerInstance = null; 131 132 protected String nativeBlob = "n"; 133 protected String dbSchema = null; 134 protected String dbCatalogue = null; 135 136 137 private java.util.List typeMappings = null; 138 139 144 public void setSkipText(String newSkip) { 145 StringUtil.assertBoolean(newSkip, "You must specify a boolean value"); 146 skipText = newSkip; 147 } 148 149 158 public void setUseNullOnCreate(String newUseNull) { 159 StringUtil.assertBoolean(newUseNull, 160 "You must specify a boolean value"); 161 useNullOnCreate = newUseNull; 162 } 163 164 172 public boolean useNullOnCreate() { 173 return StringUtil.toBoolean(useNullOnCreate); 174 } 175 176 181 public boolean skipText() { 182 return StringUtil.toBoolean(skipText); 183 } 184 185 191 public void setUniqueRowKeyword(String newKey) { 192 uniqueRowKeyword = newKey; 193 } 194 195 200 public String getUniqueRowKeyword() { 201 return uniqueRowKeyword; 202 } 203 204 209 public void setLimitationSyntax(String newLimit) { 210 limitationSyntax = newLimit; 211 } 212 213 218 public String getLimitationSyntax() { 219 return limitationSyntax; 220 } 221 222 228 public void setLimitationPosition(String newPos) { 229 limitationPosition = newPos; 230 } 231 232 237 public String getLimitationPosition() { 238 return limitationPosition; 239 } 240 241 246 public void setDbTest(String newTest) { 247 dbTest = newTest; 248 } 249 250 255 public String getDbTest() { 256 return dbTest; 257 } 258 259 264 public void setDbStats(String newStats) { 265 StringUtil.assertBoolean(newStats, "You must specify a boolean value"); 266 dbStats = newStats; 267 } 268 269 274 public boolean dbStats() { 275 return StringUtil.toBoolean(dbStats); 276 } 277 278 284 public void setCreateTableIndicies(String newIndicies) { 285 StringUtil.assertBoolean(newIndicies, 286 "createTableIndicies must be y, n, true, false, yes, or no"); 287 createTableIndicies = newIndicies; 288 } 289 290 295 public boolean createTableIndicies() { 296 return StringUtil.toBoolean(createTableIndicies); 297 } 298 299 304 public void setDateSelectFormat(String newFormat) { 305 dateSelectFormat = newFormat; 306 } 307 308 313 public void setTimeSelectFormat(String newFormat) { 314 timeSelectFormat = newFormat; 315 } 316 317 322 public void setDateTimeSelectFormat(String newFormat) { 323 dateTimeSelectFormat = newFormat; 324 } 325 326 331 public void setDateUpdateFormat(String newFormat) { 332 dateUpdateFormat = newFormat; 333 } 334 335 340 public void setTimeUpdateFormat(String newFormat) { 341 timeUpdateFormat = newFormat; 342 } 343 344 349 public void setDateTimeUpdateFormat(String newFormat) { 350 dateTimeUpdateFormat = newFormat; 351 } 352 353 359 public void setDateSelectFunction(String newFunction) { 360 dateSelectFunction = newFunction; 361 } 362 363 369 public void setTimeSelectFunction(String newFunction) { 370 timeSelectFunction = newFunction; 371 } 372 373 378 public void setDateTimeSelectFunction(String newFunction) { 379 dateTimeSelectFunction = newFunction; 380 } 381 382 388 public void setDateUpdateFunction(String newFunction) { 389 dateUpdateFunction = newFunction; 390 } 391 392 398 public void setTimeUpdateFunction(String newFunction) { 399 timeUpdateFunction = newFunction; 400 } 401 402 407 public void setDateTimeUpdateFunction(String newFunction) { 408 dateTimeUpdateFunction = newFunction; 409 } 410 411 416 public String getDateSelectFormat() { 417 return dateSelectFormat; 418 } 419 420 426 public String getDateSelectFunction() { 427 return dateSelectFunction; 428 } 429 430 435 public String getDateUpdateFormat() { 436 return dateUpdateFormat; 437 } 438 439 444 public String getDateUpdateFunction() { 445 return dateUpdateFunction; 446 } 447 448 453 public String getTimeSelectFormat() { 454 return timeSelectFormat; 455 } 456 457 462 public String getTimeSelectFunction() { 463 return timeSelectFunction; 464 } 465 466 471 public String getTimeUpdateFormat() { 472 return timeUpdateFormat; 473 } 474 475 480 public String getTimeUpdateFunction() { 481 return timeUpdateFunction; 482 } 483 484 489 public String getDateTimeSelectFormat() { 490 return dateTimeSelectFormat; 491 } 492 493 498 public String getDateTimeSelectFunction() { 499 return dateTimeSelectFunction; 500 } 501 502 507 public String getDateTimeUpdateFormat() { 508 return dateTimeUpdateFormat; 509 } 510 511 516 public String getDateTimeUpdateFunction() { 517 return dateTimeUpdateFunction; 518 } 519 520 525 public void setDriver(String newDriver) { 526 StringUtil.assertNotBlank(newDriver, "Driver name must be specified"); 527 driver = newDriver.trim(); 528 } 529 530 536 public void addWildcard(String newWild) { 537 wildCards.addElement(newWild); 538 } 539 540 545 public Vector getWildcards() { 546 return wildCards; 547 } 548 549 554 public void setDriverType(String newDriverType) { 555 driverType = newDriverType.trim(); 556 } 557 558 563 public String getDriverType() { 564 return driverType; 565 } 566 567 572 public String getDriver() { 573 return driver; 574 } 575 576 581 public void setUrl(String newUrl) { 582 url = newUrl; 583 } 584 585 590 public String getUrl() { 591 return SystemMacros.getInstance().expandValue(url); 592 } 593 594 600 public void setConnectFormat(String newFormat) { 601 StringUtil.assertNotBlank(newFormat, 602 "Connection format must be specified"); 603 connectFormat = newFormat.trim(); 604 } 605 606 612 public String getConnectFormat() { 613 return connectFormat; 614 } 615 616 621 public void setLogin(String newLogin) { 622 login = newLogin; 623 } 624 625 630 public String getLogin() { 631 return login; 632 } 633 634 640 public void setHasBooleanType(String newValue) { 641 StringUtil.assertBoolean(newValue, 642 "You must specify a boolean value for nativeBool attribute"); 643 this.nativeBool = newValue; 644 } 645 646 647 653 public void setNativeBlob(String newValue) { 654 StringUtil.assertBoolean(newValue, 655 "You must specify a boolean value for nativeBool attribute"); 656 this.nativeBlob = newValue; 657 } 658 659 664 public boolean isNativeBlob() { 665 return StringUtil.toBoolean(this.nativeBlob); 666 } 667 668 676 public void setEscapeHandler(String newValue) { 677 678 try { 679 680 Class clazz = ClassLocator.loadClass(newValue); 681 escapeHandlerInstance = (EscapeHandler) clazz.newInstance(); 682 } catch (InstantiationException ex) { 683 escapeHandlerInstance = new DefaultEscapeHandler(); 684 throw new IllegalArgumentException ("Unable to instantiate database escape handler: " + 685 newValue + 686 " please check your expresso-config.xml file"); 687 } catch (IllegalAccessException ex) { 688 escapeHandlerInstance = new DefaultEscapeHandler(); 689 throw new IllegalArgumentException ("Unable to construct database escape handler: " + 690 newValue + 691 " it does not have a default constructor"); 692 } catch (ClassNotFoundException ex) { 693 escapeHandlerInstance = new DefaultEscapeHandler(); 694 throw new IllegalArgumentException ("Unable to load database escape handler: " + 695 newValue + 696 " please check your expresso-config.xml file"); 697 } 698 escapeHandler = newValue; 699 700 } 701 702 707 public String getEscapeHandler() { 708 return escapeHandler; 709 } 710 711 public EscapeHandler getEscapeHandlerClass() { 712 return this.escapeHandlerInstance; 713 } 714 715 720 public boolean isNativeBool() { 721 return StringUtil.toBoolean(this.nativeBool); 722 } 723 724 729 public void setPassword(String newPassword) { 730 password = newPassword; 731 } 732 733 738 public String getPassword() { 739 return password; 740 } 741 742 747 public void setCache(String newCache) { 748 StringUtil.assertBoolean(newCache, "You must specify a boolean value"); 749 cache = newCache; 750 } 751 752 757 public boolean cache() { 758 return StringUtil.toBoolean(cache); 759 } 760 761 766 public void setCheckZeroUpdate(String newCheckZeroUpdate) { 767 StringUtil.assertBoolean(newCheckZeroUpdate, 768 "You must specify a boolean value for checkZeroUpdate"); 769 checkZeroUpdate = newCheckZeroUpdate; 770 System.out.println("ConfigJDBC.setCheckZeroUpdate() newValue:" + 771 newCheckZeroUpdate); 772 } 773 774 779 public String getCheckZeroUpdate() { 780 return checkZeroUpdate; 781 } 782 783 788 public boolean checkZeroUpdate() { 789 return StringUtil.toBoolean(checkZeroUpdate); 790 } 791 792 798 public java.util.List getTypeMappings() { 799 return typeMappings; 800 } 801 802 808 public java.util.Vector getTypeMappingVector() { 809 return new Vector (typeMappings); 810 } 811 812 818 public void setTypeMappings(java.util.List newValue) { 819 this.typeMappings = newValue; 820 } 821 822 827 public void addTypeMapping(TypeMappingConfig newValue) { 828 if (typeMappings == null) { 829 typeMappings = new java.util.ArrayList (10); 830 } 831 832 typeMappings.add(newValue); 833 } 834 835 840 public String getStringNotTrim() { 841 return stringNotTrim; 842 } 843 844 849 public String getTransactionNotActive() { 850 return transactionNotActive; 851 } 852 853 858 public void setStringNotTrim(String newValue) { 859 StringUtil.assertBoolean(newValue, 860 "You must specify a boolean value for stringNoTrim attribute"); 861 this.stringNotTrim = newValue; 862 } 863 864 869 public void setTransactionNotActive(String newValue) { 870 StringUtil.assertBoolean(newValue, 871 "You must specify a boolean value for transactionNotActive attribute"); 872 transactionNotActive = newValue; 873 } 874 875 881 public boolean isStringNotTrim() { 882 return StringUtil.toBoolean(this.stringNotTrim); 883 } 884 885 890 public boolean isTransactionNotActive() { 891 return StringUtil.toBoolean(this.transactionNotActive); 892 } 893 894 895 898 public String getDbCatalogue() { 899 return dbCatalogue; 900 } 901 902 905 public String getDbSchema() { 906 return dbSchema; 907 } 908 909 912 public void setDbCatalogue(String newValue) { 913 this.dbCatalogue = newValue; 914 } 915 916 919 public void setDbSchema(String newValue) { 920 this.dbSchema = newValue; 921 } 922 923 } 924 | Popular Tags |