List of usage examples for java.lang String compareToIgnoreCase
public int compareToIgnoreCase(String str)
From source file:org.mythdroid.activities.Recordings.java
private Dialog createFilterDialog() { final ArrayList<String> titles = new ArrayList<String>(); OnClickListener no = new OnClickListener() { @Override//from w w w. j a va2s. c o m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }; if (recordings == null) return new AlertDialog.Builder(this).setTitle(R.string.filterRec).setMessage(R.string.noRecs) .setPositiveButton(R.string.ok, no).create(); RECORDINGSLOOP: for (Program prog : recordings) { for (String title : titles) if (title.compareToIgnoreCase(prog.Title) == 0) continue RECORDINGSLOOP; titles.add(prog.Title); } Collections.sort(titles); return new AlertDialog.Builder(this).setTitle(R.string.filterRec).setAdapter( new ArrayAdapter<String>(this, R.layout.simple_list_item_1, titles), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); filter = titles.get(which); refresh(); } }).create(); }
From source file:com.google.dart.tools.ui.internal.typehierarchy.TypeHierarchyContentProvider_NEW.java
/** * Builds complete sub-types hierarchy in {@link #superToSubsMap}. *///from w w w .j a v a2 s .co m private void fillSubTypes(TypeHierarchyItem type, TypeItem item) { int[] subIds = type.getSubclasses(); TypeHierarchyItem[] subTypes = new TypeHierarchyItem[subIds.length]; for (int i = 0; i < subIds.length; i++) { int id = subIds[i]; subTypes[i] = items.get(id); } Arrays.sort(subTypes, new Comparator<TypeHierarchyItem>() { @Override public int compare(TypeHierarchyItem o1, TypeHierarchyItem o2) { String name1 = o1.getClassElement().getName(); String name2 = o2.getClassElement().getName(); return name1.compareToIgnoreCase(name2); } }); List<TypeItem> subItems = Lists.newArrayList(); for (TypeHierarchyItem subType : subTypes) { if (seenItems.add(subType)) { TypeItem subItem = new TypeItem(subType); subToSuperMap.put(subItem, item); subItems.add(subItem); fillSubTypes(subType, subItem); } } superToSubsMap.put(item, subItems); }
From source file:org.sipfoundry.openfire.vcard.provider.SipXVCardProvider.java
/** * Loads the vCard using the SipX vCard Provider first On failure, attempt to load it from * database.//from ww w.jav a 2s . co m * */ @Override public Element loadVCard(String username) { synchronized (username.intern()) { if (username.compareToIgnoreCase(PA_USER) == 0) { return defaultProvider.loadVCard(username); } return getVCard(username); } }
From source file:scrabble.frmStartup.java
private void txtContinueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtContinueActionPerformed String filePath = txtFilePath.getText(); // revisamos que haya seleccionar un path de archivo if (filePath.compareTo("") == 0) { //No existe un path JOptionPane.showMessageDialog(this, "Debes seleccionar un archivo para continuar.", "Error", JOptionPane.ERROR_MESSAGE); return;//from w w w. j a va2 s . c om } //verificamos que el archivo exista File f = new File(filePath); if (f.exists() && !f.isDirectory()) { String ext1 = FilenameUtils.getExtension(filePath); if (ext1.compareToIgnoreCase("xml") == 0) { //todo read xml file XStream xstream = new XStream(); try { //converting xml to object //xstream.alias("scrabble", Scrabble.class); xstream.processAnnotations(Scrabble.class); scrabble = (Scrabble) xstream.fromXML(FileUtils.readFileToString(f, Charset.defaultCharset())); //revisamos que exista al menos un jugador if (jugadores.size() > 0) { //abrir el juego this.setVisible(false); frmGame = new frmScrabbleGame(this, scrabble); frmGame.setVisible(true); frmGame.addWindowListener(this); } else { JOptionPane.showMessageDialog(this, "Ingresa al menos un jugador", "Error", JOptionPane.ERROR_MESSAGE); return; } } catch (IOException ex) { Logger.getLogger(frmStartup.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(this, "Ocurri un error al intentar leer el archivo.", "Error", JOptionPane.ERROR_MESSAGE); return; } } else { JOptionPane.showMessageDialog(this, "Extensin del archivo es incorreta. Por favor selecciona un archivo XML", "Error", JOptionPane.ERROR_MESSAGE); return; } } else { //No existe un path JOptionPane.showMessageDialog(this, "El Archivo seleccionado es incorrecto", "Error", JOptionPane.ERROR_MESSAGE); return; } }
From source file:dev.agustin.serializer.MainWindow.java
private void load3dFile() { int state = getJFileChooser().showOpenDialog(this); if (state == JFileChooser.APPROVE_OPTION) { File f = getJFileChooser().getSelectedFile(); try {/*from w ww .j a v a 2 s . c o m*/ BufferedReader br = new BufferedReader(new FileReader(f)); String fileExtension = FilenameUtils.getExtension(f.getName()); this.saveDirectory = FilenameUtils.getPath(f.getPath()); if (fileExtension.compareToIgnoreCase("3ds") == 0) { //3ds file, load in the engine try { this.objectArray = Loader.load3DS(f.getCanonicalPath(), 1); } catch (Exception ex) { System.out.print(ex.getMessage()); } } else if (fileExtension.compareToIgnoreCase("obj") == 0) { //obj file try { String mtlFile = f.getCanonicalPath().replace(".obj", ".mtl"); this.objectArray = Loader.loadOBJ(f.getCanonicalPath(), mtlFile, 1); } catch (Exception ex) { System.out.println("ERROR LOADING MATERIAL! trying without material"); System.out.print(ex.getMessage()); try { this.objectArray = Loader.loadOBJ(f.getCanonicalPath(), null, 1); } catch (Exception ex2) { System.out.println("Error loading object, aborting."); System.out.print(ex.getMessage()); } } } else { System.out.println("Error loading file " + f.getName() + " not a 3D Studio (.3DS) file"); } br.close(); setTitle(title); hasChanged = false; System.out.println("Now dumping textures names:"); Enumeration<String> textures = TextureManager.getInstance().getNames(); while (textures.hasMoreElements()) { System.out.println(textures.nextElement()); } System.out.println("Done."); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } }
From source file:org.apache.marmotta.ucuenca.wk.commons.function.SemanticDistance.java
private double ngd(String a, String b) throws IOException, SQLException { int min = 0;/*from w ww .j a va 2 s . co m*/ int min2 = 1; a = a.trim(); b = b.trim(); if (a.compareToIgnoreCase(b) == min) { return 0; } //double n0 = getResultsCount(""+a+""); //double n1 = getResultsCount(""+b+""); //String c = ""+a+" "+b+""; double n0 = getResultsCount("\"" + a + "\"~10"); double n1 = getResultsCount("\"" + b + "\"~10"); String c = "\"" + a + " " + b + "\"~50"; double n2 = getResultsCount(c); double m = 5029469; double distance = 0; int measure = 0; double l1 = Math.max(Math.log10(n0), Math.log10(n1)) - Math.log10(n2); double l2 = Math.log10(m) - Math.min(Math.log10(n0), Math.log10(n1)); if (measure == min) { distance = l1 / l2; } if (measure == min2) { distance = 1 - (Math.log10(n2) / Math.log10(n0 + n1 - n2)); } if (n0 == min || n1 == min || n2 == min) { distance = 1; } return distance; }
From source file:com.sqewd.open.dal.services.DataServices.java
@Path("/save/{type}") @POST// w ww .j av a 2s . com @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public JResponse<DALResponse> save(@Context HttpServletRequest req, @PathParam("type") String type, String data, @DefaultValue("off") @QueryParam("d") String debugs) throws Exception { try { Timer timer = new Timer(); log.debug("[ENTITY TYPE:" + type + "]"); boolean debug = false; if (debugs.compareToIgnoreCase("on") == 0) debug = true; DataManager dm = DataManager.get(); StructEntityReflect enref = ReflectionUtils.get().getEntityMetadata(type); if (enref == null) throw new Exception("No entity found for type [" + type + "]"); Class<?> typec = Class.forName(enref.Class); ObjectMapper mapper = new ObjectMapper(); AbstractEntity entity = (AbstractEntity) mapper.readValue(data, typec); if (debug) log.debug(entity.toString()); DALResponse response = new DALResponse(); OperationResponse or = dm.save(entity); response.setMessage("SAVE"); response.setData(or); response.setTimetaken(timer.stop()); return JResponse.ok(response).build(); } catch (Exception e) { LogUtils.stacktrace(log, e); log.error(e.getLocalizedMessage()); DALResponse response = new DALResponse(); response.setState(EnumResponseState.Exception); response.setMessage(e.getLocalizedMessage()); return JResponse.ok(response).build(); } }
From source file:org.pau.assetmanager.viewmodel.AnnotationViewModel.java
public List<String> getConceptsForFiltering(@BindingParam("type") String type) { List<String> conceptsForFiltering = new LinkedList<String>(); conceptsForFiltering.addAll(getConcepts(type)); // sort concept in a case-unsensitive way Collections.sort(conceptsForFiltering, new Comparator<String>() { @Override/*from w w w . j a v a2 s .c o m*/ public int compare(String stringA, String stringB) { return stringA.compareToIgnoreCase(stringB); } }); conceptsForFiltering.add(0, AnnotationsFilter.ALL_CONCEPTS); return conceptsForFiltering; }
From source file:at.gv.egovernment.moa.id.auth.servlet.SSOSendAssertionServlet.java
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String id = null;/*from w w w . jav a 2 s . c o m*/ Logger.info("Receive " + SSOSendAssertionServlet.class + " Request"); try { Object idObject = req.getParameter(ID); if (idObject != null && (idObject instanceof String)) { id = (String) idObject; } String value = req.getParameter(PARAM); value = StringEscapeUtils.escapeHtml(value); if (!ParamValidatorUtils.isValidUseMandate(value)) throw new WrongParametersException("SSOSendAssertionServlet", PARAM, null); //get module and action Object moduleObject = req.getParameter(MODULE); String module = null; if (moduleObject != null && (moduleObject instanceof String)) { module = (String) moduleObject; } Object actionObject = req.getParameter(ACTION); String action = null; if (actionObject != null && (actionObject instanceof String)) { action = (String) actionObject; } if (MiscUtil.isEmpty(module) || MiscUtil.isEmpty(action) || MiscUtil.isEmpty(id)) { Logger.warn("No Moduel or Action parameter received!"); throw new WrongParametersException("Module or Action is empty", "", "auth.10"); } SSOManager ssomanager = SSOManager.getInstance(); //get SSO Cookie for Request String ssoId = ssomanager.getSSOSessionID(req); //check SSO session if (ssoId != null) { String correspondingMOASession = ssomanager.existsOldSSOSession(ssoId); if (correspondingMOASession != null) { Logger.warn("Request sends an old SSO Session ID(" + ssoId + ")! " + "Invalidate the corresponding MOASession with ID=" + correspondingMOASession); AuthenticationSessionStoreage.destroySession(correspondingMOASession); ssomanager.deleteSSOSessionID(req, resp); } } boolean isValidSSOSession = ssomanager.isValidSSOSession(ssoId, null); String moaSessionID = null; if (isValidSSOSession) { //check UseMandate flag String valueString = null; ; if ((value != null) && (value.compareTo("") != 0)) { valueString = value; } else { valueString = "false"; } if (valueString.compareToIgnoreCase("true") == 0) { moaSessionID = AuthenticationSessionStoreage.getMOASessionSSOID(ssoId); AuthenticationSession moasession = AuthenticationSessionStoreage.getSession(moaSessionID); AuthenticationSessionStoreage.setAuthenticated(moaSessionID, true); String redirectURL = new DataURLBuilder().buildDataURL(moasession.getAuthURL(), ModulUtils.buildAuthURL(module, action, id), ""); resp.setContentType("text/html"); resp.setStatus(302); resp.addHeader("Location", redirectURL); Logger.debug("REDIRECT TO: " + redirectURL); } else { throw new AuthenticationException("auth.21", new Object[] {}); } } else { handleError("SSO Session is not valid", null, req, resp, id); } } catch (MOADatabaseException e) { handleError("SSO Session is not found", e, req, resp, id); } catch (WrongParametersException e) { handleError("Parameter is not valid", e, req, resp, id); } catch (AuthenticationException e) { handleError(e.getMessage(), e, req, resp, id); } catch (Exception e) { Logger.error("SSOSendAssertion has an interal Error.", e); } }