Example usage for java.util ArrayList indexOf

List of usage examples for java.util ArrayList indexOf

Introduction

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

Prototype

public int indexOf(Object o) 

Source Link

Document

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

Usage

From source file:eplic.core.breakpoint.BreakpointManager.java

/**
 * breakpoint set, normal setIS//from ww w. j ava 2s  .c o  m
 * IS?NSbreakpoint
 * 
 * @param nor
 * @param rec
 * @return result set
 */
public ArrayList<ILineBreakpoint> diffResult(ArrayList<ILineBreakpoint> nor, ArrayList<ILineBreakpoint> rec) {
    for (ILineBreakpoint nm : nor) {
        while (rec.indexOf(nm) != -1) {
            rec.remove(nm);
        }
    }
    _result = new ArrayList<ILineBreakpoint>(rec.size());
    for (ILineBreakpoint b : rec) {
        _result.add(b);
    }
    return _result;
}

From source file:org.fiware.cybercaptor.server.informationsystem.graph.InformationSystemGraph.java

/**
 * Transform this graph to a json object (vertices arcs)
 *
 * @return the JSON object related to this graph
 *//*from   w  w w . ja  v  a2 s .co  m*/
public JSONObject toJsonObject() {
    //Build the json list of hosts
    JSONObject json = new JSONObject();
    JSONObject arcs_object = new JSONObject();
    JSONArray arcs_array = new JSONArray();
    ArrayList<InformationSystemGraphVertex> vertices = this.getVertices();

    // Arcs
    for (InformationSystemGraphArc topologicalGraphArc : this.getArcs()) {
        JSONObject arc_object = new JSONObject();
        int id_destination = vertices.indexOf(topologicalGraphArc.getDestination());
        int id_source = vertices.indexOf(topologicalGraphArc.getSource());
        arc_object.put("dst", id_destination);
        arc_object.put("src", id_source);
        arc_object.put("label", topologicalGraphArc.getRelatedVulnerability());
        arcs_array.put(arc_object);
    }
    arcs_object.put("arc", arcs_array);
    json.put("arcs", arcs_object);

    JSONObject vertices_object = new JSONObject();
    JSONArray vertices_array = new JSONArray();
    // Vertices
    for (InformationSystemGraphVertex topologicalVertex : vertices) {
        JSONObject vertex_object = new JSONObject();
        int id = vertices.indexOf(topologicalVertex);
        vertex_object.put("id", id);
        vertex_object.put("type", topologicalVertex.getType().toString().toUpperCase());
        if (topologicalVertex.getType().equals(InformationSystemGraphVertex.TopologyVertexType.Machine)) {
            vertex_object.put("name", topologicalVertex.getMachine().getName());
            JSONArray ipAddresses = new JSONArray();
            for (Interface networkInterface : topologicalVertex.getMachine().getInterfaces().values()) {
                ipAddresses.put(networkInterface.getAddress());
            }
            vertex_object.put("ip_addresses", ipAddresses);
        } else if (topologicalVertex.getType()
                .equals(InformationSystemGraphVertex.TopologyVertexType.Network)) {
            vertex_object.put("name", topologicalVertex.getNetwork().getName());
            vertex_object.put("ip_address", topologicalVertex.getNetwork().getAddress() + "/"
                    + topologicalVertex.getNetwork().getMask());
        }
        vertex_object.put("compromised", topologicalVertex.isCompromised());
        vertex_object.put("source_of_attack", topologicalVertex.isMachineOfAttacker());
        vertex_object.put("target", topologicalVertex.isTarget());

        vertices_array.put(vertex_object);
    }
    vertices_object.put("vertex", vertices_array);
    json.put("vertices", vertices_object);

    return json;
}

From source file:cn.edu.fjnu.shop.http.RequestParams.java

@Override
public String toString() {
    StringBuilder result = new StringBuilder();
    for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
        if (result.length() > 0)
            result.append("&");

        result.append(entry.getKey());//from  ww  w . ja v a  2  s  .co  m
        result.append("=");
        result.append(entry.getValue());
    }

    for (ConcurrentHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
        if (result.length() > 0)
            result.append("&");

        result.append(entry.getKey());
        result.append("=");
        result.append("FILE");
    }

    for (ConcurrentHashMap.Entry<String, ArrayList<String>> entry : urlParamsWithArray.entrySet()) {
        if (result.length() > 0)
            result.append("&");

        ArrayList<String> values = entry.getValue();
        for (String value : values) {
            if (values.indexOf(value) != 0)
                result.append("&");
            result.append(entry.getKey());
            result.append("=");
            result.append(value);
        }
    }

    return result.toString();
}

From source file:control.JGeraGraficos.java

