001: /*
002: * Created on 13.07.2005 for PIROL
003: *
004: * SVN header information:
005: * $Author: javamap $
006: * $Rev: 856 $
007: * $Date: 2007-06-18 21:15:27 -0700 (Mon, 18 Jun 2007) $
008: * $Id: Attribute2UnitMap.java 856 2007-06-19 04:15:27Z javamap $
009: */
010: package de.fho.jump.pirol.utilities.metaData;
011:
012: import java.util.Collection;
013: import java.util.HashMap;
014:
015: /**
016: * Meta information object to store the units for the attributes in a layer.
017: *
018: * @author Ole Rahn
019: * <br>
020: * <br>FH Osnabrück - University of Applied Sciences Osnabrück,
021: * <br>Project: PIROL (2005),
022: * <br>Subproject: Daten- und Wissensmanagement
023: *
024: * @version $Rev: 856 $
025: *
026: */
027: public class Attribute2UnitMap {
028:
029: protected HashMap<String, String> attribute2unit = new HashMap<String, String>();
030: protected boolean useHTMLLineBreaks = false;
031: /**
032: * key to be used in the meta information map
033: */
034: protected static final String KEY_ATTRIBUTE2UNIT = "attribute2unit";
035:
036: public void clear() {
037: attribute2unit.clear();
038: }
039:
040: public boolean containsAttribute(String attributeName) {
041: return attribute2unit.containsKey(attributeName);
042: }
043:
044: public boolean containsUnit(String unitString) {
045: return attribute2unit.containsValue(unitString);
046: }
047:
048: public String getUnitString(String attributeName) {
049: return attribute2unit.get(attributeName);
050: }
051:
052: public String put(String attributeName, String unitString) {
053: return attribute2unit.put(attributeName, unitString);
054: }
055:
056: public String removeAttribute(String attributeName) {
057: return attribute2unit.remove(attributeName);
058: }
059:
060: public Collection values() {
061: return attribute2unit.values();
062: }
063:
064: public String toString() {
065:
066: Object[] keys = this .attribute2unit.keySet().toArray();
067: String result = this .getClass().getName()
068: + (useHTMLLineBreaks ? ":<br>\n" : ":\n");
069:
070: for (int i = 0; i < this .attribute2unit.size(); i++) {
071: result += keys[i].toString() + " - "
072: + this .attribute2unit.get(keys[i]).toString()
073: + (useHTMLLineBreaks ? "<br>\n" : "\n");
074: }
075:
076: return result;
077: }
078:
079: /**
080: * tells you if @link{Attribute2UnitMap#toString()} uses <br> or just backslash+n to begin a new line.
081: *@return value of useHTMLLineBreaks
082: */
083: public boolean isUseHTMLLineBreaks() {
084: return useHTMLLineBreaks;
085: }
086:
087: /**
088: * Controlls if @link{Attribute2UnitMap#toString()} uses <br> or just backslash+n to begin a new line.
089: */
090: public void setUseHTMLLineBreaks(boolean useHTMLLineBreaks) {
091: this .useHTMLLineBreaks = useHTMLLineBreaks;
092: }
093:
094: /**
095: * for java2xml
096: *@return attribute2unit map
097: */
098: public HashMap getAttribute2unit() {
099: return attribute2unit;
100: }
101:
102: /**
103: * for java2xml
104: *@param attribute2unit map
105: */
106: public void setAttribute2unit(HashMap<String, String> attribute2unit) {
107: this.attribute2unit = attribute2unit;
108: }
109:
110: }
|