読み込んだヘッダーを元に、マッピング情報を補完する。
<p>カラムの位置である番号を確定する。</p>
<p>存在しないカラムがある場合は、部分的な読み込みとして、ダミーのカラム情報を作成する。</p>
@param headers
@param columns
@param SuperCsvInvalidAnnotationException
487130
private void setupMappingColumns(final String[] headers) {
        
        final List<ColumnMapping> columnMappingList = beanMapping.getColumns();
        final HeaderMapper headerMapper = beanMapping.getHeaderMapper();
        
        // 一致するラベルがあれば、カラムの番号を補完する
        final int headerSize = headers.length;
        for(int i=0; i < headerSize;i ++) {
            
            final String header = headers[i];
            
            /*
             * 番号が決まっておらず、ラベルが一致するカラム情報を抽出する。
             * ※既に番号が決まっているが、ラベルが一致しないのものは、後からチェックする。
             */
            List<ColumnMapping> undeterminedColumnList = columnMappingList.stream()
                .filter(col -> col.getNumber() <= 0)
                .filter(col -> headerMapper.toMap(col, beanMapping.getConfiguration(), beanMapping.getGroups()).equals(header))
                .collect(Collectors.toList());
            
            final int columnNumber = i+1;
            undeterminedColumnList.forEach(col -> col.setNumber(columnNumber));
            
        }
        
        // カラムの番号順に並び変える
        columnMappingList.sort(null);
        
        // 決定していないカラム番号のチェック
        BeanMappingFactoryHelper.validateNonDeterminedColumnNumber(beanMapping.getType(), columnMappingList, headers);
        
        // 重複しているカラム番号のチェック
        BeanMappingFactoryHelper.validateDuplicatedColumnNumber(beanMapping.getType(), columnMappingList);
        
        // 不足しているカラム番号の補完
        final Optional<CsvPartial> partialAnno = Optional.ofNullable(beanMapping.getType().getAnnotation(CsvPartial.class));
        BeanMappingFactoryHelper.supplyLackedNumberMappingColumn(beanMapping.getType(), columnMappingList, partialAnno, headers);
        
        beanMapping.setColumns(columnMappingList);
        
    }
225699
@SuppressWarnings({"unchecked"})
    protected <T> void buildValidators(final BeanMapping<T> beanMapping, final CsvBean beanAnno, final Class<?>[] groups) {
        
        // CsvValidatorの取得
        final List<CsvValidator<T>> validators = Arrays.stream(beanAnno.validators())
                .map(v -> (CsvValidator<T>)configuration.getBeanFactory().create(v))
                .collect(Collectors.toList());
        beanMapping.addAllValidators(validators);
        
        beanMapping.setSkipValidationOnWrite(configuration.isSkipValidationOnWrite());
        beanMapping.setGroups(groups);
        
    }
762143
public void setColumns(String columns) throws PageException {
	this.columns = ListUtil.toStringArray(ListUtil.listToArrayRemoveEmpty(columns, ","));
    }
697199
@Override
    protected void populateColumnSchema(ArrayList<VoltTable.ColumnInfo> columns) {
        super.populateColumnSchema(columns);
        columns.add(new ColumnInfo(VoltSystemProcedure.CNAME_SITE_ID, VoltSystemProcedure.CTYPE_ID));
        columns.add(new ColumnInfo("PARTITION_ID",  VoltType.INTEGER));
        columns.add(new ColumnInfo("CACHE1_LEVEL",  VoltType.INTEGER));
        columns.add(new ColumnInfo("CACHE2_LEVEL",  VoltType.INTEGER));
        columns.add(new ColumnInfo("CACHE1_HITS",   VoltType.BIGINT));
        columns.add(new ColumnInfo("CACHE2_HITS",   VoltType.BIGINT));
        columns.add(new ColumnInfo("CACHE_MISSES",  VoltType.BIGINT));
        columns.add(new ColumnInfo("PLAN_TIME_MIN", VoltType.BIGINT));
        columns.add(new ColumnInfo("PLAN_TIME_MAX", VoltType.BIGINT));
        columns.add(new ColumnInfo("PLAN_TIME_AVG", VoltType.BIGINT));
        columns.add(new ColumnInfo("FAILURES",      VoltType.BIGINT));
    }
