Example usage for java.lang String compareToIgnoreCase

List of usage examples for java.lang String compareToIgnoreCase

Introduction

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

Prototype

public int compareToIgnoreCase(String str) 

Source Link

Document

Compares two strings lexicographically, ignoring case differences.

Usage

From source file:net.sf.jabb.web.action.VfsTreeAction.java

protected List<JsTreeNodeData> getChildNodes(FileObject rootFile, String parentPath)
        throws FileSystemException {
    List<JsTreeNodeData> childNodes = new LinkedList<JsTreeNodeData>();
    FileObject parent = null;/*from   w w  w.  j  a v  a  2 s  .  c om*/
    if (requestData.isRoot()) {
        parent = rootFile;
    } else {
        parent = rootFile.resolveFile(parentPath, NameScope.DESCENDENT_OR_SELF);
    }
    for (FileObject child : parent.getChildren()) {
        JsTreeNodeData childNode = populateTreeNodeData(rootFile, child);
        childNodes.add(childNode);
    }
    if (sortByName || folderFirst) {
        Collections.sort(childNodes, new Comparator<JsTreeNodeData>() {

            @Override
            public int compare(JsTreeNodeData o1, JsTreeNodeData o2) {
                int result = 0;
                if (folderFirst) {
                    String t1 = o1.getAttr().get("rel").toString();
                    String t2 = o2.getAttr().get("rel").toString();
                    if (t1.equalsIgnoreCase(t2)) {
                        result = 0;
                    } else if ("file".equalsIgnoreCase(t2)) {
                        result = -1;
                    } else if ("file".equalsIgnoreCase(t1)) {
                        result = 1;
                    } else {
                        result = t1.compareToIgnoreCase(t2);
                    }
                }
                if (result == 0 && sortByName) {
                    String n1 = o1.getData().toString();
                    String n2 = o2.getData().toString();
                    result = n1.compareToIgnoreCase(n2);
                }
                return result;
            }

        });
    }
    return childNodes;
}

From source file:org.moe.gradle.remote.Server.java

public boolean checkFileMD5(String remotePath, @NotNull File localFile) {
    // Get local file md5
    final Future<String> localMD5Future = executor.submit(() -> {
        try {/* w ww  .ja  v a2  s  . c  o  m*/
            return DigestUtils.md5Hex(new FileInputStream(localFile));
        } catch (IOException ignore) {
            return null;
        }
    });

    // Get remote file md5
    assertConnected();
    final ServerCommandRunner runner = new ServerCommandRunner(this, "check file md5",
            "" + "[ -f '" + remotePath + "' ] && md5 -q '" + remotePath + "'");
    runner.setQuiet(true);
    try {
        runner.run();
    } catch (GradleException ignore) {
        return false;
    }
    final String remoteMD5 = runner.getOutput().trim();

    // Check equality
    final String localMD5;
    try {
        localMD5 = localMD5Future.get();
    } catch (InterruptedException | ExecutionException e) {
        throw new GradleException(e.getMessage(), e);
    }
    if (localMD5 == null) {
        return false;
    }
    return remoteMD5.compareToIgnoreCase(localMD5) == 0;
}

From source file:nattable.DataGridNatTable.java

private Comparator getCustomComparator() {
    return new Comparator() {
        public int compare(String o1, String o2) {
            return o1.compareToIgnoreCase(o2);
        }/*  w w w .  ja v  a  2  s . c  o  m*/

        @Override
        public int compare(Object arg0, Object arg1) {
            // TODO Auto-generated method stub
            return 0;
        }
    };
}

