001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.platform.attribute; 005 006 007 import java.util.Collections; 008 import java.util.HashMap; 009 import java.util.Map; 010 011 /** 012 * @author azin azadi 013 */ 014 public class AttributeSetImpl implements AttributeSet { 015 protected HashMap<String, Object> atr = new HashMap<String, Object>(); 016 017 public AttributeSetImpl() { 018 //Nothing to do! 019 } 020 021 022 public Map<String, Object> getAttrs() { 023 return Collections.unmodifiableMap(atr); 024 } 025 026 public void put(String name, Object value) { 027 if (name == null) { 028 throw new RuntimeException("key=null" + value); 029 } 030 atr.put(name, value); 031 } 032 033 034 public Object get(String name) { 035 return atr.get(name); 036 } 037 038 public boolean contains(String name) { 039 return atr.containsKey(name); 040 } 041 042 043 /** 044 * clears all attributes in this set, this means that after calling this method the set of attributes will be empty 045 */ 046 public void clear() { 047 atr = new HashMap<String, Object>(); 048 } 049 }