Skip to content

Commit

Permalink
Add XmlIoAbstractSequenceDescription.toXML with basePathURI
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed Sep 14, 2024
1 parent c9fbc6a commit ab19266
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mpicbg/spim/data/SpimDataExample2.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,19 @@ 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();

final BasicImgLoader imgLoader = sequenceDescription.getImgLoader();
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() ) );
Expand Down Expand Up @@ -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 );
}

/**
Expand Down

0 comments on commit ab19266

Please sign in to comment.