]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/ltk/LocalResourceSource.java
Removed org.simantics.ltk[.antlr] bundles, exact import for antlr
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / ltk / LocalResourceSource.java
diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/ltk/LocalResourceSource.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/ltk/LocalResourceSource.java
new file mode 100644 (file)
index 0000000..34cda23
--- /dev/null
@@ -0,0 +1,39 @@
+package org.simantics.graph.compiler.internal.ltk;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class LocalResourceSource implements ISource {
+    Class<?> clazz;
+    String resource;
+    
+    public LocalResourceSource(Class<?> clazz, String resource) {
+        this.clazz = clazz;
+        this.resource = resource;
+    }
+
+    @Override
+    public InputStream open() throws IOException {
+        return clazz.getResourceAsStream(resource);
+    }
+    
+    @Override
+    public String getName() {
+        return resource;
+    }
+
+    @Override
+    public int length() throws IOException {
+        return -1;
+    }
+    
+    @Override
+    public int startPos() {
+        return 0;
+    }
+    
+    @Override
+    public int startLine() {
+        return 0;
+    }
+}