You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2018/07/05 10:45:52 UTC

[02/13] incubator-taverna-language git commit: Add helper functions

Add helper functions


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/252e3d8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/252e3d8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/252e3d8b

Branch: refs/heads/cwlparser
Commit: 252e3d8b11914b16a8212ef86d1cf435017209fe
Parents: 3091092
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon May 21 15:29:02 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon May 21 15:29:38 2018 +0200

----------------------------------------------------------------------
 .../org/apache/taverna/scufl2/cwl/Parser.java   | 79 ++++++++++++++++++++
 1 file changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/252e3d8b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
index 544d3d4..8cc6655 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
@@ -6,6 +6,44 @@ import java.util.HashMap;
 import java.util.Map;
 
 
+
+class InputField {
+
+    public String key;
+    public String type;
+    public int position;
+    public String prefix;
+
+    public InputField(String _key) {
+        key = _key;
+        type = "";
+        position = -1;
+        prefix = "";
+    }
+
+    public InputField(String _key, String _type) {
+        key = _key;
+        type = _type;
+        position = -1;
+        prefix = "";
+    }
+
+    public InputField(String _key, String _type, int pos) {
+        key = _key;
+        type = _type;
+        position = pos;
+        prefix = "";
+    }
+
+    public InputField(String _key, String _type, int pos, String _prefix) {
+        key = _key;
+        type = _type;
+        position = pos;
+        prefix = _prefix;
+    }
+}
+
+
 public class Parser {
 
     private String yamlLine;
@@ -38,4 +76,45 @@ public class Parser {
             System.err.println("Parser init error: " + e );
         }
     }
+
+
+
+
+    private int getNextLineIndex(int index) {
+        index++;
+
+        while(yamlFile.get(index).equals("")) {
+            index++;
+        }
+
+        return index;
+    }
+
+    public static int getDepth(String line) {
+        int count = 0;
+        int idx = 0;
+        while(idx < line.length()) {
+            if(line.charAt(idx) != ' ') {
+                break;
+            }
+            count++;
+            idx++;
+        }
+        assert count % 2 == 0;
+        return count / 2;
+    }
+
+    public static String getKeyFromLine(String line) {
+        int commaIndex = line.indexOf(':');
+        assert commaIndex != -1;
+
+        return line.substring(0, commaIndex).trim();
+    }
+
+    public static String getValueFromLine(String line) {
+        int commaIndex = line.indexOf(':');
+        assert commaIndex != -1;
+
+        return line.substring(commaIndex + 1).trim();
+    }
 }