Example usage for java.util Collections reverse

List of usage examples for java.util Collections reverse

Introduction

In this page you can find the example usage for java.util Collections reverse.

Prototype

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void reverse(List<?> list) 

Source Link

Document

Reverses the order of the elements in the specified list.

This method runs in linear time.

Usage

From source file:jp.bugscontrol.bugzilla.Product.java

@Override
protected void loadBugs() {
    final Product p = this;
    final List<jp.bugscontrol.general.Bug> newList = new ArrayList<jp.bugscontrol.general.Bug>();
    final BugzillaTask task = new BugzillaTask(server, "Bug.search", "'product':'" + p.getName()
            + "', 'resolution':'', 'limit':0, 'include_fields':['id', 'summary', 'priority', 'status', 'creator', 'assigned_to', 'resolution', 'creation_time']",
            new TaskListener() {
                @Override//w  w w.j  ava2s .  com
                public void doInBackground(final String s) {
                    try {
                        final JSONObject object = new JSONObject(s);
                        final JSONArray bugs = object.getJSONObject("result").getJSONArray("bugs");
                        final int size = bugs.length();
                        for (int i = 0; i < size; ++i) {
                            newList.add(new Bug(p, bugs.getJSONObject(i)));
                        }
                        Collections.reverse(newList);
                    } catch (final Exception e) {
                        e.printStackTrace();
                    }
                }

                @Override
                public void onPostExecute(final String s) {
                    p.clearBugs();
                    p.addBugs(newList);
                    bugsListUpdated();
                }
            });
    task.execute();
}

From source file:it.drwolf.ridire.index.results.LeftContext.java

@Override
public String toString() {
    // return super.toString();
    List<String> l1 = this.strTokenizer.reset(this.context).getTokenList();
    Collections.reverse(l1);
    return StringUtils.join(l1, " ").replaceAll("_", " ");
}

From source file:com.intuit.tank.service.impl.v1.report.FileReader.java

/**
 * @param f/* w w w  . j a  va  2  s.c  o m*/
 * @param l
 * @return
 * @throws IOException
 */
@SuppressWarnings({ "unchecked" })
private static long getStartChar(File f, long numLines, long total) throws IOException {
    List<String> lines = FileUtils.readLines(f);
    long count = 0;
    if (lines.size() > numLines) {
        Collections.reverse(lines);
        for (int i = 0; i < numLines; i++) {
            count += lines.get(i).length() + 1;
        }
        count = total - (count + 1);
    }
    return count;
}

From source file:com.admob.rocksteady.common.ServiceManager.java

public void shutdown() {
    logger.info("ServiceManager shutting down registered Services");
    Collections.reverse(services);
    for (String service : services) {
        shutdownService(service);//  w  w  w . j a  v a 2  s . c om
    }
}

From source file:com.caricah.iotracah.bootstrap.runner.ResourceService.java

public List<BaseSystemHandler> getReversedSystemBaseSetLoader() {

    List<BaseSystemHandler> listBaseSystemHandler = getSystemBaseSetLoader();

    Collections.reverse(listBaseSystemHandler);

    return listBaseSystemHandler;
}

From source file:com.none.tom.simplerssreader.feed.SavedEntries.java

public static void reverse() {
    Collections.reverse(sDbEntries);
}

From source file:controller.HostelController.java

@ResponseBody
@RequestMapping(value = "/getApplication.do")
public Map getApplication(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> result = new HashMap<String, Object>();
    List<Application> applications = hostelService.getApplications();
    Collections.reverse(applications);
    result.put("applications", applications);
    return result;
}

From source file:kr.ac.cau.mecs.cass.processor.CASSensorProcessor.java

@Override
public Signal process(Signal signal) {
    Signal resignal = new Signal();

    resignal.setReceiver(signal.getSender());
    resignal.setSender("CASS");
    resignal.setAction(new Action(Action.ACT_SENSOR));

    CAECalculator calc = new CAECalculator();

    if (currentUser != null) {
        JSONObject _jobj = (JSONObject) signal.getPayload().getPayload().getData();

        JSONArray jsensors = _jobj.optJSONArray("sensors");

        List<SensorEntity> sensors = new ArrayList<>();

        for (int i = 0; i < jsensors.length(); i++) {
            sensors.add(SensorEntity.fromJSONObject(jsensors.getJSONObject(i)));
        }/*  www .  java  2s.  c  o m*/

        List<ActionScoreEntity> scores = new ArrayList<>();
        for (DBCAUEntity cau : currentUser.getCaus()) {
            for (DBActionEntity action : cau.getActions()) {
                scores.add(calc.calculateActionScore(cau, action, sensors));
            }
        }

        Collections.sort(scores);
        Collections.reverse(scores);//decending order...

        JSONObject jobj = new JSONObject();
        JSONArray jarr = new JSONArray();

        for (ActionScoreEntity score : scores) {
            jarr.put(score.toJSONObject());
        }
        jobj.put("scores", jarr);

        resignal.setPayload(new Payload(new JSONObjectPayload(jobj)));

    } else {
        setGenericMessage(resignal, "invalid credential");
    }

    return resignal;
}

From source file:net.sourceforge.vulcan.spring.SpringEventPool.java

public List<Event> getEvents(EventType type) {
    final List<Event> list = getEvents(new EventType[] { type });

    if (type.equals(EventType.BUILD)) {
        Collections.reverse(list);
    }/*ww w  . ja v a 2s.  com*/

    return list;
}

From source file:de.interactive_instruments.ShapeChange.SBVR.SbvrErrorListener.java

@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
        String msg, RecognitionException e) {

    SbvrErrorInfo err = new SbvrErrorInfo();

    err.setErrorCategory(Category.SYNTAX_ERROR);
    err.setErrorMessage(msg);/*from   w w  w  . j av a2  s. c o m*/
    err.setMetadataFromToken((Token) offendingSymbol);

    List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
    Collections.reverse(stack);
    err.setRuleInvocationStack(StringUtils.join(stack, " "));

    /*
     * 2015-03-30 JE: the following code would get the sbvr rule text
     * containing the token if the input contained line breaks. However, due
     * to SBVR rule text now being preprocessed (in
     * SbvrConstraintImpl.setText()) to replace such whitespace, we only
     * have a single line of text which is the whole SBVR rule.
     */
    //      CommonTokenStream tokens = (CommonTokenStream) recognizer
    //            .getInputStream();
    //      String input = tokens.getTokenSource().getInputStream().toString();      
    //      String[] lines = input.split("\n");      
    //      String errorLine = lines[line - 1];
    //      err.setErrorLineText(errorLine);

    this.errors.add(err);
}