Package noop.interpreter

Source Code of noop.interpreter.CommandLineLibraryNameParser

package noop.interpreter;

import noop.model.Project;

/**
* When specifying a library on the command line, a string-valued representation is needed.
* This Parser looks for a format such as com.google.Noop/lang and provides the
* Project and library name for the lang library.
* @author Alex Eagle (alexeagle@google.com)
*/
class CommandLineLibraryNameParser {
  private String libraryPath;
  private String libraryName;
  private Project project;

  public CommandLineLibraryNameParser(String libraryPath) {
    this.libraryPath = libraryPath;
  }

  public String getLibraryName() {
    return libraryName;
  }

  public Project getProject() {
    return project;
  }

  public CommandLineLibraryNameParser invoke() {
    String[] parts = libraryPath.split("/");
    String project = parts[0];
    libraryName = parts[1];
    String namespace = project.substring(0, project.lastIndexOf("."));
    String projectName = project.substring(project.lastIndexOf(".") + 1);
    this.project = new Project(projectName, namespace, "");
    return this;
  }
}
TOP

Related Classes of noop.interpreter.CommandLineLibraryNameParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.