public ChartPanel GetGraficoParcial(ArrayList<DadosEstatisticos> listaParcial, String Titulo) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int i = 0;//from w w  w . jav  a2 s.c o  m
    dataset.clear();
    for (DadosEstatisticos dados : listaParcial) {
        i++;
        if (listaParcial.indexOf(dados) < 2) {
            dataset.setValue(dados.getTempoGasto(), "C" + i + " - " + dados.getDescricao(), "C" + i);
        } else {
            dataset.setValue(dados.getTempoGasto(), "C" + i + " - " + dados.getDimensoes(), "C" + i);
        }
    }

    JFreeChart chart = ChartFactory.createBarChart(Titulo, null, "Tempo(ms)", dataset,
            PlotOrientation.HORIZONTAL, true, true, true);

    ChartPanel CP = new ChartPanel(chart);
    CP.setBounds(5, 15, 180, 470);

    return CP;
}

From source file:control.JGeraGraficos.java

private void PrintGrafico(ArrayList<DadosEstatisticos> listaJava, ArrayList<DadosEstatisticos> listaJavaThRead,
        ArrayList<DadosEstatisticos> listaOpenCl) {
    int i = 0;/*from ww w.java2s. com*/
    String titulo = "";
    for (DadosEstatisticos dados : listaJava) {
        i++;
        if (listaJava.indexOf(dados) < 2) {
            titulo = titulo + "C" + i + " - " + dados.getDescricao() + "       ";
        } else {
            titulo = titulo + "C" + i + " - " + dados.getDimensoes() + "       ";
        }
    }

    JFreeChart chart = createGraficoXY("GRAFICO TOTAL DE PROCESSOS", titulo, " TEMPO (ms)",
            createDataset(listaJava, listaJavaThRead, listaOpenCl));
    ChartFrame frame = new ChartFrame("GRAFICO TOTAL DE PROCESSOS", chart);

    frame.setExtendedState(ChartFrame.MAXIMIZED_BOTH);
    frame.setVisible(true);

}

From source file:org.cds06.speleograph.data.fileio.SpeleoFileWriter.java

private Integer writeHeaders(List<Series> series, Integer[][] columns) {
    ArrayList<NumberAxis> axes = new ArrayList<>();
    for (Series s : series) {
        NumberAxis axis = s.getAxis();/*from   ww  w .  jav a  2 s .c o m*/
        if (axes.contains(axis))
            continue;
        axes.add(axis);
        int id = axes.indexOf(axis);
        boolean typeAxis = axis.equals(s.getType().getAxis());
        try {
            write("axis", Integer.toString(id), '"' + axis.getLabel() + '"',
                    DecimalFormat.getInstance().format(axis.getLowerBound()),
                    DecimalFormat.getInstance().format(axis.getUpperBound()), "type:" + (typeAxis ? "1" : "0"));
        } catch (Exception e) {
            log.error("Can not write axis to file", e);
        }
    }
    write("date", "", Integer.toString(allocatedColumns), "d/M/y H:m:s");
    allocatedColumns++;
    for (Series s : series) {
        String[] seriesDescriptor = { Integer.toString(allocatedColumns), s.getType().getName(),
                s.getType().getUnit() };
        if (s.isMinMax()) {
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min-max:1"); // NON-NLS
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "min:" + Integer.toString(allocatedColumns)); // NON-NLS
            seriesDescriptor = ArrayUtils.add(seriesDescriptor,
                    "max:" + Integer.toString(allocatedColumns + 1)); // NON-NLS
            columns[series.indexOf(s)] = new Integer[] { allocatedColumns, allocatedColumns + 1 };
            allocatedColumns++;
            allocatedColumns++;
        } else {
            columns[series.indexOf(s)] = new Integer[] { allocatedColumns };
            allocatedColumns++;
        }
        if (s.isShow())
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "show:1"); // NON-NLS
        if (s.getColor() != null)
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "color:" + s.getColor().getRGB()); // NON-NLS
        if (s.isMinMax())
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "stepped:1"); // NON-NLS
        if (s.getStyle() != null) {
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "style:" + s.getStyle().toString()); // NON-NLS
        }
        if (s.isNameHumanSet()) {
            seriesDescriptor = ArrayUtils.add(seriesDescriptor, "name:" + s.getName()); // NON-NLS
        }
        seriesDescriptor = ArrayUtils.add(seriesDescriptor, "axis:" + axes.indexOf(s.getAxis()));
        write(seriesDescriptor);
    }
    return allocatedColumns;
}

From source file:org.jasig.ssp.web.api.reports.EarlyAlertStudentReferralReportController.java

protected List<EarlyAlertStudentReportTO> processReports(List<EarlyAlertStudentReportTO> reports) {

    ArrayList<EarlyAlertStudentReportTO> compressedReports = new ArrayList<EarlyAlertStudentReportTO>();
    if (reports == null || reports.size() <= 0)
        return compressedReports;

    for (EarlyAlertStudentReportTO reportTO : reports) {
        Integer index = compressedReports.indexOf(reportTO);
        if (index != null && index >= 0) {
            BaseStudentReportTO compressedReportTo = compressedReports.get(index);
            compressedReportTo.processDuplicate(reportTO);
        } else {/*from   ww  w.ja  v a 2s. c  o  m*/
            compressedReports.add(reportTO);
        }
    }

    return compressedReports;
}

