[ 
https://issues.apache.org/jira/browse/STANBOL-878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13549557#comment-13549557
 ] 

Rupert Westenthaler commented on STANBOL-878:
---------------------------------------------

## Design

### User level API

User Level Components/Services include

* AnalyzedTextSerializer: Serializes an AnalysedText instance as JSON
* AnalyzedTextParser: Parses AnalysedText instanced from JSON. The Blog 
(ContentPart containing the PlainText) needs to be pared to the #parse(..) 
method. This is because the text is not included in the serialized JSON.

All services can be used within and outside an OSGI environment. The 
AnalyzedTextSerializer/-parser are registered as OSGI services. Outside of an 
OSGI environment the static #getDefaultInstance() method can be used for 
initialization.

### JAX-RS support

The AnalyzedTextWriter: JAX-RS Provider that produces "application/json" for 
AnalysedText instances. There is no AnalyzedTextReader because parsing an 
AnalyzedText requires the Blob to be available.

### Extensibility for Value Types

The AnalyzedText ContentPart supports the use of arbitrary annotation types by 
the use of the generically types <code>Annotation&lt;T&gt;</code> class. By 
using such annotation one can add <code>Value&lt;T&gt;</code> annotations 
<code>Span</code>s. This means that a JSON serialization needs to support all 
used <code>T</code> classes.

For this two mechanisms are supported:

1. __[Jackson Data Bindings](http://wiki.fasterxml.com/JacksonDataBinding):__ 
Primary this ensures to support primitive Java classes like string, all kind of 
numbers but also collections of such types. However Jackson also brings support 
for Bean like classes (see documentation for details). This will always used as 
fallback if option _(2)_ is not available.
2. __ValueTypeSerializer/-Parser:__ This allows to provide specific 
serializes/parsers for <code>T</code> (value type) classes by implementing the 
<code>ValueTypeParser</code> and <code>ValueTypeSerializer</code> interfaces. 
Implementations MUST BE registered as OSGI services AND also provide the  
'<code>META-INF/services/{interface-name}.properties</code>' file as used by 
the 
[ServiceLoader](http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html)
 utility. 

### Streaming support

Both the Parser and Serializer support streaming. This means that the JSON is 
not read into memory but is processed <code>Span</code> by <code>Span</code>.





                
> Add serialization support to the AnalyzedText ContentPart
> ---------------------------------------------------------
>
>                 Key: STANBOL-878
>                 URL: https://issues.apache.org/jira/browse/STANBOL-878
>             Project: Stanbol
>          Issue Type: New Feature
>          Components: Enhancer
>            Reporter: Rupert Westenthaler
>            Assignee: Rupert Westenthaler
>
> Provide support for JSON serialization/parsing of AnalyzedText including 
> Annotation. Also provide a JAX-RS MessageBodyReader/-Writer implementation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to