Package pattern.datafield

Source Code of pattern.datafield.DataFieldFactory

/*
* Copyright (c) 2007-2013 Concurrent, Inc. All Rights Reserved.
*
* Project and contact information: http://www.concurrentinc.com/
*/

package pattern.datafield;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;

import pattern.PatternException;
import pattern.XPathReader;

public class DataFieldFactory {
  /** Field LOG */
  private static final Logger LOG = LoggerFactory
      .getLogger(DataFieldFactory.class);

  /**
   * Create the appropriate DataField object based on parsing the data
   * dictionary in a PMML file.
   *
   * @param reader
   * @param node
   * @param name
   * @param op_type
   * @param data_type
   * @return DataField
   * @throws PatternException
   */
  public static DataField getDataField(XPathReader reader, Node node,
      String name, String op_type, String data_type)
      throws PatternException {
    DataField df = null;

    if ("continuous".equals(op_type) && "double".equals(data_type))
      df = new ContinuousDataField(name, op_type, data_type);
    else if ("categorical".equals(op_type) && "string".equals(data_type)) {
      df = new CategoricalDataField(name, op_type, data_type);
      df.parse(reader, node);
    } else {
      String message = String.format(
          "unsupported DataField type %s / %s: ", op_type, data_type);
      LOG.error(message);
      throw new PatternException(message);
    }

    return df;
  }
}
TOP

Related Classes of pattern.datafield.DataFieldFactory

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.