From source file:org.h2gis.drivers.osm.OSMParser.java

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    String type = attributes.getValue("type");
    if (progress.isCanceled()) {
        throw new SAXException("Canceled by user");
    }// w  w  w  .j ava 2  s.  c  o m
    if (localName.compareToIgnoreCase("node") == 0) {
        nodeOSMElement = new NodeOSMElement(Double.valueOf(attributes.getValue("lat")),
                Double.valueOf(attributes.getValue("lon")));
        setCommonsAttributes(nodeOSMElement, attributes);
        tagLocation = TAG_LOCATION.NODE;
    } else if (localName.compareToIgnoreCase("way") == 0) {
        wayOSMElement = new WayOSMElement();
        setCommonsAttributes(wayOSMElement, attributes);
        tagLocation = TAG_LOCATION.WAY;
    } else if (localName.compareToIgnoreCase("tag") == 0) {
        String key = attributes.getValue("k");
        String value = attributes.getValue("v");
        boolean insertTag = true;
        switch (tagLocation) {
        case NODE:
            insertTag = nodeOSMElement.addTag(key, value);
            break;
        case WAY:
            insertTag = wayOSMElement.addTag(key, value);
            break;
        case RELATION:
            insertTag = relationOSMElement.addTag(key, value);
            break;
        }
        try {
            if (insertTag && !insertedTagsKeys.contains(key)) {
                tagPreparedStmt.setObject(1, key);
                tagPreparedStmt.execute();
                insertedTagsKeys.add(key);
            }
        } catch (SQLException ex) {
            if (ex.getErrorCode() != ErrorCode.DUPLICATE_KEY_1
                    && !TAG_DUPLICATE_EXCEPTION.equals(ex.getSQLState())) {
                throw new SAXException("Cannot insert the tag :  {" + key + " , " + value + "}", ex);
            }
        }
    } else if (localName.compareToIgnoreCase("nd") == 0) {
        wayOSMElement.addRef(attributes.getValue("ref"));
    } else if (localName.compareToIgnoreCase("relation") == 0) {
        relationOSMElement = new OSMElement();
        setCommonsAttributes(relationOSMElement, attributes);
        tagLocation = TAG_LOCATION.RELATION;
    } else if (localName.compareToIgnoreCase("member") == 0) {
        if (type.equalsIgnoreCase("node")) {
            try {
                nodeMemberPreparedStmt.setObject(1, relationOSMElement.getID());
                nodeMemberPreparedStmt.setObject(2, Long.valueOf(attributes.getValue("ref")));
                nodeMemberPreparedStmt.setObject(3, attributes.getValue("role"));
                nodeMemberPreparedStmt.setObject(4, idMemberOrder);
                nodeMemberPreparedStmt.addBatch();
                nodeMemberPreparedStmtBatchSize++;
            } catch (SQLException ex) {
                throw new SAXException(
                        "Cannot insert the node member for the relation :  " + relationOSMElement.getID(), ex);
            }
        } else if (type.equalsIgnoreCase("way")) {
            try {
                wayMemberPreparedStmt.setObject(1, relationOSMElement.getID());
                wayMemberPreparedStmt.setObject(2, Long.valueOf(attributes.getValue("ref")));
                wayMemberPreparedStmt.setObject(3, attributes.getValue("role"));
                wayMemberPreparedStmt.setObject(4, idMemberOrder);
                wayMemberPreparedStmt.addBatch();
                wayMemberPreparedStmtBatchSize++;
            } catch (SQLException ex) {
                throw new SAXException(
                        "Cannot insert the way member for the relation :  " + relationOSMElement.getID(), ex);
            }
        } else if (type.equalsIgnoreCase("relation")) {
            try {
                relationMemberPreparedStmt.setObject(1, relationOSMElement.getID());
                relationMemberPreparedStmt.setObject(2, Long.valueOf(attributes.getValue("ref")));
                relationMemberPreparedStmt.setObject(3, attributes.getValue("role"));
                relationMemberPreparedStmt.setObject(4, idMemberOrder);
                relationMemberPreparedStmt.addBatch();
                relationMemberPreparedStmtBatchSize++;
            } catch (SQLException ex) {
                throw new SAXException(
                        "Cannot insert the relation member for the relation :  " + relationOSMElement.getID(),
                        ex);
            }
        }
    }
}

From source file:com.devnexus.ting.web.controller.AmazonCallbackController.java

@RequestMapping(value = "/s/amazon/payment.act", method = RequestMethod.POST)
public String processPayment(HttpServletRequest request, String recipientEmail, String referenceId,
        String status) {

    LOG.info("Received message form Amazon:" + formatHttpRequest(request));
    Long referenceLong = 0l;//from  w  ww  .  j  a  va  2s  .c  o m
    // Load user amazon
    // Set amazon's credentials
    // Set amazon to security context
    // SecurityContextHolder.getContext().setAuthentication(new
    // UsernamePasswordAuthenticationToken("System", "System",
    // ArrayUtils.makeList(new UserAuthority AuthorityType.ADMIN)));

    try {
        referenceLong = Long.parseLong(referenceId);
    } catch (NumberFormatException nfe) {
        LOG.error("The reference ID:" + referenceId + " was not a number.");
        LOG.error("Logging amazon information and returning.");
        return "/amazon/OK.jsp";
    }
    if (status.compareToIgnoreCase("PF") == 0) {// problems capt'm. Notify
        // someone
        LOG.info("Payment Failed :");
        // set unpaid
        // set unpending
        // save
    } else {// Money is coming, register the game
        LOG.info("Paying for registration:");
        // set paid
        // set not pending
        // save
    }

    return "OK";
}

From source file:com.symbian.driver.core.report.TefResultParser.java

/**
 * @throws IOException /*from  www  . j a v  a2 s  .  c  om*/
 * @throws ParseException 
 * @see com.symbian.driver.core.report.ResultParser#parseResults()
 */
