Example usage for java.util ArrayList clone

List of usage examples for java.util ArrayList clone

Introduction

In this page you can find the example usage for java.util ArrayList clone.

Prototype

public Object clone() 

Source Link

Document

Returns a shallow copy of this ArrayList instance.

Usage

From source file:edu.rit.csh.androidwebnews.DisplayThreadsActivity.java

@Override
public void update(String jsonString) {
    if (jsonString.startsWith("Error:")) { // error in the Async Task
        connectionDialog.setMessage(jsonString);
        if (!connectionDialog.isShowing()) {
            connectionDialog.show();/*from ww  w.j  a  v  a2 s  .  co m*/
        }
    } else {
        try {
            JSONObject obj = new JSONObject(jsonString);
            if (obj.has("error")) {
                if (!dialog.isShowing()) {
                    dialog.show();
                }
            } else if (obj.has("posts_older")) {
                if (hc.getThreadsFromString(jsonString).size() == 0) {
                    //hitBottom = true;
                    ((DisplayThreadsFragment) getSupportFragmentManager()
                            .findFragmentById(R.id.threadsfragment)).addThreads(new ArrayList<PostThread>());
                } else if (!requestedAdditionalThreads) {
                    ArrayList<PostThread> threads = hc.getThreadsFromString(jsonString);
                    lastFetchedThreads.clear();
                    lastFetchedThreads = (ArrayList<PostThread>) threads.clone();
                    ((DisplayThreadsFragment) getSupportFragmentManager()
                            .findFragmentById(R.id.threadsfragment)).update(threads);
                } else {
                    ArrayList<PostThread> newThreads = hc.getThreadsFromString(jsonString);
                    for (PostThread thread : newThreads)
                        lastFetchedThreads.add(thread);
                    ((DisplayThreadsFragment) getSupportFragmentManager()
                            .findFragmentById(R.id.threadsfragment)).addThreads(newThreads);
                    requestedAdditionalThreads = false;
                }
            } else if (obj.has("unread_counts")) { // unread count
                int unread = hc.getUnreadCountFromString(jsonString)[0];
                int groupUnread = 0;
                for (Newsgroup group : hc
                        .getNewsGroupFromString(sharedPref.getString("newsgroups_json_string", ""))) {
                    groupUnread += group.unreadCount;
                }
                if (unread != groupUnread) {
                    hc.getNewsGroups();
                } else {
                    newsgroupListMenu.update(
                            hc.getNewsGroupFromString(sharedPref.getString("newsgroups_json_string", "")));
                }
            } else { // newsgroups
                SharedPreferences.Editor editor = sharedPref.edit();
                editor.putString("newsgroups_json_string", jsonString);
                editor.commit();
                newsgroupListMenu.update(hc.getNewsGroupFromString(jsonString));
            }
        } catch (JSONException ignored) {
        }
    }
}

From source file:de.tudresden.inf.rn.mobilis.groups.overlays.GroupsOverlay.java

public void updateAllOverlayItems(ArrayList<GroupItemInfo> items) {
    if (items != null) {
        this.groupItemInfos = items;
        mOverlays.clear();//w w w .  j  ava  2  s.  c  om
        ArrayList<OverlayItem> newItems = new ArrayList<OverlayItem>();

        for (GroupItemInfo gii : items) {
            OverlayItem oi = new OverlayItem(new GeoPoint(gii.latitudeE6, gii.longitudeE6), gii.name,
                    "groupID=" + gii.groupId);
            newItems.add(oi);
        }

        mOverlays = (ArrayList<OverlayItem>) newItems.clone();

        //Log.i(TAG,"updateAllOverlayItems(). new size:"+mOverlays.size());
        setLastFocusedIndex(-1);
        populate();
    }
}

From source file:com.ge.research.semtk.load.DataCleaner.java

/**
 * Take a row of data and perform splits, returning a set of rows.
 * @param row the input row of data/*ww w  .  j  a  v  a 2  s  .  c  o m*/
 * @return rows of data containing split fields
 */
