com.flexive.shared.content
Class FxGroupData

java.lang.Object
  extended by com.flexive.shared.content.FxData
      extended by com.flexive.shared.content.FxGroupData
All Implemented Interfaces:
java.io.Serializable

public class FxGroupData
extends FxData

FxData extension for groups

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.flexive.shared.content.FxData
indices, POSITION_BOTTOM, POSITION_TOP, xp, XPathFull, xpPrefix
 
Constructor Summary
FxGroupData(java.lang.String xpPrefix, java.lang.String alias, int index, java.lang.String xPath, java.lang.String xPathFull, int[] indices, long assignmentId, FxMultiplicity assignmentMultiplicity, int pos, FxGroupData parent, java.util.List<FxData> data, boolean systemInternal)
           
 
Method Summary
 FxData addChild(FxData child)
          Add a child FxData at the correct position
 FxData addEmptyChild(java.lang.String xPath, int pos)
          Add an and FxData entry with the given XPath to this group (must be a direct child of this group, no nesting allowed!).
 void addGroup(java.lang.String xPath, FxGroupAssignment fxGroupAssignment, int pos)
          Add a group entry at the given XPath.
 void addProperty(java.lang.String xPath, FxPropertyAssignment assignment, FxValue value, int pos)
          Add a property at the given XPath location, removing eventually existing properties.
protected  void applyIndices()
          Apply the multiplicity to XPath and children if its a group
 void compactPositions(boolean includeSubGroups)
          Synchronize positions closing gaps optionally including sub groups
 FxData containsChild(XPathElement check)
          Check if a child with the same alias and multiplicity that is not empty exists.
protected  FxGroupData copy(FxGroupData parent)
          Create an independent copy of this group or property FxData
static FxGroupData createVirtualRootGroup(java.lang.String xpPrefix)
          Helper to create a virtual root group
 void explode(boolean explodeChildGroups)
          "Explode" this group by adding all createable assignments at the bottom
 void fixChildIndices()
          'Fix' the indices of children after they have been added to reflect the parent groups index in their XPath
 java.util.List<FxData> getChildren()
          Get all child entries for this group
 java.util.List<java.lang.String> getCreateableChildren(boolean includeExisting)
          Get a list of child FxData instances (as XPath with full indices) that can be created as children for this group.
 FxGroupData getGroup(java.lang.String xPath)
          Get the group denoted by the given XPath
 java.util.List<FxPropertyData> getPropertyData(long propertyId, boolean includeEmpty)
          Get a list of all FxPropertyData entries that are assigned to propertyId
protected  java.util.List<FxReference> getReferences(boolean includeSubGroups)
          Get a list of all FxReference values in this group and optionally all sub groups
 boolean isEmpty()
          Is this data empty?
 boolean isGroup()
          Is this FxData a property or group?
 boolean isProperty()
          Is this FxData a property or group?
 boolean isRootGroup()
          Is this group the root group?
 void moveChild(XPathElement xp, int delta)
          Move a child element identified by its alias and multiplicity by delta positions within this group If delta is Integer.MAX_VALUE the data will always be placed at the bottom, Integer.MIN_VALUE will always place it at the top.
 void removeChild(FxData data)
          Remove the requested child data and compact indices and positions
 void removeEmptyEntries()
          Remove all empty entries of this group that are not required
 void removeEmptyEntries(boolean includeRequired)
          Remove all empty entries of this group
 void replaceChild(XPathElement xpath, FxData data)
           
 
Methods inherited from class com.flexive.shared.content.FxData
compact, createNew, equals, getAlias, getAssignment, getAssignmentId, getAssignmentMultiplicity, getCreateableElements, getElements, getIndex, getIndices, getOccurances, getParent, getPos, getRemoveableElements, getXPath, getXPathElement, getXPathFull, getXPathPrefix, hashCode, isRemoveable, isSystemInternal, mayCreateMore, setPos, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FxGroupData

public FxGroupData(java.lang.String xpPrefix,
                   java.lang.String alias,
                   int index,
                   java.lang.String xPath,
                   java.lang.String xPathFull,
                   int[] indices,
                   long assignmentId,
                   FxMultiplicity assignmentMultiplicity,
                   int pos,
                   FxGroupData parent,
                   java.util.List<FxData> data,
                   boolean systemInternal)
            throws FxInvalidParameterException
Throws:
FxInvalidParameterException
Method Detail

isProperty

public boolean isProperty()
Is this FxData a property or group?

Specified by:
isProperty in class FxData
Returns:
if this FxData is a property or group

isGroup

public boolean isGroup()
Is this FxData a property or group?

Specified by:
isGroup in class FxData
Returns:
if this FxData is a property or group

getChildren

public java.util.List<FxData> getChildren()
Get all child entries for this group

Returns:
child entries

isEmpty

public boolean isEmpty()
Is this data empty?

Specified by:
isEmpty in class FxData
Returns:
empty

createVirtualRootGroup

public static FxGroupData createVirtualRootGroup(java.lang.String xpPrefix)
                                          throws FxInvalidParameterException
Helper to create a virtual root group

Parameters:
xpPrefix - XPath prefix like "FxType name[@pk=..]"
Returns:
virtual root group
Throws:
FxInvalidParameterException - on errors

moveChild

public void moveChild(XPathElement xp,
                      int delta)