public void parseResults(final int aResultRootLength) throws IOException, ParseException {
    String extention = ".htm";
    //only if the loggin channel is exclusively chosen to be serial...
    String lTefLogChannel = TDConfig.getInstance().getLogChannel();
    if (lTefLogChannel != null && lTefLogChannel.compareToIgnoreCase("serial") == 0) {
        extention = ".log";
    }

    iResultFile = new File(TDConfig.getInstance().getPreferenceFile(TDConfig.RESULT_ROOT),
            ModelUtils.getBaseDirectory((Task) (iTefObject.eContainer().eContainer()),
                    TDConfig.getInstance().getPreferenceInteger(TDConfig.RUN_NUMBER))
                    + iTestName.concat(extention));

    String lRelativeResultPath = "."
            + iResultFile.toString().substring(aResultRootLength, iResultFile.toString().length());

    iTefReport.setLog(lRelativeResultPath);

    // Setup specific TEFLog stuff
    TefTestCaseSummary lTefTestCaseSummary = null;
    TefTestStepSummary lTefTestStepSummary = null;
    TefTestRunWsProgramSummary lTefTestRunWsProgramSummary = null;

    boolean lStepFlag = false;
    boolean lCaseFlag = false;
    boolean lRunProgramFlag = false;

    iTefReport.setTefTestStepSummary(lTefTestStepSummary);

    // Parse Results line by lne
    BufferedReader lBufferedReader = new BufferedReader(new FileReader(iResultFile));

    String lResultsLine = null;
    while ((lResultsLine = lBufferedReader.readLine()) != null) {

        // Matchers Count
        Matcher lTestCaseCountMatch = TEST_CASE_COUNT_PATTERN.matcher(lResultsLine);
        Matcher lTestStepCountMatch = TEST_STEP_COUNT_PATTERN.matcher(lResultsLine);
        Matcher lRunWsProgramCountMatch = RUN_WS_PROGRAM_COUNT_PATTERN.matcher(lResultsLine);

        // Matchers Common for TestCase and TestStep and RunProgram
        Matcher lPassMatch = PASS_PATTERN.matcher(lResultsLine);
        Matcher lFailMatch = FAIL_PATTERN.matcher(lResultsLine);
        Matcher lSkipMatch = SKIP_PATTERN.matcher(lResultsLine);

        // Matchers Common for TestStep and RunProgram
        Matcher lPanicMatch = PANIC_PATTERN.matcher(lResultsLine);
        Matcher lUnexecutedMatch = UNEXECUTED_PATTERN.matcher(lResultsLine);
        Matcher lUnknownMatch = UNKOWN_PATTERN.matcher(lResultsLine);
        Matcher lAbortMatch = ABORT_PATTERN.matcher(lResultsLine);

        // Matchers for TestStep
        Matcher lRunTestStepMatch = RUN_TEST_STEP_PATTERN.matcher(lResultsLine);

        // Matchers for TestCase
        Matcher lEndTestCaseMatch = END_TEST_CASE_PATTERN.matcher(lResultsLine);
        Matcher lInconclusiveMatch = INCONCLUSIVE_CASE_PATTERN.matcher(lResultsLine);
        Matcher lSkippedMatch = SKIPPED_TEST_CASE_PATTERN.matcher(lResultsLine);

        // Matchers for RunProgram
        Matcher lRunWsProgramMatch = RUN_WS_PROGRAM_PATTERN.matcher(lResultsLine);

        // Matchers for Summaries Flags
        Matcher lSummaryFlagMatch = SUMMARY_FLAG.matcher(lResultsLine);
        Matcher lStepFlagMatch = STEP_SUMMARY_FLAG.matcher(lResultsLine);
        Matcher lCaseFlagMatch = CASE_SUMMARY_FLAG.matcher(lResultsLine);
        Matcher lRunProgramFlagMatch = RUN_PROGRAM_FLAG.matcher(lResultsLine);

        try {

            ////////////////////////////////
            // Set Counts
            ////////////////////////////////
            if (lTestCaseCountMatch.find()) {

                // Count Summary: TEF Case
                lTefTestCaseSummary = createTefTestCaseSummary();
                lTefTestCaseSummary.setCount(Integer.parseInt(lTestCaseCountMatch.group(1).trim()));

            } else if (lTestStepCountMatch.find()) {

                // Count Summary: TEF Step
                lTefTestStepSummary = createTefTestStepSummary();
                lTefTestStepSummary.setCount(Integer.parseInt(lTestStepCountMatch.group(1).trim()));

            } else if (lRunWsProgramCountMatch.find()) {

                // Count Summary: TEF Run Program
                lTefTestRunWsProgramSummary = createRunWsProgramSummary();
                lTefTestRunWsProgramSummary.setCount(Integer.parseInt(lRunWsProgramCountMatch.group(1).trim()));

            }
            ////////////////////////////////
            // Set Common for STEP, CASE and RUN_PROGRAM
            ////////////////////////////////
            else if (lPassMatch.find()) {

                // Pass match: For STEP, CASE and RUN_PROGRAM
                int lPass = Integer.parseInt(lPassMatch.group(1).trim());

                if (lStepFlag && lTefTestStepSummary != null) {
                    lTefTestStepSummary.setPass(lPass);
                } else if (lCaseFlag && lTefTestCaseSummary != null) {
                    lTefTestCaseSummary.setPass(lPass);
                } else if (lRunProgramFlag && lTefTestRunWsProgramSummary != null) {
                    lTefTestRunWsProgramSummary.setPass(lPass);
                }

            } else if (lFailMatch.find()) {

                // Fail match: For STEP, CASE and RUN_PROGRAM
                int lFail = Integer.parseInt(lFailMatch.group(1).trim());

                if (lStepFlag && lTefTestStepSummary != null) {
                    lTefTestStepSummary.setFail(lFail);
                } else if (lCaseFlag && lTefTestCaseSummary != null) {
                    lTefTestCaseSummary.setFail(lFail);
                } else if (lRunProgramFlag && lTefTestRunWsProgramSummary != null) {
                    lTefTestRunWsProgramSummary.setFail(lFail);
                }

            } else if (lInconclusiveMatch.find()) {

                // Inconclusive match: For STEP, CASE and RUN_PROGRAM
                int lInconclusive = Integer.parseInt(lInconclusiveMatch.group(1).trim());

                if (lStepFlag && lTefTestStepSummary != null) {
                    lTefTestStepSummary.setInconclusive(lInconclusive);
                } else if (lCaseFlag && lTefTestCaseSummary != null) {
                    lTefTestCaseSummary.setInconclusive(lInconclusive);
                } else if (lRunProgramFlag && lTefTestRunWsProgramSummary != null) {
                    lTefTestRunWsProgramSummary.setInconclusive(lInconclusive);
                }
            } else if (lSkipMatch.find()) {

                // SKIPPED_SELECTIVELY match: For CASE
                int lSkipped = Integer.parseInt(lSkipMatch.group(1).trim());

                if (lCaseFlag && lTefTestCaseSummary != null) {
                    lTefTestCaseSummary.setSkippedSelectively(lSkipped);
                }
            }
            ////////////////////////////////
            // Set Common for STEP and RUN_PROGRAM
            ////////////////////////////////
            else if (lPanicMatch.find()) {

                // Panic match: For STEP and RUN_PROGRAM
                int lPanic = Integer.parseInt(lPanicMatch.group(1).trim());

                if (lStepFlag && lTefTestStepSummary != null) {
                    lTefTestStepSummary.setPanic(lPanic);
                } else if (lRunProgramFlag && lTefTestRunWsProgramSummary != null) {
                    lTefTestRunWsProgramSummary.setPanic(lPanic);
                }

            } else if (lUnexecutedMatch.find()) {

                // Unexecuted match: For STEP and RUN_PROGRAM
                int lUnexecuted = Integer.parseInt(lUnexecutedMatch.group(1).trim());

                if (lStepFlag && lTefTestStepSummary != null) {
                    lTefTestStepSummary.setUnexecuted(lUnexecuted);
                } else if (lRunProgramFlag && lTefTestRunWsProgramSummary != null) {
                    lTefTestRunWsProgramSummary.setUnexecuted(lUnexecuted);
                }

            } else if (lUnknownMatch.find()) {

                // Unknown match: For STEP and RUN_PROGRAM
                int lUnknown = Integer.parseInt(lUnknownMatch.group(1).trim());

                if (lStepFlag && lTefTestStepSummary != null) {
                    lTefTestStepSummary.setUnknown(lUnknown);
                } else if (lRunProgramFlag && lTefTestRunWsProgramSummary != null) {
                    lTefTestRunWsProgramSummary.setUnknown(lUnknown);
                }

            } else if (lAbortMatch.find()) {

                // Abort match: For STEP and RUN_PROGRAM
                int lAbort = Integer.parseInt(lAbortMatch.group(1).trim());

                if (lStepFlag && lTefTestStepSummary != null) {
                    lTefTestStepSummary.setAbort(lAbort);
                } else if (lRunProgramFlag && lTefTestRunWsProgramSummary != null) {
                    lTefTestRunWsProgramSummary.setAbort(lAbort);
                }

            }
            ////////////////////////////////
            // Set Induvidual Results
            ////////////////////////////////
            else if (lRunTestStepMatch.find()) {

                // Parse Induvidual STEP
                String lName = lRunTestStepMatch.group(1).trim();
                String lResult = lRunTestStepMatch.group(2).trim().toLowerCase();

                TefTestStep lTefTestStep = ReportFactory.eINSTANCE.createTefTestStep();
                lTefTestStepSummary = createTefTestStepSummary();
                lTefTestStepSummary.getTestCase().add(lTefTestStep);

                lTefTestStep.setName(lName);
                lTefTestStep.setResult(TefTestStepResult.get(lResult));

            } else if (lEndTestCaseMatch.find()) {

                // Parse Induvidual CASE
                String lName = lEndTestCaseMatch.group(1).trim();
                String lResult = lEndTestCaseMatch.group(2).trim().toLowerCase();

                TefTestCase lTefTestCase = ReportFactory.eINSTANCE.createTefTestCase();
                if (lTefTestCaseSummary == null) {
                    lTefTestCaseSummary = createTefTestCaseSummary();
                }
                lTefTestCaseSummary.getTestCase().add(lTefTestCase);

                lTefTestCase.setName(lName);
                lTefTestCase.setResult(TefTestCaseResult.get(lResult));
            } else if (lSkippedMatch.find()) {

                // Parse Induvidual CASE
                String lName = lSkippedMatch.group(2).trim();
                String lResult = lSkippedMatch.group(3).trim().toLowerCase();

                TefTestCase lTefTestCase = ReportFactory.eINSTANCE.createTefTestCase();
                if (lTefTestCaseSummary == null) {
                    lTefTestCaseSummary = createTefTestCaseSummary();
                }
                lTefTestCaseSummary.getTestCase().add(lTefTestCase);

                lTefTestCase.setName(lName);
                lTefTestCase.setResult(TefTestCaseResult.get(lResult));

            } else if (lRunWsProgramMatch.find()) {

                // Parse Induvidual PROGRAM
                String lName = lRunWsProgramMatch.group(1).trim();
                String lResult = lRunWsProgramMatch.group(2).trim().toLowerCase();

                TefTestRunWsProgram lRunWsProgram = ReportFactory.eINSTANCE.createTefTestRunWsProgram();
                lTefTestRunWsProgramSummary = createRunWsProgramSummary();
                lTefTestRunWsProgramSummary.getTestCase().add(lRunWsProgram);

                lRunWsProgram.setName(lName);
                lRunWsProgram.setResult(TefTestRunWsProgramResult.get(lResult));

            }
            ////////////////////////////////
            // Summary Flag matchers
            ////////////////////////////////
            else if (lSummaryFlagMatch.find() || lStepFlagMatch.find()) {
                lStepFlag = true;
                lCaseFlag = false;
                lRunProgramFlag = false;
            } else if (lCaseFlagMatch.find()) {
                lCaseFlag = true;
                lStepFlag = false;
                lRunProgramFlag = false;
            } else if (lRunProgramFlagMatch.find()) {
                lRunProgramFlag = true;
                lStepFlag = false;
                lCaseFlag = false;
            }

        } catch (Throwable lThrowable) {
            LOGGER.log(Level.SEVERE,
                    "Could not parse line: \"" + lResultsLine + "\"; because of: " + lThrowable.getMessage(),
                    lThrowable);
        }
    }

    // Ensure that if nothing worked at least something is 0.
    if (lTefTestStepSummary != null || (lTefTestCaseSummary == null && lTefTestRunWsProgramSummary == null
            && lTefTestStepSummary == null)) {
        TefTestStepSummary lTefStep = createTefTestStepSummary();

        if (lTefStep.getPass() == 0 && lTefStep.getFail() == 0 && lTefStep.getPanic() == 0
                && lTefStep.getUnexecuted() == 0 && lTefStep.getUnknown() == 0 && lTefStep.getAbort() == 0) {
            lTefStep.setUnknown(1);
        }
    }
}

