3 * Copyright (C) 2016 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.molecular
.io
;
13 import info
.bioinfweb
.commons
.io
.XMLUtils
;
14 import info
.bioinfweb
.jphyloio
.ReaderStreamDataProvider
;
15 import info
.bioinfweb
.jphyloio
.WriterStreamDataProvider
;
16 import info
.bioinfweb
.jphyloio
.objecttranslation
.InvalidObjectSourceDataException
;
17 import info
.bioinfweb
.jphyloio
.objecttranslation
.implementations
.AbstractXMLObjectTranslator
;
19 import java
.io
.IOException
;
21 import javax
.xml
.stream
.XMLEventReader
;
22 import javax
.xml
.stream
.XMLStreamException
;
23 import javax
.xml
.stream
.XMLStreamWriter
;
25 import eu
.etaxonomy
.cdm
.model
.molecular
.SingleReadAlignment
;
26 import eu
.etaxonomy
.taxeditor
.molecular
.l10n
.Messages
;
31 * <i>JPhyloIO</i> object translator to read and write a shift list of a {@link SingleReadAlignment} object from and
37 public class CDMPherogramAlignmentObjectTranslator
extends AbstractXMLObjectTranslator
<SingleReadAlignment
.Shift
[]>
38 implements SingleReadAlignmentRDFXMLConstants
{
41 public Class
<SingleReadAlignment
.Shift
[]> getObjectClass() {
42 return SingleReadAlignment
.Shift
[].class;
47 public SingleReadAlignment
.Shift
[] readXMLRepresentation(XMLEventReader reader
, ReaderStreamDataProvider
<?
> streamDataProvider
)
48 throws IOException
, XMLStreamException
, InvalidObjectSourceDataException
{
51 throw new InternalError(Messages
.CDMPherogramAlignmentObjectTranslator_NOT_IMPLEMENTED
);
56 public void writeXMLRepresentation(XMLStreamWriter writer
, Object object
, WriterStreamDataProvider
<?
> streamDataProvider
)
57 throws IOException
, XMLStreamException
, ClassCastException
{
59 SingleReadAlignment
.Shift
[] shifts
= (SingleReadAlignment
.Shift
[])object
;
60 XMLUtils
.writeStartElement(writer
, TAG_SHIFTS
);
61 for (SingleReadAlignment
.Shift shift
: shifts
) {
62 XMLUtils
.writeStartElement(writer
, TAG_SHIFT
);
63 XMLUtils
.writeAttribute(writer
, ATTR_POSITION
, Integer
.toString(shift
.position
));
64 XMLUtils
.writeAttribute(writer
, ATTR_SHIFT
, Integer
.toString(shift
.shift
));
65 writer
.writeEndElement();
67 writer
.writeEndElement();