Class ContentHolder
- Direct Known Subclasses:
ContentHolderForInput,ContentHolderForOutput
A ContentHolder should be placed in a Data Transfer Object (DTO)
like the following:
public class CityDTO {
@Table(
dataModel = "urn:ebx:module:cities-module:/WEB-INF/ebx/schemas/person.xsd",
tablePath = "/root/Person")
public ContentHolder person;
}
This same DTO is usable as an argument of REST operations
or as a response object. When used as an argument,
the ContentHolder will be automatically created
(an ContentHolderForInput instance) and supplied
with the appropriate part of information coming from the HTTP request.
When used as a response, a ContentHolder must be created through the
ContentHolderForOutput.createForRecord(com.onwbp.adaptation.Adaptation)
method, providing the wished
table record,
and returned.
A JSON format, for a given ContentHolder, can be described by using
the ExtendedOutput annotation.
Two formats are available:
- the compact format: used by default when no annotation is present over the DTO field.
-
the extended format:
which has multiple levels of configuration using different options from
Include. This format can be activated by adding aExtendedOutputannotation to the DTO field.
- Since:
- 6.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionabstract ContentHolderForInputUnwraps thisContentHolderto get aContentHolderForInputif it has been instantiated as so.abstract ObjectReturns the value of the specified path.final Objectget(SchemaNode aNode) Returns the value of the local absolute path of specified node.final booleangetBoolean(Path aPath) Returns thebooleanvalue of the path specified, orfalseif no value is defined.final DateReturns theDatevalue of the path specified, ornullif no value is defined.final intReturns theintvalue of the specified path, or0if no value is defined.final <T> List<T>Returns theListvalue of the specified path, or an emptyArrayListif no value is defined.final StringReturns theStringvalue of the specified path ornullif no value is defined.abstract booleanReturnstrueif this content holder is for input,falseotherwise.
-
Method Details
-
isForInput
public abstract boolean isForInput()Returnstrueif this content holder is for input,falseotherwise. -
asContentHolderForInput
Unwraps thisContentHolderto get aContentHolderForInputif it has been instantiated as so.- Returns:
- the unwrapped
ContentHolderForInput. - Throws:
IllegalStateException- if thisContentHolderhas not been instantiated for input.
-
get
Returns the value of the specified path.The resolution of the value is done according to the following rules:
- If the specified node is a function, always returns the evaluation of the function.
- If the target node specifies a specific
osd:inheritanceinheritance property, returns the locally defined value if a local value is defined (or "overwritten"/null); if no local value is defined, looks up the first locally defined value, according to theosd:inheritanceproperties. - Otherwise, the default inheritance mechanism is used:
if the value is locally defined, it is returned (it can be
null); otherwise, looks up the first locally defined value according to the built-in child-to-parent relationship of datasets; if no locally defined value is found, the data model default value is returned (nullis returned if the data model does not define a default value).
Access and mapping rules:
The access and mapping rules between XML Schema and Java are described in the chapter Mapping to Java.
- Throws:
PathAccessException- ifaPathdoes not refer to an existing node in the underlying type tree structure, or the specified node is above a terminal node.- See Also:
-
get
Returns the value of the local absolute path of specified node.- Throws:
IllegalArgumentException-- if the specified node does not belong to the data model of the current content.
- if the current content is a table record and the specified node is not in the same table as the one of the current record.
- if the current content is a dataset and the specified node is a table record node.
- See Also:
-
getString
Returns theStringvalue of the specified path ornullif no value is defined.- Throws:
PathAccessException- ifaPathdoes not refer to an existing node in the underlying type tree structure.ClassCastException- if the value of the node is not aString, that is, the underlying type node is not an XML Schemastringtype.- See Also:
-
getInt
Returns theintvalue of the specified path, or0if no value is defined.- Throws:
PathAccessException- ifaPathdoes not refer to an existing node in the underlying type tree structure.ClassCastException- if the value of the node is not anint, that is, the underlying type node is not an XML Schemaintegertype.- See Also:
-
getBoolean
Returns thebooleanvalue of the path specified, orfalseif no value is defined.- Throws:
PathAccessException- ifaPathdoes not refer to an existing node in the underlying type tree structure.ClassCastException- if the value of the node is not aboolean, that is, the underlying type node is not an XML Schemabooleantype.- See Also:
-
getDate
Returns theDatevalue of the path specified, ornullif no value is defined.The mapping rules of the types
xs:dateandxs:timehave some particularities that are described in Mapping to Java.- Throws:
PathAccessException- ifaPathdoes not refer to an existing node in the underlying type tree structure.ClassCastException- if the value of the node is not aDate, that is, the underlying type node is not an XML Schemadatetype.- See Also:
-
getList
Returns theListvalue of the specified path, or an emptyArrayListif no value is defined.A node contains a
Listwhen, in the XML Schema, the corresponding node has been declared withmaxOccurs > 1. The complete access and mapping rules between XML Schema and Java are described in the chapter Mapping to Java.- Throws:
PathAccessException- ifaPathdoes not refer to an existing node in the underlying type tree structure.ClassCastException- if the value of the node is not aList, that is, the underlying type node does not havemaxOccurs > 1in XML Schema.- See Also:
-