From source file:org.eclipse.php.internal.ui.editor.contentassist.PHPCompletionProposalSorter.java

@Override
public int compare(ICompletionProposal p1, ICompletionProposal p2) {
    if (p1 instanceof AbstractScriptCompletionProposal && p2 instanceof AbstractScriptCompletionProposal) {
        AbstractScriptCompletionProposal cp1 = (AbstractScriptCompletionProposal) p1;
        AbstractScriptCompletionProposal cp2 = (AbstractScriptCompletionProposal) p2;

        IModelElement el1 = cp1.getModelElement();
        IModelElement el2 = cp2.getModelElement();

        if (el1.getElementType() == IModelElement.TYPE && el2.getElementType() == IModelElement.TYPE) {
            try {
                int result = Boolean.compare(PHPFlags.isNamespace(((IType) el1).getFlags()),
                        PHPFlags.isNamespace(((IType) el2).getFlags()));
                if (result != 0) {
                    return result;
                }/*from   w  w w.  j  ava2  s . c o  m*/
            } catch (ModelException e) {
                Logger.logException(e);
            }
        }

        if (el1.getElementName().equals(el2.getElementName())) {
            String parent1 = getParentQualifier(el1.getParent());
            String parent2 = getParentQualifier(el2.getParent());

            if (parent1 == null && parent2 == null) {
                return 0;
            } else if (parent1 == null) {
                return -1;
            } else if (parent2 == null) {
                return 1;
            }

            int segments1 = StringUtils.countMatches(parent1, "\\"); //$NON-NLS-1$
            int segments2 = StringUtils.countMatches(parent2, "\\"); //$NON-NLS-1$
            // bump up elements in global namespace
            if (segments1 == 0 || segments2 == 0) {
                return Integer.compare(segments1, segments2);
            }
            return parent1.compareToIgnoreCase(parent2);
        }
        return 0;
    }
    return 0;
}

