Class ModelAwareRepeater
- java.lang.Object
-
- org.ametys.plugins.repository.data.holder.group.impl.ModelAwareRepeater
-
- All Implemented Interfaces:
Repeater
- Direct Known Subclasses:
ModifiableModelAwareRepeater
public class ModelAwareRepeater extends Object implements Repeater
Class for model aware repeaters
-
-
Field Summary
Fields Modifier and Type Field Description protected RepeaterDefinition
_definition
Definition of this repeaterprotected ModelAwareDataHolder
_parent
Parent of the currentRepeater
protected RepositoryData
_repositoryData
Repository data to use to store entries in the repositoryprotected ModelAwareDataHolder
_root
RootDataHolder
-
Constructor Summary
Constructors Constructor Description ModelAwareRepeater(RepositoryData repositoryData, ModelAwareDataHolder parent, ModelAwareDataHolder root, RepeaterDefinition definition)
Creates a model aware repeater
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Attributes
_getEntryAttributes(ModelAwareRepeaterEntry entry)
void
commentsToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor)
Generates SAX events for the comments of the data in the given view in the currentDataHolder
void
copyTo(ModifiableRepeater repeater)
Copies the currentRepeater
to the givenModifiableRepeater
.void
dataToSAX(ContentHandler contentHandler)
Generates SAX events for the data in the model of the currentDataHolder
void
dataToSAX(ContentHandler contentHandler, String dataPath, DataContext context)
Generates SAX events for the data at the given data path in the currentDataHolder
Do not generate any event if there is no values at the given pathvoid
dataToSAX(ContentHandler contentHandler, DataContext context)
Generates SAX events for the data in the model of the currentDataHolder
void
dataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor)
Generates SAX events for the data in the given view in the currentRepeater
void
dataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context)
Generates SAX events for the data in the given view in the currentRepeater
List<? extends ModelAwareRepeaterEntry>
getEntries()
Retrieves the repeater entries, sorted by positionModelAwareRepeaterEntry
getEntry(int position)
Retrieves the repeater entry at the given position.RepeaterDefinition
getModel()
Retrieves the repeater's modelModelAwareDataHolder
getParentDataHolder()
Retrieves the parent of the currentRepeater
RepositoryData
getRepositoryData()
Retrieves the repository data used by thisRepeater
ModelAwareDataHolder
getRootDataHolder()
Retrieves the rootDataHolder
of the current repeaterint
getSize()
Retrieves the size of the repeaterboolean
hasEntry(int position)
Determines if the repeater has an entry at the given position.
-
-
-
Field Detail
-
_definition
protected RepeaterDefinition _definition
Definition of this repeater
-
_parent
protected ModelAwareDataHolder _parent
Parent of the currentRepeater
-
_root
protected ModelAwareDataHolder _root
RootDataHolder
-
_repositoryData
protected RepositoryData _repositoryData
Repository data to use to store entries in the repository
-
-
Constructor Detail
-
ModelAwareRepeater
public ModelAwareRepeater(RepositoryData repositoryData, ModelAwareDataHolder parent, ModelAwareDataHolder root, RepeaterDefinition definition)
Creates a model aware repeater- Parameters:
repositoryData
- the repository data of the repeaterparent
- the parent of the createdRepeater
root
- the rootDataHolder
definition
- the definition of the repeater
-
-
Method Detail
-
getEntries
public List<? extends ModelAwareRepeaterEntry> getEntries()
Description copied from interface:Repeater
Retrieves the repeater entries, sorted by position- Specified by:
getEntries
in interfaceRepeater
- Returns:
- the repeater entries
-
getEntry
public ModelAwareRepeaterEntry getEntry(int position)
Description copied from interface:Repeater
Retrieves the repeater entry at the given position. The position starts at index 1. The position can be an integer between 1 and the repeater size to get an entry from the beginning Or the position can an integer between 0 and - the repeater size to get an entry from the end (0 means at the end, -1 means before the last one and so on)
-
getSize
public int getSize()
Description copied from interface:Repeater
Retrieves the size of the repeater
-
hasEntry
public boolean hasEntry(int position)
Description copied from interface:Repeater
Determines if the repeater has an entry at the given position. The position starts at index 1. The position can be an integer between 1 and the repeater size to get an entry from the beginning Or the position can an integer between 0 and - the repeater size to get an entry from the end (0 means at the end, -1 means before the last one and so on)
-
getModel
public RepeaterDefinition getModel()
Retrieves the repeater's model- Returns:
- the repeater's model
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) throws SAXException, IOException
Description copied from interface:Repeater
Generates SAX events for the data at the given data path in the currentDataHolder
Do not generate any event if there is no values at the given path- Specified by:
dataToSAX
in interfaceRepeater
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventsdataPath
- the path of the data to SAXcontext
- The context of the data to SAX- Throws:
SAXException
- if an error occurs during the SAX events generationIOException
- if an error occurs while reading a value using the I/O API
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the model of the currentDataHolder
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX events- Throws:
SAXException
- if an error occurs during the SAX events generationIOException
- if an error occurs while reading a value using the I/O APIBadItemTypeException
- if the saxed value's type does not matches the stored data
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, DataContext context) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the model of the currentDataHolder
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventscontext
- The context of the data to SAX- Throws:
SAXException
- if an error occurs during the SAX events generationIOException
- if an error occurs while reading a value using the I/O APIBadItemTypeException
- if the saxed value's type does not matches the stored data
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the given view in the currentRepeater
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventsviewItemAccessor
- theViewItemAccessor
referencing the items for which generate SAX events- Throws:
SAXException
- if an error occurs during the SAX events generationIOException
- if an error occurs while reading a value using the I/O APIBadItemTypeException
- if the saxed value's type does not matches the stored data
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the given view in the currentRepeater
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventsviewItemAccessor
- theViewItemAccessor
referencing the items for which generate SAX eventscontext
- The context of the data to SAX- Throws:
SAXException
- if an error occurs during the SAX events generationIOException
- if an error occurs while reading a value using the I/O APIBadItemTypeException
- if the saxed value's type does not matches the stored data
-
_getEntryAttributes
private Attributes _getEntryAttributes(ModelAwareRepeaterEntry entry)
-
commentsToSAX
public void commentsToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor) throws SAXException
Generates SAX events for the comments of the data in the given view in the currentDataHolder
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventsviewItemAccessor
- theViewItemAccessor
referencing the items for which generate SAX events- Throws:
SAXException
- if an error occurs during the SAX events generation
-
copyTo
public void copyTo(ModifiableRepeater repeater) throws UndefinedItemPathException, BadItemTypeException, UnknownTypeException, NotUniqueTypeException
Description copied from interface:Repeater
Copies the currentRepeater
to the givenModifiableRepeater
.- Specified by:
copyTo
in interfaceRepeater
- Parameters:
repeater
- The destination repeater. Can not be null.- Throws:
UndefinedItemPathException
- if one of the copied data is not defined by the model of the destinationModifiableModelAwareRepeater
BadItemTypeException
- if the type defined by the model of the destinationModifiableModelAwareRepeater
doesn't match the copied valueUnknownTypeException
NotUniqueTypeException
-
getRepositoryData
public RepositoryData getRepositoryData()
Description copied from interface:Repeater
Retrieves the repository data used by thisRepeater
- Specified by:
getRepositoryData
in interfaceRepeater
- Returns:
- the repository data used by this
Repeater
-
getParentDataHolder
public ModelAwareDataHolder getParentDataHolder()
Description copied from interface:Repeater
Retrieves the parent of the currentRepeater
- Specified by:
getParentDataHolder
in interfaceRepeater
- Returns:
- the parent of the current
Repeater
-
getRootDataHolder
public ModelAwareDataHolder getRootDataHolder()
Description copied from interface:Repeater
Retrieves the rootDataHolder
of the current repeater- Specified by:
getRootDataHolder
in interfaceRepeater
- Returns:
- the root
DataHolder
-
-