44982
protected void parseHeaderElements(Element actionElement, AbstractMessageContentBuilder messageBuilder, List<ValidationContext> validationContexts) {
        Element headerElement = DomUtils.getChildElementByTagName(actionElement, "header");
        Map<String, Object> messageHeaders = new LinkedHashMap<>();

        if (headerElement != null) {
            List<?> elements = DomUtils.getChildElementsByTagName(headerElement, "element");
            for (Iterator<?> iter = elements.iterator(); iter.hasNext();) {
                Element headerValue = (Element) iter.next();
                
                String name = headerValue.getAttribute("name");
                String value = headerValue.getAttribute("value");
                String type = headerValue.getAttribute("type");

                if (StringUtils.hasText(type)) {
                    value = MessageHeaderType.createTypedValue(type, value);
                }
                
                messageHeaders.put(name, value);
            }
            
            List<Element> headerDataElements = DomUtils.getChildElementsByTagName(headerElement, "data");
            for (Element headerDataElement : headerDataElements) {
                messageBuilder.getHeaderData().add(DomUtils.getTextValue(headerDataElement).trim());
            }

            List<Element> headerResourceElements = DomUtils.getChildElementsByTagName(headerElement, "resource");
            for (Element headerResourceElement : headerResourceElements) {
                String charset = headerResourceElement.getAttribute("charset");
                messageBuilder.getHeaderResources().add(headerResourceElement.getAttribute("file") + (StringUtils.hasText(charset) ? FileUtils.FILE_PATH_CHARSET_PARAMETER + charset : ""));
            }

            // parse fragment with xs-any element
            List<Element> headerFragmentElements = DomUtils.getChildElementsByTagName(headerElement, "fragment");
            for (Element headerFragmentElement : headerFragmentElements) {
                List<Element> fragment = DomUtils.getChildElements(headerFragmentElement);
                if (!CollectionUtils.isEmpty(fragment)) {
                    messageBuilder.getHeaderData().add(PayloadElementParser.parseMessagePayload(fragment.get(0)));
                }
            }

            messageBuilder.setMessageHeaders(messageHeaders);

            if (headerElement.hasAttribute("ignore-case")) {
                boolean ignoreCase = Boolean.valueOf(headerElement.getAttribute("ignore-case"));
                validationContexts.stream().filter(context -> context instanceof HeaderValidationContext)
                                            .map(context -> (HeaderValidationContext) context)
                                            .forEach(context -> context.setHeaderNameIgnoreCase(ignoreCase));
            }
        }
    }