From source file:org.parosproxy.paros.core.scanner.plugin.TestExternalRedirect.java

public void scan(HttpMessage msg, String param, String value) {

    String locationHeader = null;
    String locationHeader2 = null;
    String redirect = "";

    URI uri = null;/*from  w ww.  j av a2  s . co m*/

    msg = getNewMsg();
    try {
        sendAndReceive(msg, false);
        if (msg.getResponseHeader().getStatusCode() != HttpStatusCode.MOVED_PERMANENTLY
                && msg.getResponseHeader().getStatusCode() != HttpStatusCode.FOUND) {
            // not redirect page, return;
            return;
        }

        locationHeader = msg.getResponseHeader().getHeader(HttpHeader.LOCATION);
        if (locationHeader == null) {
            return;
        }

        if (locationHeader.compareToIgnoreCase(value) == 0) {
            // URI found in param 
            redirect = redirect1;
        } else if (locationHeader.compareToIgnoreCase(getURLDecode(value)) == 0) {
            redirect = getURLEncode(redirect1);
        }

        if (redirect != null) {
            uri = new URI(locationHeader, true);
            locationHeader2 = uri.getPathQuery();
            if (locationHeader2.compareToIgnoreCase(value) == 0) {
                // path and query found in param
                redirect = redirect2;
            } else if (locationHeader2.compareToIgnoreCase(getURLDecode(value)) == 0) {
                redirect = getURLEncode(redirect2);
            }
        }

        if (redirect == null) {
            return;
        }

    } catch (Exception e) {

    }

    msg = getNewMsg();
    setParameter(msg, param, redirect);
    try {
        sendAndReceive(msg, false);
        if (checkResult(msg, param + "=" + redirect)) {
            return;
        }

    } catch (Exception e) {

    }

}

