View Javadoc

1   /*
2    * Copyright 2002 - 2006 JEuclid, http://jeuclid.sf.net
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /* $Id: AttributeMap.java 310 2007-05-18 20:26:36Z maxberger $ */
18  
19  package net.sourceforge.jeuclid.elements.support.attributes;
20  
21  import java.util.Map;
22  
23  /**
24   * Generic interface to access XML attributes.
25   * 
26   * @author Max Berger
27   * @version $Revision: 310 $
28   */
29  public interface AttributeMap {
30  
31      /**
32       * return true if an attribute is present.
33       * 
34       * @param attrName
35       *            name of the attribute to look for.
36       * @return true if attrName is present.
37       */
38      boolean hasAttribute(String attrName);
39  
40      /**
41       * retrieve the value of the attribute as String.
42       * 
43       * @param attrName
44       *            name of the attribute
45       * @return the value of the attribute as String.
46       */
47      String getString(String attrName);
48  
49      /**
50       * retrieve the value of the attribute as String.
51       * 
52       * @param attrName
53       *            name of the attribute
54       * @param defaultValue
55       *            value to use if unset.
56       * @return the value of the attribute as String.
57       */
58      String getString(String attrName, String defaultValue);
59  
60      /**
61       * retrieve the value of the attribute as boolean.
62       * 
63       * @param attrName
64       *            name of the attribute.
65       * @param defaultValue
66       *            value to use if unset.
67       * @return a boolean value.
68       */
69      boolean getBoolean(String attrName, boolean defaultValue);
70  
71      /**
72       * retrieve the attributes as map.
73       * 
74       * @return a Map&ltString,String>
75       */
76      Map<String, String> getAsMap();
77  
78  }