org.kohsuke.stapler.lang
Class KlassNavigator<C>

java.lang.Object
  extended by org.kohsuke.stapler.lang.KlassNavigator<C>

public abstract class KlassNavigator<C>
extends java.lang.Object

Strategy pattern to provide navigation across class-like objects in other languages of JVM.

Implementations should be stateless and typically a singleton.

Author:
Kohsuke Kawaguchi

Field Summary
static KlassNavigator<java.lang.Class> JAVA
           
 
Constructor Summary
KlassNavigator()
           
 
Method Summary
abstract  java.lang.Iterable<Klass<?>> getAncestors(C clazz)
          Lists up all the ancestor classes, from specific to general, without any duplicate.
abstract  java.net.URL getResource(C clazz, java.lang.String resourceName)
          Loads the resources associated with this class.
abstract  Klass<?> getSuperClass(C clazz)
          Gets the super class.
abstract  java.lang.Class toJavaClass(C clazz)
          For backward compatibility, map the given class to the closest Java equivalent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA

public static final KlassNavigator<java.lang.Class> JAVA
Constructor Detail

KlassNavigator

public KlassNavigator()
Method Detail

getResource

public abstract java.net.URL getResource(C clazz,
                                         java.lang.String resourceName)
Loads the resources associated with this class.

In stapler, the convention is that the "associated" resources live in the directory named after the fully qualified class name (as opposed to the behavior of Class.getResource(String), that looks for resources in the same package as the class.)

But other languages can choose their own conventions if it makes more sense to do so. For example, stapler-jruby uses camelized class name.

Implementation must consult MetaClassLoader.debugLoader if it's available. Implementation must not look for resources in the base type. That operation is performed by the caller when needed.

Returns:
non-null if the resource is found. Otherwise null.

getAncestors

public abstract java.lang.Iterable<Klass<?>> getAncestors(C clazz)
Lists up all the ancestor classes, from specific to general, without any duplicate. This is used to look up a resource.


getSuperClass

public abstract Klass<?> getSuperClass(C clazz)
Gets the super class.

Returns:
Can be null.

toJavaClass

public abstract java.lang.Class toJavaClass(C clazz)
For backward compatibility, map the given class to the closest Java equivalent. In the worst case, this is Object.class



Copyright © 2012. All Rights Reserved.