Move a child element identified by its alias and multiplicity by delta positions within this group If delta is Integer.MAX_VALUE the data will always be placed at the bottom, Integer.MIN_VALUE will always place it at the top.

Parameters:
xp - element to move
delta - delta positions to move

addChild

public FxData addChild(FxData child)
Add a child FxData at the correct position

Parameters:
child - FxData to add
Returns:
the child

addEmptyChild

public FxData addEmptyChild(java.lang.String xPath,
                            int pos)
                     throws FxInvalidParameterException,
                            FxNoAccessException,
                            FxNotFoundException,
                            FxCreateException
Add an and FxData entry with the given XPath to this group (must be a direct child of this group, no nesting allowed!). Empty groups consist of empty but preinitialized elements!

Parameters:
xPath - XPath to add to this group (must be a direct child of this group, no nesting allowed!)
pos - position in same hierarchy level
Returns:
the added data element
Throws:
FxInvalidParameterException - on errors
FxNoAccessException - on errors
FxNotFoundException - on errors
FxCreateException - on errors

applyIndices

protected void applyIndices()
Apply the multiplicity to XPath and children if its a group

Specified by:
applyIndices in class FxData

fixChildIndices

public void fixChildIndices()
'Fix' the indices of children after they have been added to reflect the parent groups index in their XPath


removeEmptyEntries

public void removeEmptyEntries()
Remove all empty entries of this group that are not required

See Also:
removeEmptyEntries(boolean)

removeEmptyEntries

public void removeEmptyEntries(boolean includeRequired)
Remove all empty entries of this group

Parameters:
includeRequired - include entries that are required?

compactPositions

public void compactPositions(boolean includeSubGroups)
Synchronize positions closing gaps optionally including sub groups

Parameters:
includeSubGroups - close gaps for subgroups as well?

isRootGroup

public boolean isRootGroup()
Is this group the root group?

Returns:
if this group is the root group

getGroup

public FxGroupData getGroup(java.lang.String xPath)
                     throws FxNotFoundException,
                            FxInvalidParameterException
Get the group denoted by the given XPath

Parameters:
xPath - requested XPath for the group
Returns:
FxGroupData
Throws:
FxNotFoundException - if no group with this XPath is found
FxInvalidParameterException - if the XPath is invalid

addProperty

public void addProperty(java.lang.String xPath,
                        FxPropertyAssignment assignment,
                        FxValue value,
                        int pos)
                 throws FxInvalidParameterException,
                        FxNotFoundException
Add a property at the given XPath location, removing eventually existing properties. The group for this property has to exist already!

Parameters:
xPath - requested XPath
assignment - assignment of the property
value - value
pos - position
Throws:
FxInvalidParameterException - if the XPath is invalid
FxNotFoundException - if the parent group does not exist

containsChild

public FxData containsChild(XPathElement check)
Check if a child with the same alias and multiplicity that is not empty exists. No elements of subgroups are checked, just direct childs!

Parameters:
check - XPathElement to check
Returns:
FxData or null

replaceChild

public void replaceChild(XPathElement xpath,
                         FxData data)

addGroup

public void addGroup(java.lang.String xPath,
                     FxGroupAssignment fxGroupAssignment,
                     int pos)
              throws FxInvalidParameterException,
                     FxNotFoundException,
                     FxCreateException
Add a group entry at the given XPath. Existing entries will stay untouched but position adjusted. If parent groups of this group do not exist, they will be created as well.

Parameters:
xPath - requested XPath
fxGroupAssignment - the assignment of the group
pos - position
Throws:
FxInvalidParameterException - on errors
FxNotFoundException - on errors
FxCreateException - on errors

removeChild

public void removeChild(FxData data)
                 throws FxInvalidParameterException,
                        FxNoAccessException
Remove the requested child data and compact indices and positions

Parameters:
data - FxData to remove
Throws:
FxInvalidParameterException - on errors
FxNoAccessException - on errors

explode

public void explode(boolean explodeChildGroups)
"Explode" this group by adding all createable assignments at the bottom

Parameters:
explodeChildGroups - recursively explode all existing child groups?

getCreateableChildren

public java.util.List<java.lang.String> getCreateableChildren(boolean includeExisting)
Get a list of child FxData instances (as XPath with full indices) that can be created as children for this group. Readonly or no access properties or groups will not be returned!

Parameters:
includeExisting - include entries for children that already exist but with a new (higher) multiplicity?
Returns:
List of XPaths

copy

protected FxGroupData copy(FxGroupData parent)
Create an independent copy of this group or property FxData

Specified by:
copy in class FxData
Parameters:
parent - parent group
Returns:
independent copy

getReferences

protected java.util.List<FxReference> getReferences(boolean includeSubGroups)
Get a list of all FxReference values in this group and optionally all sub groups

Parameters:
includeSubGroups - collect FxReferences from sub groups as well?
Returns:
list of all FxReference values in this group and optionally all sub groups

getPropertyData

public java.util.List<FxPropertyData> getPropertyData(long propertyId,
                                                      boolean includeEmpty)
Get a list of all FxPropertyData entries that are assigned to propertyId

Parameters:
propertyId - the property id requested
includeEmpty - include empty data instances?
Returns:
list of all FxPropertyData entries that are assigned to propertyId