/** * 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 <tt>NullArgumentException</tt>. * * @param name Argument name. */ public NullArgumentException(final String name) { super(makeMessage(name)); this.name = name; this.index = null; }
/** * 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 <tt>NullArgumentException</tt>. * * @param name Argument name. * @param index Argument index. */ public NullArgumentException(final String name, final Object index) { super(makeMessage(name, index)); this.name = name; this.index = index; }
/** * Construct a CompoundKey. * * @param elements Elements of the key. */ public CompoundKey(final Object elements[]) { if (elements == null) throw new NullArgumentException("elements"); this.elements = elements; }
/** * Construct a <tt>NullArgumentException</tt>. * * @param name Argument name. * @param index Argument index. */ public NullArgumentException(final String name, final long index) { super(makeMessage(name, new Long(index))); this.name = name; this.index = new Long(index); }
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 new field instance. * * @param instance The instance object the given field belongs to. * @param fieldName The name of the field to find in the instance. * * @throws NullArgumentException Instance or fieldName is <tt>null</tt>. * @throws NoSuchFieldException */ public FieldInstance(final Object instance, final String fieldName) throws NoSuchFieldException { if (instance == null) throw new NullArgumentException("instance"); if (fieldName == null) throw new NullArgumentException("fieldName"); // Get the field object field = instance.getClass().getField(fieldName); // Check if the field is assignable ? if (! field.getDeclaringClass().isAssignableFrom(instance.getClass())) throw new IllegalArgumentException ("field does not belong to instance class"); this.instance = instance; }
/** * Prints the nested <code>Throwable</code> to the given stream. * * @param nested Nested <code>Throwable</code>. * @param stream Stream to print to. */ public static void print(final Throwable nested, final PrintStream stream) { if (stream == null) throw new NullArgumentException("stream"); if (NestedThrowable.NESTED_TRACE_ENABLED && nested != null) { synchronized (stream) { if (NestedThrowable.PARENT_TRACE_ENABLED) { stream.print(" + nested throwable: "); } else { stream.print("[ parent trace omitted ]: "); } nested.printStackTrace(stream); } } }
/** * Prints the nested <code>Throwable</code> to the given writer. * * @param nested Nested <code>Throwable</code>. * @param writer Writer to print to. */ public static void print(final Throwable nested, final PrintWriter writer) { if (writer == null) throw new NullArgumentException("writer"); if (NestedThrowable.NESTED_TRACE_ENABLED && nested != null) { synchronized (writer) { if (NestedThrowable.PARENT_TRACE_ENABLED) { writer.print(" + nested throwable: "); } else { writer.print("[ parent trace omitted ]: "); } nested.printStackTrace(writer); } } } }
/** * 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); } }