List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:org.apache.stanbol.enhancer.engine.disambiguation.mlt.DisambiguatorEngine.java
protected String findContext(String label, List<String> allEntities, String a) { String allEntityString = ""; //JOptionPane.showMessageDialog(null, " a= "+a); for (int i = 0; i < allEntities.size(); i++) { if (label.compareToIgnoreCase(allEntities.get(i)) != 0 && (a != null) && (a.contains(allEntities.get(i)))) { allEntityString = allEntityString + " " + allEntities.get(i); }/*from www.j av a2 s .c o m*/ //JOptionPane.showMessageDialog(null, " 1a= "+a+" allE0 "+allEntities.get(i)+"tot "+allEntityString); } return allEntityString; }
From source file:jails.http.MediaType.java
/** * Compares this {@link MediaType} to another alphabetically. * @param other media type to compare to * @see #sortBySpecificity(List)//w w w .j av a 2 s . co m */ public int compareTo(MediaType other) { int comp = this.type.compareToIgnoreCase(other.type); if (comp != 0) { return comp; } comp = this.subtype.compareToIgnoreCase(other.subtype); if (comp != 0) { return comp; } comp = this.parameters.size() - other.parameters.size(); if (comp != 0) { return comp; } TreeSet<String> thisAttributes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); thisAttributes.addAll(this.parameters.keySet()); TreeSet<String> otherAttributes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); otherAttributes.addAll(other.parameters.keySet()); Iterator<String> thisAttributesIterator = thisAttributes.iterator(); Iterator<String> otherAttributesIterator = otherAttributes.iterator(); while (thisAttributesIterator.hasNext()) { String thisAttribute = thisAttributesIterator.next(); String otherAttribute = otherAttributesIterator.next(); comp = thisAttribute.compareToIgnoreCase(otherAttribute); if (comp != 0) { return comp; } String thisValue = this.parameters.get(thisAttribute); String otherValue = other.parameters.get(otherAttribute); if (otherValue == null) { otherValue = ""; } comp = thisValue.compareTo(otherValue); if (comp != 0) { return comp; } } return 0; }
From source file:photosharing.api.conx.RecommendationDefinition.java
/** * manages the recommendations for a file * /*from w ww . ja v a2 s. c o m*/ * @see photosharing.api.base.APIDefinition#run(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public void run(HttpServletRequest request, HttpServletResponse response) { /** * get the users bearer token from the session object */ HttpSession session = request.getSession(false); Object o = session.getAttribute(OAuth20Handler.CREDENTIALS); if (o == null) { logger.warning("Credentials can't be found"); response.setStatus(HttpStatus.SC_BAD_REQUEST); } else { OAuth20Data data = (OAuth20Data) o; String bearer = data.getAccessToken(); // Parameters to use String likeParam = request.getParameter("r"); // r = recommendation String lid = request.getParameter("lid"); String uid = request.getParameter("uid"); // Test is the key parameters are invalid if (likeParam == null || likeParam.isEmpty() || lid == null || uid == null || uid.isEmpty() || lid.isEmpty()) { response.setStatus(HttpStatus.SC_PRECONDITION_FAILED); } // Branches to removing a recommendation else if (likeParam.compareToIgnoreCase("off") == 0) { String nonce = getNonce(bearer, response); if (!nonce.isEmpty()) { unlike(bearer, uid, lid, nonce, response); } } // Branches to creating a recommendation else if (likeParam.compareToIgnoreCase("on") == 0) { String nonce = getNonce(bearer, response); if (!nonce.isEmpty()) { like(bearer, uid, lid, nonce, response); } } // Catch all for Response Code SC_PRECONDITION_FAILED (412) else { response.setStatus(HttpStatus.SC_PRECONDITION_FAILED); } } }
From source file:com.couchbase.jdbc.core.ProtocolImpl.java
@Override public void setSchema(String schema) throws SQLException { if (schema != null && schema.compareToIgnoreCase("system") == 0) { schema = '#' + schema; }//from ww w. java2 s. c o m this.schema = schema; }
From source file:org.andstatus.app.net.social.ConnectionPumpio.java
ConnectionAndUrl getConnectionAndUrl(ApiRoutineEnum apiRoutine, String userId) throws ConnectionException { ConnectionAndUrl conu = new ConnectionAndUrl(); conu.url = this.getApiPath(apiRoutine); if (TextUtils.isEmpty(conu.url)) { throw new ConnectionException(StatusCode.UNSUPPORTED_API, "The API is not supported yet: " + apiRoutine); }/* www . j a v a2 s .co m*/ if (TextUtils.isEmpty(userId)) { throw new IllegalArgumentException(apiRoutine + ": userId is required"); } String username = userOidToUsername(userId); String nickname = usernameToNickname(username); if (TextUtils.isEmpty(nickname)) { throw new IllegalArgumentException(apiRoutine + ": wrong userId=" + userId); } String host = usernameToHost(username); conu.httpConnection = http; if (TextUtils.isEmpty(host)) { throw new IllegalArgumentException(apiRoutine + ": host is empty for the userId=" + userId); } else if (http.data.originUrl == null || host.compareToIgnoreCase(http.data.originUrl.getHost()) != 0) { MyLog.v(this, "Requesting data from the host: " + host); HttpConnectionData connectionData1 = http.data.clone(); connectionData1.oauthClientKeys = null; connectionData1.originUrl = UrlUtils.buildUrl(host, connectionData1.isSsl); conu.httpConnection = http.getNewInstance(); conu.httpConnection.setConnectionData(connectionData1); } if (!conu.httpConnection.data.areOAuthClientKeysPresent()) { conu.httpConnection.registerClient(getApiPath(ApiRoutineEnum.REGISTER_CLIENT)); if (!conu.httpConnection.getCredentialsPresent()) { throw ConnectionException.fromStatusCodeAndHost(StatusCode.NO_CREDENTIALS_FOR_HOST, "No credentials", conu.httpConnection.data.originUrl); } } conu.url = conu.url.replace("%nickname%", nickname); return conu; }
From source file:gov.nih.nci.evs.browser.utils.MappingSearchUtils.java
public ResolvedConceptReferencesIteratorWrapper searchByNameOrCode(Vector schemes, Vector versions, String matchText, String matchAlgorithm, int maxToReturn, String searchTarget) { if (searchTarget.compareToIgnoreCase(SearchUtils.SEARCH_BY_CODE_ONLY) == 0) { return searchByCode(schemes, versions, matchText, matchAlgorithm, SearchContext.SOURCE_OR_TARGET_CODES, maxToReturn);/* www . j ava 2s . c o m*/ } else { return searchByName(schemes, versions, matchText, matchAlgorithm, maxToReturn); } }
From source file:com.eTilbudsavis.etasdk.model.Shoppinglist.java
/** * Compare method, that uses the {@link Shoppinglist#getName() name} * to compare two lists./*from w ww .j a v a 2s . c o m*/ */ public int compareTo(Shoppinglist another) { if (another == null) return -1; String t1 = getName(); String t2 = another.getName(); if (t1 == null || t2 == null) { return t1 == null ? (t2 == null ? 0 : 1) : -1; } //ascending order return t1.compareToIgnoreCase(t2); }
From source file:org.georchestra.security.HeadersManagementStrategy.java
/** * Copies the request headers from the original request to the proxy request. It may modify the * headers slightly// ww w . ja v a 2 s . c o m */ @SuppressWarnings("unchecked") public synchronized void configureRequestHeaders(HttpServletRequest originalRequest, HttpRequestBase proxyRequest) { Enumeration<String> headerNames = originalRequest.getHeaderNames(); String headerName = null; StringBuilder headersLog = new StringBuilder("Request Headers:\n"); headersLog.append("==========================================================\n"); if (referer != null) { addHeaderToRequestAndLog(proxyRequest, headersLog, REFERER_HEADER_NAME, this.referer); } while (headerNames.hasMoreElements()) { headerName = headerNames.nextElement(); if (headerName.compareToIgnoreCase(CONTENT_LENGTH) == 0) { continue; } if (headerName.equalsIgnoreCase(COOKIE_ID)) { continue; } if (filter(originalRequest, headerName, proxyRequest)) { continue; } if (noAcceptEncoding && headerName.equalsIgnoreCase(ACCEPT_ENCODING)) { continue; } if (headerName.equalsIgnoreCase(HOST)) { continue; } // Don't forward 'sec-*' headers, those headers must be managed by security-proxy if (headerName.toLowerCase().startsWith(PROTECTED_HEADER_PREFIX)) { continue; } if (referer != null && headerName.equalsIgnoreCase(REFERER_HEADER_NAME)) { continue; } String value = originalRequest.getHeader(headerName); addHeaderToRequestAndLog(proxyRequest, headersLog, headerName, value); } // see https://github.com/georchestra/georchestra/issues/509: addHeaderToRequestAndLog(proxyRequest, headersLog, SEC_PROXY, "true"); handleRequestCookies(originalRequest, proxyRequest, headersLog); HttpSession session = originalRequest.getSession(); for (HeaderProvider provider : headerProviders) { for (Header header : provider.getCustomRequestHeaders(session, originalRequest)) { if ((header.getName().equalsIgnoreCase(SEC_USERNAME) || header.getName().equalsIgnoreCase(SEC_ROLES)) && proxyRequest.getHeaders(header.getName()) != null && proxyRequest.getHeaders(header.getName()).length > 0) { Header[] originalHeaders = proxyRequest.getHeaders(header.getName()); for (Header originalHeader : originalHeaders) { headersLog.append("\t" + originalHeader.getName()); headersLog.append("="); headersLog.append(originalHeader.getValue()); headersLog.append("\n"); } } else { proxyRequest.addHeader(header); headersLog.append("\t" + header.getName()); headersLog.append("="); headersLog.append(header.getValue()); headersLog.append("\n"); } } } headersLog.append("=========================================================="); logger.trace(headersLog.toString()); }
From source file:com.symbian.driver.core.controller.tasks.TEFTask.java
public Map<? extends Exception, ESeverity> execute(Task aTask, PreProcessor aSymbianDevice) { // step1 : prepare TEF command String lTargetScript = iTestExecuteScript.getSymbianPath(); // get rid of $: from symbian path lTargetScript = lTargetScript.replace("$:", ILiterals.C); String lOperator = null;//from www . ja va2 s. c o m String lTestCasesString = ""; TestCasesList lTestCasesList = iTestExecuteScript.getTestCasesList(); // Get TestCases if there are any if (lTestCasesList != null) { lOperator = lTestCasesList.getOperator().getLiteral().equalsIgnoreCase("exclude") ? "-tcx" : "-tci"; Iterator lIter = lTestCasesList.getTestCase().iterator(); while (lIter.hasNext()) { TestCase lTestCase = (TestCase) lIter.next(); String lTarget = lTestCase.getTarget(); if (ModelUtils.isTestCasesFile(lTarget)) { // if it's file then calculate the destination. lTestCasesString = lTestCasesString + (new File(lTargetScript)).getParent().toString() + File.separator + (new File(lTarget)).getName(); lTestCasesString = lTestCasesString.replace("$:", ILiterals.C); } else { // it's either a range or a single test case lTestCasesString = lTestCasesString + lTarget; } if (lIter.hasNext()) { lTestCasesString = lTestCasesString + ","; } } } if (lOperator != null && lTestCasesString != "") { lTargetScript = lTargetScript + " " + lOperator + " " + lTestCasesString; } // Create TEF process try { iDeviceProxy = DeviceCommsProxy.getInstance(); } catch (Exception lException) { LOGGER.log(Level.SEVERE, lException.getMessage(), lException); iExceptions.put(lException, ESeverity.ERROR); return iExceptions; } List<String> lArgs = new LinkedList<String>(); lArgs.add(lTargetScript); String lUCCAddress = null; try { lUCCAddress = CONFIG.getPreference(TDConfig.UCC_IP_ADDRESS); } catch (ParseException lParseException) { iExceptions.put(lParseException, ESeverity.ERROR); LOGGER.log(Level.WARNING, "Could not get the UCC Address. Please ensure you have specified the correct address using the -f switch.", lParseException); return iExceptions; } // step2 : start a serial listener if necessary SerialListener listen = null; // if TEF is configured for logchannel = serial / both then have the // serial listener here String lChannel = CONFIG.getLogChannel(); if (lChannel == null) { lChannel = "file"; // BC } if (lChannel != null && (lChannel.compareToIgnoreCase("serial") == 0 || lChannel.compareToIgnoreCase("both") == 0)) { // also consider giving it the results path to dump the real time // logs into... try { String lScriptName = new File(iTestExecuteScript.getSymbianPath()).getName().replaceAll("\\.script", ".log"); File lPCResultPath = new File(CONFIG.getPreferenceFile(TDConfig.RESULT_ROOT) + ModelUtils.getBaseDirectory((Task) iTestExecuteScript.eContainer().eContainer(), CONFIG.getPreferenceInteger(TDConfig.RUN_NUMBER)) + File.separator); File lPCLogFile = new File(lPCResultPath.getAbsolutePath() + lScriptName); if (!lPCResultPath.isDirectory() && !lPCResultPath.mkdirs()) { LOGGER.severe("Could not create result folder: " + lPCResultPath); iExceptions.put(new Exception("Could not create result folder"), ESeverity.ERROR); } else { listen = new SerialListener(CONFIG.getPreference(TDConfig.TEFPORT), lPCLogFile); } } catch (ParseException parseEx) { LOGGER.log(Level.SEVERE, parseEx.getMessage(), parseEx); iExceptions.put(parseEx, ESeverity.ERROR); } } // step3 : prepare crash-monitoring if specified to do so boolean lRecovery = isRecoveryOn(); if (lRecovery) monitorTestApps(); // step4 : run the process be it UCC or normal boolean lRes = false; // Execute the Test if (lUCCAddress != null && !lUCCAddress.equalsIgnoreCase("")) { // Run Script with UCC lRes = runUCC(lArgs, aTask); } else { // Run Script without UCC lRes = runRegular(lArgs, aTask); } if (lRes) { if (lChannel != null && (lChannel.compareToIgnoreCase("file") == 0 || lChannel.compareToIgnoreCase("both") == 0)) { retrieveResultFile(aTask); } else if (lChannel != null && (lChannel.compareToIgnoreCase("serial") == 0 || lChannel.compareToIgnoreCase("both") == 0)) { if (listen != null) { listen.setM_Life(false); // kill the listener thread. } } } // step5 : check crash status, if crash happens, retrieve crash data try { if (lRecovery) { if (CoreDumpProxy.getInstance().isAppCrash()) retrieveCrashData(); // Stop PCDS if it's running if (CoreDumpProxy.getInstance().stopServer()) LOGGER.info("PCDS stopped successfully!"); else LOGGER.info("Failed to stop PCDS!"); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Unable to create PCDS proxy. Recovery disabled!", e); } return iExceptions; }
From source file:org.apache.archiva.common.utils.VersionComparator.java
@Override public int compare(String o1, String o2) { if (o1 == null && o2 == null) { return 0; }/*from w w w . j a v a 2s . co m*/ if (o1 == null) { return 1; } if (o2 == null) { return -1; } String[] parts1 = toParts(o1); String[] parts2 = toParts(o2); int diff; int partLen = Math.max(parts1.length, parts2.length); for (int i = 0; i < partLen; i++) { diff = comparePart(safePart(parts1, i), safePart(parts2, i)); if (diff != 0) { return diff; } } diff = parts2.length - parts1.length; if (diff != 0) { return diff; } return o1.compareToIgnoreCase(o2); }