This is an automated email from the ASF dual-hosted git repository.

liuxun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new a162a20  [ZEPPELIN-4164] Fixed submarine interpreter CommandParser 
causes openjdk to fail to compile
a162a20 is described below

commit a162a2001262aeced7a1791ffb1e4949f68ccbd2
Author: Xun Liu <liu...@apache.org>
AuthorDate: Tue May 21 19:20:49 2019 +0800

    [ZEPPELIN-4164] Fixed submarine interpreter CommandParser causes openjdk to 
fail to compile
    
    ### What is this PR for?
    Fixed submarine interpreter CommandParser causes openjdk to fail to compile.
    
    ### What type of PR is it?
    [Bug Fix]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-4164
    
    ### How should this be tested?
    [CI pass](https://travis-ci.org/liuxunorg/zeppelin/builds/535245936)
    
    ### Screenshots (if appropriate)
    <img width="1279" alt="CommandParser" 
src="https://user-images.githubusercontent.com/3677382/58141107-b5d20000-7c74-11e9-910a-0c934511fd52.png";>
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: Xun Liu <liu...@apache.org>
    
    Closes #3369 from liuxunorg/ZEPPELIN-4164 and squashes the following 
commits:
    
    48e464b74 [Xun Liu] [ZEPPELIN-4164] Fixed submarine interpreter 
CommandParser causes openjdk to fail to compile.
---
 .../zeppelin/submarine/commons/CommandParser.java  | 242 ---------------------
 1 file changed, 242 deletions(-)

diff --git 
a/submarine/src/main/java/org/apache/zeppelin/submarine/commons/CommandParser.java
 
b/submarine/src/main/java/org/apache/zeppelin/submarine/commons/CommandParser.java
deleted file mode 100644
index d1749d2..0000000
--- 
a/submarine/src/main/java/org/apache/zeppelin/submarine/commons/CommandParser.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed 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.
- */
-
-package org.apache.zeppelin.submarine.commons;
-
-import javafx.util.Pair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.function.Consumer;
-import java.util.stream.Stream;
-
-public class CommandParser {
-  private Logger LOGGER = LoggerFactory.getLogger(CommandParser.class);
-
-  private Map<String, String> configValues = new HashMap<>();
-
-  /**
-   * The default character used to denote comments
-   */
-  public static final transient char COMMENT = '#';
-
-  /**
-   * The default character used to denote assignment
-   */
-  public static final transient char EQUAL_SIGN = '=';
-
-  private String command = "";
-
-  /**
-   * Populate this Config using a Scanner
-   *
-   * @param sc
-   */
-  public void populate(Scanner sc) {
-    while (sc.hasNext()) {
-      parseAndAdd(sc.nextLine());
-    }
-  }
-
-  public void populate(String sc) {
-    String[] lines = sc.split("\n");
-    for (int n = 0; n < lines.length; n++) {
-      String line = lines[n];
-      parseAndAdd(line);
-    }
-  }
-
-  /**
-   * Populate this Config using a BufferedReader
-   *
-   * @param sc
-   */
-  public void populate(BufferedReader sc) {
-    Stream<String> s = sc.lines();
-
-    s.forEach(new Consumer<String>() {
-      @Override
-      public void accept(String arg0) {
-        parseAndAdd(arg0);
-      }
-    });
-  }
-
-  /**
-   * Populate Config with file
-   * @param f
-   */
-  public void populate(File f) {
-    try {
-      BufferedReader br = new BufferedReader(new FileReader(f));
-      populate(br);
-      br.close();
-    } catch (FileNotFoundException e) {
-      LOGGER.error(e.getMessage(), e);
-    } catch (IOException e) {
-      LOGGER.error(e.getMessage(), e);
-    }
-  }
-
-  /**
-   * Add a line in the format `key=value` to this Config
-   *
-   * @param line
-   * @throws IllegalArgumentException In the event the line is incorrectly 
formatted
-   */
-  private void parseAndAdd(String line) throws IllegalArgumentException {
-    Pair<String, String> p = getEntryFromString(line);
-
-    if (p == null)
-      return;
-
-    addEntry(p);
-  }
-
-  /**
-   * Given a line in the format `key=value`, this method discards any comments 
and
-   * returns a Pair<key, value>.
-   * @param entry
-   * @return
-   * @throws IllegalArgumentException
-   */
-  private Pair<String, String> getEntryFromString(String entry)
-      throws IllegalArgumentException {
-
-    // Parse comments, if there are any
-    int commentIndex = entry.indexOf(COMMENT);
-
-    if (commentIndex != -1) {
-      entry = entry.substring(0, commentIndex);
-    }
-
-    if (isBlank(entry)) {
-      return null;
-    }
-
-    int index = entry.indexOf(EQUAL_SIGN);
-
-    // Throw exception if no `=` found
-    if (index == -1) {
-      command = entry;
-      return null;
-    }
-
-    String key = entry.substring(0, index).trim().toUpperCase();
-    String value = entry.substring(index + 1, entry.length()).trim();
-
-    return new Pair<>(key, value);
-  }
-
-  /**
-   * Add an entry with given name and value to the internal map.
-   *
-   * @param key
-   * @param value
-   * @return
-   */
-  private boolean addEntry(String key, String value) {
-    if (configValues.containsKey(key)) {
-      return false;
-    } else {
-      configValues.put(key, value);
-      return true;
-    }
-  }
-
-  private boolean isBlank(String e) {
-    for (char c : e.toCharArray()) {
-      if (!Character.isWhitespace(c))
-        return false;
-    }
-
-    return true;
-  }
-
-  /**
-   * Add an entry from a given Pair<key, value> to the internal map.
-   *
-   * @param val
-   * @return
-   */
-  private boolean addEntry(Pair<String, String> val) {
-    return addEntry(val.getKey(), val.getValue());
-  }
-
-  public String getCommand() {
-    return command;
-  }
-
-  /**
-   * Get the config value for a specified key
-   *
-   * @param key
-   * @return The retrieved value, of null if not registered
-   */
-  public String getConfig(String key) {
-    return configValues.get(key);
-  }
-
-  /**
-   * Get the config value for a specified key, or defaults
-   *
-   * @param key
-   * @param def Default value
-   * @return The retrieved value, of null if not registered
-   */
-  public String getConfig(String key, String def) {
-    return configValues.getOrDefault(key, def);
-  }
-
-  /**
-   * Get the integer config value for a specified key
-   *
-   * @param key
-   * @return
-   * @throws IllegalArgumentException If specified key is not found
-   */
-  public int getIntConfig(String key) {
-    String s = getConfig(key);
-
-    if (s == null)
-      throw new IllegalArgumentException("Key `" + key + "` not found!");
-
-    return Integer.parseInt(s);
-  }
-
-  /**
-   * Get the integer config value for a specified key, defaulting if not found
-   *
-   * @param key
-   * @param def Default value
-   * @return
-   * @throws IllegalArgumentException If specified key is not found
-   */
-  public int getIntConfig(String key, int def) {
-    String s = getConfig(key);
-
-    if (s == null)
-      return def;
-
-    return Integer.parseInt(s);
-  }
-}

Reply via email to