public class OMEXMLServiceImpl extends loci.common.services.AbstractService implements OMEXMLService
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LATEST_VERSION
Latest OME-XML version namespace.
|
private static org.slf4j.Logger |
LOGGER
Logger for this class.
|
static java.lang.String |
NO_OME_XML_MSG |
private static javax.xml.transform.Templates |
reorderXSLT
Reordering stylesheet.
|
private static loci.common.xml.XMLTools.SchemaReader |
SCHEMA_CLASSPATH_READER
Finds OME-XML schema definitions in specifications.jar.
|
private static java.lang.String |
SCHEMA_PATH |
private static java.util.regex.Pattern |
SCHEMA_URL_PATTERN
The pattern of system ID URLs for OME-XML schema definitions.
|
private static javax.xml.transform.Templates |
update2003FC
Stylesheets for updating from previous schema releases.
|
private static javax.xml.transform.Templates |
update200706 |
private static javax.xml.transform.Templates |
update200802 |
private static javax.xml.transform.Templates |
update200809 |
private static javax.xml.transform.Templates |
update200909 |
private static javax.xml.transform.Templates |
update201004 |
private static javax.xml.transform.Templates |
update201006 |
private static javax.xml.transform.Templates |
update201106 |
private static javax.xml.transform.Templates |
update201206 |
private static javax.xml.transform.Templates |
update201306 |
private static javax.xml.transform.Templates |
update201501 |
private static java.lang.String |
XSLT_2003FC |
private static java.lang.String |
XSLT_200706 |
private static java.lang.String |
XSLT_200802 |
private static java.lang.String |
XSLT_200809 |
private static java.lang.String |
XSLT_200909 |
private static java.lang.String |
XSLT_201004 |
private static java.lang.String |
XSLT_201006 |
private static java.lang.String |
XSLT_201106 |
private static java.lang.String |
XSLT_201206 |
private static java.lang.String |
XSLT_201306 |
private static java.lang.String |
XSLT_201501 |
private static java.lang.String |
XSLT_PATH |
Constructor and Description |
---|
OMEXMLServiceImpl()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addMetadataOnly(OMEXMLMetadata omexmlMeta,
int image)
Insert a MetadataOnly element under the Image specified by 'index' in the
given OME-XML metadata object.
|
void |
addMetadataOnly(OMEXMLMetadata omexmlMeta,
int image,
boolean resolve)
Insert a MetadataOnly element under the Image specified by 'index' in the
given OME-XML metadata object.
|
void |
addModuloAlong(OMEXMLMetadata meta,
CoreMetadata core,
int imageIdx)
Adds ModuloAlong* annotations to the given OME-XML metadata object,
using the given CoreMetadata object to determine modulo dimensions.
|
MetadataRetrieve |
asRetrieve(MetadataStore meta)
Gets the given
MetadataStore object as a MetadataRetrieve . |
MetadataStore |
asStore(MetadataRetrieve meta)
Gets the given
MetadataRetrieve object as a MetadataStore . |
void |
convertMetadata(MetadataRetrieve src,
MetadataStore dest)
Copies information from a metadata retrieval object
(source) into a metadata store (destination).
|
void |
convertMetadata(java.lang.String xml,
MetadataStore dest)
Converts information from an OME-XML string (source)
into a metadata store (destination).
|
private void |
createModulo(OMEXMLMetadata meta,
Modulo modulo,
ome.xml.model.StructuredAnnotations annotations,
ome.xml.model.Image image,
int imageIdx,
int annotationIndex,
int imageAnnotation)
Create a ModuloAlong* annotation corresponding to the given
Modulo . |
OMEXMLMetadata |
createOMEXMLMetadata()
Creates an OME-XML metadata object using reflection, to avoid
direct dependencies on the optional
loci.formats.ome package. |
OMEXMLMetadata |
createOMEXMLMetadata(java.lang.String xml)
Creates an OME-XML metadata object using reflection, to avoid
direct dependencies on the optional
loci.formats.ome package,
wrapping a DOM representation of the given OME-XML string. |
OMEXMLMetadata |
createOMEXMLMetadata(java.lang.String xml,
java.lang.String version)
Creates an OME-XML metadata object using reflection, to avoid
direct dependencies on the optional
loci.formats.ome package,
wrapping a DOM representation of the given OME-XML string. |
ome.xml.model.OMEModelObject |
createOMEXMLRoot(java.lang.String xml)
Constructs an OME root node.
|
private ome.xml.meta.OMEXMLMetadataRoot |
createRoot(java.lang.String xml)
Constructs an OME root node.
|
boolean |
equals(org.w3c.dom.Node e1,
org.w3c.dom.Node e2)
Compares two Elements for equality.
|
private org.w3c.dom.Node |
findChildWithID(org.w3c.dom.Node root,
java.lang.String name,
java.lang.String id)
Return the child node with specified value for the "ID" attribute.
|
private org.w3c.dom.Node |
findRootNode(org.w3c.dom.Node child)
Return the absolute root node for the specified child node.
|
java.lang.String |
getLatestVersion()
Retrieves the latest supported version of the OME-XML schema.
|
private Modulo |
getModuloAlong(OMEXMLMetadata omexml,
java.lang.String tag,
int image)
Create a
Modulo corresponding to the given ModuloAlong* tag. |
Modulo |
getModuloAlongC(OMEXMLMetadata omexml,
int image)
Retrieve the ModuloAlongC annotation in the given Image in the given
OME-XML metadata object.
|
Modulo |
getModuloAlongT(OMEXMLMetadata omexml,
int image)
Retrieve the ModuloAlongT annotation in the given Image in the given
OME-XML metadata object.
|
Modulo |
getModuloAlongZ(OMEXMLMetadata omexml,
int image)
Retrieve the ModuloAlongZ annotation in the given Image in the given
OME-XML metadata object.
|
OMEXMLMetadata |
getOMEMetadata(MetadataRetrieve src)
Returns a
OMEXMLMetadata object with the same
contents as the given MetadataRetrieve, converting it if necessary. |
java.lang.String |
getOMEXML(MetadataRetrieve src)
Extracts an OME-XML metadata string from the given metadata object,
by converting to an OME-XML metadata object if necessary.
|
java.lang.String |
getOMEXMLVersion(java.lang.Object o)
Gets the schema version for the given OME-XML metadata or root object
(e.g., "2007-06" or "2003-FC").
|
java.util.Hashtable |
getOriginalMetadata(OMEXMLMetadata omexmlMeta)
Parse any OriginalMetadata annotations from the given OME-XML metadata
object and store them in a Hashtable.
|
boolean |
isEqual(OMEXMLMetadata src1,
OMEXMLMetadata src2)
Determine whether or not two OMEXMLMetadata objects are equal.
|
boolean |
isOMEXMLMetadata(java.lang.Object o)
Checks whether the given object is an OME-XML metadata object.
|
boolean |
isOMEXMLRoot(java.lang.Object o)
Checks whether the given object is an OME-XML root object.
|
void |
populateOriginalMetadata(OMEXMLMetadata omexmlMeta,
java.util.Hashtable<java.lang.String,java.lang.Object> metadata)
Adds the key/value pairs in the specified Hashtable as new
OriginalMetadata annotations in the given OME-XML metadata object.
|
void |
populateOriginalMetadata(OMEXMLMetadata omexmlMeta,
java.lang.String key,
java.lang.String value)
Adds the specified key/value pair as a new OriginalMetadata node
to the given OME-XML metadata object.
|
void |
removeBinData(OMEXMLMetadata omexmlMeta)
Remove all of the BinData elements from the given OME-XML metadata object.
|
void |
removeChannels(OMEXMLMetadata omexmlMeta,
int image,
int sizeC)
Remove all but the first sizeC valid Channel elements from the given
OME-XML metadata object.
|
void |
removeTiffData(OMEXMLMetadata omexmlMeta)
Remove all of the TiffData elements from the given OME-XML metadata object.
|
java.lang.String |
transformToLatestVersion(java.lang.String xml)
Transforms the given OME-XML string to the latest supported version of
of the OME-XML schema.
|
boolean |
validateOMEXML(java.lang.String xml)
Attempts to validate the given OME-XML string using
Java's XML validation facility.
|
boolean |
validateOMEXML(java.lang.String xml,
boolean pixelsHack)
Attempts to validate the given OME-XML string using
Java's XML validation facility.
|
private java.lang.String |
verifyOMENamespace(java.lang.String xml)
Ensures that an xmlns:ome element exists.
|
public static final java.lang.String LATEST_VERSION
public static final java.lang.String NO_OME_XML_MSG
private static final org.slf4j.Logger LOGGER
private static final java.lang.String XSLT_PATH
private static final java.lang.String XSLT_2003FC
private static final java.lang.String XSLT_200706
private static final java.lang.String XSLT_200802
private static final java.lang.String XSLT_200809
private static final java.lang.String XSLT_200909
private static final java.lang.String XSLT_201004
private static final java.lang.String XSLT_201006
private static final java.lang.String XSLT_201106
private static final java.lang.String XSLT_201206
private static final java.lang.String XSLT_201306
private static final java.lang.String XSLT_201501
private static javax.xml.transform.Templates reorderXSLT
private static javax.xml.transform.Templates update2003FC
private static javax.xml.transform.Templates update200706
private static javax.xml.transform.Templates update200802
private static javax.xml.transform.Templates update200809
private static javax.xml.transform.Templates update200909
private static javax.xml.transform.Templates update201004
private static javax.xml.transform.Templates update201006
private static javax.xml.transform.Templates update201106
private static javax.xml.transform.Templates update201206
private static javax.xml.transform.Templates update201306
private static javax.xml.transform.Templates update201501
private static final java.lang.String SCHEMA_PATH
private static final java.util.regex.Pattern SCHEMA_URL_PATTERN
private static final loci.common.xml.XMLTools.SchemaReader SCHEMA_CLASSPATH_READER
public java.lang.String getLatestVersion()
OMEXMLService
getLatestVersion
in interface OMEXMLService
OMEXMLService.getLatestVersion()
public java.lang.String transformToLatestVersion(java.lang.String xml) throws loci.common.services.ServiceException
OMEXMLService
transformToLatestVersion
in interface OMEXMLService
loci.common.services.ServiceException
OMEXMLService.transformToLatestVersion(String)
public OMEXMLMetadata createOMEXMLMetadata() throws loci.common.services.ServiceException
OMEXMLService
loci.formats.ome
package.createOMEXMLMetadata
in interface OMEXMLService
AbstractOMEXMLMetadata
,
or null if the class is not available.loci.common.services.ServiceException
- If there is an error creating the OME-XML
metadata object.OMEXMLService.createOMEXMLMetadata()
public OMEXMLMetadata createOMEXMLMetadata(java.lang.String xml) throws loci.common.services.ServiceException
OMEXMLService
loci.formats.ome
package,
wrapping a DOM representation of the given OME-XML string.createOMEXMLMetadata
in interface OMEXMLService
AbstractOMEXMLMetadata
,
or null if the class is not available.loci.common.services.ServiceException
- If there is an error creating the OME-XML
metadata object.OMEXMLService.createOMEXMLMetadata(java.lang.String)
public OMEXMLMetadata createOMEXMLMetadata(java.lang.String xml, java.lang.String version) throws loci.common.services.ServiceException
OMEXMLService
loci.formats.ome
package,
wrapping a DOM representation of the given OME-XML string.createOMEXMLMetadata
in interface OMEXMLService
xml
- The OME-XML string to use for initial population of the
metadata object.version
- The OME-XML version to use (e.g., "2003-FC" or "2007-06").
If the xml and version parameters are both null, the newest version is
used.AbstractOMEXMLMetadata
,
or null if the class is not available.loci.common.services.ServiceException
- If there is an error creating the OME-XML
metadata object.OMEXMLService.createOMEXMLMetadata(java.lang.String, java.lang.String)
public ome.xml.model.OMEModelObject createOMEXMLRoot(java.lang.String xml) throws loci.common.services.ServiceException
OMEXMLService
createOMEXMLRoot
in interface OMEXMLService
xml
- String of XML to create the root node from.loci.common.services.ServiceException
- If there is an error creating the OME-XML
metadata object.OMEXMLService.createOMEXMLRoot(java.lang.String)
public boolean isOMEXMLMetadata(java.lang.Object o)
OMEXMLService
isOMEXMLMetadata
in interface OMEXMLService
OMEXMLMetadata
.OMEXMLService.isOMEXMLMetadata(java.lang.Object)
public boolean isOMEXMLRoot(java.lang.Object o)
OMEXMLService
isOMEXMLRoot
in interface OMEXMLService
OME
.OMEXMLService.isOMEXMLRoot(java.lang.Object)
private ome.xml.meta.OMEXMLMetadataRoot createRoot(java.lang.String xml) throws loci.common.services.ServiceException
xml
- String of XML to create the root node from.java.io.IOException
- If there is an error reading from the string.org.xml.sax.SAXException
- If there is an error parsing the XML.javax.xml.parsers.ParserConfigurationException
- If there is an error preparing the
parsing infrastructure.loci.common.services.ServiceException
public java.lang.String getOMEXMLVersion(java.lang.Object o)
OMEXMLService
getOMEXMLVersion
in interface OMEXMLService
OMEXMLMetadata
.OMEXMLService.getOMEXMLVersion(java.lang.Object)
public OMEXMLMetadata getOMEMetadata(MetadataRetrieve src) throws loci.common.services.ServiceException
OMEXMLService
OMEXMLMetadata
object with the same
contents as the given MetadataRetrieve, converting it if necessary.getOMEMetadata
in interface OMEXMLService
loci.common.services.ServiceException
- If there is an error creating the OME-XML
metadata object.OMEXMLService.getOMEMetadata(loci.formats.meta.MetadataRetrieve)
public java.lang.String getOMEXML(MetadataRetrieve src) throws loci.common.services.ServiceException
OMEXMLService
getOMEXML
in interface OMEXMLService
loci.common.services.ServiceException
- If there is an error creating the OME-XML
metadata object.OMEXMLService.getOMEXML(loci.formats.meta.MetadataRetrieve)
public boolean validateOMEXML(java.lang.String xml)
OMEXMLService
validateOMEXML
in interface OMEXMLService
xml
- XML string to validate.OMEXMLService.validateOMEXML(java.lang.String)
public boolean validateOMEXML(java.lang.String xml, boolean pixelsHack)
OMEXMLService
validateOMEXML
in interface OMEXMLService
xml
- XML string to validate.pixelsHack
- Whether to ignore validation errors
due to childless Pixels elementsOMEXMLService.validateOMEXML(java.lang.String, boolean)
public Modulo getModuloAlongZ(OMEXMLMetadata omexml, int image)
OMEXMLService
getModuloAlongZ
in interface OMEXMLService
omexml
- An object of type
OMEXMLMetadata
image
- the index of the Image to which the Annotation is linkedOMEXMLService.getModuloAlongZ(OMEXMLMetadata, int)
public Modulo getModuloAlongC(OMEXMLMetadata omexml, int image)
OMEXMLService
getModuloAlongC
in interface OMEXMLService
omexml
- An object of type
OMEXMLMetadata
image
- the index of the Image to which the Annotation is linkedOMEXMLService.getModuloAlongC(OMEXMLMetadata, int)
public Modulo getModuloAlongT(OMEXMLMetadata omexml, int image)
OMEXMLService
getModuloAlongT
in interface OMEXMLService
omexml
- An object of type
OMEXMLMetadata
image
- the index of the Image to which the Annotation is linkedOMEXMLService.getModuloAlongT(OMEXMLMetadata, int)
private Modulo getModuloAlong(OMEXMLMetadata omexml, java.lang.String tag, int image)
Modulo
corresponding to the given ModuloAlong* tag.omexml
- the OMEXMLMetadata from which to retrieve the ModuloAlong* tagtag
- the tag name (e.g. "ModuloAlongC")image
- the Image index within the OMEXMLMetadatapublic java.util.Hashtable getOriginalMetadata(OMEXMLMetadata omexmlMeta)
OMEXMLService
getOriginalMetadata
in interface OMEXMLService
omexmlMeta
- An object of type
OMEXMLMetadata
.OMEXMLService.getOriginalMetadata(loci.formats.ome.OMEXMLMetadata)
public void populateOriginalMetadata(OMEXMLMetadata omexmlMeta, java.util.Hashtable<java.lang.String,java.lang.Object> metadata)
OMEXMLService
populateOriginalMetadata
in interface OMEXMLService
omexmlMeta
- An object of type
OMEXMLMetadata
.metadata
- A hashtable containing metadata key/value pairs.OMEXMLService.populateOriginalMetadata(loci.formats.ome.OMEXMLMetadata, Hashtable)
public void populateOriginalMetadata(OMEXMLMetadata omexmlMeta, java.lang.String key, java.lang.String value)
OMEXMLService
populateOriginalMetadata
in interface OMEXMLService
omexmlMeta
- An object of type
OMEXMLMetadata
.key
- Metadata key to populate.value
- Metadata value corresponding to the specified key.OMEXMLService.populateOriginalMetadata(loci.formats.ome.OMEXMLMetadata, java.lang.String, java.lang.String)
public void convertMetadata(java.lang.String xml, MetadataStore dest) throws loci.common.services.ServiceException
OMEXMLService
convertMetadata
in interface OMEXMLService
loci.common.services.ServiceException
- If there is an error creating the OME-XML
metadata object.OMEXMLService.convertMetadata(java.lang.String, loci.formats.meta.MetadataStore)
public void convertMetadata(MetadataRetrieve src, MetadataStore dest)
OMEXMLService
convertMetadata
in interface OMEXMLService
OMEXMLService.convertMetadata(loci.formats.meta.MetadataRetrieve, loci.formats.meta.MetadataStore)
public void removeBinData(OMEXMLMetadata omexmlMeta)
OMEXMLService
removeBinData
in interface OMEXMLService
OMEXMLService.removeBinData(OMEXMLMetadata)
public void removeTiffData(OMEXMLMetadata omexmlMeta)
OMEXMLService
removeTiffData
in interface OMEXMLService
OMEXMLService.removeTiffData(OMEXMLMetadata)
public void removeChannels(OMEXMLMetadata omexmlMeta, int image, int sizeC)
OMEXMLService
removeChannels
in interface OMEXMLService
OMEXMLService.removeChannels(OMEXMLMetadata, int, int)
public void addMetadataOnly(OMEXMLMetadata omexmlMeta, int image)
OMEXMLService
addMetadataOnly
in interface OMEXMLService
OMEXMLService.addMetadataOnly(OMEXMLMetadata, int)
public void addMetadataOnly(OMEXMLMetadata omexmlMeta, int image, boolean resolve)
OMEXMLService
addMetadataOnly
in interface OMEXMLService
OMEXMLService.addMetadataOnly(OMEXMLMetadata, int, boolean)
public boolean isEqual(OMEXMLMetadata src1, OMEXMLMetadata src2)
OMEXMLService
isEqual
in interface OMEXMLService
OMEXMLService.isEqual(OMEXMLMetadata, OMEXMLMetadata)
public void addModuloAlong(OMEXMLMetadata meta, CoreMetadata core, int imageIdx)
OMEXMLService
addModuloAlong
in interface OMEXMLService
meta
- An object of type OMEXMLMetadata
core
- A fully populated object of type
CoreMetadata
imageIdx
- Index of the Image to which the annotation should be linked.private void createModulo(OMEXMLMetadata meta, Modulo modulo, ome.xml.model.StructuredAnnotations annotations, ome.xml.model.Image image, int imageIdx, int annotationIndex, int imageAnnotation)
Modulo
.meta
- the OMEXMLMetadata in which to create the annotationmodulo
- the Modulo object that contains the annotation dataannotations
- the list of existing annotationsimage
- the Image to which the new annotation should be linkedimageIdx
- the index of the ImageannotationIndex
- the index to be assigned to the new annotationimageAnnotation
- the index to be assigned to the new annotation linkpublic MetadataStore asStore(MetadataRetrieve meta)
OMEXMLService
MetadataRetrieve
object as a MetadataStore
.
Returns null if the object is incompatible and cannot be casted.asStore
in interface OMEXMLService
OMEXMLService.asStore(loci.formats.meta.MetadataRetrieve)
public MetadataRetrieve asRetrieve(MetadataStore meta)
OMEXMLService
MetadataStore
object as a MetadataRetrieve
.
Returns null if the object is incompatible and cannot be casted.asRetrieve
in interface OMEXMLService
OMEXMLService.asRetrieve(loci.formats.meta.MetadataStore)
private java.lang.String verifyOMENamespace(java.lang.String xml)
public boolean equals(org.w3c.dom.Node e1, org.w3c.dom.Node e2)
private org.w3c.dom.Node findRootNode(org.w3c.dom.Node child)
private org.w3c.dom.Node findChildWithID(org.w3c.dom.Node root, java.lang.String name, java.lang.String id)
Copyright © 2019 Open Microscopy Environment