//# 1 errors, 253 messages
//#
/*
    //#ArrayListTransferHandler.java:1:1: class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
    //#ArrayListTransferHandler.java:1:1: method: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.addons.ui_swing.components.reorderablelist;

import com.dmdirc.logger.ErrorLevel;
import com.dmdirc.logger.Logger;

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.TransferHandler;

/**
 * Arraylist Transfer handler.
 */
public final class ArrayListTransferHandler extends TransferHandler {

    /**
     * A version number for this class. It should be changed whenever the class
     * structure is changed (or anything else that would prevent serialized
     * objects being unserialized with the new class).
     */
    private static final long serialVersionUID = 1;
    /** Local Transfer flavour. */
    private DataFlavor localArrayListFlavor;
    /** Serial Transfer flavour. */
    private final DataFlavor serialArrayListFlavor;
    /** Source component. */
    private JList sourceList;
    /** Dragged Indices. */
    private int[] indices;
    /** Index to add item(s). */
    private int addIndex = -1;
    /** Number of items to add. */
    private int addCount;

    /** Instantiates a new ArrayListTransferHandler. */
    public ArrayListTransferHandler() {
        super();
    //#ArrayListTransferHandler.java:66: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): "unable to create data flavor: "._tainted
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): com.dmdirc.logger.ErrorLevel.LOW
    //#input(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): this
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): new DataFlavor(ArrayListTransferHandler#1) num objects
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): new DataFlavor(ArrayListTransferHandler#3) num objects
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): this.addIndex
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): this.localArrayListFlavor
    //#output(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): this.serialArrayListFlavor
    //#new obj(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): new DataFlavor(ArrayListTransferHandler#1)
    //#new obj(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): new DataFlavor(ArrayListTransferHandler#3)
    //#presumption(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): init'ed(com.dmdirc.logger.ErrorLevel.LOW)
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): this.addIndex == -1
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): init'ed(this.localArrayListFlavor)
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): this.serialArrayListFlavor == &new DataFlavor(ArrayListTransferHandler#3)
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): new DataFlavor(ArrayListTransferHandler#1) num objects <= 1
    //#post(void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()): new DataFlavor(ArrayListTransferHandler#3) num objects == 1

        try {
            localArrayListFlavor = new DataFlavor(
                    DataFlavor.javaJVMLocalObjectMimeType + ";class=java.util.ArrayList");
        } catch (ClassNotFoundException e) {
            Logger.userError(ErrorLevel.LOW, "unable to create data flavor: " + e.getMessage());
    //#ArrayListTransferHandler.java:72: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
    //#    method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
        }
        serialArrayListFlavor = new DataFlavor(ArrayList.class, "ArrayList"); //NOPMD
    }
    //#ArrayListTransferHandler.java:75: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler()

    /** {@inheritDoc} */
    @Override
    public boolean importData(final JComponent comp, final Transferable t) {
        if (!canImport(comp, t.getTransferDataFlavors())) {
    //#ArrayListTransferHandler.java:80: method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.importData(JComponent, Transferable)
    //#input(bool importData(JComponent, Transferable)): "Unable to import data: "._tainted
    //#input(bool importData(JComponent, Transferable)): "Unsupported data flavor: "._tainted
    //#input(bool importData(JComponent, Transferable)): com.dmdirc.logger.ErrorLevel.LOW
    //#input(bool importData(JComponent, Transferable)): comp
    //#input(bool importData(JComponent, Transferable)): t
    //#input(bool importData(JComponent, Transferable)): this
    //#input(bool importData(JComponent, Transferable)): this.indices
    //#input(bool importData(JComponent, Transferable)): this.indices.length
    //#input(bool importData(JComponent, Transferable)): this.indices[0]
    //#input(bool importData(JComponent, Transferable)): this.indices[1..4_294_967_295]
    //#input(bool importData(JComponent, Transferable)): this.localArrayListFlavor
    //#input(bool importData(JComponent, Transferable)): this.serialArrayListFlavor
    //#input(bool importData(JComponent, Transferable)): this.sourceList
    //#output(bool importData(JComponent, Transferable)): return_value
    //#output(bool importData(JComponent, Transferable)): this.addCount
    //#output(bool importData(JComponent, Transferable)): this.addIndex
    //#output(bool importData(JComponent, Transferable)): this.indices
    //#pre[5] (bool importData(JComponent, Transferable)): t != null
    //#pre[1] (bool importData(JComponent, Transferable)): (soft) comp != null
    //#pre[4] (bool importData(JComponent, Transferable)): (soft) init'ed(this.indices)
    //#pre[7] (bool importData(JComponent, Transferable)): (soft) this.indices.length in {1..4_294_967_296}
    //#pre[8] (bool importData(JComponent, Transferable)): (soft) init'ed(this.indices[0])
    //#pre[9] (bool importData(JComponent, Transferable)): (soft) init'ed(this.indices[1..4_294_967_295])
    //#pre[10] (bool importData(JComponent, Transferable)): (soft) init'ed(this.localArrayListFlavor)
    //#pre[12] (bool importData(JComponent, Transferable)): (soft) this.sourceList != null
    //#presumption(bool importData(JComponent, Transferable)): init'ed(com.dmdirc.logger.ErrorLevel.LOW)
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferData(...)@86 != null
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferData(...)@88 != null
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...).length@80 <= 4_294_967_295
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...).length@85 <= 4_294_967_295
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...).length@87 <= 4_294_967_295
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...)@80 != null
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...)@85 != null
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...)@87 != null
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...)[0..4_294_967_295]@80 != null
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...)[0..4_294_967_295]@85 != null
    //#presumption(bool importData(JComponent, Transferable)): java.awt.datatransfer.Transferable:getTransferDataFlavors(...)[0..4_294_967_295]@87 != null
    //#post(bool importData(JComponent, Transferable)): init'ed(return_value)
    //#post(bool importData(JComponent, Transferable)): possibly_updated(this.addCount)
    //#post(bool importData(JComponent, Transferable)): possibly_updated(this.addIndex)
    //#post(bool importData(JComponent, Transferable)): this.indices == One-of{old this.indices, null}
    //#post(bool importData(JComponent, Transferable)): init'ed(this.indices)
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:java.awt.datatransfer.DataFlavor:equals
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:javax.swing.JList:instanceof
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:javax.swing.JList:getModel
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:javax.swing.DefaultListModel:instanceof
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:javax.swing.JList:getSelectedIndex
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:java.lang.Object:equals
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:javax.swing.DefaultListModel:getSize
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:java.util.List:size
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:java.util.List:get
    //#unanalyzed(bool importData(JComponent, Transferable)): Effects-of-calling:javax.swing.DefaultListModel:add
            return false;
        }

        try {
            if (hasLocalArrayListFlavor(t.getTransferDataFlavors())) {
                return doImport((JList) comp, (ArrayList) t.getTransferData(localArrayListFlavor));
            } else if (hasSerialArrayListFlavor(t.getTransferDataFlavors())) {
                return doImport((JList) comp, (ArrayList) t.getTransferData(serialArrayListFlavor));
            } else {
                return false;
            }
        } catch (UnsupportedFlavorException e) {
            Logger.userError(ErrorLevel.LOW, "Unsupported data flavor: " + e.getMessage());
    //#ArrayListTransferHandler.java:93: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
    //#    method: bool importData(JComponent, Transferable)
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
            return false;
        } catch (IOException e) {
            Logger.userError(ErrorLevel.LOW, "Unable to import data: " + e.getMessage());
    //#ArrayListTransferHandler.java:96: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
    //#    method: bool importData(JComponent, Transferable)
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
            return false;
    //#ArrayListTransferHandler.java:97: end of method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.importData(JComponent, Transferable)
        }
    }

    /**
     * Imports the tranferrable data into the list.
     * 
     * @param target target list
     * @param transferList transferable list
     * 
     * @return Whether the data was imported
     */
    private boolean doImport(final JList target, final List transferList) {
        int index = target.getSelectedIndex();
    //#ArrayListTransferHandler.java:110: method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.doImport(JList, List)
    //#input(bool doImport(JList, List)): target
    //#input(bool doImport(JList, List)): this
    //#input(bool doImport(JList, List)): this.indices
    //#input(bool doImport(JList, List)): this.indices.length
    //#input(bool doImport(JList, List)): this.indices[0]
    //#input(bool doImport(JList, List)): this.indices[1..4_294_967_295]
    //#input(bool doImport(JList, List)): this.sourceList
    //#input(bool doImport(JList, List)): transferList
    //#output(bool doImport(JList, List)): return_value
    //#output(bool doImport(JList, List)): this.addCount
    //#output(bool doImport(JList, List)): this.addIndex
    //#output(bool doImport(JList, List)): this.indices
    //#pre[4] (bool doImport(JList, List)): target != null
    //#pre[9] (bool doImport(JList, List)): this.sourceList != null
    //#pre[3] (bool doImport(JList, List)): (soft) init'ed(this.indices)
    //#pre[6] (bool doImport(JList, List)): (soft) this.indices.length in {1..4_294_967_296}
    //#pre[7] (bool doImport(JList, List)): (soft) init'ed(this.indices[0])
    //#pre[8] (bool doImport(JList, List)): (soft) init'ed(this.indices[1..4_294_967_295])
    //#pre[10] (bool doImport(JList, List)): (soft) transferList != null
    //#presumption(bool doImport(JList, List)): java.util.List:size(...)@131 + index in {-4_294_967_296..4_294_967_295}
    //#presumption(bool doImport(JList, List)): javax.swing.DefaultListModel:getSize(...)@117 <= 4_294_967_294
    //#presumption(bool doImport(JList, List)): javax.swing.JList:getModel(...)@116 != null
    //#presumption(bool doImport(JList, List)): javax.swing.JList:getSelectedIndex(...)@110 <= 4_294_967_293
    //#post(bool doImport(JList, List)): return_value == 1
    //#post(bool doImport(JList, List)): possibly_updated(this.addCount)
    //#post(bool doImport(JList, List)): possibly_updated(this.addIndex)
    //#post(bool doImport(JList, List)): this.indices == One-of{null, old this.indices}
    //#post(bool doImport(JList, List)): init'ed(this.indices)
    //#test_vector(bool doImport(JList, List)): this.indices: Addr_Set{null}, Inverse{null}
    //#test_vector(bool doImport(JList, List)): java.lang.Object:equals(...)@111: {0}, {1}
    //#test_vector(bool doImport(JList, List)): javax.swing.JList:getSelectedIndex(...)@110: {0..4_294_967_293}, {-2_147_483_648..-1}
        if (sourceList.equals(target) && indices != null && index >= indices[0] - 1 && index <= indices[indices.length - 1]) {
            indices = null;
            return true;
        }

        final DefaultListModel listModel = (DefaultListModel) target.getModel();
        final int max = listModel.getSize();

        if (index < 0) {
            index = max;
        } else {
            index++;
            if (index > max) {
                index = max;
            }

        }
        addIndex = index;
        addCount = transferList.size();

        for (int i = 0; i < transferList.size(); i++) {
            listModel.add(index++, transferList.get(i));
        }

        return true;
    //#ArrayListTransferHandler.java:135: end of method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.doImport(JList, List)
    }

    /** {@inheritDoc} */
    @Override
    protected void exportDone(final JComponent source, final Transferable data,
            final int action) {
        if ((action == MOVE) && (indices != null)) {
    //#ArrayListTransferHandler.java:142: method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.exportDone(JComponent, Transferable, int)
    //#input(void exportDone(JComponent, Transferable, int)): action
    //#input(void exportDone(JComponent, Transferable, int)): this
    //#input(void exportDone(JComponent, Transferable, int)): this.addCount
    //#input(void exportDone(JComponent, Transferable, int)): this.addIndex
    //#input(void exportDone(JComponent, Transferable, int)): this.indices
    //#input(void exportDone(JComponent, Transferable, int)): this.indices.length
    //#input(void exportDone(JComponent, Transferable, int)): this.indices[0..4_294_967_295]
    //#input(void exportDone(JComponent, Transferable, int)): this.sourceList
    //#output(void exportDone(JComponent, Transferable, int)): this.addCount
    //#output(void exportDone(JComponent, Transferable, int)): this.addIndex
    //#output(void exportDone(JComponent, Transferable, int)): this.indices
    //#output(void exportDone(JComponent, Transferable, int)): this.indices[0..4_294_967_295]
    //#pre[5] (void exportDone(JComponent, Transferable, int)): (soft) init'ed(this.addCount)
    //#pre[6] (void exportDone(JComponent, Transferable, int)): (soft) this.addIndex != 4_294_967_294
    //#pre[7] (void exportDone(JComponent, Transferable, int)): (soft) init'ed(this.indices)
    //#pre[9] (void exportDone(JComponent, Transferable, int)): (soft) this.indices[0..4_294_967_295] in {-2_147_483_647..4_294_967_294}
    //#pre[11] (void exportDone(JComponent, Transferable, int)): (soft) this.indices.length <= 4_294_967_295
    //#pre[12] (void exportDone(JComponent, Transferable, int)): (soft) this.sourceList != null
    //#presumption(void exportDone(JComponent, Transferable, int)): javax.swing.JList:getModel(...)@143 != null
    //#post(void exportDone(JComponent, Transferable, int)): this.addCount == 0
    //#post(void exportDone(JComponent, Transferable, int)): this.addIndex == -1
    //#post(void exportDone(JComponent, Transferable, int)): this.indices == null
    //#post(void exportDone(JComponent, Transferable, int)): init'ed(this.indices[0..4_294_967_295])
    //#test_vector(void exportDone(JComponent, Transferable, int)): action: {-2_147_483_648..1, 3..4_294_967_295}, {2}
    //#test_vector(void exportDone(JComponent, Transferable, int)): this.addCount: {-2_147_483_648..0}, {1..4_294_967_295}
    //#test_vector(void exportDone(JComponent, Transferable, int)): this.indices: Addr_Set{null}, Inverse{null}
            final DefaultListModel model = (DefaultListModel) sourceList.getModel();

            if (addCount > 0) {
                for (int i = 0; i < indices.length; i++) {
                    if (indices[i] > addIndex) {
                        indices[i] += addCount;
    //#ArrayListTransferHandler.java:148: ?overflow
    //#    this.indices[i] + this.addCount in {-2_147_483_648..4_294_967_295}
    //#    severity: SUPPRESSED
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
    //#    method: void exportDone(JComponent, Transferable, int)
    //#    basic block: bb_7
    //#    assertion: this.indices[i] + this.addCount in {-2_147_483_648..4_294_967_295}
    //#    VN: this.addCount + this.indices[i]
    //#    Expected: {-2_147_483_648..4_294_967_295, Invalid}
    //#    Bad: {4_294_967_296..8_589_934_589}
    //#    Attribs:  Int  Bad > Exp
                    }
                }
            }
            for (int i = indices.length - 1; i >= 0; i--) {
                model.remove(indices[i]);
            }
        }

        indices = null;
        addIndex = -1;
        addCount = 0;
    }
    //#ArrayListTransferHandler.java:160: end of method: void com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.exportDone(JComponent, Transferable, int)

    /** 
     * Do any of the specified flavours match the local flavour.
     * 
     * @param transferFlavors Flavours to check
     *
     * @return whether the transferFlavors is supported
     */
    private boolean hasLocalArrayListFlavor(final DataFlavor[] transferFlavors) {
        if (localArrayListFlavor == null) {
    //#ArrayListTransferHandler.java:170: method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.hasLocalArrayListFlavor(DataFlavor[])
    //#input(bool hasLocalArrayListFlavor(DataFlavor[])): this
    //#input(bool hasLocalArrayListFlavor(DataFlavor[])): this.localArrayListFlavor
    //#input(bool hasLocalArrayListFlavor(DataFlavor[])): transferFlavors
    //#input(bool hasLocalArrayListFlavor(DataFlavor[])): transferFlavors.length
    //#input(bool hasLocalArrayListFlavor(DataFlavor[])): transferFlavors[0..4_294_967_295]
    //#output(bool hasLocalArrayListFlavor(DataFlavor[])): return_value
    //#pre[2] (bool hasLocalArrayListFlavor(DataFlavor[])): init'ed(this.localArrayListFlavor)
    //#pre[3] (bool hasLocalArrayListFlavor(DataFlavor[])): (soft) transferFlavors != null
    //#pre[4] (bool hasLocalArrayListFlavor(DataFlavor[])): (soft) transferFlavors.length <= 4_294_967_295
    //#pre[5] (bool hasLocalArrayListFlavor(DataFlavor[])): (soft) transferFlavors[0..4_294_967_295] != null
    //#post(bool hasLocalArrayListFlavor(DataFlavor[])): init'ed(return_value)
    //#test_vector(bool hasLocalArrayListFlavor(DataFlavor[])): this.localArrayListFlavor: Inverse{null}, Addr_Set{null}
    //#test_vector(bool hasLocalArrayListFlavor(DataFlavor[])): java.awt.datatransfer.DataFlavor:equals(...)@175: {0}, {1}
            return false;
        }

        for (int i = 0; i < transferFlavors.length; i++) {
            if (transferFlavors[i].equals(localArrayListFlavor)) {
                return true;
            }
        }

        return false;
    //#ArrayListTransferHandler.java:180: end of method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.hasLocalArrayListFlavor(DataFlavor[])
    }

    /** 
     * Do any of the specified flavours match the serial flavour.
     * 
     * @param transferFlavors Flavours to check
     *
     * @return whether the flavour is supported
     */
    private boolean hasSerialArrayListFlavor(final DataFlavor[] transferFlavors) {
        if (serialArrayListFlavor == null) {
    //#ArrayListTransferHandler.java:191: method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.hasSerialArrayListFlavor(DataFlavor[])
    //#input(bool hasSerialArrayListFlavor(DataFlavor[])): this
    //#input(bool hasSerialArrayListFlavor(DataFlavor[])): this.serialArrayListFlavor
    //#input(bool hasSerialArrayListFlavor(DataFlavor[])): transferFlavors
    //#input(bool hasSerialArrayListFlavor(DataFlavor[])): transferFlavors.length
    //#input(bool hasSerialArrayListFlavor(DataFlavor[])): transferFlavors[0..4_294_967_295]
    //#output(bool hasSerialArrayListFlavor(DataFlavor[])): return_value
    //#pre[3] (bool hasSerialArrayListFlavor(DataFlavor[])): (soft) transferFlavors != null
    //#pre[4] (bool hasSerialArrayListFlavor(DataFlavor[])): (soft) transferFlavors.length <= 4_294_967_295
    //#pre[5] (bool hasSerialArrayListFlavor(DataFlavor[])): (soft) transferFlavors[0..4_294_967_295] != null
    //#post(bool hasSerialArrayListFlavor(DataFlavor[])): init'ed(return_value)
    //#test_vector(bool hasSerialArrayListFlavor(DataFlavor[])): this.serialArrayListFlavor: Inverse{null}, Addr_Set{null}
    //#test_vector(bool hasSerialArrayListFlavor(DataFlavor[])): java.awt.datatransfer.DataFlavor:equals(...)@196: {0}, {1}
            return false;
        }

        for (int i = 0; i < transferFlavors.length; i++) {
            if (transferFlavors[i].equals(serialArrayListFlavor)) {
                return true;
            }
        }

        return false;
    //#ArrayListTransferHandler.java:201: end of method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.hasSerialArrayListFlavor(DataFlavor[])
    }

    /** {@inheritDoc} */
    @Override
    public boolean canImport(final JComponent comp, final DataFlavor[] transferFlavors) {
        if (!(comp instanceof JList) || !(((JList) comp).getModel() instanceof DefaultListModel)) {
    //#ArrayListTransferHandler.java:207: method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.canImport(JComponent, DataFlavor[])
    //#input(bool canImport(JComponent, DataFlavor[])): comp
    //#input(bool canImport(JComponent, DataFlavor[])): this
    //#input(bool canImport(JComponent, DataFlavor[])): this.localArrayListFlavor
    //#input(bool canImport(JComponent, DataFlavor[])): this.serialArrayListFlavor
    //#input(bool canImport(JComponent, DataFlavor[])): transferFlavors
    //#input(bool canImport(JComponent, DataFlavor[])): transferFlavors.length
    //#input(bool canImport(JComponent, DataFlavor[])): transferFlavors[0..4_294_967_295]
    //#output(bool canImport(JComponent, DataFlavor[])): return_value
    //#pre[3] (bool canImport(JComponent, DataFlavor[])): (soft) init'ed(this.localArrayListFlavor)
    //#pre[5] (bool canImport(JComponent, DataFlavor[])): (soft) transferFlavors != null
    //#pre[6] (bool canImport(JComponent, DataFlavor[])): (soft) transferFlavors.length <= 4_294_967_295
    //#pre[7] (bool canImport(JComponent, DataFlavor[])): (soft) transferFlavors[0..4_294_967_295] != null
    //#post(bool canImport(JComponent, DataFlavor[])): init'ed(return_value)
    //#unanalyzed(bool canImport(JComponent, DataFlavor[])): Effects-of-calling:java.awt.datatransfer.DataFlavor:equals
            return false;
        }

        if (hasLocalArrayListFlavor(transferFlavors)) {
            return true;
        }

        if (hasSerialArrayListFlavor(transferFlavors)) {
            return true;
        }

        return false;
    //#ArrayListTransferHandler.java:219: end of method: bool com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.canImport(JComponent, DataFlavor[])
    }

    /** {@inheritDoc} */
    @Override
    protected Transferable createTransferable(final JComponent c) {
        if (c instanceof JList) {
    //#ArrayListTransferHandler.java:225: method: Transferable com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.createTransferable(JComponent)
    //#input(Transferable createTransferable(JComponent)): "unable to create data flavor: "._tainted
    //#input(Transferable createTransferable(JComponent)): c
    //#input(Transferable createTransferable(JComponent)): com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferable.com.dmdirc.logger.ErrorLevel.LOW
    //#input(Transferable createTransferable(JComponent)): this
    //#output(Transferable createTransferable(JComponent)): new ArrayList(createTransferable#1) num objects
    //#output(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2) num objects
    //#output(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).__Tag
    //#output(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).data
    //#output(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).localArrayListFlavor
    //#output(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).serialArrayListFlavor
    //#output(Transferable createTransferable(JComponent)): new DataFlavor(ArrayListTransferable#1) num objects
    //#output(Transferable createTransferable(JComponent)): new DataFlavor(ArrayListTransferable#3) num objects
    //#output(Transferable createTransferable(JComponent)): return_value
    //#output(Transferable createTransferable(JComponent)): this.indices
    //#output(Transferable createTransferable(JComponent)): this.sourceList
    //#new obj(Transferable createTransferable(JComponent)): new ArrayList(createTransferable#1)
    //#new obj(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2)
    //#new obj(Transferable createTransferable(JComponent)): new DataFlavor(ArrayListTransferable#1)
    //#new obj(Transferable createTransferable(JComponent)): new DataFlavor(ArrayListTransferable#3)
    //#presumption(Transferable createTransferable(JComponent)): values.length@228 <= 4_294_967_295
    //#presumption(Transferable createTransferable(JComponent)): values[i]@228 != null
    //#post(Transferable createTransferable(JComponent)): return_value in Addr_Set{null,&new ArrayListTransferable(createTransferable#2)}
    //#post(Transferable createTransferable(JComponent)): possibly_updated(this.indices)
    //#post(Transferable createTransferable(JComponent)): this.sourceList == One-of{c, old this.sourceList}
    //#post(Transferable createTransferable(JComponent)): new ArrayList(createTransferable#1) num objects <= 1
    //#post(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2) num objects <= 1
    //#post(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).__Tag == com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferable
    //#post(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).data == &new ArrayList(createTransferable#1)
    //#post(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).localArrayListFlavor in Addr_Set{null,&new DataFlavor(ArrayListTransferable#1)}
    //#post(Transferable createTransferable(JComponent)): new ArrayListTransferable(createTransferable#2).serialArrayListFlavor == &new DataFlavor(ArrayListTransferable#3)
    //#post(Transferable createTransferable(JComponent)): new DataFlavor(ArrayListTransferable#1) num objects <= 1
    //#post(Transferable createTransferable(JComponent)): new DataFlavor(ArrayListTransferable#3) num objects <= 1
    //#unanalyzed(Transferable createTransferable(JComponent)): Effects-of-calling:java.awt.datatransfer.DataFlavor
    //#unanalyzed(Transferable createTransferable(JComponent)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(Transferable createTransferable(JComponent)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(Transferable createTransferable(JComponent)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(Transferable createTransferable(JComponent)): Effects-of-calling:java.lang.ClassNotFoundException:getMessage
    //#unanalyzed(Transferable createTransferable(JComponent)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(Transferable createTransferable(JComponent)): Effects-of-calling:com.dmdirc.logger.Logger:userError
    //#test_vector(Transferable createTransferable(JComponent)): javax.swing.JList:getSelectedValues(...)@228: Addr_Set{null}, Inverse{null}
    //#test_vector(Transferable createTransferable(JComponent)): values.length@228: {1..4_294_967_295}, {0}
            sourceList = (JList) c;
            indices = sourceList.getSelectedIndices();
            final Object[] values = sourceList.getSelectedValues();

            if (values == null || values.length == 0) {
                return null;
            }

            final ArrayList<Object> alist = new ArrayList<Object>(values.length);

            for (int i = 0; i < values.length; i++) {
                final Object o = values[i];
                String str = o.toString();
                if (str == null) {
    //#ArrayListTransferHandler.java:239: Warning: test always goes same way
    //#    Test predetermined because str != null
    //#    severity: LOW
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
    //#    method: Transferable createTransferable(JComponent)
    //#    from bb: bb_7
    //#    live edge: bb_7-->bb_9
    //#    tested vn: 0
    //#    tested vn values: {0}
                    str = "";
    //#ArrayListTransferHandler.java:240: Warning: dead code
    //#    Dead code here because str != null
    //#    severity: LOW
    //#    class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
    //#    method: Transferable createTransferable(JComponent)
    //#    dead bb: bb_8
                }
                alist.add(str);
            }

            return new ArrayListTransferable(alist);
        }

        return null;
    //#ArrayListTransferHandler.java:248: end of method: Transferable com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.createTransferable(JComponent)
    }

    /** {@inheritDoc} */
    @Override
    public int getSourceActions(final JComponent c) {
        return COPY_OR_MOVE;
    //#ArrayListTransferHandler.java:254: method: int com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.getSourceActions(JComponent)
    //#output(int getSourceActions(JComponent)): return_value
    //#post(int getSourceActions(JComponent)): return_value == 3
    //#ArrayListTransferHandler.java:254: end of method: int com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.getSourceActions(JComponent)
    }
}
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferHandler]
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.canImport(Ljavax/swing/JComponent;[Ljava/awt/datatransfer/DataFlavor;)Z
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.createTransferable(Ljavax/swing/JComponent;)Ljava/awt/datatransfer/Transferable;
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.doImport(Ljavax/swing/JList;Ljava/util/List;)Z
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.exportDone(Ljavax/swing/JComponent;Ljava/awt/datatransfer/Transferable;I)V
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.getSourceActions(Ljavax/swing/JComponent;)I
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.hasLocalArrayListFlavor([Ljava/awt/datatransfer/DataFlavor;)Z
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.hasSerialArrayListFlavor([Ljava/awt/datatransfer/DataFlavor;)Z
    //#output(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.importData(Ljavax/swing/JComponent;Ljava/awt/datatransfer/Transferable;)Z
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Descendant_Table[com/dmdirc/addons/ui_swing/components/reorderablelist/ArrayListTransferHandler] == &__Dispatch_Table
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.canImport(Ljavax/swing/JComponent;[Ljava/awt/datatransfer/DataFlavor;)Z == &canImport
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.createTransferable(Ljavax/swing/JComponent;)Ljava/awt/datatransfer/Transferable; == &createTransferable
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.doImport(Ljavax/swing/JList;Ljava/util/List;)Z == &doImport
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.exportDone(Ljavax/swing/JComponent;Ljava/awt/datatransfer/Transferable;I)V == &exportDone
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.getSourceActions(Ljavax/swing/JComponent;)I == &getSourceActions
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.hasLocalArrayListFlavor([Ljava/awt/datatransfer/DataFlavor;)Z == &hasLocalArrayListFlavor
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.hasSerialArrayListFlavor([Ljava/awt/datatransfer/DataFlavor;)Z == &hasSerialArrayListFlavor
    //#post(com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init): __Dispatch_Table.importData(Ljavax/swing/JComponent;Ljava/awt/datatransfer/Transferable;)Z == &importData
    //#ArrayListTransferHandler.java:: end of method: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler.com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler__static_init
    //#ArrayListTransferHandler.java:: end of class: com.dmdirc.addons.ui_swing.components.reorderablelist.ArrayListTransferHandler
