deepdiff.app.ConfigHandler Maven / Gradle / Ivy
/*
* Copyright 2011 DeepDiff Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package deepdiff.app;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.Stack;
import org.apache.log4j.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import deepdiff.core.ConfigProperty;
import deepdiff.core.Configurable;
import deepdiff.core.DiffPointProcessor;
import deepdiff.core.DiffPointProcessorFactory;
import deepdiff.core.DiffScope;
import deepdiff.core.DiffUnitProcessor;
import deepdiff.core.DiffUnitProcessorFactory;
import deepdiff.core.IllegalConfigException;
/**
* Parses an XML config file using SAX. Parsing a config file results in new objects available via
* {@link DiffUnitProcessorFactory}, {@link DiffPointProcessorFactory}, and {@link #getScopes()}.
*/
class ConfigHandler extends DefaultHandler {
private static final String ELEM_CONFIG = "config";
private static final String ELEM_POINT_PROCESSOR = "point-processor";
private static final String ELEM_PROPERTY = "property";
private static final String ELEM_SCOPE = "scope";
private static final String ELEM_UNIT_PROCESSOR = "unit-processor";
private static final String ATTR_CLASS = "class";
private static final String ATTR_ID = "id";
private static final String ATTR_LEFT = "left";
private static final String ATTR_NAME = "name";
private static final String ATTR_RIGHT = "right";
private static final String ATTR_TYPE = "type";
private static final String ATTR_VALUE = "value";
private static final Logger log = Logger.getLogger(ConfigHandler.class);
/**
* The objects currently being processed. If processing is underway, the bottom object will be a
* List of scopes representing the config itself. The top object will be the last contextual
* object processed. Thus, any configuration elements apply to the top element.
*/
private Stack