Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.kuali.rice.kew.engine.node;
 import java.util.List;

A typesafe enumeration defining the various types of Nodes in the Workflow Engine. This class was added to aid in unifying the node type concept across multiple components within the system. It also defines type hierarchys for the various node types.

Kuali Rice Team (
 public class NodeType {
     private static final String SIMPLE_NAME = "simple";
     private static final String JOIN_NAME = "join";
     private static final String SPLIT_NAME = "split";
     private static final String SUB_PROCESS_NAME = "process";
     private static final String DYNAMIC_NAME = "dynamic";
     private static final String START_NAME = "start";
     private static final String REQUEST_ACTIVATION_NAME = "requestActivation";
     private static final String REQUESTS_NAME = "requests";
     private static final String ROLE_NAME = "role";

A Sorted List containing the NodeTypes in order sorted by largest extension depth first, i.e. in bottom-up extension order.
     private static final List typeList = new ArrayList();
     private static final Comparator depthComparator = new ExtensionDepthComparator();
     // primitive node types
     public static final NodeType SIMPLE = new NodeType(SimpleNode.classnull);
     public static final NodeType SPLIT = new NodeType(SplitNode.classSimpleSplitNode.class);
     public static final NodeType JOIN = new NodeType(JoinNode.classSimpleJoinNode.class);
     public static final NodeType SUB_PROCESS = new NodeType(SubProcessNode.classSimpleSubProcessNode.class);
     public static final NodeType DYNAMIC = new NodeType(DynamicNode.classnull);
     // derivative node types
     public static final NodeType START = new NodeType(InitialNode.classInitialNode.class);
     public static final NodeType REQUESTS = new NodeType(RequestsNode.classRequestsNode.class);
     public static final NodeType ROLE = new NodeType(RoleNode.classRoleNode.class);
     private NodeType extensionBase;
     private String name;
     private Class baseClass;
     private Class defaultClass;
     private int extensionDepth = 0;
     private NodeType(String nameClass baseClassClass defaultClass) {
     private NodeType(NodeType extensionBaseString nameClass baseClassClass defaultClass) {
         this. = extensionBase;
         this. = name;
         this. = baseClass;
         this. = defaultClass;
         while (extensionBase != null) {
             extensionBase = extensionBase.getExtensionBase();
         // keep the list sorted
     public NodeType getExtensionBase() {
         return ;
     public Class getBaseClass() {
         return ;
    public Class getDefaultClass() {
        return ;
    public String getName() {
        return ;
    public int getExtensionDepth() {
        return ;
    public boolean isAssignableFrom(Class typeClass) {
        return getBaseClass().isAssignableFrom(typeClass);
    public boolean isAssignableFrom(NodeType type) {
        return getBaseClass().isAssignableFrom(type.getBaseClass());
    public boolean isInstanceOf(Object object) {
    	return ClassLoaderUtils.isInstanceOf(objectgetBaseClass());
    public boolean isTypeOf(Class typeClass) {
        return typeClass.isAssignableFrom(getBaseClass());
    public boolean isTypeOf(NodeType type) {
        return type.getBaseClass().isAssignableFrom(getBaseClass());
    public boolean isCustomNode(String className) {
        return getDefaultClass() == null || !getDefaultClass().getName().equals(className);
    public boolean equals(Object object) {
        if (object instanceof NodeType) {
            return ((NodeType)object)..equals();
        return false;
    public int hashCode() {
        return .hashCode();
    public static NodeType fromClassName(String classNamethrows ResourceUnavailableException {
        //Class typeClass = SpringServiceLocator.getExtensionService().loadClass(className);
        Object typeObject = GlobalResourceLoader.getResourceLoader().getObject(new ObjectDefinition(className));
        if (typeObject == null) {
        	throw new ResourceUnavailableException("Could not locate the node with the given class name '" + className + "'.");
        //Class typeClass = typeObject.getClass();
    	// depends upon the proper sorting of typeList
        for (Iterator iterator = .iterator(); iterator.hasNext();) {
            NodeType type = (;
            //if (type.isAssignableFrom(typeClass)) {
            //if (ClassLoaderUtils.isInstanceOf(typeObject, type))
            if (type.isInstanceOf(typeObject)) {
                return type;
        return null;
    public static NodeType fromNode(RouteNode nodethrows ResourceUnavailableException {
        return fromClassName(node.getNodeType());
    public static NodeType fromNodeInstance(RouteNodeInstance nodeInstancethrows ResourceUnavailableException {
        return fromNode(nodeInstance.getRouteNode());

Sorts in descending extension-depth order.
    private static class ExtensionDepthComparator implements Comparator {
        public int compare(Object object1Object object2) {
            NodeType type1 = (NodeType)object1;
            NodeType type2 = (NodeType)object2;
            if (type1.getExtensionDepth() > type2.getExtensionDepth()) {
                return -1;
            } else if (type1.getExtensionDepth() < type2.getExtensionDepth()) {
                return 1;
            return 0;
    public static List<NodeTypegetTypeList(){
    	return ;
New to GrepCode? Check out our FAQ X