org.jclarion.clarion
Class ClarionQueue

java.lang.Object
  extended by org.jclarion.clarion.ClarionMemoryModel
      extended by org.jclarion.clarion.ClarionGroup
          extended by org.jclarion.clarion.ClarionQueue
All Implemented Interfaces:
ClarionQueueReader, Threaded
Direct Known Subclasses:
SimpleComboQueue

public class ClarionQueue
extends ClarionGroup
implements ClarionQueueReader

Model a queue A queue is like an Array collection in Java. Queues have following properties public fields define what is actually being stored on the queue. Works sortof like files in Clarion in that there current record which may not represent what is actually stored, and what is currently stored. Queues have what is known as sort orders. Records are sorted and you can quickly retrieve values on pre-gen sort orders. The active sort order defines the default ordering of records in a queue. i.e. record #1, record #2, record #3 retrievals may indicate a specific ordering One thing I am not clear on with respect to how clarion queues work is the fact that a queue is either list or sorted - how clarion intermixes commands of a list nature vs a sort nature. Will assume that lists are allowed to fall into disorder in event of any operation that changes ordering of elements in active sort order

Author:
barney

Nested Class Summary
static class ClarionQueue.Order
          Model parameter ordering
protected static class ClarionQueue.QueueEntry
           
static class ClarionQueue.Record
           
static class ClarionQueue.SpecialRecord
           
 
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
ClarionQueue()
           
 
Method Summary
 void add()
          Add new record into queue at end of the queue
 void add(ClarionNumber position)
          Add record into queue - at specified position
 void add(ClarionObject order)
           
 void add(ClarionQueue.Order order)
          Add record into sorted list at specified list location.
 void add(ClarionString order)
          Add new record into queue, at the specified position.
 void add(int position)
           
 void add(java.lang.String order)
          Add record into sorted list at specified list location.
 void addListener(ClarionQueueListener cmcl)
          Listen for changes to the objects representation.
 ClarionMemoryModel castTo(java.lang.Class<? extends ClarionMemoryModel> clazz)
           
 int convertQueueIndexToScreenIndex(int v)
           
 int convertScreenIndexToQueueIndex(int v)
           
 java.lang.String debugString()
           
 void delete()
          Delete last retrieved record
 void free()
          Remove all records
 void get(ClarionNumber pos)
          Get specified record
 void get(ClarionObject order)
           
 void get(ClarionQueue.Order order)
           
 void get(ClarionString order)
          Get first matching specified record based on order setting If no record is found - call to position() will yield pointer to where record should of been found had there been one
 void get(int pos)
          Get specified record
 int getPointer()
          Return current position from 1 to n for last GET, ADD or PUT operation
 int getPosition()
          Not entirely sure what this does...
 ClarionObject[] getRecord(int pos)
           
 boolean[] getSiblingTree(int row, int pos)
           
 int getSortCount()
           
 ClarionObject getValueAt(int row, int column)
           
 boolean hasChildren(int row, int pos)
           
 boolean hasSibling(int row, int pos)
           
 ClarionQueue.Order ORDER()
          Helper to construct an order object
 void put()
          Put record back into queue in last position as specified by prior get(int) or add().
 void put(boolean keepIndexedSort)
           
 void put(ClarionQueue.Order order)
          Put record back into queue - using specified sort order
 int records()
          Return number of records in the queue
 void removeListener(ClarionQueueListener cmcl)
          Stop Listening for changes to the objects representation
 void setNextAnchor(java.lang.Object anchor)
           
 void sort(ClarionQueue.Order order)
          Set active sort order to the specified order
 void sort(ClarionString order)
           
 void toggle(int row, int column)
           
 
Methods inherited from class org.jclarion.clarion.ClarionGroup
addReference, addVariable, addVariable, clear, clear, clearNull, deserialize, flatWhat, flatWhere, flatWho, genericLike, getGroupObject, getGroupParam, getGroupParamPosition, getLockedObject, getPrefix, getString, getThread, getVariableCount, initThread, merge, serialize, setNull, setOver, setOver, setPrefix, setValue, setValue, what, where, who, whoNoPrefix
 
Methods inherited from class org.jclarion.clarion.ClarionMemoryModel
addChangeListener, addChangeListener, 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

