/** * Construct an ArrayIterator. * * @param array The array to iterate over. */ public ArrayIterator(final Object[] array) { if (array == null) throw new NullArgumentException("array"); this.array = array; }
/** * Construct a FilePropertyReader with an array of filenames * to read from. * * @param filenames Filenames to load properties from */ public FilePropertyReader(String[] filenames) { if (filenames == null) throw new NullArgumentException("filenames"); this.filenames = filenames; }
/** * Construct a CompoundKey. * * @param elements Elements of the key. */ public CompoundKey(final Object elements[]) { if (elements == null) throw new NullArgumentException("elements"); this.elements = elements; }
public void setInstancePool(final InstancePool instancePool) { if (instancePool == null) throw new NullArgumentException("instancePool"); this.instancePool = instancePool; }
public void setCommandContext(final CommandContext context) { if (context == null) throw new NullArgumentException("context"); this.context = context; }
/** * Construct a new <i>constrained</i> ListQueue. * * @param list The list which will be used to store queued objects. * @param maxSize The maximum size of the queue. * * @exception IllegalArgumentException List is <i>null</i>. */ public ListQueue(final List<E> list, final int maxSize) { super(maxSize); if (list == null) throw new NullArgumentException("list"); this.list = list; }
/** * Construct a <tt>PropertyGroup</tt>. * * @param basename Base property name. * @param container Property container. * * @throws NullArgumentException Basename is <tt>null</tt>. */ public PropertyGroup(final String basename, final Properties container) { super(container); if (basename == null) throw new NullArgumentException("basename"); this.basename = basename; }
/** * Construct a new <tt>PropertyEvent</tt>. * * @param source The source of the event. * @param name The property name effected. * @param value The value of the property effected. * * @throws NullArgumentException Name or source is <tt>null</tt>. */ public PropertyEvent(final Object source, final String name, final String value) { super(source); if (name == null) throw new NullArgumentException("name"); // value can be null this.name = name; this.value = value; }
/** * Add an array of property listeners. * * @param listeners Array of property listeners to add. */ public void addPropertyListeners(PropertyListener[] listeners) { if (listeners == null) throw new NullArgumentException("listeners"); for (int i = 0; i < listeners.length; i++) { addPropertyListener(listeners[i]); } }
/** * Construct a <tt>ListSet</tt>. * * @param list The <tt>List</tt> which will be used for element storage. * * @throws IllegalArgumentException List is <tt>null</tt> or contains * duplicate entries. */ public ListSet(final List list) { if (list == null) throw new NullArgumentException("list"); // make sure there are no duplicates int size = list.size(); for (int i=0; i<size; i++) { Object obj = list.get(i); if (list.indexOf(obj) != list.lastIndexOf(obj)) { throw new IllegalArgumentException ("list contains duplicate entries"); } } this.list = list; }
/** * Capitalize the first character of the given string. * * @param string String to capitalize. * @return Capitalized string. * * @throws IllegalArgumentException String is <kk>null</kk> or empty. */ public static String capitalize(final String string) { if (string == null) throw new NullArgumentException("string"); if (string.equals("")) throw new EmptyStringException("string"); return Character.toUpperCase(string.charAt(0)) + string.substring(1); }
/** * Construct a <tt>WeakSet</tt>. Any elements in the given set will be * wrapped in {@link WeakObject} references. * * @param set The <tt>Set</tt> which will be used for element storage. * * @throws NullArgumentException Set is <tt>null</tt>. */ public WeakSet(final Set set) { if (set == null) throw new NullArgumentException("set"); // reset any elements to weak objects if (set.size() != 0) { Object elements[] = set.toArray(); set.clear(); for (int i=0; i<elements.length; i++) { add(elements[i]); } } this.set = set; }
/** * Load properties from a file into a properties map. * * @param props Properties map to load properties into. * @param filename Filename to read properties from. * * @throws IOException Failed to load properties from filename. * @throws IllegalArgumentException Filename is invalid. */ protected void loadProperties(Properties props, String filename) throws IOException { if (filename == null) throw new NullArgumentException("filename"); if (filename.equals("")) throw new IllegalArgumentException("filename"); InputStream in = new BufferedInputStream(getInputStream(filename)); props.load(in); in.close(); }
/** * Add a property listener. * * @param listener Property listener to add. */ public void addPropertyListener(PropertyListener listener) { if (listener == null) throw new NullArgumentException("listener"); if (listener instanceof BoundPropertyListener) { addPropertyListener((BoundPropertyListener) listener); } else { // only add the listener if it is not in the list already if (!unboundListeners.contains(listener)) unboundListeners.add(listener); } }
/** * Remove a property listener. * * @param listener Property listener to remove. * @return True if listener was removed. */ public boolean removePropertyListener(PropertyListener listener) { if (listener == null) throw new NullArgumentException("listener"); boolean removed = false; if (listener instanceof BoundPropertyListener) { removed = removePropertyListener((BoundPropertyListener) listener); } else { removed = unboundListeners.remove(listener); } return removed; }
/** * Get a property * * @param name Property name. * @return Property value or <tt>null</tt>. */ public Object get(final Object name) { if (name == null) throw new NullArgumentException("name"); return super.get(makePropertyName(name)); }
/** * Load properties from a PropertyReader. * * @param reader PropertyReader to read properties from. * @throws PropertyException * @throws IOException */ public void load(PropertyReader reader) throws PropertyException, IOException { if (reader == null) throw new NullArgumentException("reader"); load(reader.readProperties()); }
/** * Check if this <tt>PropertyMap</tt> contains a given property name. * * @param name Property name. * @return True if property map or defaults contains key. */ public boolean containsKey(final Object name) { if (name == null) throw new NullArgumentException("name"); return super.containsKey(makePropertyName(name)); }
/** * Remove a property. * * @param name Property name. * @return Removed property value. */ public Object remove(final Object name) { if (name == null) throw new NullArgumentException("name"); return super.remove(makePropertyName(name)); }
/** * Set a property. * * @param name Property name. * @param value Property value. * @return Previous property value or <tt>null</tt>. */ public Object put(final Object name, final Object value) { if (name == null) throw new NullArgumentException("name"); return super.put(makePropertyName(name), value); }