Package org.gradle.example.codedpoet

Source Code of org.gradle.example.codedpoet.CommandLine

package org.gradle.example.codedpoet;

import java.util.List;
import java.util.ArrayList;
import org.gradle.example.codec.Encoder;
import org.gradle.example.content.ContentFactory;
import org.gradle.example.content.Content;

public class CommandLine {

  public void getAndPrintPoem(String poetName) {
    for(String line: getPoemLines(poetName)) {
      System.out.print(line);
    }
  }

  private List<String> getPoemLines(String poetName) {
    ContentFactory contentFactory = ContentFactory.getInstance();
    Content provider = contentFactory.getContentProvider(poetName);
    List<String> clearTextLines = provider.getLines();
    Encoder encoder = new Encoder();

    List<String> encodedLines = new ArrayList<String>();
    for(String line: clearTextLines) {
      encodedLines.add(encoder.encode(line));
    }
    return encodedLines;
  }

  public static void main(String args[]) {
    if(args.length == 1) {
      String poetName = args[0];
      CommandLine commandLine = new CommandLine();
      commandLine.getAndPrintPoem(poetName);
    }
    else {
      System.out.println("usage: CommandLine <poet_name>");
    }
  }
}
TOP

Related Classes of org.gradle.example.codedpoet.CommandLine

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.