View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.engine.node;
18  
19  import java.util.Collection;
20  
21  /**
22   * The criteria defining parameters to a search through a document's node graph.
23   *
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class NodeGraphSearchCriteria {
27  
28  	// search directions
29  	public static final int SEARCH_DIRECTION_FORWARD = 1;
30  	public static final int SEARCH_DIRECTION_BACKWARD = 2;
31  	public static final int SEARCH_DIRECTION_BOTH = 3;
32  	
33  	private int searchDirection = SEARCH_DIRECTION_FORWARD;
34  	private Collection startingNodeInstances;
35  	private NodeMatcher matcher;
36  	
37  	public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, NodeMatcher matcher) {
38  		if (startingNodeInstances == null || startingNodeInstances.isEmpty()) {
39  			throw new IllegalArgumentException("Starting node instances were empty.  At least one starting node instance must be specified in order to perform a search.");
40  		}
41  		this.searchDirection = searchDirection;
42  		this.startingNodeInstances = startingNodeInstances;
43  		this.matcher = matcher;
44  	}
45  	
46  	public NodeGraphSearchCriteria(int searchDirection, Collection startingNodeInstances, String nodeName) {
47  		this(searchDirection, startingNodeInstances, new NodeNameMatcher(nodeName));
48  	}
49  
50  	public NodeMatcher getMatcher() {
51  		return matcher;
52  	}
53  
54  	public Collection getStartingNodeInstances() {
55  		return startingNodeInstances;
56  	}
57  	
58  	public int getSearchDirection() {
59  		return searchDirection;
60  	}
61  	
62  }