Example usage for java.util ArrayList set

List of usage examples for java.util ArrayList set

Introduction

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

Prototype

public E set(int index, E element) 

Source Link

Document

Replaces the element at the specified position in this list with the specified element.

Usage

From source file:org.apache.cocoon.portal.pluto.om.common.PreferenceImpl.java

/**
 * @see org.apache.pluto.om.common.Preference#getValues()
 *//*  w  ww.j  a v  a2s  . c o  m*/
public Iterator getValues() {
    // replace the NULL_VALUE String by NULL
    if (value.contains(NULL_VALUE)) {
        return null;
    }

    ArrayList returnValue = new ArrayList(value.size());
    returnValue.addAll(value);

    // replace all NULL_ARRAYENTRY Strings by NULL
    for (int i = 0; i < returnValue.size(); i++) {
        if (NULL_ARRAYENTRY.equals(returnValue.get(i))) {
            returnValue.set(i, null);
        }
    }

    return returnValue.iterator();
}

From source file:org.eclipse.xtend.typesystem.xsd.type.XMLEClassType.java

private void replaceOperation(ArrayList<Feature> list, Operation op) {
    for (int i = 0; i < list.size(); i++) {
        Feature f = list.get(i);/*w ww  .  j  a  v a2  s .c o  m*/
        if (f instanceof Operation && f.getName().equals(op.getName())
                && ((Operation) f).getParameterTypes().equals(op.getParameterTypes())) {
            // log.info("replacing " + f + " with " + op);
            list.set(i, op);
            return;
        }
    }
}

From source file:Interfaz.XYLineChart.java

/**
* Datos//from   w  w  w. ja  va 2 s. c o  m
*/
public ArrayList<Coordenada> ordenarArray(ArrayList<Coordenada> n) {
    double aux;
    double var;
    double opc;
    for (int i = 0; i < n.size() - 1; i++) {

        for (int x = i + 1; x < n.size(); x++) {
            if (n.get(x).getX() > n.get(i).getX()) {
                aux = n.get(i).getX();
                var = n.get(i).getY();
                opc = n.get(i).getZ();
                n.set(i, new Coordenada(n.get(x).getX(), n.get(x).getY(), n.get(x).getZ()));

                n.set(x, new Coordenada(aux, var, opc));
            }
        }
    }

    return n;
}

From source file:microsoft.exchange.webservices.data.credential.BearerTokenCredentialsTest.java

@Test
public void testEmitBearerAuthorizationHeader() throws URISyntaxException {

    final String authorizationHeaderKey = "Authorization";
    final String bearerTokenPrefix = "Bearer";
    final String anyValidToken = SUPERFICIALLY_VALID_TOKEN;
    HttpWebRequest mockRequest = mock(HttpWebRequest.class);

    final ArrayList<HashMap<String, String>> headersContainer = new ArrayList<HashMap<String, String>>();
    headersContainer.add(new HashMap<String, String>());
    when(mockRequest.getHeaders()).thenReturn(headersContainer.get(0));
    doAnswer(new Answer() {
        @Override/*from   ww  w  .j  ava 2s .  com*/
        public Object answer(InvocationOnMock invocation) throws Throwable {
            headersContainer.set(0, (HashMap<String, String>) invocation.getArguments()[0]);
            return null;
        }
    }).when(mockRequest).setHeaders((Map<String, String>) any());

    ExchangeCredentials creds = new BearerTokenCredentials(anyValidToken);

    creds.prepareWebRequest(mockRequest);

    Map<String, String> actualHeaders = mockRequest.getHeaders();
    Assert.assertTrue("Headers must contain authenticate line.",
            actualHeaders.containsKey(authorizationHeaderKey));
    String actualAuthorizationHeader = actualHeaders.get(authorizationHeaderKey);
    Assert.assertTrue("Header value must start with " + bearerTokenPrefix,
            actualAuthorizationHeader.startsWith(bearerTokenPrefix));
    Assert.assertTrue("Header value must contain token string.",
            actualAuthorizationHeader.contains(anyValidToken));
}

From source file:controller.FeatureController.java

public void start() {
    ArrayList<float[]> data = dataModel.getEpochList();
    if ((int) (dataModel.getSrate()) != (int) 100) {
        for (int i = 0; i < data.size(); i++) {
            data.set(i, getResampler().resample(data.get(i)));
        }// w w  w .  j a v  a 2  s.  c  o m
    }

    //KCdetection is not thread safe!!!
    float[] kcPercentage = new float[featureModel.getNumberOfEpochs()];

    for (int i = 0; i < data.size(); i++) {
        kcDetector.detect(data.get(i));
        kcPercentage[i] = (float) kcDetector.getPercentageSum();
    }
    featureModel.setKcPercentage(kcPercentage);

    float[][] features = computeFeatures(data);

    featureModel.setFeatures(features);
}

