facets.core.app
Class ValueContent

java.lang.Object
  extended by facets.util.Tracer
      extended by facets.core.app.ValueContent
All Implemented Interfaces:
Titled

public abstract class ValueContent
extends Tracer
implements Titled

Encapsulates common operations on ValueNode content.


Field Summary
 ValueNode working
          Content passed to the constructor, working and backup copies.
 
Constructor Summary
ValueContent(java.lang.String title, ValueNode master, ValueNode working)
          Unique constructor.
 
Method Summary
 void applyChanges()
          Implements abstract method.
 boolean hasChanged()
          Does the working copy differ from the master?
 SIndexing newIndexing(ValueNode values, java.lang.String title, java.lang.Object[] indexables, java.lang.Object indexed)
          Creates an indexing related to the specified values.
 SIndexing newMultipleIndexing(ValueNode values, java.lang.String title, java.lang.String[] keys, boolean invertValues)
          Creates a multiple indexing from flag values.
 SNumeric newNumeric(ValueNode values, java.lang.String key, NumberPolicy policy)
           
 STextual newTextual(ValueNode values, java.lang.String key)
          Creates a textual target representing the specified value.
 SToggling newToggling(ValueNode values, java.lang.String key)
          Convenience method for normal toggling creation.
 SToggling newToggling(ValueNode values, java.lang.String title, boolean invertValue)
          Creates a toggling target representing the specified value.
 void reverseChanges()
          Implements abstract method.
abstract  void targetValuesUpdated(STarget target, ValueNode values, java.lang.String keys)
          Called by the couplers of targets created with convenience methods.
 java.lang.String title()
          Return human-readable identifying text.
 java.lang.String toString()
           
protected  void traceOutput(java.lang.String msg)
          Outputs complete trace messages to console or elsewhere.
 
Methods inherited from class facets.util.Tracer
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutputWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

working

public final ValueNode working
Content passed to the constructor, working and backup copies.

Constructor Detail

ValueContent

public ValueContent(java.lang.String title,
                    ValueNode master,
                    ValueNode working)
Unique constructor.

Parameters:
master - values to be updated with any changes
working - stored as working; must not be master but must be state equal ie a deep copy; should be shared with any other active ValueContents updating the same master
Method Detail

hasChanged

public final boolean hasChanged()
Does the working copy differ from the master?

Checks state equality of working with master passed to constructor.


applyChanges

public final void applyChanges()
Implements abstract method.

Sets the state of master passed to constructor from working.


reverseChanges

public final void reverseChanges()
Implements abstract method.

Sets the state of working to a backup of master passed to constructor and calls applyChanges().


targetValuesUpdated

public abstract void targetValuesUpdated(STarget target,
                                         ValueNode values,
                                         java.lang.String keys)
Called by the couplers of targets created with convenience methods.

Parameters:
target - created in the calling method
values - as passed to and (usually) updated by the method
keys - as passed to the method (maybe concatenated)

newTextual

public final STextual newTextual(ValueNode values,
                                 java.lang.String key)
Creates a textual target representing the specified value.

Attaches a coupler which

  1. puts the text state as the value
  2. calls targetValuesUpdated(STarget,ValueNode,String) with the textual and the parameters passed

Parameters:
values - contains the value
key - retrieves the value

newToggling

public final SToggling newToggling(ValueNode values,
                                   java.lang.String key)
Convenience method for normal toggling creation.

Calls newToggling(ValueNode,String,boolean) with invertState passed false.


traceOutput

protected void traceOutput(java.lang.String msg)
Description copied from class: Tracer
Outputs complete trace messages to console or elsewhere.

Default prepends helpful classname to message.

Overrides:
traceOutput in class Tracer
Parameters:
msg - passed from one of the public methods

newToggling

public final SToggling newToggling(ValueNode values,
                                   java.lang.String title,
                                   boolean invertValue)
Creates a toggling target representing the specified value.

Attaches a coupler which

  1. puts the toggling state as the value
  2. calls targetValuesUpdated(STarget,ValueNode,String) with the toggling and the parameters passed

Parameters:
values - contains the value
title - for the toggling, as key (up to |) retrieves the value
invertValue - should values be exposed as the reverse of their stored state and vice-versa

newMultipleIndexing

public final SIndexing newMultipleIndexing(ValueNode values,
                                           java.lang.String title,
                                           java.lang.String[] keys,
                                           boolean invertValues)
Creates a multiple indexing from flag values.

Attaches a coupler which

  1. updates the values from the keys and SIndexing.indices()
  2. calls targetValuesUpdated(STarget,ValueNode,String) with the indexing, values and the keys concatenated

Parameters:
values - contains the flags
title - passed to indexing
keys - become the indexables; the flags they retrieve define the indices

newIndexing

public final SIndexing newIndexing(ValueNode values,
                                   java.lang.String title,
                                   java.lang.Object[] indexables,
                                   java.lang.Object indexed)
Creates an indexing related to the specified values.

This is purely a convenience method as it adds no functionality beyond constructing the indexing.

Parameters:
values - passed by the empty coupler to targetValuesUpdated(STarget,ValueNode,String) together with the indexing and title
title - passed to indexing
indexables - passed to indexing
indexed - passed to indexing

newNumeric

public final SNumeric newNumeric(ValueNode values,
                                 java.lang.String key,
                                 NumberPolicy policy)

title

public final java.lang.String title()
Description copied from interface: Titled
Return human-readable identifying text.

Specified by:
title in interface Titled
Returns:
non-null, non-empty string with no structural whitespace

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object