1264622
protected void columnToContentValue(ContentValues contentValues,
			TColumn column, Object value) {

		String columnName = column.getName();

		if (value instanceof Number) {
			if (value instanceof Byte) {
				validateValue(column, value, Byte.class, Short.class,
						Integer.class, Long.class);
				contentValues.put(columnName, (Byte) value);
			} else if (value instanceof Short) {
				validateValue(column, value, Short.class, Integer.class,
						Long.class);
				contentValues.put(columnName, (Short) value);
			} else if (value instanceof Integer) {
				validateValue(column, value, Integer.class, Long.class);
				contentValues.put(columnName, (Integer) value);
			} else if (value instanceof Long) {
				validateValue(column, value, Long.class, Double.class);
				contentValues.put(columnName, (Long) value);
			} else if (value instanceof Float) {
				validateValue(column, value, Float.class);
				contentValues.put(columnName, (Float) value);
			} else if (value instanceof Double) {
				validateValue(column, value, Double.class);
				contentValues.put(columnName, (Double) value);
			} else {
				throw new GeoPackageException("Unsupported Number type: "
						+ value.getClass().getSimpleName());
			}
		} else if (value instanceof String) {
			validateValue(column, value, String.class);
			String stringValue = (String) value;
			if (column.getMax() != null
					&& stringValue.length() > column.getMax()) {
				throw new GeoPackageException(
						"String is larger than the column max. Size: "
								+ stringValue.length() + ", Max: "
								+ column.getMax() + ", Column: " + columnName);
			}
			contentValues.put(columnName, stringValue);
		} else if (value instanceof byte[]) {
			validateValue(column, value, byte[].class);
			byte[] byteValue = (byte[]) value;
			if (column.getMax() != null && byteValue.length > column.getMax()) {
				throw new GeoPackageException(
						"Byte array is larger than the column max. Size: "
								+ byteValue.length + ", Max: "
								+ column.getMax() + ", Column: " + columnName);
			}
			contentValues.put(columnName, byteValue);
		}
72112
private ByteBuffer columnValueAsBytes(ByteBuffer columnName, String columnFamilyName, String columnValue)
    {
        CfDef columnFamilyDef = getCfDef(columnFamilyName);
        AbstractType<?> defaultValidator = getFormatType(columnFamilyDef.default_validation_class);

        for (ColumnDef columnDefinition : columnFamilyDef.getColumn_metadata())
        {
            byte[] currentColumnName = columnDefinition.getName();

            if (ByteBufferUtil.compare(currentColumnName, columnName) == 0)
            {
                try
                {
                    String validationClass = columnDefinition.getValidation_class();
                    return getBytesAccordingToType(columnValue, getFormatType(validationClass));
                }
                catch (Exception e)
                {
                    throw new RuntimeException(e);
                }
            }
        }

        return defaultValidator.fromString(columnValue);
    }
1071629
@Override
    public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) {
        // call superclass and get string value
        Identifier columnIdentifier = super.toPhysicalColumnName(name, context);
        String columnIdentifierText = columnIdentifier.getText();
        if (StringUtils.equalsAnyIgnoreCase(columnIdentifierText, RESERVED_WORDS_ORACLE)) {
            columnIdentifier = convertToLimitedLowerCase(context, columnIdentifier, columnNamePrefix);
        }

        return columnIdentifier;
    }
857487
public static void setColumnsMap(Record record, Map<String, Object> columns) {
		record.setColumnsMap(columns);
	}
279037
@SuppressWarnings("unchecked")
    public T headerValidator(String ... validatorNames) {
        Assert.notNull(applicationContext, "Citrus application context is not initialized!");

        for (String validatorName : validatorNames) {
            headerValidationContext.addHeaderValidator(applicationContext.getBean(validatorName, HeaderValidator.class));
        }

        return self;
    }
442760
public static <T> ColumnInfo<T> fromAnnotation(CsvColumn csvColumn, String fieldName, Class<T> type, Field field,
			Method getMethod, Method setMethod, Converter<T, ?> converter) {
		return fromAnnoation(csvColumn.converterClass(), csvColumn.format(), csvColumn.converterFlags(),
				csvColumn.columnName(), csvColumn.defaultValue(), csvColumn.afterColumn(), csvColumn.mustNotBeBlank(),
				csvColumn.mustBeSupplied(), csvColumn.trimInput(), fieldName, type, field, getMethod, setMethod,
				converter);
	}
348738
public static void pruneDenseTableColumnsV2(List<RawColumn> columns) {
    ListIterator<RawColumn> iterator = columns.listIterator();
    while (iterator.hasNext()) {
      RawColumn column = iterator.next();
      if (column.kind.equals(KIND_COMPACT_VALUE) && column.name.asInternal().isEmpty()) {
        iterator.remove();
      }
    }
  }
392863
public List<CsvError> convert(final SuperCsvException exception, final BeanMapping<?> beanMapping) {
        
        Objects.requireNonNull(beanMapping, "beanMapping should not be null.");
        Objects.requireNonNull(exception, "exception should not be null.");
        
        final List<CsvError> errors = new ArrayList<>();
        
        if(exception instanceof SuperCsvBindingException) {
            errors.addAll(convert((SuperCsvBindingException) exception, beanMapping));
            
        } if(exception instanceof SuperCsvRowException) {
            errors.addAll(convert((SuperCsvRowException) exception, beanMapping));
            
        } else if(exception instanceof SuperCsvValidationException) {
            errors.addAll(convert((SuperCsvValidationException)exception, beanMapping));
            
        } else if(exception instanceof SuperCsvCellProcessorException) {
            errors.addAll(convert((SuperCsvCellProcessorException)exception, beanMapping));
            
        } else if(exception instanceof SuperCsvNoMatchColumnSizeException) {
            errors.addAll(convert((SuperCsvNoMatchColumnSizeException)exception, beanMapping));
            
        } else if(exception instanceof SuperCsvNoMatchHeaderException) {
            errors.addAll(convert((SuperCsvNoMatchHeaderException)exception, beanMapping));
            
        } else {
            errors.addAll(convertDefault(exception, beanMapping));
            
        }
        
        return errors;
    }
