Package org.ametys.runtime.model.type
Class DataContext
- java.lang.Object
-
- org.ametys.runtime.model.type.DataContext
-
- Direct Known Subclasses:
RepositoryDataContext
public class DataContext extends Object
Object that gives some context for data manipulation
-
-
Field Summary
Fields Modifier and Type Field Description private List<String>
_dataPath
private List<String>
_fullDataPath
private Locale
_locale
private Optional<String>
_objectId
private boolean
_renderEmptyValues
private Optional<String>
_rootObjectId
-
Constructor Summary
Constructors Modifier Constructor Description protected
DataContext()
Creates a new instance of aDataContext
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_cloneContextData(DataContext context)
Clone the data of the current context in the given oneDataContext
addSegmentToDataPath(String segment)
Add a segment to the data pathDataContext
addSuffixToLastSegment(String suffix)
Add a suffix to the last segment of the data pathDataContext
cloneContext()
Creates a new instance of aDataContext
, with the current context valuesString
getDataPath()
Retrieves the data pathString
getFullDataPath()
Retrieves the full data pathLocale
getLocale()
Retrieves the locale to use for localized dataOptional<String>
getObjectId()
Retrieves the identifier of the object from which the data path is computedOptional<String>
getRootObjectId()
Retrieves the identifier of the object from which the full data path is computedstatic DataContext
newInstance()
Creates a new instance of aDataContext
boolean
renderEmptyValues()
Determines if the empty values have to be renderedDataContext
withDataPath(String dataPath)
Sets the data pathDataContext
withEmptyValues(boolean renderEmptyValues)
Set tofalse
to not render empty values (default totrue
)DataContext
withFullDataPath(String fullDataPath)
Sets the full data pathDataContext
withLocale(Locale locale)
Sets the locale to use for localized data.DataContext
withObjectId(String objectId)
Set the identifier of the object from which the data path is computedDataContext
withRootObjectId(String rootObjectId)
Set the identifier of the object from which the full data path is computed
-
-
-
Field Detail
-
_fullDataPath
private List<String> _fullDataPath
-
_rootObjectId
private Optional<String> _rootObjectId
-
_renderEmptyValues
private boolean _renderEmptyValues
-
-
Constructor Detail
-
DataContext
protected DataContext()
Creates a new instance of aDataContext
-
-
Method Detail
-
newInstance
public static DataContext newInstance()
Creates a new instance of aDataContext
- Returns:
- the created instance
-
cloneContext
public DataContext cloneContext()
Creates a new instance of aDataContext
, with the current context values- Returns:
- the created instance
-
_cloneContextData
protected void _cloneContextData(DataContext context)
Clone the data of the current context in the given one- Parameters:
context
- the clone
-
getLocale
public Locale getLocale()
Retrieves the locale to use for localized data- Returns:
- the locale, or null if no local has been set
-
withLocale
public DataContext withLocale(Locale locale)
Sets the locale to use for localized data. Do not setLocale
to use all existing ones.- Parameters:
locale
- the locale to set- Returns:
- the current
DataContext
-
getDataPath
public String getDataPath()
Retrieves the data path- Returns:
- the dataPath
-
withDataPath
public DataContext withDataPath(String dataPath)
Sets the data path- Parameters:
dataPath
- the data path to set- Returns:
- the current
DataContext
-
getFullDataPath
public String getFullDataPath()
Retrieves the full data path- Returns:
- the fullDataPath
-
withFullDataPath
public DataContext withFullDataPath(String fullDataPath)
Sets the full data path- Parameters:
fullDataPath
- the full data path to set- Returns:
- the current
DataContext
-
addSegmentToDataPath
public DataContext addSegmentToDataPath(String segment)
Add a segment to the data path- Parameters:
segment
- the segment to add to the data path- Returns:
- the current
DataContext
-
addSuffixToLastSegment
public DataContext addSuffixToLastSegment(String suffix)
Add a suffix to the last segment of the data path- Parameters:
suffix
- the suffix to add to the last segment- Returns:
- the current
DataContext
-
getObjectId
public Optional<String> getObjectId()
Retrieves the identifier of the object from which the data path is computed- Returns:
- the object identifier
-
withObjectId
public DataContext withObjectId(String objectId)
Set the identifier of the object from which the data path is computed- Parameters:
objectId
- the object identifier to set- Returns:
- the current
DataContext
-
getRootObjectId
public Optional<String> getRootObjectId()
Retrieves the identifier of the object from which the full data path is computed- Returns:
- the root object identifier
-
withRootObjectId
public DataContext withRootObjectId(String rootObjectId)
Set the identifier of the object from which the full data path is computed- Parameters:
rootObjectId
- the root object identifier to set- Returns:
- the current
DataContext
-
renderEmptyValues
public boolean renderEmptyValues()
Determines if the empty values have to be rendered- Returns:
true
if empty values must be rendered (default),false
otherwise
-
withEmptyValues
public DataContext withEmptyValues(boolean renderEmptyValues)
Set tofalse
to not render empty values (default totrue
)- Parameters:
renderEmptyValues
-true
to render the empty values,false
otherwise- Returns:
- the current
DataContext
-
-