public final class DataHolderHelper extends Object
Modifier | Constructor and Description |
---|---|
private |
DataHolderHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
copyDataHolder(DataHolder source,
ModifiableDataHolder destination)
Copies the source
DataHolder to the given ModifiableDataHolder destination. |
static void |
dataHolderToSAX(DataHolder dataHolder,
ContentHandler contentHandler,
Locale locale)
Generates SAX events for the given
DataHolder |
static void |
dataHolderValueToSAX(DataHolder dataHolder,
ContentHandler contentHandler,
String dataPath,
String tagName,
Locale locale)
Generates SAX events for the data at the given data path in the given
DataHolder
Do not generate any event if there is no values at the given path |
static String |
getDefinitionPathFromDataPath(String dataPath)
Retrieves the given dataPath as a definition path (without the repeaterEntry positions)
|
static ModelItem |
getModelItem(String path,
Collection<? extends ModelItemContainer> itemContainers)
Retrieves the model item at the given relative path
|
static RepeaterEntry |
getRepeaterEntry(DataHolder dataHolder,
String repeaterName,
int entryPosition)
Retrieves the repeater entry represented by the given path segment
|
static Pair<String,Integer> |
getRepeaterNameAndEntryPosition(String pathSegment)
Retrieves the pair of repeater name and entry position of the given path segment
Return
null if the given path does not represent a repeater entry |
static boolean |
hasModelItem(String path,
Collection<? extends ModelItemContainer> itemContainers)
Checks if there is a model item at the given relative path
|
static boolean |
isRepeaterEntryPath(String path)
Test if the path is a repeater entry path (for example entries[1])
|
private DataHolderHelper()
public static boolean hasModelItem(String path, Collection<? extends ModelItemContainer> itemContainers)
path
- path of the model item. This path is relative to the given containers. No matter if it is a definition or data path (with repeater entry positions)itemContainers
- model item containers where to search if there is a model itemtrue
if there is model item at this path, false
otherwisepublic static ModelItem getModelItem(String path, Collection<? extends ModelItemContainer> itemContainers) throws IllegalArgumentException, UndefinedItemPathException
path
- path of the model item to retrieve. This path is relative to the given containers. No matter if it is a definition or data path (with repeater entry positions)itemContainers
- model item containers where to search the model itemIllegalArgumentException
- if the given path is null or emptyUndefinedItemPathException
- if there is no item defined at the given path in given item containerspublic static String getDefinitionPathFromDataPath(String dataPath)
dataPath
- the data pathpublic static RepeaterEntry getRepeaterEntry(DataHolder dataHolder, String repeaterName, int entryPosition) throws BadItemTypeException
dataHolder
- data holder that contains the repeater entry. The data holder must be the direct parent of the repeaterrepeaterName
- the name of the repeaterentryPosition
- the position of the entryBadItemTypeException
- if the value stored in the repository for the given repeater name is not a repeaterpublic static boolean isRepeaterEntryPath(String path)
path
- the path representing the repeater entrypublic static Pair<String,Integer> getRepeaterNameAndEntryPosition(String pathSegment)
null
if the given path does not represent a repeater entrypathSegment
- the path segment representing the repeater entrypublic static void copyDataHolder(DataHolder source, ModifiableDataHolder destination)
DataHolder
to the given ModifiableDataHolder
destination.source
- the source DataHolder
destination
- the ModifiableDataHolder
destinationpublic static void dataHolderToSAX(DataHolder dataHolder, ContentHandler contentHandler, Locale locale) throws SAXException
DataHolder
dataHolder
- the DataHolder
to SAXcontentHandler
- the ContentHandler
that will receive the SAX eventslocale
- The locale to use for localized data, such as MultilingualString
. Can be null
to generate SAX events for all existing Locale
s.SAXException
- if an error occurs during the SAX events generationpublic static void dataHolderValueToSAX(DataHolder dataHolder, ContentHandler contentHandler, String dataPath, String tagName, Locale locale) throws SAXException
DataHolder
Do not generate any event if there is no values at the given pathdataHolder
- the DataHolder
containing the value to SAXcontentHandler
- the ContentHandler
that will receive the SAX eventsdataPath
- the path of the data to SAXtagName
- the tag name of the SAX event to generate. If null
the name of the data is usedlocale
- The locale to use for localized data, such as MultilingualString
. Can be null
to generate SAX events for all existing Locale
s.SAXException
- if an error occurs during the SAX events generation