ServiceMetadata metadata = new ServiceMetaData();
metadata.setVersion("1.0.0");
metadata.setVendor("http://www.anc.org");
metadata.setAllows("http://vocab.lappsgrid.org/ns/usage#any");
metadata.setLicense("http://vocab.lappsgrid.org/ns/license/apache-2.0");
IOSpecification requires = metadata.getRequires();
requires.addFormat("http://vocab.lappsgrid.org/ns/media/xml#gate");
requires.setEncoding("UTF-8");
requires.addAnnotation("http://vocab.lappsgrid.org/Token");
IOSpecification produces = metadata.getProduces();
produces.addFormat("http://vocab.lappsgrid.org/ns/media/xml#gate");
produces.setEncoding("UTF-8");
produces.addAnnotation("http://vocab.lappsgrid.org/Sentence")"
System.out.println(metadata.toPrettyJson());
The classes ServiceMetadataBuilder
and DataSourceMetaDataBuilder
provide a Fluent API for constructing ServiceMetadata and DataSourceMetadata object respectively.
ServiceMetadata md = new ServiceMetadataBuilder()
.licence(Uri.APACHE2)
.version("1.0.0")
.requires(URI.TOKEN)
.produces(Uri.SENTENCE)
.build();
File file = ... /* The file containing the metadata in JSON. */
ServiceMetadata metadata = new ServiceMetadata(file);
System.out.println(metadata.getVendor());
There is also a constructor that accepts a String object containing the JSON
String json = "{ ... }";
ServiceMetadata metadata = new ServiceMetadata(json);
System.out.println(metadata.getVendor());