org.palo.api.impl.subsets
Class AbstractSubsetState

java.lang.Object
  extended by org.palo.api.impl.subsets.AbstractSubsetState
All Implemented Interfaces:
SubsetState
Direct Known Subclasses:
FlatState, HierarchicalState, RegExState

public abstract class AbstractSubsetState
extends java.lang.Object

The AbstractSubsetState is a default implementation of the SubsetState interface.

Note: for internal usage only

Version:
$Id: AbstractSubsetState.html,v 1.8 2009/07/09 11:01:46 ArndHouben Exp $

Constructor Summary
AbstractSubsetState(java.lang.String id)
           
 
Method Summary
 void addPath(Element element, java.lang.String path)
          Adds the specified path for the given visible element
 void addVisibleElement(Element element, int position)
          Adds the given element to the list of all visible elements.
 void addVisibleElment(Element element)
          Adds the given element to the list of all visible elements
 boolean containsPath(Element element, java.lang.String path)
          Checks if this SubsetState contains the specified path for the given Element
 java.lang.String getExpression()
          Returns an optional expression to determine the visible elements
 java.lang.String getId()
          Returns the unique state id.
 java.lang.String getName()
          Returns an optional name for the state.
 java.lang.String[] getPaths(Element element)
          Returns all paths for the given Element or null, if no paths were defined.
 int[] getPositions(Element element)
          Returns the positions of the given visible element.
 Attribute getSearchAttribute()
          Returns an attribute field that is used for searching with the regular expression.
 Element[] getVisibleElements()
          Returns all visible elements.
 boolean isVisible(Element element)
          Checks if the given Element is visible within this SubsetState.
 void removeAllVisibleElements()
          Convenience method to remove all visible elements
 void removePath(Element element, java.lang.String path)
          Removes the specified path for the given visible element.
 void removeVisibleElement(Element element)
          Removes the given element from the list of all visible elements
 void setExpression(java.lang.String expression)
          Sets an expression to determine the visible elements
 void setName(java.lang.String name)
          Sets an optional name, label or description
 void setSearchAttribute(Attribute searchAttribute)
          Sets the attribute field that is used instead of the element name when filtering with a regular expression
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSubsetState

public AbstractSubsetState(java.lang.String id)
Method Detail

setExpression

public final void setExpression(java.lang.String expression)
Description copied from interface: SubsetState
Sets an expression to determine the visible elements

Specified by:
setExpression in interface SubsetState
Parameters:
expression - a state expression to describe the visible elements

addVisibleElment

public final void addVisibleElment(Element element)
Description copied from interface: SubsetState
Adds the given element to the list of all visible elements

Specified by:
addVisibleElment in interface SubsetState
Parameters:
element - the element to show

addVisibleElement

public final void addVisibleElement(Element element,
                                    int position)
Description copied from interface: SubsetState
Adds the given element to the list of all visible elements. The position parameter can be used to store additional information about the element position.

Specified by:
addVisibleElement in interface SubsetState
Parameters:
element - the element to show
position - an element position

removeVisibleElement

public final void removeVisibleElement(Element element)
Description copied from interface: SubsetState
Removes the given element from the list of all visible elements

Specified by:
removeVisibleElement in interface SubsetState
Parameters:
element - the element to remove

removeAllVisibleElements

public final void removeAllVisibleElements()
Description copied from interface: SubsetState
Convenience method to remove all visible elements

Specified by:
removeAllVisibleElements in interface SubsetState

getExpression

public final java.lang.String getExpression()
Description copied from interface: SubsetState
Returns an optional expression to determine the visible elements

Specified by:
getExpression in interface SubsetState
Returns:
the state expression or null if none was set

getId

public final java.lang.String getId()
Description copied from interface: SubsetState
Returns the unique state id.

Specified by:
getId in interface SubsetState
Returns:
the state id.

setName

public final void setName(java.lang.String name)
Description copied from interface: SubsetState
Sets an optional name, label or description

Specified by:
setName in interface SubsetState
Parameters:
name - a human readable label

getName

public final java.lang.String getName()
Description copied from interface: SubsetState
Returns an optional name for the state.

Specified by:
getName in interface SubsetState
Returns:
the state name or null if none was set

getVisibleElements

public final Element[] getVisibleElements()
Description copied from interface: SubsetState
Returns all visible elements.

Note: the array could be empty but that does not necessarily mean that no element is visible because an expression can determine the elements too.

Specified by:
getVisibleElements in interface SubsetState
Returns:
the visible elements

getSearchAttribute

public final Attribute getSearchAttribute()
Description copied from interface: SubsetState
Returns an attribute field that is used for searching with the regular expression.

Specified by:
getSearchAttribute in interface SubsetState
Returns:
the state search attribute field or null if none was set

setSearchAttribute

public final void setSearchAttribute(Attribute searchAttribute)
Description copied from interface: SubsetState
Sets the attribute field that is used instead of the element name when filtering with a regular expression

Specified by:
setSearchAttribute in interface SubsetState
Parameters:
searchAttribute - field used for filtering

getPaths

public final java.lang.String[] getPaths(Element element)
Description copied from interface: SubsetState
Returns all paths for the given Element or null, if no paths were defined. An element path consists of a comma separated list of element ids. Since an element can be referenced several times, multiple paths are possible.

Specified by:
getPaths in interface SubsetState
Parameters:
element - a visible element
Returns:
all existing element paths or null

addPath

public final void addPath(Element element,
                          java.lang.String path)
Description copied from interface: SubsetState
Adds the specified path for the given visible element

Specified by:
addPath in interface SubsetState
Parameters:
element - a visible element
path - a path to the visible element

removePath

public final void removePath(Element element,
                             java.lang.String path)
Description copied from interface: SubsetState
Removes the specified path for the given visible element.

Specified by:
removePath in interface SubsetState
Parameters:
element - a visible element
path - the path to remove

containsPath

public final boolean containsPath(Element element,
                                  java.lang.String path)
Description copied from interface: SubsetState
Checks if this SubsetState contains the specified path for the given Element

Specified by:
containsPath in interface SubsetState
Parameters:
element - a visible element
path - a valid path to the visible element
Returns:
true if the path is known for the given element, false otherwise

getPositions

public final int[] getPositions(Element element)
Description copied from interface: SubsetState
Returns the positions of the given visible element. This is useful if subset defines no hierarchy but contains same element several times.

Specified by:
getPositions in interface SubsetState
Parameters:
element - a visible element
Returns:
its positions

isVisible

public final boolean isVisible(Element element)
Description copied from interface: SubsetState
Checks if the given Element is visible within this SubsetState.

Specified by:
isVisible in interface SubsetState
Parameters:
element - the Element to check
Returns:
true if it is visible, false otherwise