001 // Copyright 2011 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry5.plastic; 016 017 /** 018 * Support for building the equivalent of a Java switch statement. 019 */ 020 public interface SwitchBlock 021 { 022 /** 023 * Adds a handler for a particular case value. This method should only be invoked at most once for each case 024 * value. 025 * 026 * @param caseValue 027 * value to match 028 * @param jumpToEnd 029 * true if a jump to the end should be provided, or false 030 * if either the callback generated a return opcode, or 031 * it is desired to "drop down" into the next case handler. 032 * The last case handled drop down out of the SwitchBlock. 033 * @param callback 034 * provides the logic for the specified case 035 */ 036 void addCase(int caseValue, boolean jumpToEnd, InstructionBuilderCallback callback); 037 038 /** 039 * Adds the default handler. This is optional, and is only allowed after all cases have been added. 040 * The default handler automatically throws an {@link IllegalArgumentException}. 041 * 042 * @param callback 043 * provides the logic for the default handler case. 044 */ 045 void addDefault(InstructionBuilderCallback callback); 046 047 }