Java Doc for Persistable.java in  » Content-Management-System » TransferCM » com » methodhead » persistable » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » TransferCM » com.methodhead.persistable 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.methodhead.persistable.Persistable

All known Subclasses:   com.methodhead.shim.IncludeModule,  com.methodhead.shim.NavModule,  com.methodhead.shim.TextModule,  com.methodhead.event.Event,  com.methodhead.transfer.SiteExtension,  com.methodhead.property.Property,  com.methodhead.persistable.KeyedPersistable,
Persistable
public class Persistable extends BasicDynaBean (Code)

A base class for database-backed objects. Methods are provided to simplify managing data in a database: Persistable.saveNew saveNew() , Persistable.save save() , Persistable.loadload() , Persistable.loadAll loadAll() , and Persistable.deleteAlldeleteAll() . Methods are also provided to box and unbox primitive values.

Persistable subclasses BasicDynaBean from the BeanUtils component of Jakarta Commons. This makes any Persistable-based object compatible with libraries that operate on DynaBeans, such as Apache Struts.

As it is a DynaBean, DynaClass plays an important role in a persistable's operation. Make sure the persistable's dynaclass is defined appropriately:

  • The dynaclass's name should match the table name in the database.

  • The dynaclass's dynaproperties should match the corresponding column names and types in the table.

  • The dynaclass's newInstance() should return an appropriate object.




Constructor Summary
public  Persistable(DynaClass dynaClass)
    

Method Summary
public static  voiddeleteAll(DynaClass dynaClass, String whereClause)
     Deletes all persistables according to the specified whereClause.
public  voiddeleteAll(String whereClause)
     Deletes all persistables according to the specified whereClause.
public  booleangetBoolean(String property)
     Returns property, unboxing the value if necessary; false is returned if the property has not been set.
public  DategetDate(String property)
     Returns property, unboxing the value if necessary.
public  doublegetDouble(String property)
     Returns property, unboxing the value if necessary; 0.0 is returned if the property has not been set.
public  intgetInt(String property)
     Returns property, unboxing the value if necessary; returns 0 if the property has not been set.
public static  StringgetSqlLiteral(String value)
     Returns a string literal suitable for use in a SQL statement by escaping single quotes and then wrapping the string in single quotes.
public static  StringgetSqlLiteral(Boolean value)
     Returns a string literal suitable for use in a SQL statement, using '1' for true and '0' for false.
public static  StringgetSqlLiteral(Date value)
     Returns a date literal suitable for use in a SQL statement by wrapping a standard SQL date in single quotes.
protected  StringgetSqlLiteral(DynaProperty dynaProperty)
     Returns the value of dynaProperty in a form suitable for use in a SQL statement.
public  StringgetString(String property)
     Returns property, unboxing the value if necessary.
public  voidload(String whereClause)
     Loads the persistable according to the specified whereClause.
public static  ListloadAll(DynaClass dynaClass, String whereClause, String orderByClause)
     Returns a list containing all persistables for the specified WHERE and ORDER BY clauses.
public  ListloadAll(String whereClause, String orderByClause)
     Returns a list containing all persistables for the specified WHERE and ORDER BY clauses.
public  voidsave(String whereClause)
     Saves the persistable, by updating any rows to which the specified whereClause clause applies.
public  voidsaveNew()
     Saves the persistable by inserting a new row.
public  voidsetAsObject(String property, Object value)
     Sets property by calling Persistable.setAsString setAsString() with value.toString().
public  voidsetAsString(String property, String value)
    

Sets property to value, converting value from a string to the appropriate type in a sensible way.

public  voidsetBoolean(String property, boolean value)
     Sets property to value, boxing the value if necessary.
public  voidsetDate(String property, Date value)
     Sets property to value, boxing the value if necessary.
public  voidsetDouble(String property, double value)
     Sets property to value, boxing the value if necessary.
public  voidsetInt(String property, int value)
     Sets property to value, boxing the value if necessary.
protected static  voidsetProperty(DynaBean persistable, DynaProperty dynaProperty, ResultSet rs)
     Convenience method to set the dynaProperty of persistable with the corresponding value from rs.
public  voidsetString(String property, String value)
     Sets property to value, boxing the value if necessary.


Constructor Detail
Persistable
public Persistable(DynaClass dynaClass)(Code)