private ArrayList<ArrayList<String>> performSplits(ArrayList<String> row) {

    ArrayList<ArrayList<String>> rows = new ArrayList<ArrayList<String>>();
    rows.add(row); // start with the input row

    String delimiter;
    String header;
    String value;
    for (int i = 0; i < row.size(); i++) { // for each value in the row         
        value = row.get(i);
        header = headers.get(i);
        delimiter = columnsToSplit.get(header);

        if (delimiter != null && value.contains(delimiter)) { // if this value needs to be split

            String[] splitValues = value.split(delimiter); // split the value
            ArrayList<ArrayList<String>> rowsNew = new ArrayList<ArrayList<String>>();

            // for each previous row, replace with new set of rows with split values
            for (ArrayList<String> rowOld : rows) {
                for (String splitValue : splitValues) {
                    ArrayList<String> rowNew = (ArrayList<String>) rowOld.clone();
                    rowNew.set(i, splitValue.trim()); // replace the unsplit value with the split value  (trim to remove unwanted spaces, e.g. after commas)
                    rowsNew.add(rowNew);
                }
            }
            rows = rowsNew; // overwrite old rows with new rows 
        }
    }
    return rows;
}

From source file:edu.umd.cfar.lamp.viper.examples.textline.TextlineModel.java

/**
 * Constructor with dimensions as array, text, and occlusion and offset lists
 * (used by TextlineInterpolator to create the interpolated object)
 * /*  w  ww. java 2s  .co m*/
 * @param oboxArray the array of 5 ints describing the OrientedBox
 * @param text the text contained by the box
 * @param occ the ArrayList object containing the occlusions
 * @param off the ArrayList object containing the word offsets
 */
public TextlineModel(int[] oboxArray, String textIn, ArrayList occ, ArrayList off) {
    this();
    obox = new OrientedBox(oboxArray);
    occlusions = (ArrayList) occ.clone();
    wordOffsets = (ArrayList) off.clone();
    setText(textIn, null);
}

From source file:edu.umd.cfar.lamp.viper.examples.textline.TextlineModel.java

/**
 * Constructor with dimensions, text, and occlusion and offset lists
 * (used by AttributeWrapperTextline for XML deserialization)
 * /*from  w  w w .  j a v  a2  s.co m*/
 * @param x the x-coordinate of the origin
 * @param y the y-coordinate of the origin
 * @param width the width of the box
 * @param height the height of the box
 * @param rotation the orientation of the box (in positive degrees)
 * @param text the text contained by the box
 * @param occ the ArrayList object containing the occlusions
 * @param off the ArrayList object containing the word offsets
 */
public TextlineModel(int x, int y, int width, int height, int rotation, String textIn, ArrayList occ,
        ArrayList off) {
    this();
    obox = new OrientedBox(x, y, width, height, rotation);
    occlusions = (ArrayList) occ.clone();
    wordOffsets = (ArrayList) off.clone();
    setText(textIn, null);
}

From source file:org.apache.axis2.engine.DispatchPhase.java

