示例#1
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre> -T &lt;NUM|NOM|STR|DAT&gt;
   *  The type of attribute to create:
   *  NUM = Numeric attribute
   *  NOM = Nominal attribute
   *  STR = String attribute
   *  DAT = Date attribute
   *  (default: NUM)</pre>
   *
   * <pre> -C &lt;index&gt;
   *  Specify where to insert the column. First and last
   *  are valid indexes.(default: last)</pre>
   *
   * <pre> -N &lt;name&gt;
   *  Name of the new attribute.
   *  (default: 'Unnamed')</pre>
   *
   * <pre> -L &lt;label1,label2,...&gt;
   *  Create nominal attribute with given labels
   *  (default: numeric attribute)</pre>
   *
   * <pre> -F &lt;format&gt;
   *  The format of the date values (see ISO-8601)
   *  (default: yyyy-MM-dd'T'HH:mm:ss)</pre>
   *
   * <!-- options-end -->
   *
   * @param options the list of options as an array of strings
   * @throws Exception if an option is not supported
   */
  public void setOptions(String[] options) throws Exception {
    String tmpStr;

    tmpStr = Utils.getOption('T', options);
    if (tmpStr.length() != 0) setAttributeType(new SelectedTag(tmpStr, TAGS_TYPE));
    else setAttributeType(new SelectedTag(Attribute.NUMERIC, TAGS_TYPE));

    tmpStr = Utils.getOption('C', options);
    if (tmpStr.length() == 0) tmpStr = "last";
    setAttributeIndex(tmpStr);

    setAttributeName(Utils.unbackQuoteChars(Utils.getOption('N', options)));

    if (m_AttributeType == Attribute.NOMINAL) {
      tmpStr = Utils.getOption('L', options);
      if (tmpStr.length() != 0) setNominalLabels(tmpStr);
    } else if (m_AttributeType == Attribute.DATE) {
      tmpStr = Utils.getOption('F', options);
      if (tmpStr.length() != 0) setDateFormat(tmpStr);
    }

    if (getInputFormat() != null) {
      setInputFormat(getInputFormat());
    }
  }
示例#2
0
 public void testAddString() {
   m_Filter = getFilter();
   ((Add) m_Filter).setAttributeType(new SelectedTag(Attribute.STRING, Add.TAGS_TYPE));
   testBuffered();
   testType(Attribute.STRING);
 }
示例#3
0
 public void testAddDate() {
   m_Filter = getFilter();
   ((Add) m_Filter).setAttributeType(new SelectedTag(Attribute.DATE, Add.TAGS_TYPE));
   testBuffered();
   testType(Attribute.DATE);
 }