Example usage for org.springframework.batch.item.file.transform FieldSet hasNames

List of usage examples for org.springframework.batch.item.file.transform FieldSet hasNames

Introduction

In this page you can find the example usage for org.springframework.batch.item.file.transform FieldSet hasNames.

Prototype

boolean hasNames();

Source Link

Document

Check if there are names defined for the fields.

Usage

From source file:fr.acxio.tools.agia.item.database.AbstractFieldSetSqlParameterSourceProvider.java

protected MapSqlParameterSource mapFieldSet(MapSqlParameterSource sMapSqlParameterSource, FieldSet sFieldSet,
        int sRecIdx) {
    if (sFieldSet != null) {
        boolean aHasNames = sFieldSet.hasNames();
        int aFieldCount = sFieldSet.getFieldCount();
        String[] aNames = aHasNames ? sFieldSet.getNames() : null;
        String[] aValues = sFieldSet.getValues();
        for (int i = 0; i < aFieldCount; i++) {
            sMapSqlParameterSource.addValue(String.format(fieldsetNameFormat, sRecIdx,
                    (aHasNames && (aNames[i] != null) && !aNames[i].isEmpty()) ? aNames[i]
                            : String.format(unnamedColumnFormat, i)),
                    aValues[i]);/*from w  w  w .j  a v a2  s .c om*/
        }
    }
    return sMapSqlParameterSource;
}

From source file:fr.acxio.tools.agia.transform.ListFieldSetToMapProcessor.java

protected Map<String, Object> mapFieldSet(FieldSet sFieldSet, int sRecIdx) {
    Map<String, Object> aResult = new HashMap<String, Object>();
    if (sFieldSet != null) {
        boolean aHasNames = sFieldSet.hasNames();
        int aFieldCount = sFieldSet.getFieldCount();
        String[] aNames = aHasNames ? sFieldSet.getNames() : null;
        String[] aValues = sFieldSet.getValues();
        for (int i = 0; i < aFieldCount; i++) {
            aResult.put(String.format(fieldsetNameFormat, sRecIdx,
                    (aHasNames && (aNames[i] != null) && !aNames[i].isEmpty()) ? aNames[i]
                            : String.format(unnamedColumnFormat, i)),
                    aValues[i]);//from  w  w  w  . ja  v  a 2  s.co  m
        }
    }
    return aResult;
}

From source file:fr.acxio.tools.agia.item.MultiLineItemReader.java

@Override
public synchronized T read() {

    List<FieldSet> aTmpResult = new ArrayList<FieldSet>();
    boolean aConditionResult = false;

    FieldSet line = readNextFieldSet();
    while (!aConditionResult && (line != null)) {
        aTmpResult.add(line);/*from  w ww  .  jav  a  2  s  .c om*/
        if (nextItem != null) {
            updateContext(currentVariableName, (line.hasNames()) ? line.getProperties() : line.getValues(),
                    getEvaluationContext());
            updateContext(nextVariableName,
                    (nextItem.hasNames()) ? nextItem.getProperties() : nextItem.getValues(),
                    getEvaluationContext());
            aConditionResult = getExpressionResolver().evaluate(newRecordCondition, getEvaluationContext(),
                    Boolean.class);
        }
        if (!aConditionResult) {
            line = readNextFieldSet();
        }
    }

    return (aTmpResult.isEmpty() ? null : mapFieldSets(aTmpResult));
}