public void checkPostConditions(MessageContext msgContext) throws AxisFault {
    EndpointReference toEPR = msgContext.getTo();

    if (msgContext.getAxisService() == null) {
        AxisFault fault = new AxisFault(
                Messages.getMessage("servicenotfoundforepr", ((toEPR != null) ? toEPR.getAddress() : "")));
        fault.setFaultCode(org.apache.axis2.namespace.Constants.FAULT_CLIENT);
        throw fault;
    }/*from  ww  w .j av  a 2s . c o m*/

    AxisService service = msgContext.getAxisService();
    AxisOperation operation = msgContext.getAxisOperation();

    // If operation is an excluded operation, throw an exception.
    // This code is needed to enable exclude operations for static WSDL files. 
    // Without this code, if one specifies excludeOperations in services.xml
    // file and a static WSDL is used that contains the operation, 
    // the operation would succeed.
    if (operation != null && service.isExcludedOperation(operation.getName().getLocalPart())) {
        AxisFault fault = new AxisFault(Messages.getMessage("operationnotfoundforepr2",
                ((toEPR != null) ? toEPR.getAddress() : ""), msgContext.getWSAAction()));
        fault.setFaultCode(org.apache.axis2.namespace.Constants.FAULT_CLIENT);
        throw fault;
    }

    // If we're configured to do so, check the service for a single op...
    if (operation == null && JavaUtils.isTrue(service.getParameterValue(AxisService.SUPPORT_SINGLE_OP))) {
        Iterator<AxisOperation> ops = service.getOperations();
        // If there's exactly one, that's the one we want.  If there's more, forget it.
        if (ops.hasNext()) {
            operation = (AxisOperation) ops.next();
            if (ops.hasNext()) {
                operation = null;
            }
        }
        msgContext.setAxisOperation(operation);
    }

    // If we still don't have an operation, fault.
    if (operation == null) {
        AxisFault fault = new AxisFault(Messages.getMessage("operationnotfoundforepr2",
                ((toEPR != null) ? toEPR.getAddress() : ""), msgContext.getWSAAction()));
        fault.setFaultCode(org.apache.axis2.namespace.Constants.FAULT_CLIENT);
        throw fault;
    }

    validateTransport(msgContext);

    validateBindings(msgContext);

    loadContexts(service, msgContext);

    if (msgContext.getOperationContext() == null) {
        throw new AxisFault(Messages.getMessage("cannotBeNullOperationContext"));
    }

    if (msgContext.getServiceContext() == null) {
        throw new AxisFault(Messages.getMessage("cannotBeNullServiceContext"));
    }

    // TODO - review this
    if ((msgContext.getAxisOperation() == null) && (msgContext.getOperationContext() != null)) {
        msgContext.setAxisOperation(msgContext.getOperationContext().getAxisOperation());
    }

    if ((msgContext.getAxisService() == null) && (msgContext.getServiceContext() != null)) {
        msgContext.setAxisService(msgContext.getServiceContext().getAxisService());
    }

    // We should send an early ack to the transport whever possible, but some modules need
    // to use the backchannel, so we need to check if they have disabled this code.
    String mepString = msgContext.getAxisOperation().getMessageExchangePattern();

    if (isOneway(mepString)) {
        Object requestResponseTransport = msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
        if (requestResponseTransport != null) {

            Boolean disableAck = getDisableAck(msgContext);
            if (disableAck == null || disableAck.booleanValue() == false) {
                ((RequestResponseTransport) requestResponseTransport).acknowledgeMessage(msgContext);
            }
        }
    } else if (AddressingHelper.isReplyRedirected(msgContext)
            && AddressingHelper.isFaultRedirected(msgContext)) {

        if (mepString.equals(WSDL2Constants.MEP_URI_IN_OUT) || mepString.equals(WSDL2Constants.MEP_URI_IN_OUT)
                || mepString.equals(WSDL2Constants.MEP_URI_IN_OUT)) {
            // OR, if 2 way operation but the response is intended to not use the response channel of a 2-way transport
            // then we don't need to keep the transport waiting.

            Object requestResponseTransport = msgContext
                    .getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
            if (requestResponseTransport != null) {

                // We should send an early ack to the transport whever possible, but some modules need
                // to use the backchannel, so we need to check if they have disabled this code.
                Boolean disableAck = getDisableAck(msgContext);

                if (disableAck == null || disableAck.booleanValue() == false) {
                    ((RequestResponseTransport) requestResponseTransport).acknowledgeMessage(msgContext);
                }

            }
        }
    }

    ArrayList operationChain = msgContext.getAxisOperation().getRemainingPhasesInFlow();
    msgContext.setExecutionChain((ArrayList) operationChain.clone());
}

From source file:com.almende.eve.ggdemo.HolonAgent.java

