/** * Adds, to the existing information, a field that is forwarded directly * from the source record(s) to the destination record(s). * * @param sourceField the position in the source record(s) * @param targetField the position in the destination record(s) */ public void addForwardedField(int sourceField, int targetField) { if(isTargetFieldPresent(targetField)) { throw new InvalidSemanticAnnotationException("Target field "+targetField+" was added twice."); } FieldSet targetFields = fieldMapping.get(sourceField); if (targetFields != null) { fieldMapping.put(sourceField, targetFields.addField(targetField)); } else { fieldMapping.put(sourceField, new FieldSet(targetField)); } }
@Test public void testAddListToSet() { check(new FieldSet().addField(1).addFields(new FieldList(14, 3, 1)), 1, 3, 14); }
/** * Adds, to the existing information, a field that is forwarded directly * from the source record(s) in the first input to the destination * record(s). * * @param input the input of the source field * @param sourceField the position in the source record * @param targetField the position in the destination record */ public void addForwardedField(int input, int sourceField, int targetField) { Map<Integer, FieldSet> fieldMapping; if (input != 0 && input != 1) { throw new IndexOutOfBoundsException(); } else if (input == 0) { fieldMapping = this.fieldMapping1; } else { fieldMapping = this.fieldMapping2; } if(isTargetFieldPresent(targetField, fieldMapping)) { throw new InvalidSemanticAnnotationException("Target field "+targetField+" was added twice to input "+input); } FieldSet targetFields = fieldMapping.get(sourceField); if (targetFields != null) { fieldMapping.put(sourceField, targetFields.addField(targetField)); } else { fieldMapping.put(sourceField, new FieldSet(targetField)); } }
@Test public void testFieldSetAdds() { check(new FieldSet().addField(1).addField(2), 1, 2); check(FieldSet.EMPTY_SET.addField(3).addField(2), 3, 2); check(new FieldSet(13).addFields(new FieldSet(17, 31, 42)), 17, 13, 42, 31); check(new FieldSet(14).addFields(new FieldSet(17)), 17, 14); check(new FieldSet(3).addFields(2, 8, 5, 7), 3, 2, 8, 5, 7); check(new FieldSet().addFields(new FieldSet())); check(new FieldSet().addFields(new FieldSet(3, 4)), 4, 3); check(new FieldSet(5, 1).addFields(new FieldSet()), 5, 1); }
@Test public void testImmutability() { FieldSet s1 = new FieldSet(); FieldSet s2 = new FieldSet(5); FieldSet s3 = new FieldSet(Integer.valueOf(7)); FieldSet s4 = new FieldSet(5, 4, 7, 6); s1.addFields(s2).addFields(s3); s2.addFields(s4); s4.addFields(s1); s1.addField(Integer.valueOf(14)); s2.addFields(78, 13, 66, 3); assertEquals(0, s1.size()); assertEquals(1, s2.size()); assertEquals(1, s3.size()); assertEquals(4, s4.size()); }
excludedFields = excludedFields.addField(ffd.getPosition());
/** * Creates SemanticProperties by adding an offset to each input field index of the given SemanticProperties. * * @param props The SemanticProperties to which the offset is added. * @param numInputFields The original number of fields of the input. * @param offset The offset that is added to each input field index. * @return New SemanticProperties with added offset. */ public static SingleInputSemanticProperties addSourceFieldOffset(SingleInputSemanticProperties props, int numInputFields, int offset) { SingleInputSemanticProperties offsetProps = new SingleInputSemanticProperties(); if (props.getReadFields(0) != null) { FieldSet offsetReadFields = new FieldSet(); for (int r : props.getReadFields(0)) { offsetReadFields = offsetReadFields.addField(r + offset); } offsetProps.addReadFields(offsetReadFields); } for (int s = 0; s < numInputFields; s++) { FieldSet targetFields = props.getForwardingTargetFields(0, s); for (int t : targetFields) { offsetProps.addForwardedField(s + offset, t); } } return offsetProps; }
"semantic forwarded field information. Will only use the field with the lowest index."); newFieldCombo = newFieldCombo.addField(targetField.toArray()[0]);
int sourceField = props.getForwardingSourceField(input, targetField); if (sourceField >= 0) { newFields = newFields.addField(sourceField); } else {
"semantic forwarded field information. Will only use the field with the lowest index."); newFields = newFields.addField(targetField.toArray()[0]);
int sourceField = props.getForwardingSourceField(input, targetField); if (sourceField >= 0) { newGrouping = newGrouping.addField(sourceField); } else { return null;
/** * Adds, to the existing information, a field that is forwarded directly * from the source record(s) to the destination record(s). * * @param sourceField the position in the source record(s) * @param targetField the position in the destination record(s) */ public void addForwardedField(int sourceField, int targetField) { if(isTargetFieldPresent(targetField)) { throw new InvalidSemanticAnnotationException("Target field "+targetField+" was added twice."); } FieldSet targetFields = fieldMapping.get(sourceField); if (targetFields != null) { fieldMapping.put(sourceField, targetFields.addField(targetField)); } else { fieldMapping.put(sourceField, new FieldSet(targetField)); } }
/** * Adds, to the existing information, a field that is forwarded directly * from the source record(s) to the destination record(s). * * @param sourceField the position in the source record(s) * @param targetField the position in the destination record(s) */ public void addForwardedField(int sourceField, int targetField) { if(isTargetFieldPresent(targetField)) { throw new InvalidSemanticAnnotationException("Target field "+targetField+" was added twice."); } FieldSet targetFields = fieldMapping.get(sourceField); if (targetFields != null) { fieldMapping.put(sourceField, targetFields.addField(targetField)); } else { fieldMapping.put(sourceField, new FieldSet(targetField)); } }
/** * Adds, to the existing information, a field that is forwarded directly * from the source record(s) in the first input to the destination * record(s). * * @param input the input of the source field * @param sourceField the position in the source record * @param targetField the position in the destination record */ public void addForwardedField(int input, int sourceField, int targetField) { Map<Integer, FieldSet> fieldMapping; if (input != 0 && input != 1) { throw new IndexOutOfBoundsException(); } else if (input == 0) { fieldMapping = this.fieldMapping1; } else { fieldMapping = this.fieldMapping2; } if(isTargetFieldPresent(targetField, fieldMapping)) { throw new InvalidSemanticAnnotationException("Target field "+targetField+" was added twice to input "+input); } FieldSet targetFields = fieldMapping.get(sourceField); if (targetFields != null) { fieldMapping.put(sourceField, targetFields.addField(targetField)); } else { fieldMapping.put(sourceField, new FieldSet(targetField)); } }
/** * Adds, to the existing information, a field that is forwarded directly * from the source record(s) in the first input to the destination * record(s). * * @param input the input of the source field * @param sourceField the position in the source record * @param targetField the position in the destination record */ public void addForwardedField(int input, int sourceField, int targetField) { Map<Integer, FieldSet> fieldMapping; if (input != 0 && input != 1) { throw new IndexOutOfBoundsException(); } else if (input == 0) { fieldMapping = this.fieldMapping1; } else { fieldMapping = this.fieldMapping2; } if(isTargetFieldPresent(targetField, fieldMapping)) { throw new InvalidSemanticAnnotationException("Target field "+targetField+" was added twice to input "+input); } FieldSet targetFields = fieldMapping.get(sourceField); if (targetFields != null) { fieldMapping.put(sourceField, targetFields.addField(targetField)); } else { fieldMapping.put(sourceField, new FieldSet(targetField)); } }
/** * Creates SemanticProperties by adding an offset to each input field index of the given SemanticProperties. * * @param props The SemanticProperties to which the offset is added. * @param numInputFields The original number of fields of the input. * @param offset The offset that is added to each input field index. * @return New SemanticProperties with added offset. */ public static SingleInputSemanticProperties addSourceFieldOffset(SingleInputSemanticProperties props, int numInputFields, int offset) { SingleInputSemanticProperties offsetProps = new SingleInputSemanticProperties(); if (props.getReadFields(0) != null) { FieldSet offsetReadFields = new FieldSet(); for (int r : props.getReadFields(0)) { offsetReadFields = offsetReadFields.addField(r + offset); } offsetProps.addReadFields(offsetReadFields); } for (int s = 0; s < numInputFields; s++) { FieldSet targetFields = props.getForwardingTargetFields(0, s); for (int t : targetFields) { offsetProps.addForwardedField(s + offset, t); } } return offsetProps; }
/** * Creates SemanticProperties by adding an offset to each input field index of the given SemanticProperties. * * @param props The SemanticProperties to which the offset is added. * @param numInputFields The original number of fields of the input. * @param offset The offset that is added to each input field index. * @return New SemanticProperties with added offset. */ public static SingleInputSemanticProperties addSourceFieldOffset(SingleInputSemanticProperties props, int numInputFields, int offset) { SingleInputSemanticProperties offsetProps = new SingleInputSemanticProperties(); if (props.getReadFields(0) != null) { FieldSet offsetReadFields = new FieldSet(); for (int r : props.getReadFields(0)) { offsetReadFields = offsetReadFields.addField(r + offset); } offsetProps.addReadFields(offsetReadFields); } for (int s = 0; s < numInputFields; s++) { FieldSet targetFields = props.getForwardingTargetFields(0, s); for (int t : targetFields) { offsetProps.addForwardedField(s + offset, t); } } return offsetProps; }