GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members  

Preferences.java

Go to the documentation of this file.
00001 package org.gridlab.gat;
00002 
00003 import java.util.Hashtable;
00004 import java.util.Map;
00005 import java.util.jar.Attributes;
00006 
00007 /**
00008  * An instance of this class represents user preferences for selecting adaptors.
00009  * Currently this class is a place holder for the user preferences, the
00010  * structure of which is in development.
00011  */
00012 public class Preferences extends Hashtable {
00013 
00014     /**
00015      * Constructs a new Preferences no mappings.
00016      */
00017     public Preferences() {
00018         super();
00019     }
00020 
00021     /**
00022      * Constructs a new Preferences with the same mappings as the given Map.
00023      */
00024     public Preferences(Map map) {
00025         super(map);
00026     }
00027 
00028     /**
00029      * Associates the specified value with the specified key in this map
00030      * (optional operation). If the map previously contained a mapping for this
00031      * key, the old value is replaced.
00032      * 
00033      * @param key
00034      *            key with which the specified value is to be associated.
00035      * @param value
00036      *            value to be associated with the specified key.
00037      * @return previous value associated with specified key, or <tt>null</tt>
00038      *         if there was no mapping for key. A <tt>null</tt> return can
00039      *         also indicate that the map previously associated <tt>null</tt>
00040      *         with the specified key, if the implementation supports
00041      *         <tt>null</tt> values.
00042      * 
00043      * @throws UnsupportedOperationException
00044      *             if the <tt>put</tt> operation is not supported by this map.
00045      * @throws ClassCastException
00046      *             if the class of the specified key or value prevents it from
00047      *             being stored in this map.
00048      * @throws IllegalArgumentException
00049      *             if some aspect of this key or value prevents it from being
00050      *             stored in this map.
00051      * @throws NullPointerException
00052      *             this map does not permit <tt>null</tt> keys or values, and
00053      *             the specified key or value is <tt>null</tt>.
00054      */
00055     public Object put(Object key, Object value) {
00056         /*
00057          * Note: This uglyness is required as Attributes keys are
00058          * Attributes.Name instances and not String instances. ( An
00059          * Attributes.Name class is only a wrapper around a String used as the
00060          * keys in Attributes instances are case insensitive and can contain
00061          * only certain letters. ) Attributes's values are String instances.
00062          */
00063         if ((key instanceof Attributes.Name) && (value instanceof String)) {
00064             return super.put(key, value);
00065         } else {
00066             return super.put(new Attributes.Name((String) key), (String) value);
00067         }
00068     }
00069 }