ClarionQueue

public ClarionQueue()
Method Detail

ORDER

public ClarionQueue.Order ORDER()
Helper to construct an order object

Returns:

setNextAnchor

public void setNextAnchor(java.lang.Object anchor)

add

public void add()
Add new record into queue at end of the queue


add

public void add(ClarionNumber position)
Add record into queue - at specified position

Parameters:
order -

add

public void add(int position)

add

public void add(ClarionObject order)

get

public void get(ClarionObject order)

add

public void add(ClarionString order)
Add new record into queue, at the specified position. If record already exists at a given position push it 'down' If position indicated is invalid, then insert at end

Parameters:
order -

add

public void add(java.lang.String order)
Add record into sorted list at specified list location. String is comma separated with leading '+' or '-' to indicate either ascending or descending order

Parameters:
order -

add

public void add(ClarionQueue.Order order)
Add record into sorted list at specified list location.


put

public void put()
Put record back into queue in last position as specified by prior get(int) or add(). If last get or add operation was sort based - then put does not bother trying to insert in specific position If there are sort orders - reinsert record back into sort, taking into consideration possible change of sort location


put

public void put(boolean keepIndexedSort)

put

public void put(ClarionQueue.Order order)
Put record back into queue - using specified sort order


delete

public void delete()
Delete last retrieved record


free

public void free()
Remove all records


sort

public void sort(ClarionQueue.Order order)
Set active sort order to the specified order

Parameters:
order -

sort

public void sort(ClarionString order)

records

public int records()
Return number of records in the queue

Specified by:
records in interface ClarionQueueReader
Returns:

getValueAt

public ClarionObject getValueAt(int row,
                                int column)
Specified by:
getValueAt in interface ClarionQueueReader

getRecord

public ClarionObject[] getRecord(int pos)
Specified by:
getRecord in interface ClarionQueueReader

get

public void get(int pos)
Get specified record


get

public void get(ClarionNumber pos)
Get specified record


get

public void get(ClarionString order)
Get first matching specified record based on order setting If no record is found - call to position() will yield pointer to where record should of been found had there been one


get

public void get(ClarionQueue.Order order)

getPosition

public int getPosition()
Not entirely sure what this does... Clarion documentation is very confusing Returns position in active sort order based on all fields. If no exact match then return next position. I am choosing to interprete this as thus: + if there is no active sort order (unsorted) then return getPointer() + if there is active sort order then return equivalent of get(order);getPointer() but do not explicitly call those -i.e. do not mess with buffer

Returns:

getPointer

public int getPointer()
Return current position from 1 to n for last GET, ADD or PUT operation

Returns:

getSortCount

public int getSortCount()

addListener

public void addListener(ClarionQueueListener cmcl)
Listen for changes to the objects representation. Note that listener is weakly referenced. You need to maintain a strong reference to the listener object in order for it not to be garbage collected

Specified by:
addListener in interface ClarionQueueReader
Parameters:
cmcl -

removeListener

public void removeListener(ClarionQueueListener cmcl)
Stop Listening for changes to the objects representation

Specified by:
removeListener in interface ClarionQueueReader
Parameters:
cmcl -

debugString

public java.lang.String debugString()

toggle

public void toggle(int row,
                   int column)
Specified by:
toggle in interface ClarionQueueReader

hasChildren

public boolean hasChildren(int row,
                           int pos)
Specified by:
hasChildren in interface ClarionQueueReader

getSiblingTree

public boolean[] getSiblingTree(int row,
                                int pos)
Specified by:
getSiblingTree in interface ClarionQueueReader

hasSibling

public boolean hasSibling(int row,
                          int pos)

convertQueueIndexToScreenIndex

public int convertQueueIndexToScreenIndex(int v)
Specified by:
convertQueueIndexToScreenIndex in interface ClarionQueueReader

convertScreenIndexToQueueIndex

public int convertScreenIndexToQueueIndex(int v)
Specified by:
convertScreenIndexToQueueIndex in interface ClarionQueueReader

castTo

public ClarionMemoryModel castTo(java.lang.Class<? extends ClarionMemoryModel> clazz)
Overrides:
castTo in class ClarionMemoryModel


Copyright © 2010. All Rights Reserved.