public abstract class ContentHolder extends Object
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:
Include
. This format
can be activated by adding a ExtendedOutput
annotation to the DTO field.
Table
Modifier and Type | Method and Description |
---|---|
abstract ContentHolderForInput |
asContentHolderForInput()
Unwraps this
ContentHolder to get a ContentHolderForInput
if it has been instantiated as so. |
abstract Object |
get(Path aPath)
Returns the value of the specified path.
|
Object |
get(SchemaNode aNode)
Returns the value of the local absolute path of specified node.
|
boolean |
getBoolean(Path aPath)
Returns the
boolean value of the path specified, or false
if no value is defined. |
Date |
getDate(Path aPath)
Returns the
Date value of the path specified, or null if
no value is defined. |
int |
getInt(Path aPath)
Returns the
int value of the specified path, or 0 if no
value is defined. |
<T> List<T> |
getList(Path aPath)
Returns the
List value of the specified path, or an empty
ArrayList if no value is defined. |
String |
getString(Path aPath)
Returns the
String value of the specified path or null if
no value is defined. |
abstract boolean |
isForInput()
Returns
true if this content holder is for input, false otherwise. |
public abstract boolean isForInput()
true
if this content holder is for input, false
otherwise.public abstract ContentHolderForInput asContentHolderForInput()
ContentHolder
to get a ContentHolderForInput
if it has been instantiated as so.ContentHolderForInput
.IllegalStateException
- if this ContentHolder
has not been instantiated for input.public abstract Object get(Path aPath) throws PathAccessException
The resolution of the value is done according to the following rules:
osd:inheritance
inheritance 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 the osd:inheritance
properties.
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 (null
is 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.
PathAccessException
- if aPath
does not refer to an existing node in the underlying
type tree structure, or the specified node is above a terminal node.Adaptation
,
Adaptation.get(Path)
public final Object get(SchemaNode aNode)
IllegalArgumentException
- get(Path)
,
SchemaNode.getPathInAdaptation()
public final String getString(Path aPath) throws PathAccessException
String
value of the specified path or null
if
no value is defined.PathAccessException
- if aPath
does not refer to an existing node in the underlying
type tree structure.ClassCastException
- if the value of the node is not a String
, that is, the underlying type
node is not an XML Schema string
type.get(Path)
public final int getInt(Path aPath) throws PathAccessException
int
value of the specified path, or 0
if no
value is defined.PathAccessException
- if aPath
does not refer to an existing node in the underlying
type tree structure.ClassCastException
- if the value of the node is not an int
, that is, the underlying type
node is not an XML Schema integer
type.get(Path)
public final boolean getBoolean(Path aPath) throws PathAccessException
boolean
value of the path specified, or false
if no value is defined.PathAccessException
- if aPath
does not refer to an existing node in the underlying
type tree structure.ClassCastException
- if the value of the node is not a boolean
, that is,
the underlying type node is not an XML Schema boolean
type.get(Path)
public final Date getDate(Path aPath) throws PathAccessException
Date
value of the path specified, or null
if
no value is defined.
The mapping rules of the types xs:date
and xs:time
have some particularities that are described in
Mapping to Java.
PathAccessException
- if aPath
does not refer to an existing node in the underlying
type tree structure.ClassCastException
- if the value of the node is not a Date
, that is, the underlying type
node is not an XML Schema date
type.get(Path)
public final <T> List<T> getList(Path aPath) throws PathAccessException
List
value of the specified path, or an empty
ArrayList
if no value is defined.
A node contains a List
when, in the XML Schema, the corresponding node
has been declared with maxOccurs > 1
.
The complete access and mapping rules between XML Schema and Java are described in the chapter
Mapping to Java.
PathAccessException
- if aPath
does not refer to an existing node in the underlying
type tree structure.ClassCastException
- if the value of the node is not a List
, that is, the underlying type
node does not have maxOccurs > 1
in XML Schema.get(Path)