Skip to content

Commit 5dfb1ed

Browse files
Add demo module (Java)
1 parent 3dd968e commit 5dfb1ed

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

binary-array-ld-demo/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>binary-array-ld</artifactId>
7+
<groupId>net.binary-array-ld</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>binary-array-ld-demo</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
15+
<name>Binary Array Linked Data - Demos</name>
16+
<description>Examples of Binary Array to Linked Data API usage.</description>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>net.binary-array-ld</groupId>
21+
<artifactId>binary-array-ld-netcdf</artifactId>
22+
<version>${project.parent.version}</version>
23+
</dependency>
24+
</dependencies>
25+
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package net.bald;
2+
3+
import net.bald.model.ModelBinaryArrayConverter;
4+
import net.bald.netcdf.NetCdfBinaryArray;
5+
import org.apache.jena.rdf.model.Model;
6+
7+
import java.io.FileOutputStream;
8+
import java.io.OutputStream;
9+
10+
/**
11+
* Demonstration of how to call the API in Java code.
12+
*/
13+
public class NetCdfConvertJava {
14+
public static void convert(String inputLoc, String outputLoc, String format) throws Exception {
15+
BinaryArray ba = NetCdfBinaryArray.create(inputLoc, "http://test.binary-array-ld.net/example");
16+
Model model = ModelBinaryArrayConverter.convert(ba);
17+
18+
try (OutputStream output = new FileOutputStream(outputLoc)) {
19+
model.write(output, format);
20+
}
21+
}
22+
23+
public static void convert() throws Exception {
24+
convert("/path/to/input.nc", "/path/to/input.ttl", "ttl");
25+
}
26+
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<module>binary-array-ld-cli</module>
2828
<module>binary-array-ld-netcdf</module>
2929
<module>binary-array-ld-test</module>
30+
<module>binary-array-ld-demo</module>
3031
</modules>
3132

3233
<dependencies>

0 commit comments

Comments
 (0)