Package com.java7developer.chapter1

Examples of com.java7developer.chapter1.Java7CatchExample$ConfigurationException


                              ConditionType conditionType,
                              String conditionValue) throws ReservedFieldException, ConfigurationException {
        super(metricRegistry, id, title, order, Type.SUBSTRING, cursorStrategy, sourceField, targetField, extractorConfig, creatorUserId, converters, conditionType, conditionValue);

        if (extractorConfig == null || extractorConfig.get("begin_index") == null || extractorConfig.get("end_index") == null) {
            throw new ConfigurationException("Missing configuration fields. Required: begin_index, end_index");
        }

        try {
            beginIndex = (Integer) extractorConfig.get("begin_index");
            endIndex = (Integer) extractorConfig.get("end_index");
        } catch (ClassCastException e) {
            throw new ConfigurationException("Index positions cannot be casted to Integer.");
        }
    }
View Full Code Here


    public SplitAndCountConverter(Map<String, Object> config) throws ConfigurationException {
        super(Type.SPLIT_AND_COUNT, config);

        if (config.get("split_by") == null || ((String) config.get("split_by")).isEmpty()) {
            throw new ConfigurationException("Missing config [split_by].");
        }

        splitBy = (String) config.get("split_by");
        splitByEscaped = Pattern.quote((String) config.get("split_by"));
    }
View Full Code Here

                                  ConditionType conditionType,
                                  String conditionValue) throws ReservedFieldException, ConfigurationException {
        super(metricRegistry, id, title, order, Type.SPLIT_AND_INDEX, cursorStrategy, sourceField, targetField, extractorConfig, creatorUserId, converters, conditionType, conditionValue);

        if (extractorConfig == null || extractorConfig.get("index") == null || extractorConfig.get("split_by") == null) {
            throw new ConfigurationException("Missing configuration fields. Required: index, split_by");
        }

        try {
            index = ((Integer) extractorConfig.get("index"))-1;
            splitChar = (String) extractorConfig.get("split_by");
        } catch (ClassCastException e) {
            throw new ConfigurationException("Parameters cannot be casted.");
        }
    }
View Full Code Here

    public DateConverter(Map<String, Object> config) throws ConfigurationException {
        super(Type.DATE, config);

        if (config.get("date_format") == null || ((String) config.get("date_format")).isEmpty()) {
            throw new ConfigurationException("Missing config [date_format].");
        }

        dateFormat = (String) config.get("date_format");
    }
View Full Code Here

                          final ConditionType conditionType,
                          final String conditionValue) throws ReservedFieldException, ConfigurationException {
        super(metricRegistry, id, title, order, Type.REGEX, cursorStrategy, sourceField, targetField, extractorConfig, creatorUserId, converters, conditionType, conditionValue);

        if (extractorConfig == null || extractorConfig.get(CONFIG_REGEX_VALUE) == null || ((String) extractorConfig.get(CONFIG_REGEX_VALUE)).isEmpty()) {
            throw new ConfigurationException("Missing regex configuration field: regex_value");
        }

        pattern = Pattern.compile((String) extractorConfig.get(CONFIG_REGEX_VALUE), Pattern.DOTALL);
    }
View Full Code Here

        }
        assertNotNull(csvConverter);
    }

    private void assertConfigException(Map<String, Object> configMap) {
        ConfigurationException configurationException = null;
        try {
            new CsvConverter(configMap);
        } catch (ConfigurationException e) {
            configurationException = e;
        }
View Full Code Here

    public CsvConverter(Map<String, Object> config) throws ConfigurationException {
        super(Type.CSV, config);
        try {
            String columnHeader = (String) config.get("column_header");
            if (columnHeader == null || columnHeader.isEmpty()) {
                throw new ConfigurationException("Missing column headers.");
            }
            separator = firstCharOrDefault(config.get("separator"), CSVParser.DEFAULT_SEPARATOR);
            quoteChar = firstCharOrDefault(config.get("quote_char"), CSVParser.DEFAULT_QUOTE_CHARACTER);
            escapeChar = firstCharOrDefault(config.get("escape_char"), CSVParser.DEFAULT_ESCAPE_CHARACTER);
            strictQuotes = Objects.firstNonNull((Boolean) config.get("strict_quotes"), false);
            trimLeadingWhiteSpace = Objects.firstNonNull((Boolean) config.get("trim_leading_whitespace"), true);

            final CSVParser parser = getCsvParser();
            fieldNames = parser.parseLine(columnHeader);
            if (fieldNames.length == 0) {
                throw new ConfigurationException("No field names found.");
            }
        } catch (Exception e) {
            throw new ConfigurationException("Invalid configuration for CsvConverter");
        }
    }
View Full Code Here

TOP

Related Classes of com.java7developer.chapter1.Java7CatchExample$ConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.