/** * Sets the format of the input instances. * * @param instanceInfo an Instances object containing the input instance * structure (any instances contained in the object are ignored - * only the structure is required). * @return true if the outputFormat may be collected immediately * @throws Exception if the format couldn't be set successfully */ @Override public boolean setInputFormat(Instances instanceInfo) throws Exception { Instances outputFormat; Attribute newAttribute; super.setInputFormat(instanceInfo); m_Counter = -1; m_Index.setUpper(instanceInfo.numAttributes()); outputFormat = new Instances(instanceInfo, 0); newAttribute = new Attribute(m_Name); if ((m_Index.getIndex() < 0) || (m_Index.getIndex() > getInputFormat().numAttributes())) { throw new IllegalArgumentException("Index out of range"); } outputFormat.insertAttributeAt(newAttribute, m_Index.getIndex()); setOutputFormat(outputFormat); return true; }
/** * Sets the format of the input instances. * * @param instanceInfo an Instances object containing the input instance * structure (any instances contained in the object are ignored - * only the structure is required). * @return true if the outputFormat may be collected immediately * @throws Exception if the format couldn't be set successfully */ @Override public boolean setInputFormat(Instances instanceInfo) throws Exception { Instances outputFormat; Attribute newAttribute; super.setInputFormat(instanceInfo); m_Counter = -1; m_Index.setUpper(instanceInfo.numAttributes()); outputFormat = new Instances(instanceInfo, 0); newAttribute = new Attribute(m_Name); if ((m_Index.getIndex() < 0) || (m_Index.getIndex() > getInputFormat().numAttributes())) { throw new IllegalArgumentException("Index out of range"); } outputFormat.insertAttributeAt(newAttribute, m_Index.getIndex()); setOutputFormat(outputFormat); return true; }