Package loci.formats.services
Class OMEXMLServiceImpl
java.lang.Object
loci.common.services.AbstractService
loci.formats.services.OMEXMLServiceImpl
- All Implemented Interfaces:
loci.common.services.Service,OMEXMLService
public class OMEXMLServiceImpl
extends loci.common.services.AbstractService
implements OMEXMLService
- Author:
- callan
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringLatest OME-XML version namespace.private static final org.slf4j.LoggerLogger for this class.static final Stringprivate static TemplatesReordering stylesheet.static final loci.common.xml.XMLTools.SchemaReaderFinds OME-XML schema definitions in specifications.jar.private static final Stringprivate static final PatternThe pattern of system ID URLs for OME-XML schema definitions.private static TemplatesStylesheets for updating from previous schema releases.private static Templatesprivate static Templatesprivate static Templatesprivate static Templatesprivate static Templatesprivate static Templatesprivate static Templatesprivate static Templatesprivate static Templatesprivate static Templatesprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMetadataOnly(OMEXMLMetadata omexmlMeta, int image) Insert a MetadataOnly element under the Image specified by 'index' in the given OME-XML metadata object.voidaddMetadataOnly(OMEXMLMetadata omexmlMeta, int image, boolean resolve) Insert a MetadataOnly element under the Image specified by 'index' in the given OME-XML metadata object.voidaddModuloAlong(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.asRetrieve(MetadataStore meta) Gets the givenMetadataStoreobject as aMetadataRetrieve.asStore(MetadataRetrieve meta) Gets the givenMetadataRetrieveobject as aMetadataStore.voidconvertMetadata(String xml, MetadataStore dest) Converts information from an OME-XML string (source) into a metadata store (destination).voidconvertMetadata(MetadataRetrieve src, MetadataStore dest) Copies information from a metadata retrieval object (source) into a metadata store (destination).private voidcreateModulo(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 givenModulo.Creates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage.Creates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage, wrapping a DOM representation of the given OME-XML string.createOMEXMLMetadata(String xml, String version) Creates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage, wrapping a DOM representation of the given OME-XML string.ome.xml.model.OMEModelObjectcreateOMEXMLRoot(String xml) Constructs an OME root node.private ome.xml.meta.OMEXMLMetadataRootcreateRoot(String xml) Constructs an OME root node.booleanCompares two Elements for equality.private NodefindChildWithID(Node root, String name, String id) Return the child node with specified value for the "ID" attribute.private NodefindRootNode(Node child) Return the absolute root node for the specified child node.Retrieves the latest supported version of the OME-XML schema.private ModulogetModuloAlong(OMEXMLMetadata omexml, String tag, int image) Create aModulocorresponding to the given ModuloAlong* tag.getModuloAlongC(OMEXMLMetadata omexml, int image) Retrieve the ModuloAlongC annotation in the given Image in the given OME-XML metadata object.getModuloAlongT(OMEXMLMetadata omexml, int image) Retrieve the ModuloAlongT annotation in the given Image in the given OME-XML metadata object.getModuloAlongZ(OMEXMLMetadata omexml, int image) Retrieve the ModuloAlongZ annotation in the given Image in the given OME-XML metadata object.Returns aOMEXMLMetadataobject with the same contents as the given MetadataRetrieve, converting it if necessary.Extracts an OME-XML metadata string from the given metadata object, by converting to an OME-XML metadata object if necessary.Gets the schema version for the given OME-XML metadata or root object (e.g., "2007-06" or "2003-FC").getOriginalMetadata(OMEXMLMetadata omexmlMeta) Parse any OriginalMetadata annotations from the given OME-XML metadata object and store them in a Hashtable.booleanisEqual(OMEXMLMetadata src1, OMEXMLMetadata src2) Determine whether or not two OMEXMLMetadata objects are equal.booleanChecks whether the given object is an OME-XML metadata object.booleanChecks whether the given object is an OME-XML root object.voidpopulateOriginalMetadata(OMEXMLMetadata omexmlMeta, String key, String value) Adds the specified key/value pair as a new OriginalMetadata node to the given OME-XML metadata object.voidpopulateOriginalMetadata(OMEXMLMetadata omexmlMeta, Hashtable<String, Object> metadata) Adds the key/value pairs in the specified Hashtable as new OriginalMetadata annotations in the given OME-XML metadata object.voidremoveBinData(OMEXMLMetadata omexmlMeta) Remove all of the BinData elements from the given OME-XML metadata object.voidremoveChannels(OMEXMLMetadata omexmlMeta, int image, int sizeC) Remove all but the first sizeC valid Channel elements from the given OME-XML metadata object.voidremoveTiffData(OMEXMLMetadata omexmlMeta) Remove all of the TiffData elements from the given OME-XML metadata object.Transforms the given OME-XML string to the latest supported version of of the OME-XML schema.booleanvalidateOMEXML(String xml) Attempts to validate the given OME-XML string using Java's XML validation facility.booleanvalidateOMEXML(String xml, boolean pixelsHack) Attempts to validate the given OME-XML string using Java's XML validation facility.private StringverifyOMENamespace(String xml) Ensures that an xmlns:ome element exists.Methods inherited from class loci.common.services.AbstractService
checkClassDependency
-
Field Details
-
LATEST_VERSION
Latest OME-XML version namespace.- See Also:
-
NO_OME_XML_MSG
-
LOGGER
private static final org.slf4j.Logger LOGGERLogger for this class. -
XSLT_PATH
- See Also:
-
XSLT_2003FC
- See Also:
-
XSLT_200706
- See Also:
-
XSLT_200802
- See Also:
-
XSLT_200809
- See Also:
-
XSLT_200909
- See Also:
-
XSLT_201004
- See Also:
-
XSLT_201006
- See Also:
-
XSLT_201106
- See Also:
-
XSLT_201206
- See Also:
-
XSLT_201306
- See Also:
-
XSLT_201501
- See Also:
-
reorderXSLT
Reordering stylesheet. -
update2003FC
Stylesheets for updating from previous schema releases. -
update200706
-
update200802
-
update200809
-
update200909
-
update201004
-
update201006
-
update201106
-
update201206
-
update201306
-
update201501
-
SCHEMA_PATH
- See Also:
-
SCHEMA_URL_PATTERN
The pattern of system ID URLs for OME-XML schema definitions. -
SCHEMA_CLASSPATH_READER
public static final loci.common.xml.XMLTools.SchemaReader SCHEMA_CLASSPATH_READERFinds OME-XML schema definitions in specifications.jar.
-
-
Constructor Details
-
OMEXMLServiceImpl
public OMEXMLServiceImpl()Default constructor.
-
-
Method Details
-
getLatestVersion
Description copied from interface:OMEXMLServiceRetrieves the latest supported version of the OME-XML schema.- Specified by:
getLatestVersionin interfaceOMEXMLService- See Also:
-
transformToLatestVersion
Description copied from interface:OMEXMLServiceTransforms the given OME-XML string to the latest supported version of of the OME-XML schema.- Specified by:
transformToLatestVersionin interfaceOMEXMLService- Throws:
loci.common.services.ServiceException- See Also:
-
createOMEXMLMetadata
Description copied from interface:OMEXMLServiceCreates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage.- Specified by:
createOMEXMLMetadatain interfaceOMEXMLService- Returns:
- A new instance of
AbstractOMEXMLMetadata, or null if the class is not available. - Throws:
loci.common.services.ServiceException- If there is an error creating the OME-XML metadata object.- See Also:
-
createOMEXMLMetadata
Description copied from interface:OMEXMLServiceCreates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage, wrapping a DOM representation of the given OME-XML string.- Specified by:
createOMEXMLMetadatain interfaceOMEXMLService- Returns:
- A new instance of
AbstractOMEXMLMetadata, or null if the class is not available. - Throws:
loci.common.services.ServiceException- If there is an error creating the OME-XML metadata object.- See Also:
-
createOMEXMLMetadata
public OMEXMLMetadata createOMEXMLMetadata(String xml, String version) throws loci.common.services.ServiceException Description copied from interface:OMEXMLServiceCreates an OME-XML metadata object using reflection, to avoid direct dependencies on the optionalloci.formats.omepackage, wrapping a DOM representation of the given OME-XML string.- Specified by:
createOMEXMLMetadatain interfaceOMEXMLService- Parameters:
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.- Returns:
- A new instance of
AbstractOMEXMLMetadata, or null if the class is not available. - Throws:
loci.common.services.ServiceException- If there is an error creating the OME-XML metadata object.- See Also:
-
createOMEXMLRoot
public ome.xml.model.OMEModelObject createOMEXMLRoot(String xml) throws loci.common.services.ServiceException Description copied from interface:OMEXMLServiceConstructs an OME root node.- Specified by:
createOMEXMLRootin interfaceOMEXMLService- Parameters:
xml- String of XML to create the root node from.- Returns:
- An ome.xml.model.OMEModelObject subclass root node.
- Throws:
loci.common.services.ServiceException- If there is an error creating the OME-XML metadata object.- See Also:
-
isOMEXMLMetadata
Description copied from interface:OMEXMLServiceChecks whether the given object is an OME-XML metadata object.- Specified by:
isOMEXMLMetadatain interfaceOMEXMLService- Returns:
- True if the object is an instance of
OMEXMLMetadata. - See Also:
-
isOMEXMLRoot
Description copied from interface:OMEXMLServiceChecks whether the given object is an OME-XML root object.- Specified by:
isOMEXMLRootin interfaceOMEXMLService- Returns:
- True if the object is an instance of
OME. - See Also:
-
createRoot
private ome.xml.meta.OMEXMLMetadataRoot createRoot(String xml) throws loci.common.services.ServiceException Constructs an OME root node. NOTE: This method is mostly here to ensure type safety of return values as instances of service dependency classes should not leak out of the interface.- Parameters:
xml- String of XML to create the root node from.- Returns:
- An ome.xml.model.OMEModelObject subclass root node.
- Throws:
IOException- If there is an error reading from the string.SAXException- If there is an error parsing the XML.ParserConfigurationException- If there is an error preparing the parsing infrastructure.loci.common.services.ServiceException
-
getOMEXMLVersion
Description copied from interface:OMEXMLServiceGets the schema version for the given OME-XML metadata or root object (e.g., "2007-06" or "2003-FC").- Specified by:
getOMEXMLVersionin interfaceOMEXMLService- Returns:
- OME-XML schema version, or null if the object is not an instance
of
OMEXMLMetadata. - See Also:
-
getOMEMetadata
public OMEXMLMetadata getOMEMetadata(MetadataRetrieve src) throws loci.common.services.ServiceException Description copied from interface:OMEXMLServiceReturns aOMEXMLMetadataobject with the same contents as the given MetadataRetrieve, converting it if necessary.- Specified by:
getOMEMetadatain interfaceOMEXMLService- Throws:
loci.common.services.ServiceException- If there is an error creating the OME-XML metadata object.- See Also:
-
getOMEXML
Description copied from interface:OMEXMLServiceExtracts an OME-XML metadata string from the given metadata object, by converting to an OME-XML metadata object if necessary.- Specified by:
getOMEXMLin interfaceOMEXMLService- Throws:
loci.common.services.ServiceException- If there is an error creating the OME-XML metadata object.- See Also:
-
validateOMEXML
Description copied from interface:OMEXMLServiceAttempts to validate the given OME-XML string using Java's XML validation facility. Requires Java 1.5+.- Specified by:
validateOMEXMLin interfaceOMEXMLService- Parameters:
xml- XML string to validate.- Returns:
- true if the XML successfully validates.
- See Also:
-
validateOMEXML
Description copied from interface:OMEXMLServiceAttempts to validate the given OME-XML string using Java's XML validation facility. Requires Java 1.5+.- Specified by:
validateOMEXMLin interfaceOMEXMLService- Parameters:
xml- XML string to validate.pixelsHack- Whether to ignore validation errors due to childless Pixels elements- Returns:
- true if the XML successfully validates.
- See Also:
-
getModuloAlongZ
Description copied from interface:OMEXMLServiceRetrieve the ModuloAlongZ annotation in the given Image in the given OME-XML metadata object. If no ModuloAlongZ annotation is present, return null.- Specified by:
getModuloAlongZin interfaceOMEXMLService- Parameters:
omexml- An object of typeOMEXMLMetadataimage- the index of the Image to which the Annotation is linked- See Also:
-
getModuloAlongC
Description copied from interface:OMEXMLServiceRetrieve the ModuloAlongC annotation in the given Image in the given OME-XML metadata object. If no ModuloAlongC annotation is present, return null.- Specified by:
getModuloAlongCin interfaceOMEXMLService- Parameters:
omexml- An object of typeOMEXMLMetadataimage- the index of the Image to which the Annotation is linked- See Also:
-
getModuloAlongT
Description copied from interface:OMEXMLServiceRetrieve the ModuloAlongT annotation in the given Image in the given OME-XML metadata object. If no ModuloAlongT annotation is present, return null.- Specified by:
getModuloAlongTin interfaceOMEXMLService- Parameters:
omexml- An object of typeOMEXMLMetadataimage- the index of the Image to which the Annotation is linked- See Also:
-
getModuloAlong
Create aModulocorresponding to the given ModuloAlong* tag.- Parameters:
omexml- the OMEXMLMetadata from which to retrieve the ModuloAlong* tagtag- the tag name (e.g. "ModuloAlongC")image- the Image index within the OMEXMLMetadata- Returns:
- the corresponding Modulo object
-
getOriginalMetadata
Description copied from interface:OMEXMLServiceParse any OriginalMetadata annotations from the given OME-XML metadata object and store them in a Hashtable.- Specified by:
getOriginalMetadatain interfaceOMEXMLService- Parameters:
omexmlMeta- An object of typeOMEXMLMetadata.- See Also:
-
populateOriginalMetadata
Description copied from interface:OMEXMLServiceAdds the key/value pairs in the specified Hashtable as new OriginalMetadata annotations in the given OME-XML metadata object.- Specified by:
populateOriginalMetadatain interfaceOMEXMLService- Parameters:
omexmlMeta- An object of typeOMEXMLMetadata.metadata- A hashtable containing metadata key/value pairs.- See Also:
-
populateOriginalMetadata
Description copied from interface:OMEXMLServiceAdds the specified key/value pair as a new OriginalMetadata node to the given OME-XML metadata object.- Specified by:
populateOriginalMetadatain interfaceOMEXMLService- Parameters:
omexmlMeta- An object of typeOMEXMLMetadata.key- Metadata key to populate.value- Metadata value corresponding to the specified key.- See Also:
-
convertMetadata
public void convertMetadata(String xml, MetadataStore dest) throws loci.common.services.ServiceException Description copied from interface:OMEXMLServiceConverts information from an OME-XML string (source) into a metadata store (destination).- Specified by:
convertMetadatain interfaceOMEXMLService- Throws:
loci.common.services.ServiceException- If there is an error creating the OME-XML metadata object.- See Also:
-
convertMetadata
Description copied from interface:OMEXMLServiceCopies information from a metadata retrieval object (source) into a metadata store (destination).- Specified by:
convertMetadatain interfaceOMEXMLService- See Also:
-
removeBinData
Description copied from interface:OMEXMLServiceRemove all of the BinData elements from the given OME-XML metadata object.- Specified by:
removeBinDatain interfaceOMEXMLService- See Also:
-
removeTiffData
Description copied from interface:OMEXMLServiceRemove all of the TiffData elements from the given OME-XML metadata object.- Specified by:
removeTiffDatain interfaceOMEXMLService- See Also:
-
removeChannels
Description copied from interface:OMEXMLServiceRemove all but the first sizeC valid Channel elements from the given OME-XML metadata object.- Specified by:
removeChannelsin interfaceOMEXMLService- See Also:
-
addMetadataOnly
Description copied from interface:OMEXMLServiceInsert a MetadataOnly element under the Image specified by 'index' in the given OME-XML metadata object.- Specified by:
addMetadataOnlyin interfaceOMEXMLService- See Also:
-
addMetadataOnly
Description copied from interface:OMEXMLServiceInsert a MetadataOnly element under the Image specified by 'index' in the given OME-XML metadata object. If the 'resolve' flag is set, references in the OME-XML metadata object will be resolved before the new element is inserted.- Specified by:
addMetadataOnlyin interfaceOMEXMLService- See Also:
-
isEqual
Description copied from interface:OMEXMLServiceDetermine whether or not two OMEXMLMetadata objects are equal. Equality is defined as: * having the same object graph (without regard to specific ID values) * having the exact same attribute values on every node (with the exception of 'ID' attributes) Note that StructuredAnnotations are ignored, i.e. the two OMEXMLMetadata objects may have wildly different things under StructuredAnnotations and still be considered equal.- Specified by:
isEqualin interfaceOMEXMLService- See Also:
-
addModuloAlong
Description copied from interface:OMEXMLServiceAdds ModuloAlong* annotations to the given OME-XML metadata object, using the given CoreMetadata object to determine modulo dimensions.- Specified by:
addModuloAlongin interfaceOMEXMLService- Parameters:
meta- An object of typeOMEXMLMetadatacore- A fully populated object of typeCoreMetadataimageIdx- Index of the Image to which the annotation should be linked.
-
createModulo
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 givenModulo.- Parameters:
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 link
-
asStore
Description copied from interface:OMEXMLServiceGets the givenMetadataRetrieveobject as aMetadataStore. Returns null if the object is incompatible and cannot be casted.- Specified by:
asStorein interfaceOMEXMLService- See Also:
-
asRetrieve
Description copied from interface:OMEXMLServiceGets the givenMetadataStoreobject as aMetadataRetrieve. Returns null if the object is incompatible and cannot be casted.- Specified by:
asRetrievein interfaceOMEXMLService- See Also:
-
verifyOMENamespace
Ensures that an xmlns:ome element exists. -
equals
Compares two Elements for equality. -
findRootNode
Return the absolute root node for the specified child node. -
findChildWithID
Return the child node with specified value for the "ID" attribute.
-