Java Doc for Database.java in  » IDE-Netbeans » mobility » example » stock » 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 » IDE Netbeans » mobility » example.stock 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   example.stock.Database

All known Subclasses:   example.stock.StockDatabase,  example.stock.AlertDatabase,
Database
abstract public class Database (Code)

This class provides a wrapper class for the RecordStore class. It allows for easier addition and deletion as well as better searching and updating of records. The used recordIDs are kept in a Vector which we use to access the indices of the records. The last used recordID is stored at the beginning of the database and when the database is opened, each recordID up to the last one used is tested to see if a record exists in that position and a new Vector of used recordIDs is generated.



Field Summary
protected volatile  RecordStoredatabase
    
protected  intlastID
    
protected  RecordComparatorrc
    
protected volatile  VectorrecordIDs
    


Method Summary
public synchronized  voidadd(String record)
    
public  voidcleanUp(String fileName)
    
public  voidclose()
    
public synchronized  voiddelete(String s)
    
public  intgetNumRecords()
    
public  voidopen(String fileName)
    

Initializes the database and if it's not a new database, loads the recordID of the last record out of the first position in the RecordStore.

public synchronized  Stringsearch(String s)
    
public synchronized  voidupdate(String s, byte[] data)
    

Field Detail
database
protected volatile RecordStore database(Code)
The database storing all the records and the last used recordID in position 1



lastID
protected int lastID(Code)
The last used ID in the database



rc
protected RecordComparator rc(Code)
The object used to compare two records and see if they are equal



recordIDs
protected volatile Vector recordIDs(Code)
The Vector of used recordIDs that are in the database





Method Detail
add
public synchronized void add(String record) throws RecordStoreNotOpenException, RecordStoreFullException, RecordStoreException(Code)

Add the record to the database
Add the recordID to our vector
Update the database's last ID counter


Parameters:
  record - The record data to be added to the database RecordStoreNotOpenException is thrown whentrying to close a RecordStore that is not open RecordStoreFullException is thrown when the storagesystem is is full RecordStoreException is thrown when a generalexception occurs in a RecordStore operation



cleanUp
public void cleanUp(String fileName) throws RecordStoreNotFoundException, RecordStoreException(Code)

Remove the database from persistant storage


Parameters:
  fileName - the name of the RecordStore to remove



close
public void close() throws RecordStoreNotOpenException, RecordStoreException(Code)

Close the database and remove it from persistant storage if it is empty

RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreException is thrown when a generalexception occurs in a RecordStore operation



delete
public synchronized void delete(String s) throws RecordStoreNotOpenException, RecordStoreException(Code)

Delete the record from the database and remove that recordID from the vector of used recordIDs


Parameters:
  s - The name of the record to delete from the database RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreException is thrown when a generalexception occurs in a RecordStore operation



getNumRecords
public int getNumRecords() throws RecordStoreNotOpenException(Code)

Return the number of records in the database

the number of records in the database RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open



open
public void open(String fileName) throws RecordStoreNotFoundException, RecordStoreException, RecordStoreFullException(Code)

Initializes the database and if it's not a new database, loads the recordID of the last record out of the first position in the RecordStore. We have stored it there when we closed the database, then checks each ID from 1 to lastID to see if they exist in the database and then add the IDs that exist to the recordIDs Vector


Parameters:
  fileName - The name of the RecordStore to open RecordStoreNotFoundException is thrown if theRecordStore indicated with fileNamecannot be found RecordStoreException is thrown when a generalexception occurs in a RecordStore operation RecordStoreFullException is thrown when thestorage system is is full



search
public synchronized String search(String s) throws RecordStoreNotOpenException, RecordStoreException(Code)

Find and return a record

The record that we're looking for ornull if not found
Parameters:
  s - The name of the record to search for RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreException is thrown when a generalexception occurs in a RecordStore operation



update
public synchronized void update(String s, byte[] data) throws RecordStoreNotOpenException, RecordStoreFullException, RecordStoreException(Code)

Update the record with the name s with the data in the byte[] array


Parameters:
  s - The name of the record to update
Parameters:
  data - the new data to update the record with RecordStoreNotOpenException is thrown when tryingto close a RecordStore that is not open RecordStoreFullException is thrown when the storagesystem is is full RecordStoreException is thrown when a generalexception occurs in a RecordStore operation



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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