soot
Class PatchingChain

java.lang.Object
  extended byjava.util.AbstractCollection
      extended bysoot.PatchingChain
All Implemented Interfaces:
Chain, Collection, Serializable
Direct Known Subclasses:
SPatchingChain

public class PatchingChain
extends AbstractCollection
implements Chain

An implementation of a Chain which can contain only Units, and handles patching to deal with element insertions and removals. This is done by calling Unit.redirectJumpsToThisTo at strategic times.

See Also:
Serialized Form

Nested Class Summary
protected  class PatchingChain.PatchingIterator
           
 
Field Summary
protected  Chain innerChain
           
 
Constructor Summary
PatchingChain(Chain aChain)
          Constructs a PatchingChain from the given Chain.
 
Method Summary
 boolean add(Object o)
          Adds the given object to this Chain.
 void addFirst(Object u)
          Adds the given object at the beginning of the Chain.
 void addLast(Object u)
          Adds the given object at the end of the Chain.
 boolean contains(Object u)
          Returns true if this patching chain contains the specified element.
 boolean follows(Object a, Object b)
          Returns true if object a follows object b in the Chain.
 Object getFirst()
          Returns the first object in this Chain.
 Object getLast()
          Returns the last object in this Chain.
 Chain getNonPatchingChain()
          Returns the inner chain used by the PatchingChain.
 Object getPredOf(Object point)
          Returns the object immediately preceding point.
 Object getSuccOf(Object point)
          Returns the object immediately following point.
 void insertAfter(Chain toInsert, Object point)
          Inserts toInsert in the Chain after point.
 void insertAfter(List toInsert, Object point)
          Inserts toInsert in the Chain after point.
 void insertAfter(Object toInsert, Object point)
          Inserts toInsert in the Chain after point.
 void insertBefore(Chain toInsert, Object point)
          Inserts toInsert in the Chain before point.
 void insertBefore(List toInsert, Object point)
          Inserts toInsert in the Chain before point.
 void insertBefore(Object toInsert, Object point)
          Inserts toInsert in the Chain before point.
 Iterator iterator()
          Returns an iterator over this Chain.
 Iterator iterator(Object u)
          Returns an iterator over this Chain, starting at the given object.
 Iterator iterator(Object head, Object tail)
          Returns an iterator over this Chain, starting at head and reaching tail (inclusive).
 boolean remove(Object obj)
          Removes the given object from this Chain.
 void removeFirst()
          Removes the first object from this Chain.
 void removeLast()
          Removes the last object from this Chain.
 int size()
          Returns the size of this Chain.
 Iterator snapshotIterator()
          Returns an iterator over a copy of this chain.
 void swapWith(Object out, Object in)
          Replaces out in the Chain by in.
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Field Detail

innerChain

protected Chain innerChain
Constructor Detail

PatchingChain

public PatchingChain(Chain aChain)
Constructs a PatchingChain from the given Chain.

Method Detail

getNonPatchingChain

public Chain getNonPatchingChain()
Returns the inner chain used by the PatchingChain. In general, this should not be used. However, direct access to the inner chain may be necessary if you wish to perform certain operations (such as control-flow manipulations) without interference from the patching algorithms.


add

public boolean add(Object o)
Adds the given object to this Chain.

Specified by:
add in interface Collection

swapWith

public void swapWith(Object out,
                     Object in)
Replaces out in the Chain by in.

Specified by:
swapWith in interface Chain

insertAfter

public void insertAfter(Object toInsert,
                        Object point)
Inserts toInsert in the Chain after point.

Specified by:
insertAfter in interface Chain

insertAfter

public void insertAfter(List toInsert,
                        Object point)
Inserts toInsert in the Chain after point.

Specified by:
insertAfter in interface Chain

insertAfter

public void insertAfter(Chain toInsert,
                        Object point)
Description copied from interface: Chain
Inserts toInsert in the Chain after point. (It would probably be better to make Chain implement List)

Specified by:
insertAfter in interface Chain

insertBefore

public void insertBefore(List toInsert,
                         Object point)
Inserts toInsert in the Chain before point.

Specified by:
insertBefore in interface Chain

insertBefore

public void insertBefore(Chain toInsert,
                         Object point)
Inserts toInsert in the Chain before point.

Specified by:
insertBefore in interface Chain

insertBefore

public void insertBefore(Object toInsert,
                         Object point)
Inserts toInsert in the Chain before point.

Specified by:
insertBefore in interface Chain

follows

public boolean follows(Object a,
                       Object b)
Returns true if object a follows object b in the Chain.

Specified by:
follows in interface Chain

remove

public boolean remove(Object obj)
Removes the given object from this Chain.

Specified by:
remove in interface Chain

contains

public boolean contains(Object u)
Returns true if this patching chain contains the specified element.

Specified by:
contains in interface Collection

addFirst

public void addFirst(Object u)
Adds the given object at the beginning of the Chain.

Specified by:
addFirst in interface Chain

addLast

public void addLast(Object u)
Adds the given object at the end of the Chain.

Specified by:
addLast in interface Chain

removeFirst

public void removeFirst()
Removes the first object from this Chain.

Specified by:
removeFirst in interface Chain

removeLast

public void removeLast()
Removes the last object from this Chain.

Specified by:
removeLast in interface Chain

getFirst

public Object getFirst()
Returns the first object in this Chain.

Specified by:
getFirst in interface Chain

getLast

public Object getLast()
Returns the last object in this Chain.

Specified by:
getLast in interface Chain

getSuccOf

public Object getSuccOf(Object point)
Returns the object immediately following point.

Specified by:
getSuccOf in interface Chain

getPredOf

public Object getPredOf(Object point)
Returns the object immediately preceding point.

Specified by:
getPredOf in interface Chain

snapshotIterator

public Iterator snapshotIterator()
Returns an iterator over a copy of this chain. This avoids ConcurrentModificationExceptions from being thrown if the underlying Chain is modified during iteration. Do not use this to remove elements which have not yet been iterated over!

Specified by:
snapshotIterator in interface Chain

iterator

public Iterator iterator()
Returns an iterator over this Chain.

Specified by:
iterator in interface Chain

iterator

public Iterator iterator(Object u)
Returns an iterator over this Chain, starting at the given object.

Specified by:
iterator in interface Chain

iterator

public Iterator iterator(Object head,
                         Object tail)
Returns an iterator over this Chain, starting at head and reaching tail (inclusive).

Specified by:
iterator in interface Chain

size

public int size()
Returns the size of this Chain.

Specified by:
size in interface Chain