soot
Class PatchingChain

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--soot.PatchingChain

public class PatchingChain
extends java.util.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.


Constructor Summary
PatchingChain(Chain aChain)
          Constructs a PatchingChain from the given Chain.
 
Method Summary
 boolean add(java.lang.Object o)
          Adds the given object to this Chain.
 void addFirst(java.lang.Object u)
          Adds the given object at the beginning of the Chain.
 void addLast(java.lang.Object u)
          Adds the given object at the end of the Chain.
 boolean contains(java.lang.Object u)
          Returns true if this patching chain contains the specified element.
 boolean follows(java.lang.Object a, java.lang.Object b)
          Returns true if object a follows object b in the Chain.
 java.lang.Object getFirst()
          Returns the first object in this Chain.
 java.lang.Object getLast()
          Returns the last object in this Chain.
 java.lang.Object getPredOf(java.lang.Object point)
          Returns the object immediately preceding point.
 java.lang.Object getSuccOf(java.lang.Object point)
          Returns the object immediately following point.
 void insertAfter(java.util.List toInsert, java.lang.Object point)
          Inserts toInsert in the Chain after point.
 void insertAfter(java.lang.Object toInsert, java.lang.Object point)
          Inserts toInsert in the Chain after point.
 void insertBefore(java.util.List toInsert, java.lang.Object point)
          Inserts toInsert in the Chain before point.
 void insertBefore(java.lang.Object toInsert, java.lang.Object point)
          Inserts toInsert in the Chain before point.
 java.util.Iterator iterator()
          Returns an iterator over this Chain.
 java.util.Iterator iterator(java.lang.Object u)
          Returns an iterator over this Chain, starting at the given object.
 java.util.Iterator iterator(java.lang.Object head, java.lang.Object tail)
          Returns an iterator over this Chain, starting at head and reaching tail (inclusive).
 boolean remove(java.lang.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.
 java.util.Iterator snapshotIterator()
          Returns an iterator over a copy of this chain.
 void swapWith(java.lang.Object out, java.lang.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
 

Constructor Detail

PatchingChain

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

add

public boolean add(java.lang.Object o)
Adds the given object to this Chain.
Overrides:
add in class java.util.AbstractCollection

swapWith

public void swapWith(java.lang.Object out,
                     java.lang.Object in)
Replaces out in the Chain by in.
Specified by:
swapWith in interface Chain

insertAfter

public void insertAfter(java.lang.Object toInsert,
                        java.lang.Object point)
Inserts toInsert in the Chain after point.
Specified by:
insertAfter in interface Chain

insertAfter

public void insertAfter(java.util.List toInsert,
                        java.lang.Object point)
Inserts toInsert in the Chain after point.
Specified by:
insertAfter in interface Chain

insertBefore

public void insertBefore(java.util.List toInsert,
                         java.lang.Object point)
Inserts toInsert in the Chain before point.
Specified by:
insertBefore in interface Chain

insertBefore

public void insertBefore(java.lang.Object toInsert,
                         java.lang.Object point)
Inserts toInsert in the Chain before point.
Specified by:
insertBefore in interface Chain

follows

public boolean follows(java.lang.Object a,
                       java.lang.Object b)
Returns true if object a follows object b in the Chain.
Specified by:
follows in interface Chain

remove

public boolean remove(java.lang.Object obj)
Removes the given object from this Chain.
Specified by:
remove in interface Chain
Overrides:
remove in class java.util.AbstractCollection

contains

public boolean contains(java.lang.Object u)
Returns true if this patching chain contains the specified element.
Overrides:
contains in class java.util.AbstractCollection

addFirst

public void addFirst(java.lang.Object u)
Adds the given object at the beginning of the Chain.
Specified by:
addFirst in interface Chain

addLast

public void addLast(java.lang.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 java.lang.Object getFirst()
Returns the first object in this Chain.
Specified by:
getFirst in interface Chain

getLast

public java.lang.Object getLast()
Returns the last object in this Chain.
Specified by:
getLast in interface Chain

getSuccOf

public java.lang.Object getSuccOf(java.lang.Object point)
Returns the object immediately following point.
Specified by:
getSuccOf in interface Chain

getPredOf

public java.lang.Object getPredOf(java.lang.Object point)
Returns the object immediately preceding point.
Specified by:
getPredOf in interface Chain

snapshotIterator

public java.util.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 java.util.Iterator iterator()
Returns an iterator over this Chain.
Specified by:
iterator in interface Chain
Overrides:
iterator in class java.util.AbstractCollection

iterator

public java.util.Iterator iterator(java.lang.Object u)
Returns an iterator over this Chain, starting at the given object.
Specified by:
iterator in interface Chain

iterator

public java.util.Iterator iterator(java.lang.Object head,
                                   java.lang.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
Overrides:
size in class java.util.AbstractCollection