Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

jFile (jrclient API)

Class jFile

com.jbase.jrcs.JFile

public final class JFile
extends Object
Represents a jBASE file variable

Constructor Summary

Modifier
Constructor and Description
protected 
JFile(int handle, String name, JConnection conn)



Method Summary

Modifier and Type
 Method
 Description
void
clearFile()
Clears the file
void
close()
Closes the file and releases the server-side handle
void
delete(String key)
Deletes a record with the given key
protected void
 finalize()

protected int
 getHandle()

JDynArray
 getIndex(String indexName)
Reads information about the specified index
String
getPath()
Retrieves the file path
JIndex
openIndex(String indexName)
Opens a named index on this file
JDynArray
read(String key)
Reads a record from the file without locking
JDynArray
read(String key, boolean locked)
Reads a record from the file, optionally locking it
JDynArray
read(String key, boolean locked, boolean wait)
Reads a record from the file, optionally locking it and waiting for the lock
JDynArray
readNamedField(String key, String field)
Reads a named field from a file record
JDynArray
readNamedField(String key, String field, boolean locked)
Reads a named field from a file record, optionally locking the record
JDynArray
readNamedField(String key, String field, boolean locked, boolean wait)
Reads a named field from a file record, optionally locking the record
JDynArray
readV(String key, int attrib)
Reads an attribute from a file record without locking
JDynArray
readV(String key, int attrib, boolean locked)
Reads an attribute from a file record, optionally locking the record
JDynArray
readV(String key, int attrib, boolean locked, boolean wait)
Reads an attribute from a file record, optionally locking the record and waiting for the lock
void
release(String key)
Releases a lock on a file record
void
releaseAll()
Releases all locks held by the current session on the given file
JSelectList
select()
Selects all keys in the file in hash order
JSelectList
sselect()
Selects all keys in the file in ascending sorted order
void
write(String key, JDynArray data)
Writes a record to the file releasing the lock if there is one
void
write(String key, JDynArray data, boolean unlock)
Writes a record to the file optionally releasing the lock
void
writeNamedField(String key, String field, JDynArray data)
Writes a named record field to the file
void
writeNamedField(String key, String field, JDynArray data, boolean unlock)
Writes a named record field to the file optionally releasing the lock
void
writeV(String key, JDynArray data, int attrib)
Writes a record attribute to the file releasing the lock if there is one
void
writeV(String key, JDynArray data, int attrib, boolean unlock)
Writes a record attribute to the file optionally releasing the lock


Methods inherited from class java.lang.Object

clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait



Constructor Detail

JFile

protected JFile(int handle, String name, JConnection conn)


Method Detail

clearFile

public void clearFile() 

throws JException

Clears the file 
Throws: JException 



close

public void close()
throws JException
Closes the file and releases the server-side handle. 
Throws: JException 



delete

public void delete(String key)
throws JException
Deletes a record with the given key 
Parameters: 
key - Record key. 
Throws: JException 



getIndex

public JDynArray getIndex(String indexName)
 throws JException 
Reads information about the specified index. 
Parameters: 
    indexName - Index name to query. 
Returns: JDynArray object with index information. 
Throws: JException



openIndex

public JIndex openIndex(String indexName)
throws JException
Opens a named index on this file. 
Parameters: 
    indexName - Index name 
Returns: JIndex object representing the resulting index variable. 
Throws: JException



getPath

public String getPath()
 throws JException 
Retrieves the file path. 
Returns: File path 
Throws: JException



read

public JDynArray read(String key, oolean locked, boolean wait)
throws JException 
Reads a record from the file, optionally locking it and waiting for the lock. 
Parameters: 
    key - Record key to read. locked - If true, performs a READU instead of READ to lock the record. 
    wait - If true and the locked parameter is specified, the program will wait for the lock rather than failing. 
Returns: JDynArray with record data. 
Throws: JException



read

public JDynArray read(String key, boolean locked)
 throws JException
Reads a record from the file, optionally locking it. 
Parameters: 
    key - Record key to read. 
    locked - If true, performs a READU instead of READ to lock the record. The method will fail immediately if it cannot                   obtain the lock. 
Returns: JDynArray with record data. 
Throws: JException



read

public JDynArray read(String key)
throws JException
Reads a record from the file without locking. 
Parameters: 
    key - Record key to read. 
Returns: JDynArray with record data. 
Throws: JException



readV

