4 byte numeric, magic cookie value. Identifies this as a data file
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException;
public void unlock(long recNo, long cookie)
throws SecurityException;
Regards, Richard
Regards, Richard
For example,the magic cookie is only used to identify the data file?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
I understand what you mean.But I don't know the use of them.
This means that you will have to note the current value and store it as a constant in your code so you can compare it later.
you can check to see if the magic cookie is there and if it matches the magic cookie you believe should be there.
Regards, Richard
If the value doesn't match I throw an Exception indicating not valid file format:
Regards, Richard
Execute first you program without cookie to check (you don't the value yet). Let the value to be printed on your screen.
Regards, Richard
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Regards, Richard
How can I do to finish writing rest code?
If I want to read some record,what things should I do?
In your code, MAGIC_COOKIE should be initialized with the value you want to check against.
Regards, Richard
Thanks for your response and critical statements!
Assuming that the MAGIC_COOKIE has been initialized to a value,what things that I do can compare to them?
Regards, Richard
private final int MAGIC_COOKIE=0;
3) Now you can change the code so, that it reads the fileheader gets magic cookie and compares with your constant MAGIC_COOKIE (which is 121). If these values are not equals you throw an Exception.
Regards, Richard
But the MAGIC_COOKIE value should be initialized to what value?
1.) You read first int value from your file header (as it is described in database schema in your assignement) and print the value on the screen. For example this value can be 121.
2.) Then you hard-code the value in your Data class:
code:
--------------------------------------------------------------------------------
private final int MAGIC_COOKIE=121;
--------------------------------------------------------------------------------
3) Now you can change the code so, that it reads the fileheader gets magic cookie and compares with your constant MAGIC_COOKIE (which is 121). If these values are not equals you throw an Exception.
Regards, Richard
OK,I did.And my cookie value is 259.
quote:
--------------------------------------------------------------------------------
2.) Then you hard-code the value in your Data class:
code:
--------------------------------------------------------------------------------
private final int MAGIC_COOKIE=121;
--------------------------------------------------------------------------------
You mean that I must use the value just got and assign it to the magic cookie firstly?
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
private final int MAGIC_COOKIE=259;
I think that is not the right exception to throw, after all the file specified was found.
Regards, Richard
have gotten exactly the MAGIC_COOKIE=259,but I have not declared the value as the constant before ensuring that.
Can I use the value directly to declare a constant?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |