org.jclarion.clarion
Class ClarionFile

java.lang.Object
  extended by org.jclarion.clarion.ClarionMemoryModel
      extended by org.jclarion.clarion.ClarionGroup
          extended by org.jclarion.clarion.ClarionFile
All Implemented Interfaces:
Threaded
Direct Known Subclasses:
ClarionAsciiFile, ClarionBasicFile, ClarionBinaryFile, ClarionSQLFile

public abstract class ClarionFile
extends ClarionGroup

Provide abstract model of a File entity in clarion.

Author:
barney

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jclarion.clarion.ClarionGroup
ClarionGroup.GroupEntry, ClarionGroup.ReferenceVariable
 
Nested classes/interfaces inherited from class org.jclarion.clarion.ClarionMemoryModel
ClarionMemoryModel.State
 
Field Summary
 
Fields inherited from class org.jclarion.clarion.ClarionGroup
map
 
Constructor Summary
ClarionFile()
           
 
Method Summary
abstract  void add()
          insert new record based on contents of record buffer
abstract  void add(int size)
          insert new record writing only fixed # of bytes.
 void addKey(ClarionKey key)
          Add sort key
abstract  boolean bof()
          Retrun true if at beginning of file
abstract  void buffer(java.lang.Integer pagesize, java.lang.Integer behind, java.lang.Integer ahead, java.lang.Integer timeout)
          Set record paging.
abstract  void build()
          Rebuild key files
 void clearNull(ClarionObject clarionObject)
           
abstract  void close()
          Close a file
static void commit()
          Commit transaction changes
abstract  void create()
          Create new file.
protected  byte[] decodeByteArraySend(java.lang.String value)
           
protected  char[] decodeCharArraySend(java.lang.String value)
           
abstract  void delete()
          Delete current record
 void deregisterCallback(Filecallbackinterface inf)
           
protected  void disposeFileState()
           
 boolean duplicateCheck(ClarionKey clarionKey)
           
abstract  boolean eof()
          Return true if at end of file
abstract  void flush()
          Flush file buffers.
abstract  void freeState(int state)
          Free memory held by stored state but do not restore state
 void functionCalled(int code, FilecallbackParams params, java.lang.String ecode, java.lang.String emsg)
           
 void functionDone(int code, FilecallbackParams params, java.lang.String ecode, java.lang.String emsg)
           
abstract  void get(ClarionKey akey)
          Get record based on particular key
abstract  void get(ClarionNumber position, java.lang.Integer len)
           
abstract  void get(ClarionString pointer, java.lang.Integer len)
          retrieve record based on specified pointer position - previously returned by pointer command.
 int getBytes()
           
protected abstract  java.lang.String getDriver()
           
protected  ClarionObject getFileProperty(int index)
           
 FileState getFileState()
           
 ClarionKey getKey(ClarionObject indx)
          Get a particular key based on index
 ClarionKey getKey(int indx)
           
 java.util.List<ClarionKey> getKeys()
           
 java.lang.String getName()
          return file name
abstract  ClarionString getNulls()
          Get encoding of status of nulls used by SQL files
abstract  int getPointer()
          Get file pointer
 ClarionString getPosition()
          Get file position
abstract  ClarionString getPosition(ClarionKey key)
           
 ClarionKey getPrimaryKey()
           
 ClarionObject[] getPrimaryKeyPosition()
           
 ClarionObject getProperty(ClarionObject index)
          get file property.
 ClarionObject getProperty(ClarionObject key, ClarionObject index)
          Get file property
 ClarionObject getProperty(java.lang.Object index)
           
 ClarionObject getProperty(java.lang.Object key, java.lang.Object index)
           
 int getSQLType(ClarionObject o)
           
abstract  int getState()
          Save state of file to be restored later.
 void initThread()
           
static boolean isPositionMatches(ClarionString string, ClarionObject[] scanFields)
           
abstract  void lock()
          Lock file
static void logout(int timeout)
          initialise transaction processing
abstract  void next()
          Get next record in current sequence
 void open()
          Open the file in read/write local but deny write others mode
abstract  void open(int mode)
          Open file in particular mode.
abstract  void previous()
          Get prior record in current sequence
abstract  void put()
          Rewrite current record
abstract  int records()
          Return number of records in file
abstract  void reget(ClarionKey key, ClarionString string)
           
 void reget(ClarionString string)
          Reget a record based on result of position method
 void registerCallback(Filecallbackinterface inf, boolean junk)
           
abstract  void remove()
          Delete a file.
 void removeKey(ClarionKey key)
          Remove a sort key.
 void removeKeys()
           
abstract  void reset(ClarionKey key, ClarionString string)
           
 void reset(ClarionString string)
          Reset sequental processing based on specified position
abstract  void restoreState(int state)
          Restore state.
static void rollback()
          rollback transaction changes
abstract  void send(java.lang.String operator)
          Send special command to the file driver
 void set()
          Set sequentual record processing
abstract  void set(ClarionKey key)
          Set key based record processing
abstract  void set(int position)
          Set sequentual record processing starting at position
 void setClonedProperty(java.lang.Object index, java.lang.Object value)
           
 void setClonedProperty(java.lang.Object key, java.lang.Object index, java.lang.Object value)
           
 void setCreate()
           
protected  void setFileProperty(int index, ClarionObject value)
           
 ClarionFile setName(ClarionString name)
           
 ClarionFile setName(java.lang.String name)
          Set name of file to read.
 void setNoMemo()
           
 void setNull(ClarionObject clarionObject)
           
abstract  void setNulls(ClarionString nulls)
          Restore encoding of status of nulls used by SQL files
 void setPrimaryKeyPosition(ClarionObject[] position)
           
 void setProperty(ClarionObject index, ClarionObject value)
          Set file property.
 void setProperty(ClarionObject key, ClarionObject index, ClarionString value)
          Set file property.
 void setProperty(java.lang.Object index, java.lang.Object value)
           
 void setProperty(java.lang.Object key, java.lang.Object index, java.lang.Object value)
           
 ClarionFile setSource(ClarionString source)
          Specify owner of the file.
abstract  void stream()
          Set output write caching on a file.
 boolean testOpen()
           
abstract  void unlock()
          Unlock previously locked file
abstract  void watch()
          Enable optimistic locking.
 
Methods inherited from class org.jclarion.clarion.ClarionGroup
addReference, addVariable, addVariable, clear, clear, deserialize, flatWhat, flatWhere, flatWho, genericLike, getGroupObject, getGroupParam, getGroupParamPosition, getLockedObject, getPrefix, getString, getThread, getVariableCount, merge, serialize, setOver, setOver, setPrefix, setValue, setValue, what, where, who, whoNoPrefix
 
Methods inherited from class org.jclarion.clarion.ClarionMemoryModel
addChangeListener, addChangeListener, castTo, getListenerCount, isAnyoneInterestedInChange, isThreaded, lock, notifyChange, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClarionFile

public ClarionFile()
Method Detail

getSQLType

public int getSQLType(ClarionObject o)

initThread

public void initThread()
Specified by:
initThread in interface Threaded
Overrides:
initThread in class ClarionGroup

setCreate

public void setCreate()

addKey

public void addKey(ClarionKey key)
Add sort key

Parameters:
key -

removeKey

public void removeKey(ClarionKey key)
Remove a sort key. Used by views

Parameters:
key -

setNoMemo

public void setNoMemo()

getBytes

public int getBytes()

removeKeys

public void removeKeys()

setSource

public ClarionFile setSource(ClarionString source)
Specify owner of the file. For SQL drivers it indicates where want to connect to

Parameters:
source - also known as owner
Returns:

setName

public ClarionFile setName(java.lang.String name)
Set name of file to read. i.e. file name for filesystem access and table name ofr SQL access

Parameters:
name -
Returns:

setName

public ClarionFile setName(ClarionString name)

open

public void open()
Open the file in read/write local but deny write others mode


stream

public abstract void stream()
Set output write caching on a file. By default it is disabled. Only applies for filesystem type files.


remove

public abstract void remove()
Delete a file.


flush

public abstract void flush()
Flush file buffers. Only applies for filesystem type files.


open

public abstract void open(int mode)
Open file in particular mode. Supported modes are: User access: x00 = read only x01 = write only x02 = read/write Remote access: x00 = any x10 = deny all x20 = deny write x30 = deny read x40 = deny nothing Open default is x22 = Read/Write user but deny write remote.

Parameters:
mode -

close

public abstract void close()
Close a file


build

public abstract void build()
Rebuild key files


next

public abstract void next()
Get next record in current sequence


previous

public abstract void previous()
Get prior record in current sequence


put

public abstract void put()
Rewrite current record


delete

public abstract void delete()
Delete current record


create

public abstract void create()
Create new file. If file already exists it will be overwritten. this call open after.


lock

public abstract void lock()
Lock file


watch

public abstract void watch()
Enable optimistic locking. On next get,next,previous or reget. make a note of contents of record. On subsequent put, fail operation if the record has changed in anyway error code for failure is 89. A second get,next,previous or reget will cancel the watch.


buffer

public abstract void buffer(java.lang.Integer pagesize,
                            java.lang.Integer behind,
                            java.lang.Integer ahead,
                            java.lang.Integer timeout)
Set record paging. We will never bother with this one but will make it abstract anyway.

Parameters:
pagesize -
behind -
ahead -
timeout -

unlock

public abstract void unlock()
Unlock previously locked file


get

public abstract void get(ClarionKey akey)
Get record based on particular key

Parameters:
akey -

add

public abstract void add()
insert new record based on contents of record buffer


add

public abstract void add(int size)
insert new record writing only fixed # of bytes. Mainly for ascii and binary file drivers


records

public abstract int records()
Return number of records in file

Returns:

get

public abstract void get(ClarionString pointer,
                         java.lang.Integer len)
retrieve record based on specified pointer position - previously returned by pointer command.

Parameters:
pointer - - the position to get
len - - the number of bytes to read, for dos drivers etc

get

public abstract void get(ClarionNumber position,
                         java.lang.Integer len)

eof

public abstract boolean eof()
Return true if at end of file

Returns:

bof

public abstract boolean bof()
Retrun true if at beginning of file

Returns:

set

public final void set()
Set sequentual record processing


set

public abstract void set(ClarionKey key)
Set key based record processing


set

public abstract void set(int position)
Set sequentual record processing starting at position

Parameters:
position - position - as returned by position method

send

public abstract void send(java.lang.String operator)
Send special command to the file driver

Parameters:
operator -

decodeByteArraySend

protected byte[] decodeByteArraySend(java.lang.String value)

decodeCharArraySend

protected char[] decodeCharArraySend(java.lang.String value)

getDriver

protected abstract java.lang.String getDriver()

getFileProperty

protected ClarionObject getFileProperty(int index)

setFileProperty

protected void setFileProperty(int index,
                               ClarionObject value)

setClonedProperty

public final void setClonedProperty(java.lang.Object index,
                                    java.lang.Object value)

setProperty

public final void setProperty(java.lang.Object index,
                              java.lang.Object value)

setProperty

public void setProperty(ClarionObject index,
                        ClarionObject value)
Set file property. i.e. prop:owner, etc

Parameters:
index -
value -

setClonedProperty

public final void setClonedProperty(java.lang.Object key,
                                    java.lang.Object index,
                                    java.lang.Object value)

setProperty

public final void setProperty(java.lang.Object key,
                              java.lang.Object index,
                              java.lang.Object value)

setProperty

public void setProperty(ClarionObject key,
                        ClarionObject index,
                        ClarionString value)
Set file property.

Parameters:
key -
index -
value -

getProperty

public final ClarionObject getProperty(java.lang.Object index)

getProperty

public ClarionObject getProperty(ClarionObject index)
get file property.

Parameters:
key -
index -
value -

getProperty

public final ClarionObject getProperty(java.lang.Object key,
                                       java.lang.Object index)

getProperty

public ClarionObject getProperty(ClarionObject key,
                                 ClarionObject index)
Get file property

Parameters:
key -
index -
Returns:

getPosition

public final ClarionString getPosition()
Get file position

Returns:

getPosition

public abstract ClarionString getPosition(ClarionKey key)

getPointer

public abstract int getPointer()
Get file pointer

Returns:

reget

public final void reget(ClarionString string)
Reget a record based on result of position method

Parameters:
string -

reget

public abstract void reget(ClarionKey key,
                           ClarionString string)

reset

public final void reset(ClarionString string)
Reset sequental processing based on specified position

Parameters:
string -

reset

public abstract void reset(ClarionKey key,
                           ClarionString string)

getKey

public final ClarionKey getKey(ClarionObject indx)
Get a particular key based on index

Parameters:
index -
Returns:

getKey

public ClarionKey getKey(int indx)

getKeys

public java.util.List<ClarionKey> getKeys()

getPrimaryKey

public ClarionKey getPrimaryKey()

getState

public abstract int getState()
Save state of file to be restored later. Saving Current file state, open etc Contents of record buffer Watch status Variable change status Null variable states Sequentual processing position


freeState

public abstract void freeState(int state)
Free memory held by stored state but do not restore state

Parameters:
state -

restoreState

public abstract void restoreState(int state)
Restore state. Memory is not freed

Parameters:
state -

getNulls

public abstract ClarionString getNulls()
Get encoding of status of nulls used by SQL files

Returns:

setNulls

public abstract void setNulls(ClarionString nulls)
Restore encoding of status of nulls used by SQL files

Parameters:
nulls -

getName

public java.lang.String getName()
return file name

Returns:

logout

public static void logout(int timeout)
initialise transaction processing

Parameters:
timeout -

rollback

public static void rollback()
rollback transaction changes


commit

public static void commit()
Commit transaction changes


getFileState

public FileState getFileState()

disposeFileState

protected void disposeFileState()

registerCallback

public void registerCallback(Filecallbackinterface inf,
                             boolean junk)

deregisterCallback

public void deregisterCallback(Filecallbackinterface inf)

functionCalled

public void functionCalled(int code,
                           FilecallbackParams params,
                           java.lang.String ecode,
                           java.lang.String emsg)

functionDone

public void functionDone(int code,
                         FilecallbackParams params,
                         java.lang.String ecode,
                         java.lang.String emsg)

testOpen

public boolean testOpen()

duplicateCheck

public boolean duplicateCheck(ClarionKey clarionKey)

isPositionMatches

public static boolean isPositionMatches(ClarionString string,
                                        ClarionObject[] scanFields)

getPrimaryKeyPosition

public ClarionObject[] getPrimaryKeyPosition()

setPrimaryKeyPosition

public void setPrimaryKeyPosition(ClarionObject[] position)

clearNull

public void clearNull(ClarionObject clarionObject)
Overrides:
clearNull in class ClarionGroup

setNull

public void setNull(ClarionObject clarionObject)
Overrides:
setNull in class ClarionGroup


Copyright © 2010. All Rights Reserved.