You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/29 10:17:21 UTC

svn commit: r769704 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: Group.java GroupIterator.java GroupIteratorImpl.java User.java UserIterator.java UserIteratorImpl.java

Author: mturk
Date: Wed Apr 29 08:17:21 2009
New Revision: 769704

URL: http://svn.apache.org/viewvc?rev=769704&view=rev
Log:
Add javadocs and missing exceptions

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIterator.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIteratorImpl.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java?rev=769704&r1=769703&r2=769704&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java Wed Apr 29 08:17:21 2009
@@ -42,7 +42,7 @@
         throws IOException, SecurityException;
     private static native boolean equals0(Descriptor a, Descriptor b);
     private static native Group[] enum0()
-        throws IOException, SecurityException, UnsupportedOperationException;
+        throws IOException, SecurityException;
     private static native Group[] enum1()
         throws IOException, SecurityException, UnsupportedOperationException;
 
@@ -65,12 +65,32 @@
         return g;
     }
 
+    /**
+     * Get the {@link GroupIterator} of all {@code local} groups defined
+     * on this system.
+     *
+     * @return GroupIterator containing all {@code local} groups.
+     * @throws IOException in case of I/O error.
+     * @throws SecurityException if the current user is not allowed to
+     *         access the system group database.
+     */
     public static GroupIterator getLocalGroups()
-        throws IOException, SecurityException, UnsupportedOperationException
+        throws IOException, SecurityException
     {
         return new GroupIteratorImpl(enum0());
     }
 
