Package Specification.Galaxy

Source Code of Specification.Galaxy.RequirementHandler

package Specification.Galaxy;

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

import FileOps.XStream.AdvancedXStreamHandler;
import Galaxy.Tree.Tool.Input.Other.Display;
import Galaxy.Tree.Tool.Requirements.Requirement;

/**
* This handler handles the requirements tag correctly. It correctly
* parses the type field as well as the contents.
* @author viper
*
*/
public class RequirementHandler extends AdvancedXStreamHandler{

  public RequirementHandler(){
    super(Requirement.class);
  }
  @Override
  public Map<String, String> mapFromObject(Object o) {
    // TODO Auto-generated method stub
    Requirement c = (Requirement) o;
    Map<String, String> myMapping;
    myMapping = new HashMap<String, String>();
    myMapping.put("type", c.getType());
    myMapping.put(NAME_TAG, "requirement");
    myMapping.put(VALUE_TAG, c.getValue());
    return myMapping;
  }

  @Override
  public Object mapToObject(Map<String, String> attributes) {
    String contents;
    String type = null;
    Requirement req;
   
    contents = attributes.get(VALUE_TAG);
    if(attributes.containsKey("type"))
      type=attributes.get("type");
   
    req = new Requirement();
    req.setType(type);
    req.setValue(contents);
   
    return req;
  }

}
TOP

Related Classes of Specification.Galaxy.RequirementHandler

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.