Package org.dd4t.databind.builder.json
Class JsonDataBinder
- java.lang.Object
-
- org.dd4t.databind.builder.BaseDataBinder
-
- org.dd4t.databind.builder.json.JsonDataBinder
-
- All Implemented Interfaces:
org.dd4t.core.databind.DataBinder
public class JsonDataBinder extends BaseDataBinder implements org.dd4t.core.databind.DataBinder
- Since:
- 17/11/14.
- Author:
- R. Kempees
-
-
Field Summary
-
Fields inherited from class org.dd4t.databind.builder.BaseDataBinder
ABSTRACT_OR_INTERFACE_MODELS, concreteComponentImpl, concreteComponentPresentationImpl, concreteComponentTemplateImpl, concreteFieldImpl, converter, renderDefaultComponentModelsOnly, renderDefaultComponentsIfNoModelFound, VIEW_MODELS, viewModelMetaKeyName, viewModelPackageRoot
-
-
Constructor Summary
Constructors Constructor Description JsonDataBinder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends org.dd4t.contentmodel.Component>
TbuildComponent(Object source, Class<T> aClass)<T extends org.dd4t.contentmodel.ComponentPresentation>
TbuildComponentPresentation(String source, Class<T> componentPresentationClass)org.dd4t.contentmodel.ComponentPresentationbuildDynamicComponentPresentation(org.dd4t.contentmodel.ComponentPresentation componentPresentation, Class<? extends org.dd4t.contentmodel.Component> aClass)<T extends org.dd4t.core.databind.BaseViewModel>
TbuildModel(Object source, Class modelClass, String templateUri)<T extends org.dd4t.core.databind.BaseViewModel>
TbuildModel(Object source, String modelName, String templateUri)Map<String,org.dd4t.core.databind.BaseViewModel>buildModels(Object source, Set<String> modelNames, String templateUri)<T extends org.dd4t.contentmodel.Page>
TbuildPage(String source, Class<T> aClass)booleancanDeserialize(String source)To-Do: implement sanity checking that we're given jsonprotected voidconfigureMapper()StringfindComponentTemplateViewName(org.dd4t.contentmodel.ComponentTemplate template)static com.fasterxml.jackson.databind.ObjectMappergetGenericMapper()StringgetRootElementName(Object componentNode)voidinit()-
Methods inherited from class org.dd4t.databind.builder.BaseDataBinder
checkViewModelConfiguration, classHasViewModelDerivatives, getConcreteComponentImpl, getConcreteComponentPresentationImpl, getConcreteComponentTemplateImpl, getConcreteFieldImpl, getConcreteModel, getConverter, getModelOrNullForExistingEntry, getViewModelMetaKeyName, getViewModelPackageRoot, isRenderDefaultComponentModelsOnly, isRenderDefaultComponentsIfNoModelFound, renderDefaultComponentModelsOnly, renderDefaultComponentsIfNoModelFound, scanAndLoadModels, setConcreteComponentImpl, setConcreteComponentPresentationImpl, setConcreteComponentTemplateImpl, setConcreteFieldImpl, setConverter, setRenderDefaultComponentModelsOnly, setRenderDefaultComponentsIfNoModelFound, setViewModelMetaKeyName, setViewModelPackageRoot
-
-
-
-
Method Detail
-
buildPage
public <T extends org.dd4t.contentmodel.Page> T buildPage(String source, Class<T> aClass) throws org.dd4t.core.exceptions.SerializationException
- Specified by:
buildPagein interfaceorg.dd4t.core.databind.DataBinder- Throws:
org.dd4t.core.exceptions.SerializationException
-
buildComponentPresentation
public <T extends org.dd4t.contentmodel.ComponentPresentation> T buildComponentPresentation(String source, Class<T> componentPresentationClass) throws org.dd4t.core.exceptions.SerializationException
- Specified by:
buildComponentPresentationin interfaceorg.dd4t.core.databind.DataBinder- Throws:
org.dd4t.core.exceptions.SerializationException
-
buildDynamicComponentPresentation
public org.dd4t.contentmodel.ComponentPresentation buildDynamicComponentPresentation(org.dd4t.contentmodel.ComponentPresentation componentPresentation, Class<? extends org.dd4t.contentmodel.Component> aClass) throws org.dd4t.core.exceptions.SerializationException- Specified by:
buildDynamicComponentPresentationin interfaceorg.dd4t.core.databind.DataBinder- Throws:
org.dd4t.core.exceptions.SerializationException
-
buildComponent
public <T extends org.dd4t.contentmodel.Component> T buildComponent(Object source, Class<T> aClass) throws org.dd4t.core.exceptions.SerializationException
- Specified by:
buildComponentin interfaceorg.dd4t.core.databind.DataBinder- Throws:
org.dd4t.core.exceptions.SerializationException
-
buildModels
public Map<String,org.dd4t.core.databind.BaseViewModel> buildModels(Object source, Set<String> modelNames, String templateUri) throws org.dd4t.core.exceptions.SerializationException
- Specified by:
buildModelsin interfaceorg.dd4t.core.databind.DataBinder- Throws:
org.dd4t.core.exceptions.SerializationException
-
buildModel
public <T extends org.dd4t.core.databind.BaseViewModel> T buildModel(Object source, String modelName, String templateUri) throws org.dd4t.core.exceptions.SerializationException
- Specified by:
buildModelin interfaceorg.dd4t.core.databind.DataBinder- Type Parameters:
T- Any mode deriving from BaseViewModel- Parameters:
source- the source object. In this case a JsonNodemodelName- the viewModel name set on the CTtemplateUri- the CT URI. Just to set it on the model- Returns:
- A concrete instance of the view model.
- Throws:
org.dd4t.core.exceptions.SerializationException
-
buildModel
public <T extends org.dd4t.core.databind.BaseViewModel> T buildModel(Object source, Class modelClass, String templateUri) throws org.dd4t.core.exceptions.SerializationException
- Specified by:
buildModelin interfaceorg.dd4t.core.databind.DataBinder- Throws:
org.dd4t.core.exceptions.SerializationException
-
getGenericMapper
public static com.fasterxml.jackson.databind.ObjectMapper getGenericMapper()
-
init
@PostConstruct public void init()
- Specified by:
initin classBaseDataBinder
-
configureMapper
protected void configureMapper()
-
findComponentTemplateViewName
public String findComponentTemplateViewName(org.dd4t.contentmodel.ComponentTemplate template) throws IOException
- Specified by:
findComponentTemplateViewNamein interfaceorg.dd4t.core.databind.DataBinder- Throws:
IOException
-
getRootElementName
public String getRootElementName(Object componentNode)
- Specified by:
getRootElementNamein interfaceorg.dd4t.core.databind.DataBinder
-
canDeserialize
public boolean canDeserialize(String source)
To-Do: implement sanity checking that we're given json- Specified by:
canDeserializein interfaceorg.dd4t.core.databind.DataBinder
-
-