consciouscode.util
Class ClassPathIterator

java.lang.Object
  extended by consciouscode.util.ClassPathIterator
All Implemented Interfaces:
Iterator<String>

public class ClassPathIterator
extends Object
implements Iterator<String>

Navigates the .class files in a classpath. The iteration returns the fully-qualified class names.


Field Summary
static String EXTENSION
           
 
Constructor Summary
ClassPathIterator(File directory)
          Create an iterator that returns the classes in a single directory tree.
ClassPathIterator(String pathList)
          Create an iterator that returns the classes in a list of directories.
 
Method Summary
 boolean hasNext()
           
 String next()
          Return a String holding the fully-qualified name of the next class.
 String nextClassName()
          Return the fully-qualified name of the next class.
 void remove()
          Unsupported operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENSION

public static final String EXTENSION
See Also:
Constant Field Values
Constructor Detail

ClassPathIterator

public ClassPathIterator(File directory)
                  throws IOException
Create an iterator that returns the classes in a single directory tree.

Parameters:
directory - must indicate a valid classpath directory; it is assumed that the files within this directory are arranged in accordance with their package structure.
Throws:
IOException

ClassPathIterator

public ClassPathIterator(String pathList)
                  throws IOException
Create an iterator that returns the classes in a list of directories.

Parameters:
pathList - must be a standard Java class path, where each directory has a structure matching the class package hierarchy. Multiple directory roots are indicated using the platform's File.pathSeparator. Any elements that do not identify a readable directory are ignored.
Throws:
IOException
Method Detail

nextClassName

public final String nextClassName()
Return the fully-qualified name of the next class.


hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<String>

next

public String next()
Return a String holding the fully-qualified name of the next class.

Specified by:
next in interface Iterator<String>

remove

public void remove()
            throws UnsupportedOperationException
Unsupported operation.

Specified by:
remove in interface Iterator<String>
Throws:
UnsupportedOperationException - in all cases.


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.