some tools useful when working with COMBINE stuff
The CombineFormatizer contains methods to obtain format URIs for certain file types.
Within the COMBINE community, file formats are usually expressed as URIs, e.g. in combinearchive:wiki. That is, an SBML file may for example be of format http://identifiers.org/combine.specifications/sbml
. This often makes things extra complicated and, thus, we developed the CombineFormatizer.
The Formatizer class provides some methods to retrieve a format given a file:
If you just have a file extension you may pass it to Formatizer.getFormatFromExtension (String)
JavaDoc:
File f = ...
String extension = f.getName ().substring (f.getName ().lastIndexOf (".") + 1);
URI format = Formatizer.getFormatFromExtension (extension);
That is obviously not the best method, but it might be a good start.
The CombineFormatizer is also able to guess formats from media types using Formatizer.getFormatFromMime (String)
JavaDoc:
File f = ...
String mime = Files.probeContentType (f.toPath ());
URI format = Formatizer.getFormatFromMime (mime);
You can also pass a file object to Formatizer.guessFormat (File)
JavaDoc:
File f = ...
URI format = Formatizer.guessFormat (f);
To learn how to extend the Formatizer to also recognize other file types see ExtendCombineFormatizer.