001 /* 002 * Copyright 1999-2001,2004 The Apache Software Foundation. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.apache.commons.workflow; 018 019 020 /** 021 * <p><strong>BlockState</strong> represents the current dynamic execution 022 * state of a <code>Block</code> that is executing nested <code>Steps</code>. 023 * This class will serve for most <code>Block</code> implementations, but 024 * may be subclassed for <code>Blocks</code> with a requirement to maintain 025 * additional state information (such as a "for" loop that needs to keep 026 * track of the starting and ending indexes, and the iteration counter).</p> 027 * 028 * @author Craig R. McClanahan 029 * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $ 030 */ 031 032 public class BlockState { 033 034 035 // ----------------------------------------------------------- Constructors 036 037 038 /** 039 * Construct a new <code>BlockState</code> instance, associated with the 040 * specified <code>block</code>, and with the specified initial value 041 * for the <code>nest</code> property. 042 * 043 * @param block The <code>block</code> whose state this object represents 044 * @param nest The initial state of the <code>nest</code> property 045 */ 046 public BlockState(Block block, boolean nest) { 047 048 super(); 049 this.block = block; 050 this.nest = nest; 051 052 } 053 054 055 // ------------------------------------------------------------- Properties 056 057 058 /** 059 * The <code>Block</code> whose state is represented by this object. 060 */ 061 protected Block block = null; 062 063 public Block getBlock() { 064 return (this.block); 065 } 066 067 068 /** 069 * Should we execute the nested <code>Steps</code> of this 070 * <code>Block</code> again when the current execution finishes? 071 */ 072 protected boolean nest = false; 073 074 public boolean getNest() { 075 return (this.nest); 076 } 077 078 public void setNest(boolean nest) { 079 this.nest = nest; 080 } 081 082 083 // --------------------------------------------------------- Public Methods 084 085 086 /** 087 * Render a String version of this object. 088 */ 089 public String toString() { 090 091 StringBuffer sb = new StringBuffer("BlockState[block="); 092 sb.append(block); 093 sb.append(", nest="); 094 sb.append(nest); 095 sb.append("]"); 096 return (sb.toString()); 097 098 } 099 100 }