Example usage for java.lang String compareTo

List of usage examples for java.lang String compareTo

Introduction

In this page you can find the example usage for java.lang String compareTo.

Prototype

public int compareTo(String anotherString) 

Source Link

Document

Compares two strings lexicographically.

Usage

From source file:ai.grakn.graql.internal.analytics.ConnectedComponentVertexProgram.java

private void update(Vertex vertex, Messenger<String> messenger, Memory memory) {
    String currentMax = vertex.value(clusterLabel);
    String max = IteratorUtils.reduce(messenger.receiveMessages(), currentMax,
            (a, b) -> a.compareTo(b) > 0 ? a : b);
    if (max.compareTo(currentMax) > 0) {
        vertex.property(clusterLabel, max);
        messenger.sendMessage(messageScopeShortcutIn, max);
        messenger.sendMessage(messageScopeShortcutOut, max);
        memory.and(VOTE_TO_HALT, false);
    }/* w ww  .  j a  v  a 2 s. com*/
}

From source file:com.ramforth.webserver.http.modules.HttpFileModule.java

private void addContentTypeHeaderForFile(IHttpResponse httpResponse, File file) {
    String extension = FilenameUtils.getExtension(file.getName());

    String mimeType = "application/octet-stream";
    if (extension.compareTo("") != 0) {
        String mimeType2 = MimeTypeMap.getInstance().getMimeTypeForExtension(extension);
        if (mimeType2 != null) {
            mimeType = mimeType2;//from  w  w w  .  j  a v  a 2s.  c  om
        }
    }

    httpResponse.setContentType(mimeType);
}

From source file:hu.petabyte.redflags.engine.gear.export.FlagExporter.java

private void sortRows() {
    Collections.sort(grid, new Comparator<ArrayList<String>>() {

        @Override/*from ww  w. j a  v a2 s .  c  om*/
        public int compare(ArrayList<String> row1, ArrayList<String> row2) {
            String id1 = row1.get(0);
            String id2 = row2.get(0);
            return id2.compareTo(id1);
        }
    });
}

From source file:com.exxonmobile.ace.hybris.storefront.history.impl.DefaultBrowseHistory.java

@Override
public BrowseHistoryEntry findUrlInHistory(final String url) {
    for (final BrowseHistoryEntry entry : getBrowseHistoryEntries()) {
        final String[] parts = entry.getUrl().split("/");
        if (parts.length > 0 && url.compareTo(parts[parts.length - 1]) == 0) {
            return entry;
        }/*w w  w . j  a  v a 2  s .  c  om*/
    }
    return null;
}

From source file:web.org.perfmon4j.restdatasource.data.Field.java

@Override
public int compareTo(Field o) {
    String myName = (primary ? "1" : "2") + name;
    String otherName = (o.primary ? "1" : "2") + o.name;

    return myName.compareTo(otherName);
}

From source file:com.qcadoo.model.internal.validators.RangeValidator.java