From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java

/**
 * Save values into the object./*w  w  w  .  j  a  v  a 2s  . c o m*/
**/
private void saveValues() {
    Enumeration<String> k = values.keys();
    Enumeration<JComponent> l = labels.elements();
    Enumeration<JComponent> v = values.elements();
    Enumeration<JCheckBox> c = valuesPresent.elements();
    SchemaSyntax syntax = objetSchema.getSyntax();

    while (v.hasMoreElements() && k.hasMoreElements()) {
        String key = k.nextElement();
        JComponent label = l.nextElement();
        JComponent composant = v.nextElement();
        JCheckBox checkbox = c.nextElement();

        // If SUP key, we have to modify the parent of this object.
        // SUP element should be a JTextField.
        if (key.compareToIgnoreCase("SUP") == 0 && composant instanceof JComboBox) {
            SchemaObject parent = null;
            if (checkbox.isSelected()) {
                String parentName = ((JComboBox) composant).getSelectedItem().toString().trim();
                parent = parentName.length() > 0 ? schema.getObjectByName(parentName) : null;
            }
            objetSchema.setParent(parent);
        }

        // Si la checkbox n'est pas slectionne, il faut regarder si les
        // valeurs sont prsentes dans l'objet, auquel cas on les supprime.
        if (!checkbox.isSelected()) {
            if (label instanceof JComboBox) {
                objetSchema.delValue(((JComboBox) label).getSelectedItem().toString());
            } else {
                objetSchema.delValue(key);
            }
        }

        // Ajout => deux possiblits :
        // - la clef est simple = c'est un JLabel
        // - la clef est multiple = c'est un JComboBox.
        else {
            if (label instanceof JLabel) {
                if (composant instanceof JLabel) {
                    SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(), key, "");
                    objetSchema.delValue(((JLabel) label).getText());
                    objetSchema.addValue(((JLabel) label).getText(), sv);
                } else if (composant instanceof JTextField) {
                    SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(), key,
                            ((JTextField) composant).getText());
                    objetSchema.delValue(((JLabel) label).getText());
                    objetSchema.addValue(((JLabel) label).getText(), sv);
                } else if (composant instanceof JComboBox) {
                    SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(), key,
                            ((JComboBox) composant).getSelectedItem().toString());
                    objetSchema.delValue(((JLabel) label).getText());
                    objetSchema.addValue(((JLabel) label).getText(), sv);
                }
            } else if (label instanceof JComboBox) {
                SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(),
                        ((JComboBox) label).getSelectedItem().toString(), "");
                objetSchema.delValue(((JComboBox) label).getSelectedItem().toString());
                objetSchema.addValue(((JComboBox) label).getSelectedItem().toString(), sv);
            }
        }
    }
}

