001: /*
002: * AttributeMap.java
003: *
004: * Version: $Revision: 1.2 $
005: *
006: * Date: $Date: 2005/10/21 21:16:33 $
007: *
008: * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
009: * Institute of Technology. All rights reserved.
010: *
011: * Redistribution and use in source and binary forms, with or without
012: * modification, are permitted provided that the following conditions are
013: * met:
014: *
015: * - Redistributions of source code must retain the above copyright
016: * notice, this list of conditions and the following disclaimer.
017: *
018: * - Redistributions in binary form must reproduce the above copyright
019: * notice, this list of conditions and the following disclaimer in the
020: * documentation and/or other materials provided with the distribution.
021: *
022: * - Neither the name of the Hewlett-Packard Company nor the name of the
023: * Massachusetts Institute of Technology nor the names of their
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033: * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034: * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036: * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037: * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038: * DAMAGE.
039: */
040:
041: package org.dspace.app.xmlui.wing;
042:
043: import java.util.HashMap;
044:
045: /**
046: * A simplified Wing version of an AttributeMap. If a namespace is set it is
047: * applied to all attributes in the Map. This is typically not what one would
048: * expect but it makes the syntax easier for Wing Elements. Either all the
049: * attributes come from one namespace or the other, but never two at the same
050: * time.
051: *
052: * @author Scott Phillips
053: */
054:
055: public class AttributeMap extends HashMap<String, String> {
056: /** Just so there are no compile warnings */
057: private static final long serialVersionUID = 1;
058:
059: /** The namespace of ALL the attributes contained within this map */
060: private Namespace namespace;
061:
062: /**
063: * Set the namespace for all attributes contained within this map.
064: *
065: * @param namespace
066: * The new namespace.
067: */
068: public void setNamespace(Namespace namespace) {
069: this .namespace = namespace;
070: }
071:
072: /**
073: *
074: * @return The namespace for all the attributes contained within this map.
075: */
076: public Namespace getNamespace() {
077: return this .namespace;
078: }
079:
080: /**
081: * Another variation of the put method to convert integer values into
082: * strings.
083: *
084: * @param key
085: * The attribute's name.
086: * @param value
087: * The value of the attribute.
088: * @return
089: */
090: public String put(String key, int value) {
091: return this .put(key, String.valueOf(value));
092: }
093:
094: /**
095: * Another variation of the put method to convert boolean values into
096: * strings. The values "yes" or "no" will be used in replacement of the
097: * boolean value.
098: *
099: * @param key
100: * @param value
101: * @return
102: */
103: public String put(String key, boolean value) {
104: return this .put(key, (value ? "yes" : "no"));
105: }
106: }
|