private String extractHeaderName(final BeanField<T> beanField) { if (beanField == null || beanField.getField() == null || beanField.getField().getDeclaredAnnotationsByType(CsvBindByName.class).length == 0) { return StringUtils.EMPTY; } final CsvBindByName bindByNameAnnotation = beanField.getField() .getDeclaredAnnotationsByType(CsvBindByName.class)[0]; return bindByNameAnnotation.column(); } }
missingRequiredHeaders.add(r.getBeanField().getField());
private String extractHeaderName(final BeanField<T> beanField) { if (beanField == null || beanField.getField() == null || beanField.getField().getDeclaredAnnotationsByType(CsvBindByName.class).length == 0) { return StringUtils.EMPTY; } final CsvBindByName bindByNameAnnotation = beanField.getField() .getDeclaredAnnotationsByType(CsvBindByName.class)[0]; return bindByNameAnnotation.column(); } }
final SortedMap<Integer, String> headerMap = new TreeMap<>(writeOrder); for(Map.Entry<Integer, BeanField<T>> entry : simpleMap.entrySet()) { headerMap.put(entry.getKey(), entry.getValue().getField().getName()); Integer key = entry.getKey(); if(r.contains(key)) { headerMap.put(entry.getKey(), r.getBeanField().getField().getName()); oneEntryMatched = true; missingRequiredHeaders.add(r.getBeanField().getField());
@Override @Deprecated public PropertyDescriptor findDescriptor(int col) { BeanField beanField = findField(col); if(beanField != null) { return findDescriptor(beanField.getField().getName()); } String columnName = getColumnName(col); if(StringUtils.isNotBlank(columnName)) { return findDescriptor(columnName); } return null; }
@Override public void verifyLineLength(int numberOfFields) throws CsvRequiredFieldEmptyException { if (!headerIndex.isEmpty()) { BeanField f; StringBuilder sb = null; for (int i = numberOfFields; i <= headerIndex.findMaxIndex(); i++) { f = findField(i); if (f != null && f.isRequired()) { if (sb == null) { sb = new StringBuilder(ResourceBundle.getBundle(ICSVParser.DEFAULT_BUNDLE_NAME, errorLocale).getString("multiple.required.field.empty")); } sb.append(' '); sb.append(f.getField().getName()); } } if (sb != null) { throw new CsvRequiredFieldEmptyException(type, sb.toString()); } } }
/** * There is no header per se for this mapping strategy, but this method * checks the first line to determine how many fields are present and * adjusts its field map accordingly. */ // The rest of the Javadoc is inherited @Override public void captureHeader(CSVReader reader) throws IOException { // Validation if (type == null) { throw new IllegalStateException(ResourceBundle .getBundle(ICSVParser.DEFAULT_BUNDLE_NAME, errorLocale) .getString("type.unset")); } String[] firstLine = reader.peek(); fieldMap.setMaxIndex(firstLine.length - 1); if (!columnsExplicitlySet) { headerIndex.clear(); for (FieldMapByPositionEntry entry : fieldMap) { Field f = entry.getField().getField(); if (f.getAnnotation(CsvCustomBindByPosition.class) != null || f.getAnnotation(CsvBindAndSplitByPosition.class) != null || f.getAnnotation(CsvBindAndJoinByPosition.class) != null || f.getAnnotation(CsvBindByPosition.class) != null) { headerIndex.put(entry.getPosition(), f.getName().toUpperCase().trim()); } } } }
requiredHeaderNames[i] = fme.getName(); requiredFields.add(fme.getField().getField());