aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Assignment Comments relating use of Caching and RandomAccessFile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Assignment Comments relating use of Caching and RandomAccessFile" Watch "Assignment Comments relating use of Caching and RandomAccessFile" New topic
Author

Assignment Comments relating use of Caching and RandomAccessFile

Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
Hi,

I have some doubts relation the use of Caching for my assignment (URLyBird 1.1.3). The following comment in my interface delivered by Sun:

// Reads a record from the file. Returns an array where each
// element is a record value.
public String[] read(int recNo) throws RecordNotFoundException;

This read-method gets the record according to the recNo from a file? Do they mean a physical database file? So is it then impossible for me to use caching?
Am I too pedantic?

And here comes my doubts or gap in my knowledge relating the use of the RandomAccessFile class:

... All numeric values are stored in the header information use the format of the DataInputStream and DataOutputStream. ...

This tells me, that the db file was created by using the above streams. The RandomAccessFile implements superclasses of the above Streams (DataInput and DataOutput).
Are these informations enough to allow the use of the RandomAccessFile to access our database file?

Thanks for your help.
cheers Bob


SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4912
    
  10

Hi Bob,

I used the RAF and I passed, and I think every scjd'er used that class

I used also a record cache. Regarding the comment of sun's interface, I left it there (completely unmodified, except for some class comments). I created my own interface, extending sun's interface (of course) and override the read-method (and all other methods) and added my javadoc comments in my own interface. And this is my javadoc comment I added to the method.



Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2247

Howdy, Bob!

As my good buddy Roel, I also used a memory cache. So when you read a record, the record is actually being accessed from memory, not from the physical .db file.
Regarding the RandomAccessFile class, please take a look at the database file reader I created. Even though I'm using FileInputStream there, you can just replace it by RandomAccessFile. It should continue to work normally.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
Hi Roel,

Roel De Nijs wrote:
I used the RAF and I passed, and I think every scjd'er used that class

Seems I was a little bit pedantic here I will enter the RAF club.
Roel De Nijs wrote:
I used also a record cache. Regarding the comment of sun's interface, I left it there (completely unmodified, except for some class comments). I created my own interface, extending sun's interface (of course) and override the read-method (and all other methods) and added my javadoc comments in my own interface. And this is my javadoc comment I added to the method. ...
Kind regards,
Roel


I really think I have a big problem. I'm not CREATIVE enough. That has to be changed
From now on I will interpret the comment "Reads a record from the file" as "Reads a record from the file via the RecordCache". I will write that down in the choices and everyone is happy.
To modify one method (read(int recNo)) does not justify creating a new interface, I think.

Thanks for opening my eyes, Roel. I feel like a new man
cheers
Bob
Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
Hi Bob,

Bob and Roel together in my thread. I feel honoured. The white knights in the night

Roberto Perillo wrote:Howdy, Bob!

As my good buddy Roel, I also used a memory cache. So when you read a record, the record is actually being accessed from memory, not from the physical .db file.
Regarding the RandomAccessFile class, please take a look at the database file reader I created. Even though I'm using FileInputStream there, you can just replace it by RandomAccessFile. It should continue to work normally.

I already used your database file reader. Works like hell (meant positive )
But I was to lazy to try it with RAF. I will try it, later.

Thanks and cheers
Bob


Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4912
    
  10

Bob Wheeler wrote:
Bob and Roel together in my thread. I feel honoured.

You certainly should be
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1966
    
    7

Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured. The white knights in the night


Haha indeed they are "white knights".

Well I'm not going to say much since my good buddies Roel and Roberto did the job already.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2247

Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured.


Come on, Bob! We are here to help. We are a team, actually (I am the goal keeper)!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11278
    
  59

Bob Wheeler wrote:Bob and Roel together in my thread. I feel honoured. The white knights in the night


Yeah - they are really great! Thanks guys!

Roberto Perillo wrote:Come on, Bob! We are here to help. We are a team, actually (I am the goal keeper)!

More football commentary.

(I've got my sister & her family over from Ireland at the moment - one Man-U, one Chelsea, & one Liverpool supporter. Sigh. )


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assignment Comments relating use of Caching and RandomAccessFile
 
Similar Threads
File Channels (a couple of points)
Data layer design.
nx:All of URLy Bird 1.1.3 about read/write lock
Synchronization of public methods in DVDDatabase
Reading Record by Rec Number