/** * Input an instance for filtering. Ordinarily the instance is processed and * made available for output immediately. Some filters require all instances * be read before producing output. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). * @throws IllegalStateException if no input format has been defined. */ @Override public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } Instance inst = (Instance) instance.copy(); // First copy string values from input to output copyValues(inst, true, inst.dataset(), outputFormatPeek()); // Insert the new attribute and reassign to output inst.setDataset(null); inst.insertAttributeAt(m_Insert.getIndex()); push(inst); // No need to copy instance return true; }
if (getInputFormat() != null) { setInputFormat(getInputFormat());
/** * Input an instance for filtering. Ordinarily the instance is processed and * made available for output immediately. Some filters require all instances * be read before producing output. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). * @throws IllegalStateException if no input format has been defined. */ @Override public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } Instance inst = (Instance) instance.copy(); // First copy string values from input to output copyValues(inst, true, inst.dataset(), outputFormatPeek()); // Insert the new attribute and reassign to output inst.setDataset(null); inst.insertAttributeAt(m_Insert.getIndex()); push(inst); // No need to copy instance return true; }
if (getInputFormat() != null) { setInputFormat(getInputFormat());
|| (m_Insert.getIndex() > getInputFormat().numAttributes())) { throw new IllegalArgumentException("Index out of range");
|| (m_Insert.getIndex() > getInputFormat().numAttributes())) { throw new IllegalArgumentException("Index out of range");