001 /*
002 * Copyright 2002 - 2006 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: AttributeMap.java 310 2007-05-18 20:26:36Z maxberger $ */
018
019 package net.sourceforge.jeuclid.elements.support.attributes;
020
021 import java.util.Map;
022
023 /**
024 * Generic interface to access XML attributes.
025 *
026 * @author Max Berger
027 * @version $Revision: 310 $
028 */
029 public interface AttributeMap {
030
031 /**
032 * return true if an attribute is present.
033 *
034 * @param attrName
035 * name of the attribute to look for.
036 * @return true if attrName is present.
037 */
038 boolean hasAttribute(String attrName);
039
040 /**
041 * retrieve the value of the attribute as String.
042 *
043 * @param attrName
044 * name of the attribute
045 * @return the value of the attribute as String.
046 */
047 String getString(String attrName);
048
049 /**
050 * retrieve the value of the attribute as String.
051 *
052 * @param attrName
053 * name of the attribute
054 * @param defaultValue
055 * value to use if unset.
056 * @return the value of the attribute as String.
057 */
058 String getString(String attrName, String defaultValue);
059
060 /**
061 * retrieve the value of the attribute as boolean.
062 *
063 * @param attrName
064 * name of the attribute.
065 * @param defaultValue
066 * value to use if unset.
067 * @return a boolean value.
068 */
069 boolean getBoolean(String attrName, boolean defaultValue);
070
071 /**
072 * retrieve the attributes as map.
073 *
074 * @return a Map<String,String>
075 */
076 Map<String, String> getAsMap();
077
078 }