Package Specification.Galaxy

Source Code of Specification.Galaxy.CommandHandler

package Specification.Galaxy;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;

import FileOps.XStream.AdvancedXStreamHandler;
import Galaxy.Tree.Tool.Command.Command;

/**
* This handler parses and generates Galaxy Tool commands properly,
* correctly handling the interpereter field as well as the value
* field.
* @author viper
*
*/
public class CommandHandler extends AdvancedXStreamHandler{

  public CommandHandler(){
    super(Command.class);
  }
  @Override
  public Map<String, String> mapFromObject(Object o) {
    // TODO Auto-generated method stub
    Command c = (Command) o;
    Map<String, String> myMapping;
    myMapping = new HashMap<String, String>();
    myMapping.put(NAME_TAG, "command");
    if(c.getCommand() != null)
      myMapping.put(VALUE_TAG, c.getCommand());
    if(c.getInterpereter()!= null)
      myMapping.put("interpreter", c.getInterpereter());
    return myMapping;
  }

  @Override
  public Object mapToObject(Map<String, String> attributes) {
    Command command;
   
    String comm;
    List<String> tokens = new ArrayList();
    final String interp;
    comm = attributes.get(VALUE_TAG);
    interp = attributes.get("interpreter");
   
   
    command = new Command(interp, comm);
    return command;
  }

}
TOP

Related Classes of Specification.Galaxy.CommandHandler

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.