Repository: incubator-taverna-language Updated Branches: refs/heads/cwlparser e5547ef8c -> 48f7dd9f7
First commit, Add YAML file parser 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/30910928 Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/30910928 Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/30910928 Branch: refs/heads/cwlparser Commit: 309109286ee0ef07c5744de67c3f83463eb6713b Parents: e5547ef Author: Majdi Haouech <[email protected]> Authored: Mon May 21 15:26:57 2018 +0200 Committer: Majdi Haouech <[email protected]> Committed: Mon May 21 15:26:57 2018 +0200 ---------------------------------------------------------------------- taverna-scufl2-cwl/pom.xml | 43 ++++++++++++++++++++ .../org/apache/taverna/scufl2/cwl/Parser.java | 41 +++++++++++++++++++ 2 files changed, 84 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/30910928/taverna-scufl2-cwl/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-scufl2-cwl/pom.xml b/taverna-scufl2-cwl/pom.xml new file mode 100644 index 0000000..7a897bd --- /dev/null +++ b/taverna-scufl2-cwl/pom.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.taverna.language</groupId> + <artifactId>apache-taverna-language</artifactId> + <version>0.16.0-incubating-SNAPSHOT</version> + </parent> + <artifactId>taverna-scufl2-cwl</artifactId> + <packaging>bundle</packaging> + <name>Apache Taverna Scufl 2 CWL parser</name> + <description>Parser for .cwl file format</description> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>taverna-scufl2-api</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons.io.version}</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/30910928/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 new file mode 100644 index 0000000..544d3d4 --- /dev/null +++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java @@ -0,0 +1,41 @@ +package org.apache.taverna.scufl2.cwl; + +import java.io.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + + +public class Parser { + + private String yamlLine; + private int fileLength; + + private Map<Integer, String> yamlFile = null; + + public Parser(File file) { + int counter = 0; + + yamlFile = new HashMap<>(); + + FileReader yamlFileDescriptor = null; + + + try { + yamlFileDescriptor = new FileReader(file); + BufferedReader bufferedReader = new BufferedReader(yamlFileDescriptor); + String parent = null; + int parentDepth = 0; + while((yamlLine = bufferedReader.readLine()) != null) { + + yamlFile.put(counter, yamlLine); + counter = counter + 1; + } + + bufferedReader.close(); + fileLength = counter; + } catch (IOException e) { + System.err.println("Parser init error: " + e ); + } + } +}
