From ab1926620956ab8c8416a2a34a499bf8c53d4a30 Mon Sep 17 00:00:00 2001 From: tpietzsch Date: Sat, 14 Sep 2024 17:12:29 +0200 Subject: [PATCH] Add XmlIoAbstractSequenceDescription.toXML with basePathURI --- src/main/java/mpicbg/spim/data/SpimDataExample2.java | 4 ++-- .../spim/data/generic/XmlIoAbstractSpimData.java | 2 +- .../sequence/XmlIoAbstractSequenceDescription.java | 11 ++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/mpicbg/spim/data/SpimDataExample2.java b/src/main/java/mpicbg/spim/data/SpimDataExample2.java index dc3e11c..f4bce2f 100644 --- a/src/main/java/mpicbg/spim/data/SpimDataExample2.java +++ b/src/main/java/mpicbg/spim/data/SpimDataExample2.java @@ -173,11 +173,11 @@ public static void exampleSequenceDescription() throws IOException, ParseExcepti { final XmlIoSequenceDescription io = new XmlIoSequenceDescription(); final SequenceDescription sequence = createSequenceDescription(); - final Document doc = new Document( io.toXml( sequence, null ) ); + final Document doc = new Document( io.toXml( sequence, ( URI ) null ) ); new XMLOutputter( Format.getPrettyFormat() ).output( doc, System.out ); final SequenceDescription fromXml = io.fromXml( doc.getRootElement(), ( URI ) null ); - new XMLOutputter( Format.getPrettyFormat() ).output( new Document( new XmlIoSequenceDescription().toXml( fromXml, null ) ), System.out ); + new XMLOutputter( Format.getPrettyFormat() ).output( new Document( new XmlIoSequenceDescription().toXml( fromXml, ( URI ) null ) ), System.out ); } public static void exampleViewRegistrations() throws SpimDataException, IOException diff --git a/src/main/java/mpicbg/spim/data/generic/XmlIoAbstractSpimData.java b/src/main/java/mpicbg/spim/data/generic/XmlIoAbstractSpimData.java index f546674..07a1de7 100644 --- a/src/main/java/mpicbg/spim/data/generic/XmlIoAbstractSpimData.java +++ b/src/main/java/mpicbg/spim/data/generic/XmlIoAbstractSpimData.java @@ -222,7 +222,7 @@ public Element toXml( final T spimData, final URI xmlParentURI ) throws SpimData final Element root = super.toXml(); root.setAttribute( SPIMDATA_VERSION_ATTRIBUTE_NAME, SPIMDATA_VERSION_ATTRIBUTE_CURRENT ); root.addContent( XmlHelpers.pathElementURI( "BasePath", spimData.getBasePathURI(), xmlParentURI ) ); - root.addContent( xmlIoSequenceDescription.toXml( spimData.getSequenceDescription(), spimData.getBasePath() ) ); + root.addContent( xmlIoSequenceDescription.toXml( spimData.getSequenceDescription(), spimData.getBasePathURI() ) ); root.addContent( xmlIoViewRegistrations.toXml( spimData.getViewRegistrations() ) ); return root; } diff --git a/src/main/java/mpicbg/spim/data/generic/sequence/XmlIoAbstractSequenceDescription.java b/src/main/java/mpicbg/spim/data/generic/sequence/XmlIoAbstractSequenceDescription.java index 24f521e..9fd7565 100644 --- a/src/main/java/mpicbg/spim/data/generic/sequence/XmlIoAbstractSequenceDescription.java +++ b/src/main/java/mpicbg/spim/data/generic/sequence/XmlIoAbstractSequenceDescription.java @@ -69,6 +69,11 @@ public XmlIoAbstractSequenceDescription( final Class< T > klass, } public Element toXml( final T sequenceDescription, final File basePath ) throws SpimDataException + { + return toXml( sequenceDescription, basePath.toURI() ); + } + + public Element toXml( final T sequenceDescription, final URI basePathURI ) throws SpimDataException { final Element elem = super.toXml(); @@ -76,7 +81,7 @@ public Element toXml( final T sequenceDescription, final File basePath ) throws if ( imgLoader != null ) { final XmlIoBasicImgLoader< ? > imgLoaderIo = ImgLoaders.createXmlIoForImgLoaderClass( imgLoader.getClass() ); - elem.addContent( createImgLoaderElement( imgLoaderIo, imgLoader, basePath ) ); + elem.addContent( createImgLoaderElement( imgLoaderIo, imgLoader, basePathURI ) ); } elem.addContent( xmlIoViewSetups.toXml( sequenceDescription.getViewSetups() ) ); @@ -128,9 +133,9 @@ public T fromXml( final Element elem, final URI basePathURI ) throws SpimDataExc * Casting madness. */ @SuppressWarnings( "unchecked" ) - private static < L extends BasicImgLoader > Element createImgLoaderElement( final XmlIoBasicImgLoader< L > imgLoaderIo, final BasicImgLoader imgLoader, final File basePath ) + private static < L extends BasicImgLoader > Element createImgLoaderElement( final XmlIoBasicImgLoader< L > imgLoaderIo, final BasicImgLoader imgLoader, final URI basePathURI ) { - return imgLoaderIo.toXml( ( L ) imgLoader, basePath ); + return imgLoaderIo.toXml( ( L ) imgLoader, basePathURI ); } /**