private boolean validateStringRange(final FieldDefinition fieldDefinition, final String value,
        final Entity validatedEntity) {
    if (from != null && ((!inclusively && value.compareTo((String) from) < 0)
            || (inclusively && value.compareTo((String) from) <= 0))) {
        addToSmallError(fieldDefinition, validatedEntity);
        return false;
    }/*from  w ww  .ja va  2 s . c o  m*/
    if (to != null && ((!inclusively && value.compareTo((String) to) > 0)
            || (inclusively && value.compareTo((String) to) >= 0))) {
        addToLargeError(fieldDefinition, validatedEntity);
        return false;
    }
    return true;
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectWMFListener.java

public boolean checkFormat(File file) {
    try {//  www  .  j  av a2s . com
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line = br.readLine();
        while ((line = br.readLine()) != null) {
            if (line.compareTo("") != 0) {
                String[] fields = line.split("\t", -1);
                //check columns number
                if (fields.length != 4) {
                    this.selectWMFUI.displayMessage("Error:\nLines have not the right number of columns");
                    br.close();
                    return false;
                }
                //check raw file names
                if (!((ClinicalData) this.dataType).getRawFilesNames().contains(fields[0])) {
                    this.selectWMFUI.displayMessage("Error:\ndata file '" + fields[0] + "' does not exist");
                    br.close();
                    return false;
                }
                //check that column number is set
                if (fields[1].compareTo("") == 0) {
                    this.selectWMFUI.displayMessage("Error:\nColumns numbers have to be set");
                    br.close();
                    return false;
                }
                try {
                    Integer.parseInt(fields[1]);
                } catch (NumberFormatException e) {
                    this.selectWMFUI.displayMessage("Error:\nColumns numbers have to be numbers");
                    br.close();
                    return false;
                }
                //check that original data value is set
                if (fields[2].compareTo("") == 0) {
                    this.selectWMFUI.displayMessage("Error:\nOriginal data values have to be set");
                    br.close();
                    return false;
                }
                //check that new data value is set
                if (fields[3].compareTo("") == 0) {
                    this.selectWMFUI.displayMessage("Error:\nNew data values have to be set");
                    br.close();
                    return false;
                }
            }
        }
        br.close();
    } catch (Exception e) {
        this.selectWMFUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
        return false;
    }
    return true;
}

From source file:adalid.core.DisplaySet.java

@Override
public int compareTo(DisplaySet o) {
    DisplaySet that;//from   w ww . java 2 s  .c o  m
    if (o != null) {
        that = o;
        String thisName = StringUtils.trimToEmpty(this.getName());
        String thatName = StringUtils.trimToEmpty(that.getName());
        return thisName.compareTo(thatName);
    }
    return 0;
}

From source file:com.all.tracker.service.InternalIPService.java

public boolean isInternalIp(String ip) {
    for (String item : ips) {
        if (item.compareTo(ip) == 0) {
            return true;
        }/*w w  w .  j a  v  a 2s .  c om*/
    }
    return false;
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SetLabelsOntologyListener.java

@Override
public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> headers = this.setLabelsOntologyUI.getHeaders();
    Vector<String> newLabels = this.setLabelsOntologyUI.getNewLabels();
    Vector<String> codes = this.setLabelsOntologyUI.getCodes();

    if (((ClinicalData) this.dataType).getCMF() == null) {
        this.setLabelsOntologyUI.displayMessage("Error: no column mapping file");
        return;//from   w  w w .  ja  va2  s .  co  m
    }
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".columns.tmp");
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n");
        try {
            BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF()));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                if (line.split("\t", -1)[3].compareTo("SUBJ_ID") == 0
                        || line.split("\t", -1)[3].compareTo("VISIT_NAME") == 0
                        || line.split("\t", -1)[3].compareTo("SITE_ID") == 0
                        || line.split("\t", -1)[3].compareTo("\\") == 0
                        || line.split("\t", -1)[3].compareTo("DATA_LABEL") == 0
                        || line.split("\t", -1)[3].compareTo("OMIT") == 0) {
                    out.write(line + "\n");
                } else {
                    File rawFile = new File(this.dataType.getPath() + File.separator + line.split("\t", -1)[0]);
                    String header = FileHandler.getColumnByNumber(rawFile,
                            Integer.parseInt(line.split("\t", -1)[2]));
                    String newLabel = newLabels.elementAt(headers.indexOf(rawFile.getName() + " - " + header));
                    if (newLabel.compareTo("") == 0) {
                        newLabel = header;
                    }
                    out.write(line.split("\t", -1)[0] + "\t" + line.split("\t", -1)[1] + "\t"
                            + line.split("\t", -1)[2] + "\t" + newLabel + "\t\t"
                            + codes.elementAt(headers.indexOf(rawFile.getName() + " - " + header)) + "\n");

                }
            }
            br.close();
        } catch (Exception e) {
            this.setLabelsOntologyUI.displayMessage("Error: " + e.getLocalizedMessage());
            e.printStackTrace();
            out.close();
        }

        out.close();
        String fileName = ((ClinicalData) this.dataType).getCMF().getName();
        FileUtils.deleteQuietly(((ClinicalData) this.dataType).getCMF());
        try {
            File fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            FileUtils.moveFile(file, fileDest);
            ((ClinicalData) this.dataType).setCMF(fileDest);
        } catch (Exception ioe) {
            this.setLabelsOntologyUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setLabelsOntologyUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setLabelsOntologyUI.displayMessage("Column mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}