org.erights.e.elib.tables
Class ROMap

java.lang.Object
  |
  +--org.erights.e.elib.tables.EMap
        |
        +--org.erights.e.elib.tables.ROMap
All Implemented Interfaces:
Amplifiable, EPrintable, Iteratable, Marker, PassByProxy, Persistent, Serializable

class ROMap
extends EMap
implements Amplifiable, PassByProxy

A ROMap gives read-only access to an underlying potentially mutable map.

Author:
Mark S. Miller

Field Summary
private  FlexMap myPrecious
           
(package private) static long serialVersionUID
           
 
Fields inherited from class org.erights.e.elib.tables.EMap
 
Fields inherited from interface org.erights.e.elib.serial.PassByProxy
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Constructor Summary
(package private) ROMap(FlexMap precious)
          Callers *MUST* be sure to hand in the only reference to this map.
 
Method Summary
 void __printOn(TextWriter out)
          Not transparently forwarded.
 FlexMap diverge(Class keyType, Class valueType)
          Enabled: Returns a FlexMap whose initial state is a snapshot of the state of this map at the time of the diverge() request.
 ESet domain()
          Enabled: Returns a set providing a read-only view of the domain of this map.
 Object get(Object key, Object instead)
          Enabled: What value does 'key' map to? Returns 'instead' if key doesn't map to anything.
 Object getKeys(Class type)
          Enabled: Returns a divergent array-of-type of all the keys in order.
 Object[] getPair()
          Enabled: Returns a pair (a two element list) of the results of getKeys() and getValues().
 Object[] getPair(Class keyType, Class valueType)
          Enabled: Returns a pair (a two element list) of the results of getKeys(keyType) and getValues(valueType).
 Object getValues(Class type)
          Enabled: Returns a divergent array-of-type of all the values in order.
 void iterate(AssocFunc func)
          Enabled: Call 'func' with each key-value pair in the table, in order.
 Class keyType()
          Enabled: All keys in this map must be of this type.
 SealedBox optSealedDispatch(Brand brand)
          Divulges itself only to a holder of org.erights.e.elib.serial.PersistentKeyHolder#THE_UNSEALER.
 EMap readOnly()
          Enabled: Returns a read-only facet on this map.
 int size()
          Enabled: How many entries are in the table?
 ConstMap snapshot()
          Enabled: Returns a ConstMap whose state is a snapshot of the state of this map at the time of the snapshot() request.
 Class valueType()
          Enabled: All values in this map must be of this type
 
Methods inherited from class org.erights.e.elib.tables.EMap
and, butNot, contains, diverge, extract, get, getKeys, getValues, intersects, maps, optExtract, or, or, printOn, sortKeys, sortKeys, sortValues, sortValues, toString, with, without
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

myPrecious

private final FlexMap myPrecious
Constructor Detail

ROMap

ROMap(FlexMap precious)
Callers *MUST* be sure to hand in the only reference to this map.

Method Detail

snapshot

public ConstMap snapshot()
Description copied from class: EMap
Enabled: Returns a ConstMap whose state is a snapshot of the state of this map at the time of the snapshot() request. A ConstMap returns itself.

Specified by:
snapshot in class EMap

readOnly

public EMap readOnly()
Description copied from class: EMap
Enabled: Returns a read-only facet on this map. Someone holding this facet may see changes, but they cannot cause them.

Specified by:
readOnly in class EMap

diverge

public FlexMap diverge(Class keyType,
                       Class valueType)
Description copied from class: EMap
Enabled: Returns a FlexMap whose initial state is a snapshot of the state of this map at the time of the diverge() request.

Further changes to the original and/or the new map are independent -- they diverge.

The new map is constrained to only hold associations from 'keyType' to 'valueType'. XXX keyType and valueType should be declared as ValueGuards rather than Classes.

Overrides:
diverge in class EMap

domain

public ESet domain()
Description copied from class: EMap
Enabled: Returns a set providing a read-only view of the domain of this map.

Specified by:
domain in class EMap

size

public int size()
Description copied from class: EMap
Enabled: How many entries are in the table?

Specified by:
size in class EMap

iterate

public void iterate(AssocFunc func)
Description copied from class: EMap
Enabled: Call 'func' with each key-value pair in the table, in order.

Specified by:
iterate in interface Iteratable
Overrides:
iterate in class EMap

get

public Object get(Object key,
                  Object instead)
Description copied from class: EMap
Enabled: What value does 'key' map to? Returns 'instead' if key doesn't map to anything.

Specified by:
get in class EMap
Parameters:
key - nullOk;
instead - nullOk;
Returns:
nullOk;
See Also:
org.erights.e.elib.ref.Ref#isSettled

getKeys

public Object getKeys(Class type)
Description copied from class: EMap
Enabled: Returns a divergent array-of-type of all the keys in order.

XXX Should 'type' be a ValueGuard rather than a Class?

Specified by:
getKeys in class EMap

getValues

public Object getValues(Class type)
Description copied from class: EMap
Enabled: Returns a divergent array-of-type of all the values in order.

XXX Should 'type' be a ValueGuard rather than a Class?

Specified by:
getValues in class EMap

getPair

public Object[] getPair()
Description copied from class: EMap
Enabled: Returns a pair (a two element list) of the results of getKeys() and getValues().

Unlike calling them individually, by getting them both together, they are guaranteed to correspond.

Overrides:
getPair in class EMap

getPair

public Object[] getPair(Class keyType,
                        Class valueType)
Description copied from class: EMap
Enabled: Returns a pair (a two element list) of the results of getKeys(keyType) and getValues(valueType).

Unlike calling them individually, by getting them both together, they are guaranteed to correspond. The default implementation here does just call getKeys(keyType), and then calls getValues(valueType), as that is fine for everything but the WeakValuesMap.

XXX Should keyType and valueType be ValueGuards rather than Classes?

Overrides:
getPair in class EMap

keyType

public Class keyType()
Description copied from class: EMap
Enabled: All keys in this map must be of this type.

XXX Should this return a ValueGuard rather than a Class?

Specified by:
keyType in class EMap

valueType

public Class valueType()
Description copied from class: EMap
Enabled: All values in this map must be of this type

XXX Should this return a ValueGuard rather than a Class?

Specified by:
valueType in class EMap

optSealedDispatch

public SealedBox optSealedDispatch(Brand brand)
Divulges itself only to a holder of org.erights.e.elib.serial.PersistentKeyHolder#THE_UNSEALER.

XXX Should provide an optional creation-time parameter of a Sealer to use in addition (or instead?) as a secret divulging channel.

Specified by:
optSealedDispatch in interface Amplifiable
Parameters:
brand -
Returns:

__printOn

public void __printOn(TextWriter out)
               throws IOException
Not transparently forwarded. Rather, prints as
      "[a => b, ...].diverge().readOnly()"
 

Specified by:
__printOn in interface EPrintable
IOException


comments?