public JDynArray readV(String key, int attrib, boolean locked, boolean wait)
throws JException
Reads an attribute from a file record, optionally locking the record and waiting for the lock. 
Parameters: 
key - Record key to read. 
attrib - Attribute number to read. 
locked - If true, performs a READVU instead of READV to lock the record. 
wait - If true and the locked parameter is specified, the program will wait for the lock rather than failing. 
Returns: JDynArray with attribute data. 
Throws: JException



readV

public JDynArray readV(String key, int attrib, boolean locked)
throws JException
Reads an attribute from a file record, optionally locking the record. 
Parameters: 
key - Record key to read. 
attrib - Attribute number to read. 
locked - If true, performs a READVU instead of READV to lock the record. The method will fail immediately if the record cannot be locked. 
Returns: JDynArray with attribute data. 
Throws: JException



readV

public JDynArray readV(String key, int attrib)
throws JException
Reads an attribute from a file record without locking. 
Parameters: 
key - Record key to read. 
attrib - Attribute number to read. 
Returns: JDynArray with attribute data. 
Throws: JException



release

public void release(String key)
 throws JException
Releases a lock on a file record. 
Parameters: 
    key - Record key. 
Throws: JException



releaseAll

public void releaseAll()
 throws JException
Releases all locks held by the current session on the given file. 
Throws: JException



select

public JSelectList select()
throws JException
Selects all keys in the file in hash order. 
Returns: JSelectList representing the resulting select list. 
Throws: JException



sselect

public JSelectList sselect()
throws JException
Selects all keys in the file in ascending sorted order. 
Returns: JSelectList representing the resulting select list. 
Throws: JException



write

public void write(String key, JDynArray data, boolean unlock)
throws JException
Writes a record to the file optionally releasing the lock. 
Parameters: 
key - Record key to write. 
data - Record data. 
unlock - If true, unlocks the record after writing. Otherwise a WRITEU is performed and the lock is kept. 
Throws: JException



write

public void write(String key, JDynArray data)

Writes a record to the file releasing the lock if there is one. 

Parameters: 

key - Record key to write. 

data - Record data. 

Throws: JException 



writeV

public void writeV(String key, JDynArray data, int attrib, boolean unlock)
throws JException
Writes a record attribute to the file optionally releasing the lock.  
Parameters: 
key - Record key to write. 
data - Attribute data. 
attrib - Attribute number to write. 
unlock - If true, unlocks the record after writing. Otherwise a WRITEVU is performed and the lock is kept. 
Throws: JException



readNamedField

public JDynArray readNamedField(String key, String field, boolean locked, boolean wait)
throws JException
Reads a named field from a file record, optionally locking the record. 
Parameters: 
key - Record key to read. 
field - Field name to read. 
locked - If true, performs a READVU instead of READV to lock the record. 
wait - If true and the locked parameter is specified, the program will wait for the lock rather than failing. 
Returns: JDynArray with attribute data. 
Throws: JException



readNamedField

public JDynArray readNamedField(String key, String field, boolean locked)
 throws JException
Reads a named field from a file record, optionally locking the record. 
Parameters: 
key - Record key to read. 
field - Field name to read. 
locked - If true, performs a READVU instead of READV to lock the record. The method will fail immediately if the record             cannot be locked.
Returns: JDynArray with attribute data. 
Throws: JException



readNamedField

public JDynArray readNamedField(String key, String field)
throws JException 
Reads a named field from a file record. 
Parameters: 
key - Record key to read. 
field - Field name to read. 
Returns: JDynArray with attribute data. 
Throws: JException



writeNamedField

public void writeNamedField(String key, String field, JDynArray data, boolean unlock)
throws JException 
Writes a named record field to the file optionally releasing the lock. 
Parameters: 
key - Record key to write. 
field - Field name to write. 
data - Field data. 
unlock - If true, unlocks the record after writing. Otherwise a WRITEVU is performed and the lock is kept.  
Throws: JException



writeNamedField

public void writeNamedField(String key, String field, JDynArray data) 

throws JException 

Writes a named record field to the file. 

Parameters: 

key - Record key to write. 

field - Field name to write. 

data - Field data. 

Throws: JException




writeV

public void writeV(String key, JDynArray data, int attrib) 

throws JException 

Writes a record attribute to the file releasing the lock if there is one. 

Parameters: 

key - Record key to write. 

data - Attribute data. 

attrib - Attribute number to write. 

Throws: JException




getHandle

protected int getHandle()



finalize

protected void finalize() 

Overrides: finalize in class Object


Was this article helpful?