6602
protected void writeRow(final String... columns) throws IOException {
		
		if( columns == null ) {
			throw new NullPointerException(String.format("columns to write should not be null on line %d", lineNumber));
		} else if( columns.length == 0 ) {
			throw new IllegalArgumentException(String.format("columns to write should not be empty on line %d",
				lineNumber));
		}
		
		StringBuilder builder = new StringBuilder();
		for( int i = 0; i < columns.length; i++ ) {
			
			columnNumber = i + 1; // column no used by CsvEncoder
			
			if( i > 0 ) {
				builder.append((char) preference.getDelimiterChar()); // delimiter
			}
			
			final String csvElement = columns[i];
			if( csvElement != null ) {
				final CsvContext context = new CsvContext(lineNumber, rowNumber, columnNumber);
				final String escapedCsv = encoder.encode(csvElement, context, preference);
				builder.append(escapedCsv);
				lineNumber = context.getLineNumber(); // line number can increment when encoding multi-line columns
			}
			
		}
		
		builder.append(preference.getEndOfLineSymbols()); // EOL
		writer.write(builder.toString());
	}
807082
private void validateSingleTableInput(Collection<? extends ConfigurableBeanJob<?>> beanJobs) {
        for (ConfigurableBeanJob<?> beanJob : beanJobs) {
            Table originatingTable = null;
            InputColumn<?>[] input = beanJob.getInput();

            for (InputColumn<?> inputColumn : input) {
                Table table = _sourceColumnFinder.findOriginatingTable(inputColumn);
                if (table != null) {
                    if (originatingTable == null) {
                        originatingTable = table;
                    } else {
                        if (!originatingTable.equals(table)) {
                            throw new IllegalArgumentException("Input columns in " + beanJob
                                    + " originate from different tables");
                        }
                    }
                }
            }
        }

    }
590454
MolgenisValidationException translateNotNullViolation(PSQLException pSqlException) {
    ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
    String tableName = serverErrorMessage.getTable();
    String message = serverErrorMessage.getMessage();
    Matcher matcher =
        Pattern.compile("null value in column \"?(.*?)\"? violates not-null constraint")
            .matcher(message);
    boolean matches = matcher.matches();
    if (matches) {
      // exception message when adding data that does not match constraint
      String columnName = matcher.group(1);

      EntityTypeDescription entityTypeDescription =
          entityTypeRegistry.getEntityTypeDescription(tableName);
      entityTypeDescription.getAttributeDescriptionMap().get(columnName);

      ConstraintViolation constraintViolation =
          new ConstraintViolation(
              format(
                  "The attribute '%s' of entity '%s' can not be null.",
                  tryGetAttributeName(tableName, columnName).orElse(TOKEN_UNKNOWN),
                  tryGetEntityTypeName(tableName).orElse(TOKEN_UNKNOWN)),
              null);
      return new MolgenisValidationException(singleton(constraintViolation));
    } else {
      // exception message when applying constraint on existing data
      matcher = Pattern.compile("column \"(.*?)\" contains null values").matcher(message);
      matches = matcher.matches();
      if (!matches) {
        throw new RuntimeException(ERROR_TRANSLATING_EXCEPTION_MSG, pSqlException);
      }
      String columnName = matcher.group(1);

      ConstraintViolation constraintViolation =
          new ConstraintViolation(
              format(
                  "The attribute '%s' of entity '%s' contains null values.",
                  tryGetAttributeName(tableName, columnName).orElse(TOKEN_UNKNOWN),
                  tryGetEntityTypeName(tableName).orElse(TOKEN_UNKNOWN)),
              null);
      return new MolgenisValidationException(singleton(constraintViolation));
    }
  }
1230815
private boolean isCsvField(final String field, final ValidationContext<Object> validationContext) {
        return validationContext.getBeanMapping().getColumnMapping(field).isPresent();
    }