org.clapper.classutil

ClassFinder

object ClassFinder

The entrance to the factory floor, providing methods for finding and filtering classes.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ClassFinder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def apply(path: Seq[File] = Seq.empty[File]): ClassFinder

    Instantiate a new ClassFinder that will search the specified classpath, or the default classpath, if no classpath is defined.

    Instantiate a new ClassFinder that will search the specified classpath, or the default classpath, if no classpath is defined.

    path

    the classpath, which is a sequence of File objects representing directories, jars and zip files to search. Defaults to classpath if empty.

    returns

    a new ClassFinder object

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def classInfoMap(stream: Stream[ClassInfo]): Map[String, ClassInfo]

    Create a map from a Stream of ClassInfo objects.

    Create a map from a Stream of ClassInfo objects. The resulting map is indexed by class name.

    returns

    a map of (classname, ClassInfo) pairs

  9. def classInfoMap(iterator: Iterator[ClassInfo]): Map[String, ClassInfo]

    Create a map from an Iterator of ClassInfo objects.

    Create a map from an Iterator of ClassInfo objects. The resulting map is indexed by class name.

    returns

    a map of (classname, ClassInfo) pairs

  10. def classpath: List[File]

    Convenient method for getting the standard JVM classpath, into a variable suitable for use with the find() method.

    Convenient method for getting the standard JVM classpath, into a variable suitable for use with the find() method.

    returns

    the classpath, as a list of File objects

  11. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def concreteSubclasses(ancestor: String, classes: Map[String, ClassInfo]): Iterator[ClassInfo]

    Variant of concreteSubclasses() that takes a string class name and a map, rather than a Class and a map.

    Variant of concreteSubclasses() that takes a string class name and a map, rather than a Class and a map.

    ancestor

    the name of the class for which to find descendent concrete subclasses

    classes

    the iterator of ClassInfo objects to search

    returns

    an iterator of ClassInfo objects that are concrete subclasses of ancestor. The iterator will be empty if no matching classes could be found.

    See also

    concreteSubclasses(String, Iterator[ClassInfo])

    concreteSubclasses(String, Stream[ClassInfo])

    concreteSubclasses(Class[_], Map[String, ClassInfo])

  13. def concreteSubclasses(ancestor: Class[_], classes: Map[String, ClassInfo]): Iterator[ClassInfo]

    Variant of concreteSubclasses() that takes a class and a Map ClassInfo objects.

    Variant of concreteSubclasses() that takes a class and a Map ClassInfo objects.

    ancestor

    the Class object of the superclass or trait for which to find descendent concrete subclasses

    classes

    the iterator of ClassInfo objects to search

    returns

    an iterator of ClassInfo objects that are concrete subclasses of ancestor. The iterator will be empty if no matching classes could be found.

    See also

    concreteSubclasses(Class[_], Iterator[ClassInfo])

    concreteSubclasses(Class[_], Stream[ClassInfo])

  14. def concreteSubclasses(ancestor: String, classes: Iterator[ClassInfo]): Iterator[ClassInfo]

    Variant of concreteSubclasses() that takes a string class name and an Iterator of ClassInfo objects, rather than a Class and an Iterator.

    Variant of concreteSubclasses() that takes a string class name and an Iterator of ClassInfo objects, rather than a Class and an Iterator.

    ancestor

    the name of the class for which to find descendent concrete subclasses

    classes

    the stream of ClassInfo objects to search

    returns

    an iterator of ClassInfo objects that are concrete subclasses of ancestor. The iterator will be empty if no matching classes could be found.

    Example:
    1. val finder = ClassFinder(myPath)
      val classes = finder.getClasses  // classes is an Stream[ClassInfo]
      // Of course, it's easier just to call the version that takes a
      // Stream...
      ClassFinder.concreteSubclasses("org.example.Foo", classes.toIterator)
    See also

    concreteSubclasses(Class[_], Iterator[ClassInfo])

    concreteSubclasses(String, Stream[ClassInfo])

  15. def concreteSubclasses(ancestor: Class[_], classes: Iterator[ClassInfo]): Iterator[ClassInfo]

    Variant of concreteSubclasses() that takes a class and an Iterator of ClassInfo objects, rather than a Class and a Stream.

    Variant of concreteSubclasses() that takes a class and an Iterator of ClassInfo objects, rather than a Class and a Stream.

    ancestor

    the Class object of the superclass or trait for which to find descendent concrete subclasses

    classes

    the iterator of ClassInfo objects to search

    returns

    an iterator of ClassInfo objects that are concrete subclasses of ancestor. The iterator will be empty if no matching classes could be found.

    Example:
    1. val finder = ClassFinder(myPath)
      val classes = finder.getClasses  // classes is an Stream[ClassInfo]
      // Of course, it's easier just to call the version that takes a
      // Stream...
      ClassFinder.concreteSubclasses(classOf[Baz], classes.toIterator)
    See also

    concreteSubclasses(Class[_], Stream[ClassInfo])

  16. def concreteSubclasses(ancestor: String, classes: Stream[ClassInfo]): Iterator[ClassInfo]

    Variant of concreteSubclasses() that takes a string class name and a Stream of ClassInfo objects, rather than a Class and a Stream.

    Variant of concreteSubclasses() that takes a string class name and a Stream of ClassInfo objects, rather than a Class and a Stream.

    ancestor

    the name of the class for which to find descendent concrete subclasses

    classes

    the stream of ClassInfo objects to search

    returns

    an iterator of ClassInfo objects that are concrete subclasses of ancestor. The iterator will be empty if no matching classes could be found.

    See also

    concreteSubclasses(Class[_], Stream[ClassInfo])

  17. def concreteSubclasses(ancestor: Class[_], classes: Stream[ClassInfo]): Iterator[ClassInfo]

    Convenience method that scans the specified classes for all concrete classes that are subclasses of a superclass or trait.

    Convenience method that scans the specified classes for all concrete classes that are subclasses of a superclass or trait. A subclass, in this definition, is a class that directly or indirectly (a) implements an interface (if the named class is an interface) or (b) extends a subclass (if the named class is a class). The class must be concrete, so intermediate abstract classes are not returned, though any children of such abstract classes will be.

    WARNINGS

    This method converts the stream to a map of classes, for easier lookup. Thus, upon its return, the stream will be empty. You can certainly recreate the stream, but at a cost. If you need to make multiple calls to this method with the same classpath, consider converting the stream to a map first, as shown below:

    val finder = ClassFinder(myPath)
    val classes = finder.getClasses  // classes is an Stream[ClassInfo]
    val classMap = ClassFinder.classInfoMap // runs the stream out, once
    val foos = ClassFinder.concreteSubclasses(classOf[org.example.Foo], classMap)
    val bars = ClassFinder.concreteSubclasses(classOf[Bar], classMap)

    This method can chew up a lot of temporary heap space, if called with a large classpath.

    ancestor

    the Class object of the superclass or trait for which to find descendent concrete subclasses

    classes

    the stream of ClassInfo objects to search

    returns

    an iterator of ClassInfo objects that are concrete subclasses of ancestor. The iterator will be empty if no matching classes could be found.

  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  20. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  23. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  24. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  25. final def notify(): Unit

    Definition Classes
    AnyRef
  26. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  28. def toString(): String

    Definition Classes
    AnyRef → Any
  29. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped