/** Extracts the OME-XML from the current {@link #metadataFile}. */ private String readMetadataFile() throws IOException { if (checkSuffix(metadataFile, "ome.tiff") || checkSuffix(metadataFile, "ome.tif") || checkSuffix(metadataFile, "ome.tf2") || checkSuffix(metadataFile, "ome.tf8") || checkSuffix(metadataFile, "ome.btf")) { // metadata file is an OME-TIFF file; extract OME-XML comment try (RandomAccessInputStream in = new RandomAccessInputStream(metadataFile)) { TiffParser parser = new TiffParser(in); return parser.getComment(); } } // assume metadata file is an XML file return DataTools.readFile(metadataFile); }
/** Extracts the OME-XML from the current {@link #metadataFile}. */ private String readMetadataFile() throws IOException { if (checkSuffix(metadataFile, "ome.tiff") || checkSuffix(metadataFile, "ome.tif") || checkSuffix(metadataFile, "ome.tf2") || checkSuffix(metadataFile, "ome.tf8") || checkSuffix(metadataFile, "ome.btf")) { // metadata file is an OME-TIFF file; extract OME-XML comment try (RandomAccessInputStream in = new RandomAccessInputStream(metadataFile)) { TiffParser parser = new TiffParser(in); return parser.getComment(); } } // assume metadata file is an XML file return DataTools.readFile(metadataFile); }
@Override public boolean isThisType(String name, boolean open) { if (checkSuffix(name, "companion.ome")) { // force the reader to pick up binary-only companion files return true; } metaFile = new Location(name).getAbsolutePath(); boolean valid = super.isThisType(name, open); if (metadataFile != null) { // this is a binary-only file // overwrite XML with what is in the companion OME-XML file String dir = new File(metaFile).getParent(); Location path = new Location(dir, metadataFile); LOGGER.debug("Checking metadata file {}", path); if (!path.exists()) return false; metadataFile = path.getAbsolutePath(); try { String xml = readMetadataFile(); service.createOMEXMLMetadata(xml); } catch (ServiceException se) { LOGGER.debug("OME-XML parsing failed", se); return false; } catch (IOException | NullPointerException e) { return false; } } return valid; }
@Override public boolean isThisType(String name, boolean open) { if (checkSuffix(name, "companion.ome")) { // force the reader to pick up binary-only companion files return true; } metaFile = new Location(name).getAbsolutePath(); boolean valid = super.isThisType(name, open); if (metadataFile != null) { // this is a binary-only file // overwrite XML with what is in the companion OME-XML file String dir = new File(metaFile).getParent(); Location path = new Location(dir, metadataFile); LOGGER.debug("Checking metadata file {}", path); if (!path.exists()) return false; metadataFile = path.getAbsolutePath(); try { String xml = readMetadataFile(); service.createOMEXMLMetadata(xml); } catch (ServiceException se) { LOGGER.debug("OME-XML parsing failed", se); return false; } catch (IOException | NullPointerException e) { return false; } } return valid; }
if (checkSuffix(fileName, "companion.ome")) { xml = DataTools.readFile(fileName); companion = true;
if (checkSuffix(fileName, "companion.ome")) { xml = DataTools.readFile(fileName); companion = true;
@Override public boolean isSingleFile(String id) throws FormatException, IOException { if (checkSuffix(id, "companion.ome")) { return false;
@Override public boolean isSingleFile(String id) throws FormatException, IOException { if (checkSuffix(id, "companion.ome")) { return false;