+
+ /**
+ * Reads the reply to the EBI Fetch Uniprot data query, unmarshals it to an
+ * Uniprot object, and returns the enclosed Entry objects, or null on any
+ * failure
+ *
+ * @param is
+ * @return
+ */
+ public List<Entry> getUniprotEntries(InputStream is)
+ {
+ List<Entry> entries = null;
+ try
+ {
+ JAXBContext jc = JAXBContext
+ .newInstance("jalview.xml.binding.uniprot");
+ XMLStreamReader streamReader = XMLInputFactory.newInstance()
+ .createXMLStreamReader(is);
+ javax.xml.bind.Unmarshaller um = jc.createUnmarshaller();
+ JAXBElement<jalview.xml.binding.uniprot.Uniprot> uniprotElement = um
+ .unmarshal(streamReader,
+ jalview.xml.binding.uniprot.Uniprot.class);
+ jalview.xml.binding.uniprot.Uniprot uniprot = uniprotElement
+ .getValue();
+
+ if (uniprot != null && !uniprot.getEntry().isEmpty())
+ {
+ entries = uniprot.getEntry();
+ }
+ } catch (JAXBException | XMLStreamException
+ | FactoryConfigurationError e)
+ {
+ if (e instanceof javax.xml.bind.UnmarshalException
+ && e.getCause() != null
+ && e.getCause() instanceof XMLStreamException
+ && e.getCause().getMessage().contains("[row,col]:[1,1]"))
+ {
+ // trying to parse an empty stream
+ return null;
+ }
+ e.printStackTrace();
+ }
+ return entries;
+ }