Package eu.clarin.sru.server.fcs
Class XMLStreamWriterHelper
- java.lang.Object
-
- eu.clarin.sru.server.fcs.XMLStreamWriterHelper
-
public class XMLStreamWriterHelper extends Object
This class provides several helper methods for writing records in the CLARIN-FCS record schema. These methods do not cover the full spectrum of all variations of records that are permitted by the CLARIN-FCS specification.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
FCS_HITS_MIMETYPE
protected static String
FCS_HITS_NS
protected static String
FCS_HITS_PREFIX
protected static String
FCS_KWIC_MIMETYPE
protected static String
FCS_KWIC_NS
protected static String
FCS_KWIC_PREFIX
protected static String
FCS_NS
protected static String
FCS_PREFIX
-
Constructor Summary
Constructors Constructor Description XMLStreamWriterHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
writeEndDataView(XMLStreamWriter writer)
Write the end of a data view (i.e.static void
writeEndResource(XMLStreamWriter writer)
Write the end of a resource (i.e.static void
writeEndResourceFragment(XMLStreamWriter writer)
Write the end of a resource fragment (i.e.static void
writeHitsDataView(XMLStreamWriter writer, String text, int[] hits, boolean secondIsLength)
Convince method to write a simple HITS data view.static void
writeHitsDataView(XMLStreamWriter writer, String left, String hit, String right)
Convince method to write a simple HITS data view.static void
writeKWICDataView(XMLStreamWriter writer, String left, String keyword, String right)
Deprecated.Use the HITS data view instead.static void
writeResourceWithHitsDataView(XMLStreamWriter writer, String pid, String ref, String text, int[] hits, boolean secondIsLength)
Convince method to write a simple HITS data view.static void
writeResourceWithHitsDataView(XMLStreamWriter writer, String pid, String ref, String left, String hit, String right)
Convince method for writing a record with a HITS data view.static void
writeResourceWithHitsDataViewLegacy(XMLStreamWriter writer, String pid, String ref, String left, String hit, String right)
Deprecated.Only use, if you want compatability to legacy FCS applications.static void
writeResourceWithKWICDataView(XMLStreamWriter writer, String pid, String ref, String left, String keyword, String right)
Deprecated.The the HITS data view instead.static void
writeStartDataView(XMLStreamWriter writer, String mimetype)
Write the start of a data view (i.e.static void
writeStartResource(XMLStreamWriter writer, String pid, String ref)
Write the start of a resource (i.e.static void
writeStartResourceFragment(XMLStreamWriter writer, String pid, String ref)
Write the start of a resource fragment (i.e.
-
-
-
Field Detail
-
FCS_NS
protected static final String FCS_NS
- See Also:
- Constant Field Values
-
FCS_PREFIX
protected static final String FCS_PREFIX
- See Also:
- Constant Field Values
-
FCS_KWIC_NS
protected static final String FCS_KWIC_NS
- See Also:
- Constant Field Values
-
FCS_KWIC_PREFIX
protected static final String FCS_KWIC_PREFIX
- See Also:
- Constant Field Values
-
FCS_KWIC_MIMETYPE
protected static final String FCS_KWIC_MIMETYPE
- See Also:
- Constant Field Values
-
FCS_HITS_NS
protected static final String FCS_HITS_NS
- See Also:
- Constant Field Values
-
FCS_HITS_PREFIX
protected static final String FCS_HITS_PREFIX
- See Also:
- Constant Field Values
-
FCS_HITS_MIMETYPE
protected static final String FCS_HITS_MIMETYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
writeStartResource
public static void writeStartResource(XMLStreamWriter writer, String pid, String ref) throws XMLStreamException
Write the start of a resource (i.e. the<Resource>
element). Calls to this method need to be balanced with calls to thewriteEndResource(XMLStreamWriter)
method.- Parameters:
writer
- theXMLStreamWriter
to be usedpid
- the persistent identifier of this resource ornull
, if not applicableref
- the reference of this resource ornull
, if not applicable- Throws:
XMLStreamException
- if an error occurred
-
writeEndResource
public static void writeEndResource(XMLStreamWriter writer) throws XMLStreamException
Write the end of a resource (i.e. the</Resource>
element). Calls to this method need to be balanced with calls to thewriteStartResource(XMLStreamWriter, String, String)
method.- Parameters:
writer
- theXMLStreamWriter
to be used- Throws:
XMLStreamException
- if an error occurred
-
writeStartResourceFragment
public static void writeStartResourceFragment(XMLStreamWriter writer, String pid, String ref) throws XMLStreamException
Write the start of a resource fragment (i.e. the<ResourceFragment>
element). Calls to this method need to be balanced with calls to thewriteEndResourceFragment(XMLStreamWriter)
method.- Parameters:
writer
- theXMLStreamWriter
to be usedpid
- the persistent identifier of this resource ornull
, if not applicableref
- the reference of this resource ornull
, if not applicable- Throws:
XMLStreamException
- if an error occurred
-
writeEndResourceFragment
public static void writeEndResourceFragment(XMLStreamWriter writer) throws XMLStreamException
Write the end of a resource fragment (i.e. the</ResourceFragment>
element). Calls to this method need to be balanced with calls to thewriteStartResourceFragment(XMLStreamWriter, String, String)
method.- Parameters:
writer
- theXMLStreamWriter
to be used- Throws:
XMLStreamException
- if an error occurred
-
writeStartDataView
public static void writeStartDataView(XMLStreamWriter writer, String mimetype) throws XMLStreamException
Write the start of a data view (i.e. the<DataView>
element). Calls to this method need to be balanced with calls to thewriteEndResource(XMLStreamWriter)
method.- Parameters:
writer
- theXMLStreamWriter
to be usedmimetype
- the MIME type of this data view applicable- Throws:
XMLStreamException
- if an error occurred
-
writeEndDataView
public static void writeEndDataView(XMLStreamWriter writer) throws XMLStreamException
Write the end of a data view (i.e. the</DataView>
element). Calls to this method need to be balanced with calls to thewriteStartDataView(XMLStreamWriter, String)
method.- Parameters:
writer
- theXMLStreamWriter
to be used- Throws:
XMLStreamException
- if an error occurred
-
writeKWICDataView
@Deprecated public static void writeKWICDataView(XMLStreamWriter writer, String left, String keyword, String right) throws XMLStreamException
Deprecated.Use the HITS data view instead.Convince method to write a KWIC data view. It automatically performs the calls towriteStartDataView(XMLStreamWriter, String)
andwriteEndDataView(XMLStreamWriter)
.- Parameters:
writer
- theXMLStreamWriter
to be usedleft
- the left context of the KWIC ornull
if not applicablekeyword
- the keyword of the KWICright
- the right context of the KWIC ornull
if not applicable- Throws:
XMLStreamException
- if an error occurred
-
writeResourceWithKWICDataView
@Deprecated public static void writeResourceWithKWICDataView(XMLStreamWriter writer, String pid, String ref, String left, String keyword, String right) throws XMLStreamException
Deprecated.The the HITS data view instead.Convince method for writing a record with a KWIC data view. The following code (arguments omitted) would accomplish the same result:... writeStartResource(...); writeKWICDataView(...); writeEndResource(...); ...
- Parameters:
writer
- theXMLStreamWriter
to be usedpid
- the persistent identifier of this resource ornull
, if not applicableref
- the reference of this resource ornull
, if not applicableleft
- the left context of the KWIC ornull
if not applicablekeyword
- the keyword of the KWICright
- the right context of the KWIC ornull
if not applicable- Throws:
XMLStreamException
- if an error occurred
-
writeHitsDataView
public static void writeHitsDataView(XMLStreamWriter writer, String left, String hit, String right) throws XMLStreamException
Convince method to write a simple HITS data view. It automatically performs the calls towriteStartDataView(XMLStreamWriter, String)
andwriteEndDataView(XMLStreamWriter)
.- Parameters:
writer
- theXMLStreamWriter
to be usedleft
- the left context of the hit ornull
if not applicablehit
- the actual hit, that will be highlightedright
- the right context of the hit ornull
if not applicable- Throws:
XMLStreamException
- if an error occurred
-
writeResourceWithHitsDataView
public static void writeResourceWithHitsDataView(XMLStreamWriter writer, String pid, String ref, String left, String hit, String right) throws XMLStreamException
Convince method for writing a record with a HITS data view. The following code (arguments omitted) would accomplish the same result:... writeStartResource(...); writeHitsDataView(...); writeEndResource(...); ...
- Parameters:
writer
- theXMLStreamWriter
to be usedpid
- the persistent identifier of this resource ornull
, if not applicableref
- the reference of this resource ornull
, if not applicableleft
- the left context of the hit ornull
if not applicablehit
- the actual hit, that will be highlightedright
- the right context of the hit ornull
if not applicable- Throws:
XMLStreamException
- if an error occurred
-
writeHitsDataView
public static void writeHitsDataView(XMLStreamWriter writer, String text, int[] hits, boolean secondIsLength) throws XMLStreamException
Convince method to write a simple HITS data view. It automatically performs the calls towriteStartDataView(XMLStreamWriter, String)
andwriteEndDataView(XMLStreamWriter)
.- Parameters:
writer
- theXMLStreamWriter
to be usedtext
- the text content of the hithits
- an even-element array containing tuples for the hit markers in the text contentsecondIsLength
- iftrue
the second element of each tuple in thishits
array is interpreted as an length; iffalse
it is interpreted as an end-offset- Throws:
XMLStreamException
- if an error occurred
-
writeResourceWithHitsDataView
public static void writeResourceWithHitsDataView(XMLStreamWriter writer, String pid, String ref, String text, int[] hits, boolean secondIsLength) throws XMLStreamException
Convince method to write a simple HITS data view. It automatically performs the calls towriteStartDataView(XMLStreamWriter, String)
andwriteEndDataView(XMLStreamWriter)
.... writeStartResource(...); writeHitsDataView(...); writeEndResource(...); ...
- Parameters:
writer
- theXMLStreamWriter
to be usedpid
- the persistent identifier of this resource ornull
, if not applicableref
- the reference of this resource ornull
, if not applicabletext
- the text content of the hithits
- an even-element array containing tuples for the hit markers in the text contentsecondIsLength
- iftrue
the second element of each tuple in thishits
array is interpreted as an length; iffalse
it is interpreted as an end-offset- Throws:
XMLStreamException
- if an error occurred
-
writeResourceWithHitsDataViewLegacy
@Deprecated public static void writeResourceWithHitsDataViewLegacy(XMLStreamWriter writer, String pid, String ref, String left, String hit, String right) throws XMLStreamException
Deprecated.Only use, if you want compatability to legacy FCS applications.Convince method for writing a record with a HITS and a KWIC data view. This method is intended for applications that want ensure computability to legacy CLARIN-FCS clients The following code (arguments omitted) would accomplish the same result:... writeStartResource(...); writeHitsDataView(...); writeKWICDataView(...); writeEndResource(...); ...
- Parameters:
writer
- theXMLStreamWriter
to be usedpid
- the persistent identifier of this resource ornull
, if not applicableref
- the reference of this resource ornull
, if not applicableleft
- the left context of the hit ornull
if not applicablehit
- the actual hit, that will be highlightedright
- the right context of the hit ornull
if not applicable- Throws:
XMLStreamException
- if an error occurred
-
-