/**
 * Merge./*from   w  w  w .  j  a  v a 2 s .  c  o m*/
 * 
 * @param size
 *            the size
 * @param sender
 *            the sender
 * @return the boolean
 * @throws JSONRPCException
 *             the jSONRPC exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public Boolean merge(@Name("size") int size, @Sender String sender) throws JSONRPCException, IOException {
    if (neighbours == null) {
        neighbours = getNeighbours();
    }
    String parent = getState().get("parent", String.class);
    if (parent != null && parent.equals(sender)) {
        return false;
    }
    ArrayList<Sub> oldsubs = getState().get("subs", type);
    ArrayList<Sub> subs = null;
    if (oldsubs == null) {
        subs = new ArrayList<Sub>();
    } else {
        subs = type.inject(oldsubs.clone());
    }
    for (Sub sub : subs) {
        if (sub.getAddress().equals(sender)) {
            return true;
        }
    }
    if (!neighbours.contains(sender)) {
        System.err.println("Merge requested by non-neighbour??? : " + sender);
        return false;
    }
    Sub sub = new Sub();
    sub.setAddress(sender);
    sub.setSize(size);
    subs.add(sub);
    if (!getState().putIfUnchanged("subs", subs, oldsubs)) {
        merge(size, sender);
    }
    getScheduler().createTask(new JSONRequest("checkMerge", null), 0);
    return true;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.excelcomponent.ExcelFormattingDialog.java

private void populateWidget() {

    if (excelFormattingDataStructure != null) {
        List<ExcelConfigurationDataStructure> listOfExcelConfiguration2 = excelFormattingDataStructure
                .getListOfExcelConfiguration();
        if (listOfExcelConfiguration2 != null && listOfExcelConfiguration2.size() > 0) {
            draggedFields.clear();/*from  ww w.  j a v  a2s. com*/
            for (ExcelConfigurationDataStructure excelConfigurationDataStructure : listOfExcelConfiguration2) {
                if (StringUtils.isNotBlank(excelConfigurationDataStructure.getFieldName())) {
                    draggedFields.add(excelConfigurationDataStructure.getFieldName());
                }
            }
            draggedFields.add(0, "Select");
            combo.setItems(convertToArray(draggedFields));
        }
        if (StringUtils.isNotBlank(excelFormattingDataStructure.getCopyOfField())) {
            combo.setText(excelFormattingDataStructure.getCopyOfField());
        }
        if (listOfExcelConfiguration2 != null) {
            this.listOfExcelConfiguration.clear();
            ArrayList tmplist = (ArrayList) this.excelFormattingDataStructure.getListOfExcelConfiguration();
            this.listOfExcelConfiguration.addAll((ArrayList) tmplist.clone());
            targetTableViewer.setInput(listOfExcelConfiguration);
        }
    }

    highlightDropFields();
    enableDeleteButton();
}

From source file:com.supremainc.biostar2.widget.FilterView.java

private void selectUser() {
    mSelectUserPopup.show(SelectType.USER, new OnSelectResultListener<ListUser>() {
        @Override/*from   w w w .  j  a va 2s .  com*/
        public void OnResult(ArrayList<ListUser> selectedItem) {
            if (selectedItem == null) {
                return;
            }
            setUserResult((ArrayList<ListUser>) selectedItem.clone());
        }
    }, null, mContext.getString(R.string.select_user_original), true, true);
}

From source file:com.supremainc.biostar2.widget.FilterView.java

private void selectEvent() {
    mSelectEventPopup.show(SelectType.EVENT_TYPE, new OnSelectResultListener<EventType>() {
        @Override/*from w w w. j a va2 s  .c om*/
        public void OnResult(ArrayList<EventType> selectedItem) {
            if (selectedItem == null) {
                return;
            }
            setEventResult((ArrayList<EventType>) selectedItem.clone());
        }
    }, null, mContext.getString(R.string.select_event), true, true);
}