+    /**
+     * Get the {@link GroupIterator} of all {@code local} groups defined
+     * on this system.
+     *
+     * @return GroupIterator containing all {@code local} groups.
+     * @throws IOException in case of I/O error.
+     * @throws SecurityException if the current user is not allowed to
+     *         access the system group database.
+     * @throws UnsupportedOperationException if the operating system does not
+     *         support the global groups concept.
+     */
     public static GroupIterator getGlobalGroups()
         throws IOException, SecurityException, UnsupportedOperationException
     {
@@ -121,13 +141,14 @@
     public final Descriptor Id;
 
     /**
-     * Compares this {@code Group} to the specified object.
+     * Compares {@code this} Group to the specified object.
      *
      * @param other a {@code Group}
      * @return  true if the class of this {@code Group} object and the
      *      class of {@code other} are exactly equal, and they point
      *      to the same system group id.
      */
+    @Override
     public boolean equals(Object other)
     {
         if (other == null)

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java?rev=769704&r1=769703&r2=769704&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java Wed Apr 29 08:17:21 2009
@@ -17,6 +17,7 @@
 package org.apache.commons.runtime;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * Group Iterator
@@ -26,13 +27,20 @@
 public abstract class GroupIterator
     implements Iterator<Group>, Iterable<Group>
 {
+
     /**
+     * Returns {@code true} if the iteration has more elements.
+     * It returns {@code true} if the {@code next} would return
+     * an group rather then throwing and exception. 
      *
+     * @return {@code true} if the iteration has more elements.
      */
     public abstract boolean hasNext();
 
     /**
+     * Returns an iterator over a set of {@link Group} elements.
      *
+     * return Iterator of type {@code Group}.
      */
     public Iterator<Group> iterator()
     {
@@ -40,14 +48,23 @@
     }
 
     /**
+     * Returns the next {@link Group} in the iteration.
      *
+     * @return the next {@code Group} in the iteration.
      */
-    public abstract Group next();
+    public abstract Group next()
+        throws NoSuchElementException;
 
     /**
+     * Removes from the underlying collection the last element returned
+     * by the iterator. This method is unsupported.
      *
+     * @throws UnsupportedOperationException is always thrown.
+     * @throws IllegalStateException is the {@code next} method has not yet
+     *         been called.
      */
     public void remove()
+        throws UnsupportedOperationException, IllegalStateException
     {
         throw new UnsupportedOperationException();
     }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java?rev=769704&r1=769703&r2=769704&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java Wed Apr 29 08:17:21 2009
@@ -17,6 +17,7 @@
 package org.apache.commons.runtime;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * Group Iterator implementation
@@ -48,10 +49,11 @@
     }
 
     public Group next()
+        throws NoSuchElementException
     {
         if (pos < len)
             return array[pos++];
         else
-            return null;
+            throw new NoSuchElementException();
     }
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java?rev=769704&r1=769703&r2=769704&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Wed Apr 29 08:17:21 2009
@@ -43,7 +43,7 @@
         throws IOException, SecurityException;
     private static native boolean equals0(Descriptor a, Descriptor b);
     private static native User[] enum0()
-        throws IOException, SecurityException, UnsupportedOperationException;
+        throws IOException, SecurityException;
 
     /**
      * Create the {@code User} object from the {@code name}.
@@ -63,12 +63,16 @@
         return u;
     }
 
-   /**
-     * Get the list of all users
-     * @return Array of Users.
+    /**
+     * Get the {@link UserIterator} of all users defined on the system.
+     *
+     * @return UserIterator containing all users.
+     * @throws IOException in case of I/O error.
+     * @throws SecurityException if the current user is not allowed to
+     *         access the system user database.
      */
     public static UserIterator getUsers()
-        throws IOException, SecurityException, UnsupportedOperationException
+        throws IOException, SecurityException
     {
         return new UserIteratorImpl(enum0());
     }
@@ -136,13 +140,14 @@
     public final Descriptor Id;
 
     /**
-     * Compares this {@code User} to the specified object.
+     * Compares {@code this} User to the specified object.
      *
      * @param other a {@code User}
      * @return  true if the class of this {@code User} object and the
      *      class of {@code other} are exactly equal, and they point
      *      to the same system user id.
      */
+    @Override
     public boolean equals(Object other)
     {
         if (other == null)

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIterator.java?rev=769704&r1=769703&r2=769704&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIterator.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIterator.java Wed Apr 29 08:17:21 2009
@@ -17,9 +17,10 @@
 package org.apache.commons.runtime;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
- * User Iterator
+ * User Iterator.
  *
  * @since Runtime 1.0
  */
@@ -27,12 +28,18 @@
     implements Iterator<User>, Iterable<User>
 {
     /**
+     * Returns {@code true} if the iteration has more elements.
+     * It returns {@code true} if the {@code next} would return
+     * an user rather then throwing and exception. 
      *
+     * @return {@code true} if the iteration has more elements.
      */
     public abstract boolean hasNext();
 
     /**
+     * Returns an iterator over a set of {@link User} elements.
      *
+     * return Iterator of type {@code User}.
      */
     public Iterator<User> iterator()
     {
@@ -40,14 +47,23 @@
     }
 
     /**
+     * Returns the next {@link User} in the iteration.
      *
+     * @return the next {@code User} in the iteration.
      */
-    public abstract User next();
+    public abstract User next()
+        throws NoSuchElementException;
 
     /**
+     * Removes from the underlying collection the last element returned
+     * by the iterator. This method is unsupported.
      *
+     * @throws UnsupportedOperationException is always thrown.
+     * @throws IllegalStateException is the {@code next} method has not yet
+     *         been called.
      */
     public void remove()
+        throws UnsupportedOperationException, IllegalStateException
     {
         throw new UnsupportedOperationException();
     }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIteratorImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIteratorImpl.java?rev=769704&r1=769703&r2=769704&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIteratorImpl.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIteratorImpl.java Wed Apr 29 08:17:21 2009
@@ -17,6 +17,7 @@
 package org.apache.commons.runtime;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * User Iterator implementation
@@ -48,10 +49,11 @@
     }
 
     public User next()
+        throws NoSuchElementException
     {
         if (pos < len)
             return array[pos++];
         else
-            return null;
+            throw new NoSuchElementException();
     }
 }