001/*-------------------------------------------------------------------------+
002|                                                                          |
003| Copyright 2005-2011 The ConQAT Project                                   |
004|                                                                          |
005| Licensed under the Apache License, Version 2.0 (the "License");          |
006| you may not use this file except in compliance with the License.         |
007| You may obtain a copy of the License at                                  |
008|                                                                          |
009|    http://www.apache.org/licenses/LICENSE-2.0                            |
010|                                                                          |
011| Unless required by applicable law or agreed to in writing, software      |
012| distributed under the License is distributed on an "AS IS" BASIS,        |
013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
014| See the License for the specific language governing permissions and      |
015| limitations under the License.                                           |
016+-------------------------------------------------------------------------*/
017package org.conqat.lib.commons.xml;
018
019/**
020 * Default implementation of {@link IXMLResolver}.
021 * 
022 * @author deissenb
023 */
024public class XMLResolver<E extends Enum<E>, A extends Enum<A>> implements IXMLResolver<E, A> {
025
026        /** Class object for attribute enum. */
027        private final Class<A> attributeClass;
028
029        /**
030         * Create new resolver.
031         * 
032         * @param attributeClass
033         *            class object for attribute enum.
034         */
035        public XMLResolver(Class<A> attributeClass) {
036                this.attributeClass = attributeClass;
037        }
038
039        /** {@inheritDoc} */
040        @Override
041        public Class<A> getAttributeClass() {
042                return attributeClass;
043        }
044
045        /** Returns <code>&lt;enum-element&gt;.name()</code>. */
046        @Override
047        public String resolveAttributeName(A attribute) {
048                return attribute.name();
049        }
050
051        /** Returns <code>&lt;enum-element&gt;.name()</code>. */
052        @Override
053        public String resolveElementName(E element) {
054                return element.name();
055        }
056
057}