-
Notifications
You must be signed in to change notification settings - Fork 16
Persist in XML format
xcesco edited this page Jan 19, 2017
·
12 revisions
The annotation @BindType
allow to persist Java class instance in its XML rapresentation
@BindType
public class User {
public String email;
public String name;
public String surname;
}
As default behaviour, @BindType
annotation bind all public fields and attribute with getter/setter.
Before serialize/deserialize java object in XML format, you need to registry the XML context:
KriptonBinder.registryBinder(new KriptonXmlContext());
Code to generate an xml version of User
instance class:
BinderContext binderContext=KriptonBinder.bind(BinderType.XML);
String result = binderContext.serialize(bean);
Generated xml will be similar to:
<?xml version="1.0" encoding="utf-8"?>
<user>
<email>dummy@test.org</email>
<name>Tonj</name>
<surname>Manero</surname>
<username>1234</username>
</user>
Kripton does not support (in current release) pretty printing, so output will be a inline xml. I format xml for readability reason.
Code to parse xml and create a User
instance:
User user=binderContext.parse(result, User.class);
- Introduction
- Goals & Features
- Kotlin
- Immutable or Mutable Pojo
- Annotation Processor Args
- Credits
- Articles
- Benchmarks
- Setup
- Tutorial
- Usage
- Dependencies and inspirations
- Stackoverflow
- Documentation
- SQL logging
- Data source options
- Indices
- SQL Type adapter
- Global SQL Type adapter
- Constraints
- Live data: welcome Architectural components!!
- Paged Live data
- Dynamic parts
- Transactional and batch operations
- Async Transactional and batch operations
- Global transaction
- Support for immutable POJO
- Generate Content provider
- Generate Database schema generation
- Database migration
- BindSqlColumn
- BindContentProvider
- BindContentProviderEntry
- BindContentProviderPath
- BindDao
- BindDaoMany2Many
- BindDataSource
- BindDataSourceOptions
- BindDataSourceUpdateTask
- BindIndex
- BindSqlRelation
- BindSqlAdapter
- BindSqlChildSelect
- BindSqlDelete
- BindSqlDynamicOrderBy
- BindSqlDynamicWhere
- BindSqlDynamicWhereParams
- BindSqlInsert
- BindSqlPageSize
- BindSqlParam
- BindSqlSelect
- BindSqlUpdate
- BindSqlType
- BindSqlTransaction