Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.bcel.generic
Class Select  view Select download Select.java

java.lang.Object
  extended byorg.apache.bcel.generic.Instruction
      extended byorg.apache.bcel.generic.BranchInstruction
          extended byorg.apache.bcel.generic.Select
All Implemented Interfaces:
java.lang.Cloneable, InstructionTargeter, java.io.Serializable, StackProducer, VariableLengthInstruction
Direct Known Subclasses:
LOOKUPSWITCH, TABLESWITCH

public abstract class Select
extends BranchInstruction
implements VariableLengthInstruction, StackProducer

Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.

We use our super's target property as the default target.

Version:
$Id: Select.java 386056 2006-03-15 11:31:56Z tcurdt $

Field Summary
protected  int fixed_length
           
protected  int[] indices
           
protected  int[] match
           
protected  int match_length
           
protected  int padding
           
protected  InstructionHandle[] targets
           
 
Fields inherited from class org.apache.bcel.generic.BranchInstruction
index, position, target
 
Fields inherited from class org.apache.bcel.generic.Instruction
length, opcode
 
Constructor Summary
(package private) Select()
          Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction().
(package private) Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget)
          (Match, target) pairs for switch.
 
Method Summary
protected  java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 boolean containsTarget(InstructionHandle ih)
           
(package private)  void dispose()
          Inform targets that they're not targeted anymore.
 void dump(java.io.DataOutputStream out)
          Dump instruction as byte code to stream out.
 int[] getIndices()
           
 int[] getMatchs()
           
 InstructionHandle[] getTargets()
           
protected  void initFromFile(org.apache.bcel.util.ByteSequence bytes, boolean wide)
          Read needed data (e.g.
 void setTarget(int i, InstructionHandle target)
          Set branch target for `i'th case
 java.lang.String toString(boolean verbose)
          Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>
protected  int updatePosition(int offset, int max_offset)
          Since this is a variable length instruction, it may shift the following instructions which then need to update their position.
 void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
           
 
Methods inherited from class org.apache.bcel.generic.BranchInstruction
getIndex, getTarget, getTargetOffset, getTargetOffset, notifyTarget, setTarget
 
Methods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, equals, getComparator, getLength, getName, getOpcode, produceStack, readInstruction, setComparator, toString, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.bcel.generic.StackProducer
produceStack
 

Field Detail

match

protected int[] match

indices

protected int[] indices

targets

protected InstructionHandle[] targets

fixed_length

protected int fixed_length

match_length

protected int match_length

padding

protected int padding
Constructor Detail

Select

Select()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise.


Select

Select(short opcode,
       int[] match,
       InstructionHandle[] targets,
       InstructionHandle defaultTarget)
(Match, target) pairs for switch. `Match' and `targets' must have the same length of course.

Method Detail

updatePosition

protected int updatePosition(int offset,
                             int max_offset)
Since this is a variable length instruction, it may shift the following instructions which then need to update their position. Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable length instructions `setPositions' performs multiple passes over the instruction list to calculate the correct (byte) positions and offsets by calling this function.

Overrides:
updatePosition in class BranchInstruction

dump

public void dump(java.io.DataOutputStream out)
          throws java.io.IOException
Dump instruction as byte code to stream out.

Overrides:
dump in class BranchInstruction

initFromFile

protected void initFromFile(org.apache.bcel.util.ByteSequence bytes,
                            boolean wide)
                     throws java.io.IOException
Read needed data (e.g. index) from file.

Overrides:
initFromFile in class BranchInstruction

toString

public java.lang.String toString(boolean verbose)
Description copied from class: BranchInstruction
Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>

Overrides:
toString in class BranchInstruction

setTarget

public void setTarget(int i,
                      InstructionHandle target)
Set branch target for `i'th case


updateTarget

public void updateTarget(InstructionHandle old_ih,
                         InstructionHandle new_ih)
Specified by:
updateTarget in interface InstructionTargeter
Overrides:
updateTarget in class BranchInstruction

containsTarget

public boolean containsTarget(InstructionHandle ih)
Specified by:
containsTarget in interface InstructionTargeter
Overrides:
containsTarget in class BranchInstruction

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 


dispose

void dispose()
Inform targets that they're not targeted anymore.

Overrides:
dispose in class BranchInstruction

getMatchs

public int[] getMatchs()

getIndices

public int[] getIndices()

getTargets

public InstructionHandle[] getTargets()