Interface Repeater
- All Known Subinterfaces:
IndexableRepeater
,ModelAwareRepeater
,ModifiableIndexableRepeater
,ModifiableModelAwareRepeater
,ModifiableRepeater
- All Known Implementing Classes:
DefaultModelAwareRepeater
,DefaultModifiableModelAwareRepeater
public interface Repeater
Interface for repeaters
Here is the format of generated SAX events for a given data in a repeater:
<entry name="<entry position>">
<sax events for the given data in the current entry>
<\entry>
...
Here is the format of JSON object for a given data in a repeater:
{
"entryCount" : <size>,
"entries" : [
{
"position" : <entry position>,
"value" : <value of data at given path in current entry>
},
...
]
}
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
copyTo
(ModifiableRepeater repeater) Copies the currentRepeater
to the givenModifiableRepeater
.void
copyTo
(ModifiableRepeater repeater, DataContext context) Copies the currentRepeater
to the givenModifiableRepeater
.dataToJSON
(String dataPath) Convert the data at the given path into a JSON objectdataToJSON
(String dataPath, DataContext context) Convert the data at the given path into a JSON objectdefault void
dataToSAX
(ContentHandler contentHandler, String dataPath) 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, 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 pathList<? extends RepeaterEntry>
Retrieves the repeater entries, sorted by positiongetEntry
(int position) Retrieves the repeater entry at the given position.Retrieves the parent of the currentRepeater
Retrieves the repository data used by thisRepeater
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.boolean
hasToMoveEntries
(Map<Integer, Integer> positionsMapping, int targetSize) Check if has to be moved according to the given position mapping.
-
Method Details
-
getEntries
List<? extends RepeaterEntry> getEntries()Retrieves the repeater entries, sorted by position- Returns:
- the repeater entries
-
getEntry
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)- Parameters:
position
- the position of the entry to retrieve- Returns:
- the repeater entry,
null
if there is no entry at this position
-
getSize
int getSize()Retrieves the size of the repeater- Returns:
- the size of the repeater
-
hasEntry
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)- Parameters:
position
- the position- Returns:
true
if the repeater has an entry at the given position,false
otherwise
-
copyTo
default void copyTo(ModifiableRepeater repeater) throws UndefinedItemPathException, BadItemTypeException Copies the currentRepeater
to the givenModifiableRepeater
.- 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 value
-
copyTo
void copyTo(ModifiableRepeater repeater, DataContext context) throws UndefinedItemPathException, BadItemTypeException Copies the currentRepeater
to the givenModifiableRepeater
.- Parameters:
repeater
- The destination repeater. Can not be null.context
- The context of the data to copy- 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 value
-
dataToSAX
default void dataToSAX(ContentHandler contentHandler, String dataPath) throws SAXException, IOException 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- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventsdataPath
- the path 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
void dataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) throws SAXException, IOException 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- 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
-
dataToJSON
Convert the data at the given path into a JSON object- Parameters:
dataPath
- the path of the data to convert- Returns:
- The value as JSON
- Throws:
IOException
- if an error occurs while reading a value using the I/O API
-
dataToJSON
Convert the data at the given path into a JSON object- Parameters:
dataPath
- the path of the data to convertcontext
- The context of the data to convert- Returns:
- The value as JSON
- Throws:
IOException
- if an error occurs while reading a value using the I/O API
-
hasToMoveEntries
Check if has to be moved according to the given position mapping. The given position mapping's key is the previous position and the value is the new one The existent entries with no corresponding entry in the position mapping should be removed the given size is taken into account to create new empty entries if needed- Parameters:
positionsMapping
- the position mappingtargetSize
- the target size of the repeater- Returns:
true
if some entries have moved,false
otherwise
-
getRepositoryData
Retrieves the repository data used by thisRepeater
- Returns:
- the repository data used by this
Repeater
-
getParentDataHolder
Retrieves the parent of the currentRepeater
- Returns:
- the parent of the current
Repeater
-
getRootDataHolder
Retrieves the rootDataHolder
of the current repeater- Returns:
- the root
DataHolder
-