From source file:org.apache.stanbol.enhancer.engine.disambiguation.mlt.DisambiguatorEngine.java

protected List<Triple> intersection(List<Suggestion> matches, List<UriRef> subsumed, MGraph graph,
        List<Triple> gainConfidence, String contentLangauge) {

    //JOptionPane.showMessageDialog(null, " intersection");
    for (int i = 0; i < subsumed.size(); i++) {
        boolean matchFound = false;
        UriRef uri = subsumed.get(i);/*from   w  w w.j a v a 2  s . c o  m*/

        UriRef uri1 = EnhancementEngineHelper.getReference(graph, uri,
                new UriRef(NamespaceEnum.fise + "entity-reference"));

        //String selectedText = EnhancementEngineHelper.getString(graph, uri, ENHANCER_ENTITY_LABEL);
        // int c=0;
        for (int j = 0; j < matches.size(); j++) {
            Suggestion suggestion = matches.get(j);
            String suggestName = suggestion.getURI();
            //JOptionPane.showMessageDialog(null, " oo3");

            if (suggestName != null && uri1 != null
                    && suggestName.compareToIgnoreCase(uri1.getUnicodeString()) == 0) {
                Triple confidenceTriple = new TripleImpl(uri, ENHANCER_CONFIDENCE,
                        LiteralFactory.getInstance().createTypedLiteral(suggestion.getScore()));
                Triple contributorTriple = new TripleImpl((UriRef) confidenceTriple.getSubject(),
                        new UriRef(NamespaceEnum.dc + "contributor"),
                        LiteralFactory.getInstance().createTypedLiteral(this.getClass().getName()));
                gainConfidence.add(confidenceTriple);
                gainConfidence.add(contributorTriple);
                matchFound = true;
            }
        }
        //   JOptionPane.showMessageDialog(null, " 53");

        if (!matchFound) {
            Triple confidenceTriple = new TripleImpl(uri, ENHANCER_CONFIDENCE,
                    LiteralFactory.getInstance().createTypedLiteral(0.0));
            Triple contributorTriple = new TripleImpl((UriRef) confidenceTriple.getSubject(),
                    new UriRef(NamespaceEnum.dc + "contributor"),
                    LiteralFactory.getInstance().createTypedLiteral(this.getClass().getName()));
            gainConfidence.add(confidenceTriple);
            gainConfidence.add(contributorTriple);
        }
    }
    //JOptionPane.showMessageDialog(null, " intersection-REteurn");

    return gainConfidence;
}