From source file:com.krawler.common.util.BaseStringUtil.java

public static String filterQuery(ArrayList filter_names, String appendCase) {
    StringBuilder filterQuery = new StringBuilder();
    // String filterQuery = "";
    String oper = "";
    String op = "";
    for (int i = 0; i < filter_names.size(); i++) {
        if (filter_names.get(i).toString().length() >= 5)
            op = filter_names.get(i).toString().substring(0, 5);
        if (op.equals("ISNOT")) {
            oper = " is not ";
            String opstr = filter_names.get(i).toString();
            filter_names.set(i, opstr.substring(5, opstr.length()));
        } else if (op.equals("NOTIN")) {
            oper = " not in(" + i + ")";
            String opstr = filter_names.get(i).toString();
            filter_names.set(i, opstr.substring(5, opstr.length()));
        } else {//www  . j  a v  a  2  s. c om
            if (filter_names.get(i).toString().length() >= 4)
                op = filter_names.get(i).toString().substring(0, 4);
            if (op.equals("LIKE")) {
                oper = " like ";
                String opstr = filter_names.get(i).toString();
                filter_names.set(i, opstr.substring(4, opstr.length()));
            } else {
                op = filter_names.get(i).toString().substring(0, 2);
                if (op.equals("<=")) {
                    oper = " <= ";
                    String opstr = filter_names.get(i).toString();
                    filter_names.set(i, opstr.substring(2, opstr.length()));
                } else if (op.equals(">=")) {
                    oper = " >= ";
                    String opstr = filter_names.get(i).toString();
                    filter_names.set(i, opstr.substring(2, opstr.length()));
                } else if (op.equals("IS")) {
                    oper = " is ";
                    String opstr = filter_names.get(i).toString();
                    filter_names.set(i, opstr.substring(2, opstr.length()));
                } else if (op.equals("IN")) {
                    oper = " in (" + i + ") ";
                    String opstr = filter_names.get(i).toString();
                    filter_names.set(i, opstr.substring(2, opstr.length()));
                } else {

                    op = filter_names.get(i).toString().substring(0, 1);
                    if (op.equals("!")) {
                        oper = " != ";
                        String opstr = filter_names.get(i).toString();
                        filter_names.set(i, opstr.substring(1, opstr.length()));
                    } else if (op.equals("<")) {
                        oper = " < ";
                        String opstr = filter_names.get(i).toString();
                        filter_names.set(i, opstr.substring(1, opstr.length()));
                    } else if (op.equals(">")) {
                        oper = " > ";
                        String opstr = filter_names.get(i).toString();
                        filter_names.set(i, opstr.substring(1, opstr.length()));
                    } else
                        oper = " = ";
                }
            }
        }

        if (i == 0) {
            // filterQuery += " where "+filter_names.get(i)+" = ? ";
            if (!op.equals("IN") && !op.equals("NOTIN"))
                filterQuery.append(" " + appendCase + " " + filter_names.get(i) + oper + " ? ");
            else
                filterQuery.append(" " + appendCase + " " + filter_names.get(i) + oper);
        } else {
            // filterQuery += " and "+filter_names.get(i)+" = ? ";
            if (!op.equals("IN") && !op.equals("NOTIN"))
                filterQuery.append(" and " + filter_names.get(i) + oper + " ? ");
            else
                filterQuery.append(" and " + " " + filter_names.get(i) + oper);
        }
    }
    return filterQuery.toString();
}

From source file:com.arainfor.thermostat.daemon.HvacMonitor.java

/**
 * This handles the callback for Thermometer changes.
 * @param thermometerChanged// w  ww. j a v a2 s.co m
 * @param value
 */
@Override
public synchronized void subjectChanged(Thermometer thermometerChanged, double value) {

    ArrayList<Temperature> temperatureList = TemperaturesList.getInstance().list();
    Iterator<Temperature> it = temperatureList.iterator();

    while (it.hasNext()) {
        Temperature temperature = it.next();
        if (temperature.getIndex() == thermometerChanged.getIndex()) {
            temperature.setValue(value);
            temperatureList.set(temperature.getIndex(), temperature);
            temperatureLogger.logMessage(temperatureList.toString());
            break;
        }
    }
}