From source file:uk.ac.diamond.scisoft.ncd.core.utils.NcdDataUtils.java

public static Dataset[] matchDataDimensions(Dataset data, Dataset bgData) {
    int bgRank = bgData.getRank();
    int[] bgShape = bgData.getShape();
    int rank = data.getRank();
    int[] shape = data.getShape();

    ArrayList<Integer> matchBgDims = new ArrayList<Integer>();
    ArrayList<Integer> nomatchBgDims = new ArrayList<Integer>();
    for (int i = 0; i < bgRank; i++) {
        nomatchBgDims.add(i);/*  ww  w . ja v  a  2s  .c o m*/
    }
    ArrayList<Integer> matchDataDims = new ArrayList<Integer>();
    ArrayList<Integer> nomatchDataDims = new ArrayList<Integer>();
    for (int i = 0; i < rank; i++) {
        nomatchDataDims.add(i);
    }

    for (int i = 0; i < Math.min(bgRank, rank); i++) {
        if (bgShape[bgRank - i - 1] == shape[rank - i - 1]) {
            matchDataDims.add(new Integer(rank - i - 1));
            matchBgDims.add(new Integer(bgRank - i - 1));
            nomatchDataDims.remove(new Integer(rank - i - 1));
            nomatchBgDims.remove(new Integer(bgRank - i - 1));
        }
    }

    Collections.reverse(matchDataDims);
    nomatchDataDims.addAll(matchDataDims);
    data = DatasetUtils.transpose(data, ArrayUtils.toPrimitive(nomatchDataDims.toArray(new Integer[] {})));

    Collections.reverse(matchBgDims);
    nomatchBgDims.addAll(matchBgDims);
    bgData = DatasetUtils.transpose(bgData, ArrayUtils.toPrimitive(nomatchBgDims.toArray(new Integer[] {})));

    // Calculate permutations to restore original data shapes after processing
    IntegerDataset revPermData = new IntegerDataset(nomatchDataDims.size());
    for (int i = 0; i < nomatchDataDims.size(); i++) {
        revPermData.set(nomatchDataDims.indexOf(i), i);
    }
    IntegerDataset revPermBg = new IntegerDataset(nomatchBgDims.size());
    for (int i = 0; i < nomatchBgDims.size(); i++) {
        revPermBg.set(nomatchBgDims.indexOf(i), i);
    }
    return new Dataset[] { data, bgData, revPermData, revPermBg };
}

From source file:org.jasig.ssp.web.api.reports.ReportBaseController.java

<T extends BaseStudentReportTO> List<T> processStudentReportTOs(Collection<T> reports) {
    ArrayList<T> compressedReports = new ArrayList<T>();
    if (reports == null || reports.size() <= 0)
        return compressedReports;

    for (T reportTO : reports) {
        Integer index = compressedReports.indexOf(reportTO);
        if (index != null && index >= 0) {
            T compressedReportTo = compressedReports.get(index);
            compressedReportTo.processDuplicate(reportTO);
        } else {//from w ww  . ja  v a 2  s .c  o  m
            reportTO.normalize();
            compressedReports.add(reportTO);
        }
    }
    return compressedReports;
}

From source file:cn.com.zzwfang.http.RequestParams.java

@Override
public String toString() {
    StringBuilder result = new StringBuilder();
    for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
        if (result.length() > 0)
            result.append("&");

        result.append(entry.getKey());/*from ww  w .j a  va  2s  .co m*/
        result.append("=");
        result.append(entry.getValue());
    }

    for (ConcurrentHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
        if (result.length() > 0)
            result.append("&");

        result.append(entry.getKey());
        result.append("=");
        result.append("FILE");
    }

    for (ConcurrentHashMap.Entry<String, ArrayList<String>> entry : urlParamsWithArray.entrySet()) {
        if (result.length() > 0)
            result.append("&");

        ArrayList<String> values = entry.getValue();
        for (String value : values) {
            if (values.indexOf(value) != 0)
                result.append("&");
            result.append(entry.getKey());
            result.append("=");
            result.append(value);
        }
    }

    for (ConcurrentHashMap.Entry<String, ArrayList<FileWrapper>> entry : fileArrayParams.entrySet()) {
        if (result.length() > 0)
            result.append("&");
        ArrayList<FileWrapper> wrappers = entry.getValue();
        for (FileWrapper wrapper : wrappers) {
            if (wrappers.indexOf(wrapper) != 0)
                result.append("&");
            result.append(entry.getKey());
            result.append("=");
            result.append("FILE");
        }
    }

    return result.toString();
}