public void prepareExecution()

in src/main/java/com/univocity/parsers/common/fields/FieldConversionMapping.java [86:136]


	public void prepareExecution(boolean writing, String[] values) {
		if (fieldNameConversionMapping.isEmpty() && fieldEnumConversionMapping.isEmpty() && fieldIndexConversionMapping.isEmpty() && convertAllMapping.isEmpty()) {
			return;
		}

		if (!conversionsByIndex.isEmpty()) {
			return;
		}

		//Note this property is shared across all conversion mappings. This is required so
		//the correct conversion sequence is registered for all fields.
		conversionsByIndex = new HashMap<Integer, List<Conversion<?, ?>>>();

		// adds the conversions in the sequence they were created.
		for (FieldSelector next : conversionSequence) {
			fieldNameConversionMapping.prepareExecution(writing, next, conversionsByIndex, values);
			fieldIndexConversionMapping.prepareExecution(writing, next, conversionsByIndex, values);
			fieldEnumConversionMapping.prepareExecution(writing, next, conversionsByIndex, values);
			convertAllMapping.prepareExecution(writing, next, conversionsByIndex, values);
		}


		Iterator<Map.Entry<Integer, List<Conversion<?, ?>>>> entryIterator = conversionsByIndex.entrySet().iterator();

		while (entryIterator.hasNext()) {
			Map.Entry<Integer, List<Conversion<?, ?>>> e = entryIterator.next();
			Iterator<Conversion<?, ?>> it = e.getValue().iterator();
			while (it.hasNext()) {
				Conversion conversion = it.next();
				if (conversion instanceof ValidatedConversion) {
					if (validationsByIndex.isEmpty()) {
						validationsByIndex = new TreeMap<Integer, List<ValidatedConversion>>();
					}

					it.remove();
					List<ValidatedConversion> validations = validationsByIndex.get(e.getKey());
					if (validations == null) {
						validations = new ArrayList<ValidatedConversion>(1);
						validationsByIndex.put(e.getKey(), validations);
					}
					validations.add((ValidatedConversion) conversion);
				}
			}

			if (e.getValue().isEmpty()) {
				entryIterator.remove();
			}
		}

		validatedIndexes = ArgumentUtils.toIntArray(validationsByIndex.keySet());
	}