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
;
30 * <i>JPhyloIO</i> object translator to read and write a shift list of a {@link SingleReadAlignment} object from and
36 public class CDMPherogramAlignmentObjectTranslator
extends AbstractXMLObjectTranslator
<SingleReadAlignment
.Shift
[]>
37 implements SingleReadAlignmentRDFXMLConstants
{
40 public Class
<SingleReadAlignment
.Shift
[]> getObjectClass() {
41 return SingleReadAlignment
.Shift
[].class;
46 public SingleReadAlignment
.Shift
[] readXMLRepresentation(XMLEventReader reader
, ReaderStreamDataProvider
<?
> streamDataProvider
)
47 throws IOException
, XMLStreamException
, InvalidObjectSourceDataException
{
50 throw new InternalError("Not implemented.");
55 public void writeXMLRepresentation(XMLStreamWriter writer
, Object object
, WriterStreamDataProvider
<?
> streamDataProvider
)
56 throws IOException
, XMLStreamException
, ClassCastException
{
58 SingleReadAlignment
.Shift
[] shifts
= (SingleReadAlignment
.Shift
[])object
;
59 XMLUtils
.writeStartElement(writer
, TAG_SHIFTS
);
60 for (SingleReadAlignment
.Shift shift
: shifts
) {
61 XMLUtils
.writeStartElement(writer
, TAG_SHIFT
);
62 XMLUtils
.writeAttribute(writer
, ATTR_POSITION
, Integer
.toString(shift
.position
));
63 XMLUtils
.writeAttribute(writer
, ATTR_SHIFT
, Integer
.toString(shift
.shift
));
64 writer
.writeEndElement();
66 writer
.writeEndElement();