List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:com.orange.oidc.tim.service.SIMStorage.java
public TokensKeys genTimAppKey(OpenidConnectParams ocp) { String status = genTimAppKey(ocp.m_server_url, ocp.m_client_id, ocp.m_scope, true); if (status != null && status.compareToIgnoreCase("0x9000") == 0) { // return tokens return read_tokens(ocp.m_server_url, ocp.m_client_id, ocp.m_scope); }/* ww w .j a v a 2 s. c o m*/ Logd(TAG, "genTimAppKey failed : " + status); return null; }
From source file:org.apache.solr.handler.component.SemanticSearchHandler.java
@Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { NamedList<Object> semanticConceptsInfo = null; String escapedQ = StringEscapeUtils .escapeJavaScript(StringEscapeUtils.escapeHtml(req.getParams().get(CommonParams.Q))); if (escapedQ != null && escapedQ.length() > 0) { String tmp = req.getParams().get("analytic"); String tmp1 = StringEscapeUtils .escapeJavaScript(StringEscapeUtils.escapeHtml(req.getParams().get("q1"))); if (tmp != null && tmp.length() > 0 && tmp.compareToIgnoreCase("relatedness") == 0 && tmp1 != null && tmp1.length() > 0) escapedQ += "___" + tmp1; SemanticSearchConfigParams params = new SemanticSearchConfigParams(); ModifiableSolrParams qparams = new ModifiableSolrParams(req.getParams()); // parse request params.wikiUrl = wikiUrl;// w w w .j a v a 2 s .c o m ParseRequestParams(req, params, qparams); // log concept to file DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); Date date = new Date(); String filename = dateFormat.format(date) + "_" + hostPort + "_" + String.valueOf(file_count); synchronized (this) { // do something thread-safe file_count++; } FileWriter f = new FileWriter("./msa_log/" + filename); f.write(escapedQ); //FileWriter f = new FileWriter("./msa_log/"+escapedQ.substring(0,escapedQ.length()>255?255:escapedQ.length())); f.close(); //req.setParams(qparams); //if(params.hidden_relax_search==false) { // super.handleRequestBody(req, rsp); //} if (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_SEARCH) { super.handleRequestBody(req, rsp); } else if (params.concepts_num >= 0 && (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_TECH_EXPLORE || params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_TECH_LANDSCAPE || params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_PRIOR)) { String orgQ = req.getParams().get(CommonParams.Q); semanticConceptsInfo = semanticsGenerator.doSemanticSearch(orgQ, params); if (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_TECH_EXPLORE) { } if (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_TECH_LANDSCAPE) { // construct new query with concepts added to it String newQuery; if (params.hidden_include_q == true) { String tmpq = orgQ; if (params.hidden_boolean == false) newQuery = getNewQuery(tmpq.toLowerCase().replace(" not ", " \\not ") .replace(" or ", " \\or ").replace(" and ", " \\and "), semanticConceptsInfo, params); else newQuery = getNewQuery(tmpq, semanticConceptsInfo, params); } else newQuery = getNewQuery("", semanticConceptsInfo, params); fillTechLandscapeQParams(newQuery, new String[] { "{!ex=fqs}publication_year,ipc_section" }, new String[] {}, params, qparams); qparams.set("fl", new String[] { "id", "title", "abstract", "assignee_orgname", "assignee_addressbook_orgname", "type", "publication_doc_number", "tags" }); req.setParams(qparams); super.handleRequestBody(req, rsp); qparams.set(CommonParams.Q, orgQ); qparams.remove("fq"); } if (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_PRIOR) { // construct new query with concepts added to it String newQuery; if (params.hidden_include_q == true) { String tmpq = req.getParams().get(CommonParams.Q); if (params.hidden_boolean == false) tmpq = tmpq.toLowerCase().replace(" not ", " \\not ").replace(" or ", " \\or ") .replace(" and ", " \\and "); newQuery = getNewQuery(tmpq, semanticConceptsInfo, params); } else newQuery = getNewQuery("", semanticConceptsInfo, params); qparams.set(CommonParams.Q, newQuery); qparams.set(CommonParams.ROWS, params.results_num); qparams.set("qf", getQuerySearchFields(params)); qparams.set("fl", new String[] { "id", "title", "abstract", "assignee_orgname", "assignee_addressbook_orgname", "type", "publication_doc_number", "tags" }); req.setParams(qparams); super.handleRequestBody(req, rsp); qparams.set(CommonParams.Q, orgQ); qparams.remove("fq"); /*ResultContext results = (org.apache.solr.response.ResultContext)rsp.getValues().get("response"); if(results!=null && results.docs!=null & results.docs.size()>0) { SolrDocumentList docs = SolrPluginUtils.docListToSolrDocumentList(results.docs, req.getSearcher(), new HashSet<String>(Arrays.asList("id")), null); for(SolrDocument doc : docs) { System.out.println(doc.getFieldValue("id")); } }*/ } } else if (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_CI) { String orgQ = req.getParams().get(CommonParams.Q); String techQ = ""; if (params.ci_freetext == false) { // construct a new query of given assignee innovations and retrieve them HttpSolrServer server = new HttpSolrServer( "http://localhost:" + hostPort + "/solr/collection1/"); ModifiableSolrParams innoQParams = new ModifiableSolrParams(); innoQParams.set(CommonParams.Q, orgQ.toLowerCase().replace(" not ", " \\not ") .replace(" or ", " \\or ").replace(" and ", " \\and ")); innoQParams.set("defType", "edismax"); innoQParams.set("qf", new String[] { "assignee" }); innoQParams.set(CommonParams.ROWS, params.ci_patents_num); innoQParams.set("sort", "publication_date desc"); // add target extract field String[] extractFields = getQueryExtractFields(params); innoQParams.set("fl", extractFields); QueryResponse innoQResp = server.query(innoQParams); // loop on results and construct a new query to explore technologies SolrDocumentList results = innoQResp.getResults(); if (results != null && results.size() > 0) { for (int i = 0; i < results.size(); i++) { SolrDocument doc = results.get(i); for (String field : extractFields) { techQ += (String) doc.getFieldValue(field) + " "; } } } } else techQ = orgQ; if (techQ.length() > 0) { if (params.ci_freetext == false || params.hidden_boolean == false) techQ = techQ.toLowerCase().replace(" not ", " \\not ").replace(" or ", " \\or ") .replace(" and ", " \\and "); semanticConceptsInfo = semanticsGenerator.doSemanticSearch(techQ, params); System.out.println(techQ); // construct new query with concepts added to it String newQuery; if (params.hidden_include_q == true) newQuery = getNewQuery(techQ, semanticConceptsInfo, params); else newQuery = getNewQuery("", semanticConceptsInfo, params); fillTechLandscapeQParams(newQuery, new String[] { "{!ex=fqs}publication_year,ipc_section" }, new String[] { "{!ex=fqs}assignee", "{!ex=fqs}assignee_addressbook_orgname_exact", "{!ex=fqs}assignee_exact" }, params, qparams); req.setParams(qparams); super.handleRequestBody(req, rsp); qparams.set(CommonParams.Q, orgQ); qparams.remove("fq"); } } else if (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_RELEVANCY) { String orgQ = req.getParams().get(CommonParams.Q); String relQ = ""; // construct a new query of given assignee innovations and retrieve them HttpSolrServer server = new HttpSolrServer("http://localhost:" + hostPort + "/solr/collection1/"); ModifiableSolrParams srcQParams = new ModifiableSolrParams(); srcQParams.set(CommonParams.Q, orgQ.toUpperCase()); srcQParams.set("defType", "edismax"); srcQParams.set("qf", new String[] { "id" }); srcQParams.set(CommonParams.ROWS, 1); // add target extract field String[] tmpf = getQueryExtractFields(params); String[] extractFields = Arrays.copyOf(tmpf, tmpf.length + 2); extractFields[tmpf.length] = "publication_date"; extractFields[tmpf.length + 1] = "*"; srcQParams.set("fl", extractFields); QueryResponse srcQResp = server.query(srcQParams); // loop on results and construct a new query to explore technologies HashMap<String, String> srcinfo = new HashMap<String, String>(); String pubdate = null; SolrDocumentList results = srcQResp.getResults(); if (results != null && results.size() == 1) { SolrDocument doc = results.get(0); for (String field : extractFields) { if (field.compareTo("publication_date") == 0) { pubdate = ((Date) doc.getFieldValue(field)).toInstant().toString(); } else if (field.compareTo("*") != 0) { String tmpval = (String) doc.getFieldValue(field); relQ += tmpval + " "; } } // add source info srcinfo.put("id", (String) doc.getFieldValue("id")); srcinfo.put("title", (String) doc.getFieldValue("title")); srcinfo.put("abstract", (String) doc.getFieldValue("abstract")); srcinfo.put("publication_date", pubdate); } else { // clear request and send back bad request syntax req.setParams(new ModifiableSolrParams()); throw new SyntaxError("(" + orgQ + ") does not exist."); } relQ = relQ.toLowerCase().replace(" not ", " \\not ").replace(" or ", " \\or ").replace(" and ", " \\and "); if (relQ.length() > 0) { semanticConceptsInfo = semanticsGenerator.doSemanticSearch(relQ, params); System.out.println(relQ); // construct new query with concepts added to it String newQuery; if (params.hidden_include_q == true) newQuery = getNewQuery(relQ, semanticConceptsInfo, params); else newQuery = getNewQuery("", semanticConceptsInfo, params); qparams.set(CommonParams.Q, newQuery); qparams.set(CommonParams.ROWS, params.priors_hits); qparams.set("qf", getQuerySearchFields(params)); qparams.set("fl", new String[] { "id" }); qparams.add("fq", "publication_date:[* TO " + pubdate + "]"); QueryResponse qResp = server.query(qparams); // loop on results and calculate relevancy results = qResp.getResults(); HashMap<String, String> priors = new HashMap<String, String>(); if (params.relevancy_priors.length > 0 && params.relevancy_priors[0].length() > 0) { for (String s : params.relevancy_priors) priors.put(s, "not found"); if (results != null && results.size() > 1) { for (int i = 0; i < results.size(); i++) { SolrDocument doc = results.get(i); String id = ((String) doc.getFieldValue("id")); if (priors.containsKey(id)) priors.put(id, String.valueOf(i + 1)); } } } else { if (results != null && results.size() > 1) { for (int i = 0; i < results.size(); i++) { SolrDocument doc = results.get(i); String id = ((String) doc.getFieldValue("id")); priors.put(id, String.valueOf(i + 1)); } } } rsp.add("sourceinfo", srcinfo); rsp.add("relevancy", priors); //req.setParams(qparams); //super.handleRequestBody(req, rsp); //qparams.set(CommonParams.Q, orgQ); //qparams.remove("fq"); } } else if (params.e_analytic_type == Enums.ENUM_ANALYTIC_TYPE.e_RELATEDNESS) { semanticConceptsInfo = semanticsGenerator.doSemanticRelatedness(req.getParams().get(CommonParams.Q), req.getParams().get("q1"), params); } // clear search string //if(params.hidden_relax_search==true || params.measure_relatedness==true) // qparams.set(CommonParams.ROWS, 0); // return back found semantic concepts in response if (semanticConceptsInfo != null) rsp.getValues().add("semantic_concepts", semanticConceptsInfo); } }
From source file:org.talend.designer.core.ui.editor.properties.DynamicTabbedPropertySection.java
/** * Sort the element order of the inputed list. * /*ww w . j a va2 s . c om*/ * @param compareList */ private void sortList(List<String> compareList) { Collections.sort(compareList, new Comparator<String>() { public int compare(String str1, String str2) { // For example: avoid job name "a_b_c" before "a_b" in the job // list. String newStr1 = str1.replaceAll("_", " "); //$NON-NLS-1$ //$NON-NLS-2$ String newStr2 = str2.replaceAll("_", " "); //$NON-NLS-1$ //$NON-NLS-2$ return newStr1.compareToIgnoreCase(newStr2); } }); }
From source file:org.kuali.kfs.module.bc.document.service.impl.BudgetDocumentServiceImpl.java
/** * @see org.kuali.kfs.module.bc.document.service.BudgetDocumentService#addOrUpdatePBGLRow(org.kuali.kfs.module.bc.document.BudgetConstructionDocument, * org.kuali.kfs.module.bc.businessobject.PendingBudgetConstructionGeneralLedger) *//*from w w w.ja va2 s . com*/ @NonTransactional public BudgetConstructionDocument addOrUpdatePBGLRow(BudgetConstructionDocument bcDoc, PendingBudgetConstructionGeneralLedger sourceRow, boolean isRevenue) { List<PendingBudgetConstructionGeneralLedger> pbglRows; if (isRevenue) { pbglRows = bcDoc.getPendingBudgetConstructionGeneralLedgerRevenueLines(); } else { pbglRows = bcDoc.getPendingBudgetConstructionGeneralLedgerExpenditureLines(); } // add or update salary setting row to set in memory - this assumes at least one row in the set // we can't even do salary setting without at least one salary detail row int index = 0; boolean insertNeeded = true; for (PendingBudgetConstructionGeneralLedger pbglRow : pbglRows) { String pbglRowKey = pbglRow.getFinancialObjectCode() + pbglRow.getFinancialSubObjectCode(); String sourceRowKey = sourceRow.getFinancialObjectCode() + sourceRow.getFinancialSubObjectCode(); if (pbglRowKey.compareToIgnoreCase(sourceRowKey) == 0) { // update insertNeeded = false; pbglRow.setAccountLineAnnualBalanceAmount(sourceRow.getAccountLineAnnualBalanceAmount()); pbglRow.setPersistedAccountLineAnnualBalanceAmount(sourceRow.getAccountLineAnnualBalanceAmount()); pbglRow.setVersionNumber(sourceRow.getVersionNumber()); break; } else { if (pbglRowKey.compareToIgnoreCase(sourceRowKey) > 0) { // insert here - drop out break; } } index++; } if (insertNeeded) { // insert the row sourceRow.setPersistedAccountLineAnnualBalanceAmount(sourceRow.getAccountLineAnnualBalanceAmount()); pbglRows.add(index, sourceRow); } return bcDoc; }
From source file:com.vuze.android.remote.SessionInfo.java
@Nullable public List<Map<?, ?>> getTags() { if (mapTags == null) { return null; }/*from w w w . j av a 2 s . c om*/ ArrayList<Map<?, ?>> list = new ArrayList<>(); synchronized (mLock) { for (int i = 0, num = mapTags.size(); i < num; i++) { list.add(mapTags.valueAt(i)); } } Collections.sort(list, new Comparator<Map<?, ?>>() { @Override public int compare(Map<?, ?> lhs, Map<?, ?> rhs) { int lType = MapUtils.getMapInt(lhs, "type", 0); int rType = MapUtils.getMapInt(rhs, "type", 0); if (lType < rType) { return -1; } if (lType > rType) { return 1; } String lhGroup = MapUtils.getMapString(lhs, "group", ""); String rhGroup = MapUtils.getMapString(rhs, "group", ""); int i = lhGroup.compareToIgnoreCase(rhGroup); if (i != 0) { return i; } String lhName = MapUtils.getMapString(lhs, "name", ""); String rhName = MapUtils.getMapString(rhs, "name", ""); return lhName.compareToIgnoreCase(rhName); } }); return list; }
From source file:vitro.vgw.wsiadapter.TCSWSIAdapter.java
private int coapObservationRequest(Node node, Resource resource) throws UnknownHostException, VitroGatewayException { int messageIDToReturn = UNDEFINED_COAP_MESSAGE_ID; String proxyAddress = getProxyAddress(node); //proxyAddress = node.getId(); if (proxyAddress != null) { String moteUriResource = ""; if (MoteResource.containsValue(resource)) { //moteUriResource += "temperature";//MoteResource.getMoteUriResource(resource); String theResourceName = MoteResource.getMoteUriResource(resource); if (theResourceName == null) { logger.error("unsupported resource"); return UNDEFINED_COAP_MESSAGE_ID; }/*from w w w. j av a2 s. co m*/ // FOR TCS adapter, we prefer the TEMPERATURE_TCS // FOR WLAB and HAI we prefer the TEMPERATURE_ALT // we do this check because the getMoteUriResource is making a reverse lookup in the hashmap (where two keys point to the same resource) if (theResourceName.compareToIgnoreCase(MoteResource.TEMPERATURE_ALT) == 0) { theResourceName = MoteResource.TEMPERATURE_TCS; } moteUriResource += theResourceName; int PORT = Constants.COAP_DEFAULT_PORT; // 15/04 CoapClientChannel clientChannelObservations = null; try { // *** Alternative approach if (!proxyAddrToClientChannelObservationsHM.isEmpty() && proxyAddrToClientChannelObservationsHM.containsKey(proxyAddress) && proxyAddrToClientChannelObservationsHM.get(proxyAddress) != null) { //re use it. clientChannelObservations = proxyAddrToClientChannelObservationsHM.get(proxyAddress); } else { clientChannelObservations = channelManager.connect((CoapClient) this, InetAddress.getByName(proxyAddress), PORT); if (clientChannelObservations != null) { proxyAddrToClientChannelObservationsHM.put(proxyAddress, clientChannelObservations); } else { logger.error("Impossible to setup a coap channel for observations!"); return UNDEFINED_COAP_MESSAGE_ID; } } // *** end of alternative approach // == Fix that was still causing too many open files: //if(clientChannelObservations!= null) { // clientChannelObservations.close(); //} //clientChannelObservations = channelManager.connect((CoapClient) this, InetAddress.getByName(proxyAddress), PORT); // == end of fix // clientChannelObservations = channelManager.connect(this, InetAddress.getByName("localhost"), PORT); CoapRequest coapRequest = clientChannelObservations.createRequest(true, CoapRequestCode.GET); //coapRequest.setProxyUri("coap://[" + node.getId() + "]:5683/" + moteUriResource); coapRequest.setUriHost(node.getId()); System.out.println("l'host " + node.getId()); coapRequest.setUriPort(PORT); System.out.println("la porta " + PORT); coapRequest.setUriPath(moteUriResource); System.out.println("l'URI " + coapRequest.getUriPath()); clientChannelObservations.sendMessage(coapRequest); messageIDToReturn = coapRequest.getMessageID(); logger.info("Sent Request: " + coapRequest.toString()); //clientChannelObservations.close(); } catch (Exception ex) { logger.error("Could not setup a coap channel or send the coapObservationRequest message!", ex); if (clientChannelObservations != null) { //clientChannelObservations.close(); } throw new WSIAdapterException("Unable to send coap observe req to " + node.getId() + " and Resource " + resource.getName()); } finally { if (clientChannelObservations != null) { //clientChannelObservations.close(); } } } else { logger.warn("No resource mapping for Node " + node.getId() + " and Resource " + resource.getName()); throw new WSIAdapterException( "No resource mapping for Node " + node.getId() + " and Resource " + resource.getName()); } // } else { logger.warn("No available proxy for Node " + node.getId() + " is found"); throw new WSIAdapterException("No available proxy for Node " + node.getId() + " is found"); } return messageIDToReturn; }
From source file:org.wso2.carbon.governance.api.util.GovernanceUtils.java
/** * Query to search for governance artifacts. */*w ww . j a v a 2 s . co m*/ * @param mediaType the media type of the artifacts to be searched for. * @param registry the registry instance to run query on. * @return the list of artifact paths. * @throws RegistryException if the operation failed. */ public static String[] findGovernanceArtifacts(String mediaType, Registry registry) throws RegistryException { String[] paths = MediaTypesUtils.getResultPaths(registry, mediaType); if (paths == null) { paths = new String[0]; } Arrays.sort(paths, new Comparator<String>() { public int compare(String o1, String o2) { int result = RegistryUtils.getResourceName(o1) .compareToIgnoreCase(RegistryUtils.getResourceName(o2)); if (result == 0) { return o1.compareToIgnoreCase(o2); } return result; } }); return paths; }
From source file:FilenameUtils.java
/** * Compares two strings using the case-sensitivity rule. * <p>/* ww w.j a v a 2s.c o m*/ * This method mimics {@link String#compareTo} but takes case-sensitivity * into account. * * @param str1 the first string to compare, not null * @param str2 the second string to compare, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ public int checkCompareTo(String str1, String str2) { if (str1 == null || str2 == null) { throw new NullPointerException("The strings must not be null"); } return sensitive ? str1.compareTo(str2) : str1.compareToIgnoreCase(str2); }
From source file:org.globus.mds.bigindex.impl.database.xml.xindice.XindiceDriver.java
public boolean findDocument(String parentCol, String documentName) throws Exception { checkInitialized();//from www . ja v a 2 s. com boolean found = false; if (this.isProfiling) { this.performanceLogger.start(); } String[] documents = this.listCollectionDocuments(parentCol); for (int i = 0; i < documents.length; i++) { if (documentName.compareToIgnoreCase(documents[i]) == 0) { found = true; break; } } if (this.isProfiling) { this.performanceLogger.stop("FindDocument"); } return found; }
From source file:org.globus.mds.bigindex.impl.database.xml.xindice.XindiceDriver.java
public boolean findCollection(String parentCol, String collectionName) throws Exception { checkInitialized();//ww w .ja v a 2s.co m boolean found = false; String[] collections = this.listChildCollections(parentCol); if (this.isProfiling) { this.performanceLogger.start(); } for (int i = 0; i < collections.length; i++) { if (collectionName.compareToIgnoreCase(collections[i]) == 0) { found = true; break; } } if (this.isProfiling) { this.performanceLogger.stop("FindCollection"); } return found; }