T2FlowReader implements WorkflowBundleReader { @Override public String guessMediaTypeForSignature(byte[] firstBytes) { if (firstBytes.length < 100) return null; Charset latin1 = Charset.forName("ISO-8859-1"); String asLatin1 = new String(firstBytes, latin1); if (!asLatin1.contains("workflow")) return null; if (!asLatin1.contains("http: return null; if (!asLatin1.contains("dataflow")) return null; return APPLICATION_VND_TAVERNA_T2FLOW_XML; }  @Override Set<String> getMediaTypes(); @Override WorkflowBundle readBundle(File bundleFile, String mediaType); @Override WorkflowBundle readBundle(InputStream inputStream, String mediaType); void setParser(T2FlowParser parser); T2FlowParser getParser(); @Override String guessMediaTypeForSignature(byte[] firstBytes); static final String APPLICATION_VND_TAVERNA_T2FLOW_XML; }
@Test public void guessMediaType() throws Exception { byte[] firstBytes = new byte[1024]; getClass().getResourceAsStream(AS_T2FLOW).read(firstBytes); assertEquals(APPLICATION_VND_TAVERNA_T2FLOW_XML, io.guessMediaTypeForSignature(firstBytes)); firstBytes[885] = 32; assertEquals(null, io.guessMediaTypeForSignature(firstBytes)); }