From source file:com.microsoft.mimickeralarm.utilities.Loggable.java

public void putEmotions(List<RecognizeResult> results) {
    try {/*w w w .ja v  a2s .  c  om*/
        ArrayList<Double> scores = new ArrayList<>();

        for (int i = 0; i < results.size(); i++) {
            scores.add(results.get(i).scores.anger);
        }
        Properties.put("Emotion Anger", new JSONArray(scores));

        for (int i = 0; i < results.size(); i++) {
            scores.set(i, results.get(i).scores.contempt);
        }
        Properties.put("Emotion Contempt", new JSONArray(scores));

        for (int i = 0; i < results.size(); i++) {
            scores.set(i, results.get(i).scores.disgust);
        }
        Properties.put("Emotion Disgust", new JSONArray(scores));

        for (int i = 0; i < results.size(); i++) {
            scores.set(i, results.get(i).scores.fear);
        }
        Properties.put("Emotion Fear", new JSONArray(scores));

        for (int i = 0; i < results.size(); i++) {
            scores.set(i, results.get(i).scores.happiness);
        }
        Properties.put("Emotion Happiness", new JSONArray(scores));

        for (int i = 0; i < results.size(); i++) {
            scores.set(i, results.get(i).scores.neutral);
        }
        Properties.put("Emotion Neutral", new JSONArray(scores));

        for (int i = 0; i < results.size(); i++) {
            scores.set(i, results.get(i).scores.sadness);
        }
        Properties.put("Emotion Sadness", new JSONArray(scores));

        for (int i = 0; i < results.size(); i++) {
            scores.set(i, results.get(i).scores.surprise);
        }
        Properties.put("Emotion Surprise", new JSONArray(scores));
    } catch (JSONException ex) {
        Logger.trackException(ex);
    }
}

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

/**
 * Take a row of data and remove n/a strings
 * @param row the input row of data/*w  w  w.  j a  va 2s  .co  m*/
 * @return cleaned rows of data
 */
private ArrayList<String> performRemoveNA(ArrayList<String> row) {
    String value;
    for (int i = 0; i < row.size(); i++) { // for each value in the row         
        value = row.get(i);
        if (value.trim().equalsIgnoreCase("n/a")) {
            row.set(i, ""); // change to empty string
        }
    }
    return row;
}

From source file:com.clematis.jsmodify.JSExecutionTracer.java

/**
 * This method sorts all four groups of trace objects into one ordered list of trace objects
 *///w w  w . ja  v  a2s . c o  m
private static ArrayList<TraceObject> sortTraceObjects() {
    ArrayList<TraceObject> sortedTrace = new ArrayList<TraceObject>();

    ArrayList<Collection<TraceObject>> allCollections = new ArrayList<Collection<TraceObject>>();

    if (story.getDomEventTraces().size() > 0) {
        allCollections.add(story.getDomEventTraces());
    }

    if (story.getFunctionTraces().size() > 0) {
        allCollections.add(story.getFunctionTraces());
    }

    if (story.getTimingTraces().size() > 0) {
        allCollections.add(story.getTimingTraces());
    }

    if (story.getXhrTraces().size() > 0) {
        allCollections.add(story.getXhrTraces());
    }

    if (allCollections.size() == 0) {
        System.out.println("No log");
        return null;
    }

    ArrayList<Integer> currentIndexInCollection = new ArrayList<Integer>();
    for (int i = 0; i < allCollections.size(); i++)
        currentIndexInCollection.add(0);

    while (true) {
        int currentMinArray = 0;

        for (int i = 0; i < allCollections.size(); i++) {
            TraceObject traceObj = Iterables.get(allCollections.get(i), currentIndexInCollection.get(i));
            TraceObject currObj = Iterables.get(allCollections.get(currentMinArray),
                    currentIndexInCollection.get(currentMinArray));
            if (traceObj.getCounter() < currObj.getCounter())
                currentMinArray = i;
        }

        sortedTrace.add(Iterables.get(allCollections.get(currentMinArray),
                currentIndexInCollection.get(currentMinArray)));

        currentIndexInCollection.set(currentMinArray, currentIndexInCollection.get(currentMinArray) + 1);
        if (currentIndexInCollection.get(currentMinArray) >= allCollections.get(currentMinArray).size()) {
            allCollections.remove(currentMinArray);
            currentIndexInCollection.remove(currentMinArray);
            if (allCollections.size() == 0)
                break;
        }
    }

    return sortedTrace;
}