|
What this is
Other links
The source code/* * Properties.java * * Created on November 25, 2002, 7:06 PM */ package org.netbeans.test.editor.app.core.properties; import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; import java.util.Vector; /** * * @author eh103527 */ public class Properties { Vector entries; /** Creates a new instance of Properties */ public Properties() { entries=new Vector(30); } public Object getProperty(java.lang.String name) { if (name == null) throw new NullPointerException("Null name property."); Entry e; for (Iterator it=entries.iterator();it.hasNext();) { e=(Entry)(it.next()); if (e.key.compareTo(name) == 0) { return e.value; } } return null; } public Object put(String name, Object value) { Object ret=null; Entry e=null; if (name == null) throw new NullPointerException("Null name property."); if (value == null) throw new NullPointerException("Null property value."); for (Iterator it=entries.iterator();it.hasNext();) { e=(Entry)(it.next()); if (e.key.compareTo(name) == 0) { ret=e.value; break; } } if (ret == null) { entries.add(new Entry(name,value)); } else { e.value=value; } return ret; } public Enumeration propertyNames() { return new Enumeration() { String[] names=getNames(); int i=0; public boolean hasMoreElements() { return (i < names.length); } public Object nextElement() { return names[i++]; } }; } private String[] getNames() { ArrayList ar=new ArrayList(); Entry e; for (Iterator it=entries.iterator();it.hasNext();) { e=(Entry)(it.next()); ar.add(e.key); } return (String[])(ar.toArray(new String[] {})); } /** Removes all mappings from this map (optional operation). * * @throws UnsupportedOperationException clear is not supported by this * map. * */ public void clear() { entries.removeAllElements(); } /** Returns true if this map contains no key-value mappings. * * @return true if this map contains no key-value mappings. * */ public boolean isEmpty() { return entries.size() == 0; } /** Removes the mapping for this key from this map if it is present * (optional operation). More formally, if this map contains a mapping * from key k to value v such that * |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.