Package eu.clarin.sru.server.fcs
Class AdvancedDataViewWriter
- java.lang.Object
-
- eu.clarin.sru.server.fcs.AdvancedDataViewWriter
-
public class AdvancedDataViewWriter extends Object
Helper class for serializing Advanced Data Views. It can be used for writing more than once, but it is not thread-save. This helper can also serialize HITS Data Views.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAdvancedDataViewWriter.Unit
-
Field Summary
Fields Modifier and Type Field Description static intNO_HIGHLIGHT
-
Constructor Summary
Constructors Constructor Description AdvancedDataViewWriter(AdvancedDataViewWriter.Unit unit)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSpan(URI layerId, long start, long end, String value)Add a span.voidaddSpan(URI layerId, long start, long end, String value, int highlight)Add a span.voidaddSpan(URI layerId, long start, long end, String value, String altValue)Add a span.voidaddSpan(URI layerId, long start, long end, String value, String altValue, int highlight)Add a span.voidreset()Reset the writer for writing a new data view (instance).voidwriteAdvancedDataView(XMLStreamWriter writer)Write the Advanced Data View to the output stream.voidwriteHitsDataView(XMLStreamWriter writer, URI layerId)Convenience method to write HITS Data View.
-
-
-
Field Detail
-
NO_HIGHLIGHT
public static final int NO_HIGHLIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AdvancedDataViewWriter
public AdvancedDataViewWriter(AdvancedDataViewWriter.Unit unit)
Constructor.- Parameters:
unit- the unit to be used for span offsets- See Also:
AdvancedDataViewWriter.Unit
-
-
Method Detail
-
reset
public void reset()
Reset the writer for writing a new data view (instance).
-
addSpan
public void addSpan(URI layerId, long start, long end, String value)
Add a span.- Parameters:
layerId- the span's layer idstart- the span's start offsetend- the span's end offsetvalue- the span's content value ornullif none- Throws:
IllegalArgumentException- if any argument is invalid
-
addSpan
public void addSpan(URI layerId, long start, long end, String value, int highlight)
Add a span.- Parameters:
layerId- the span's layer idstart- the span's start offsetend- the span's end offsetvalue- the span's content value ornullif nonehighlight- the highlight group- Throws:
IllegalArgumentException- if any argument is invalid
-
addSpan
public void addSpan(URI layerId, long start, long end, String value, String altValue)
Add a span.- Parameters:
layerId- the span's layer idstart- the span's start offsetend- the span's end offsetvalue- the span's content value ornullif nonealtValue- the span's alternate value ornullif none
-
addSpan
public void addSpan(URI layerId, long start, long end, String value, String altValue, int highlight)
Add a span.- Parameters:
layerId- the span's layer idstart- the span's start offsetend- the span's end offsetvalue- the span's content value ornullif nonealtValue- the span's alternate value ornullif nonehighlight- the highlight group- Throws:
IllegalArgumentException- if any argument is invalid
-
writeAdvancedDataView
public void writeAdvancedDataView(XMLStreamWriter writer) throws XMLStreamException
Write the Advanced Data View to the output stream.- Parameters:
writer- the writer to write to- Throws:
XMLStreamException- if an error occurred
-
writeHitsDataView
public void writeHitsDataView(XMLStreamWriter writer, URI layerId) throws XMLStreamException
Convenience method to write HITS Data View.- Parameters:
writer- the writer to write tolayerId- the layer id of the layer to be serialized as HITS Data View- Throws:
XMLStreamException- if an error occurredIllegalArgumentException- if an invalid layer id was provided
-
-