Method Detail
deleteAll
public static void deleteAll(DynaClass dynaClass, String whereClause) throws PersistableException(Code)
Deletes all persistables according to the specified whereClause. whereClause should not include the WHERE keyword; if whereClause is null, all persistables in the table are deleted.



deleteAll
public void deleteAll(String whereClause) throws PersistableException(Code)
Deletes all persistables according to the specified whereClause. whereClause should not include the WHERE keyword; if whereClause is null, all persistables in the table are deleted.



getBoolean
public boolean getBoolean(String property)(Code)
Returns property, unboxing the value if necessary; false is returned if the property has not been set.



getDate
public Date getDate(String property)(Code)
Returns property, unboxing the value if necessary.



getDouble
public double getDouble(String property)(Code)
Returns property, unboxing the value if necessary; 0.0 is returned if the property has not been set.



getInt
public int getInt(String property)(Code)
Returns property, unboxing the value if necessary; returns 0 if the property has not been set.



getSqlLiteral
public static String getSqlLiteral(String value)(Code)
Returns a string literal suitable for use in a SQL statement by escaping single quotes and then wrapping the string in single quotes. For example, "it's good to escape" becomes "'it''s good to escape'"



getSqlLiteral
public static String getSqlLiteral(Boolean value)(Code)
Returns a string literal suitable for use in a SQL statement, using '1' for true and '0' for false.



getSqlLiteral
public static String getSqlLiteral(Date value)(Code)
Returns a date literal suitable for use in a SQL statement by wrapping a standard SQL date in single quotes.



getSqlLiteral
protected String getSqlLiteral(DynaProperty dynaProperty)(Code)
Returns the value of dynaProperty in a form suitable for use in a SQL statement.



getString
public String getString(String property)(Code)
Returns property, unboxing the value if necessary.



load
public void load(String whereClause)(Code)
Loads the persistable according to the specified whereClause. If no records match whereClause, an exception is thrown. If more than one record matches, only the first is used.



loadAll
public static List loadAll(DynaClass dynaClass, String whereClause, String orderByClause)(Code)
Returns a list containing all persistables for the specified WHERE and ORDER BY clauses. whereClause should not include the WHERE keyword; if whereClause is null all persistables in the table are loaded. orderBy should not contain the ORDER BY keywords; if orderByClause is null persistables are sorted as returned from the database.



loadAll
public List loadAll(String whereClause, String orderByClause)(Code)
Returns a list containing all persistables for the specified WHERE and ORDER BY clauses. whereClause should not include the WHERE keyword; if whereClause is null all persistables in the table are loaded. orderBy should not contain the ORDER BY keywords; if orderByClause is null persistables are sorted as returned from the database.



save
public void save(String whereClause) throws PersistableException(Code)
Saves the persistable, by updating any rows to which the specified whereClause clause applies. whereClause should not include the WHERE keyword; if whereClause is null, all rows in the table are updated.



saveNew
public void saveNew()(Code)
Saves the persistable by inserting a new row.



setAsObject
public void setAsObject(String property, Object value)(Code)
Sets property by calling Persistable.setAsString setAsString() with value.toString().



setAsString
public void setAsString(String property, String value)(Code)

Sets property to value, converting value from a string to the appropriate type in a sensible way.

  • Strings: simply value or "" if value is null.
  • Integers: value if it can be successfully parsed; 0 if value is null or an empty string.
  • Booleans: true if value is "true", "yes", or "on" (case insensitive), false otherwise.
  • Doubles: value if it can be successfully parsed; 0.0 if value is null or an empty string.
  • Dates: value if it can be successfully parsed by DateFormat.getDateInstance( DateFormat.SHORT ) (e.g., "2/20/03") or DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT ) (e.g., "2/20/03 8:20 PM"); the current date if value is null or an empty string.



setBoolean
public void setBoolean(String property, boolean value)(Code)
Sets property to value, boxing the value if necessary.



setDate
public void setDate(String property, Date value)(Code)
Sets property to value, boxing the value if necessary.



setDouble
public void setDouble(String property, double value)(Code)
Sets property to value, boxing the value if necessary.



setInt
public void setInt(String property, int value)(Code)
Sets property to value, boxing the value if necessary.



setProperty
protected static void setProperty(DynaBean persistable, DynaProperty dynaProperty, ResultSet rs)(Code)
Convenience method to set the dynaProperty of persistable with the corresponding value from rs.



setString
public void setString(String property, String value)(Code)
Sets property to value, boxing the value if necessary.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.