org.geotools.event
Interface GTDelta

All Known Implementing Classes:
GTDeltaImpl

public interface GTDelta

Indicates which style constructs have been changed.

Acts as a series of breadcrumbs stored up by a StyleEvent to communicate changes.

This delta is constructed a fashion following the outline of the style document, allowing you to skip over entire branches of changes if you are not interested.

Example Use

The following examples will make use of the following allegorical data structure


 Root
  +--Parent
       +-- Child
       +-- List
             [0]--Element
 
These roles are allegorical in nature any may be played in real life by arrays, beans, collections, etc.. (as example StyleLayerDescriptor is a "Root").

Example 0: An Child is changed.


 Event.POST_CHANGE
    +---Delta1 "" -1 NO_CHANGE(Root,null,)
           +---Delta2 "Parent" -1 NO_CHANGE (Parent, null )
                  +---Delta3 "Child" -1 CHANGED (Child, oldChild )
 
Location of change is indicated by delta, including name of "Child". The oldChild is provided incase you need to un-listen or something. Parent is not considered to have changed itself (it is still has the same structure).

Example 1: An Element is changed:


 Event.POST_CHANGE
    +---Delta1 "" -1 NO_CHANGE(Root,null,)
           +---Delta2 "Parent" -1 NO_CHANGE (Parent, null )
                  +---Delta3 "List" 0 CHANGED (Element, null )
 
Location of change is indicated by delta, including position in list. Children in lists are children too, delta intentionally similar to the last.

Example 2: A new Element2 is added:


 Event.POST_CHANGE
    +---Delta1 "" -1 NO_CHANGE(Root,null,)
           +---Delta2 "Parent" -1 CHANGED (Parent, null )
                  +---Delta3 "List" 1 ADDED (Element2, null )
 

Adding Element2 results in a change to Parent (it is structured diffrently). Position of the change in the "List" is indicated.

Example 3: Swap Element and Element2


 Event.POST_CHANGE
    +---Delta1 "" -1 NO_CHANGE(Root,null,)
           +---Delta2 "Parent" -1 CHANGED (Parent, null )
                  +---Delta3 "List" 1 NO_CHANGE (Element, null )
                  +---Delta4 "List" 0 NO_CHANGE (Element2, null )
 
Moving things around does not change them, but it is a change to the Parent.

Example 5: Remove Element2


 Event.POST_CHANGE
    +---Delta1 "" -1 NO_CHANGE(Root,null,)
           +---Delta2 "Parent" -1 CHANGED (Parent, null )
                  +---Delta3 "List" -1 REMOVED ( null, Element2 )
                  +---Delta4 "List" 0 NO_CHANGE (Element, null )
 
Removing also is a considered a change to Parent, note this is a POST_CHANGE event so Element2 is an oldValue. The NO_CHANGE for Element is similar to Example4, it still indicates a change of position.

Example 6: Go Fish


 Event.POST_CHANGE
    +---Delta1 "" -1 CHANGED(Root,null,)
 
Something changed somewhere, similar to "touch".

Example 7: Shutting Down


 Event.PRE_CLOSE
    +---Delta1 "" -1 NO_CHANGE(Root,null,)
 
That was easy then...

You should be aware that the event system may "collapse" events that duplicate information, especially when considering batch changes resulting from the application of a visitor or transformation.

Author:
Jody Garnett, Refractions Research

Nested Class Summary
static class GTDelta.Kind
          Kind of Delta, used to indicate change.
 
Field Summary
static java.util.List NO_CHILDREN
          List indicating no children are present
static int NO_INDEX
          Index position is not to be considered relevent
 
Method Summary
 void accept(GTDeltaVisitor visitor)
          Accepts the given visitor.
 java.util.List getChildren()
          Finds and returns deltas for specificly changed constructs.
 GTDelta.Kind getKind()
          Returns the kind of this delta.
 java.lang.String getName()
          Name of property being affected.
 java.lang.Object getOldValue()
          Construct being replaced with a changed, getValue is the replacing value.
 int getPosition()
          Position in a "list" where the change occured, or NO_INDEX.
 java.lang.Object getValue()
          Affected construct, getKind & getChildern indicate specific details of the change.
 

Field Detail

NO_CHILDREN

public static final java.util.List NO_CHILDREN
List indicating no children are present


NO_INDEX

public static final int NO_INDEX
Index position is not to be considered relevent

See Also:
Constant Field Values
Method Detail

getKind

public GTDelta.Kind getKind()
Returns the kind of this delta.

Normally, one of ADDED, REMOVED or CHANGED.

Returns:
the kind of this resource delta
See Also:
Kind.ADDED, Kind.REMOVED, Kind.CHANGED

getValue

public java.lang.Object getValue()
Affected construct, getKind & getChildern indicate specific details of the change.

Returns:
Affected construct

getOldValue

public java.lang.Object getOldValue()
Construct being replaced with a changed, getValue is the replacing value.

Returns:
Affected construct

getPosition

public int getPosition()
Position in a "list" where the change occured, or NO_INDEX.

Returns:
Position in "list" or NO_INDEX.

getName

public java.lang.String getName()
Name of property being affected.

Returns:
name of affected Child, or null for root

getChildren

public java.util.List getChildren()
Finds and returns deltas for specificly changed constructs.

This code may be considered more accessable then the use of GTDeltaVisitor.

Returns:
List of StyleDelta

accept

public void accept(GTDeltaVisitor visitor)
Accepts the given visitor.

Parameters:
visitor -


Copyright © GeoTools. All Rights Reserved.