List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:com.sfs.whichdoctor.formatter.PersonFormatter.java
public static Collection<Object> getCollection(final PersonBean person, final String section) { Collection<Object> collection = new ArrayList<Object>(); if (section != null) { if (section.compareTo("Specialties") == 0 && person.getSpecialtyList() != null) { for (SpecialtyBean specialty : person.getSpecialtyList()) { collection.add(specialty); }//from w w w . j a va2s . c o m } if (section.compareTo("Addresses") == 0 && person.getAddress() != null) { for (AddressBean address : person.getAddress()) { collection.add(address); } } if (section.compareTo("Phone Numbers") == 0 && person.getPhone() != null) { for (PhoneBean phone : person.getPhone()) { collection.add(phone); } } if (section.compareTo("Email Addresses") == 0 && person.getEmail() != null) { for (EmailBean email : person.getEmail()) { collection.add(email); } } if (section.compareTo("Exams") == 0 && person.getExams() != null) { for (ExamBean exam : person.getExams()) { collection.add(exam); } } if (section.compareTo("Qualifications") == 0 && person.getMembershipDetails() != null) { for (QualificationBean qualification : person.getQualifications()) { collection.add(qualification); } } if (section.compareTo("Affiliations") == 0 && person.getMembershipDetails() != null) { for (MembershipBean membership : person.getMembershipDetails()) { if (StringUtils.equalsIgnoreCase(membership.getMembershipClass(), "RACP") && StringUtils.equalsIgnoreCase(membership.getMembershipType(), "Affiliation")) { collection.add(membership); } } } if (section.compareTo("Workplaces") == 0 && person.getEmployers() != null) { for (String index : person.getEmployers().keySet()) { ItemBean employer = person.getEmployers().get(index); collection.add(employer); } } if (section.compareTo("Memos") == 0 && person.getMemo() != null) { for (MemoBean memo : person.getMemo()) { collection.add(memo); } } } return collection; }
From source file:com.optimusinfo.elasticpath.cortex.cart.AsyncTaskGetCompleteCart.java
@Override protected void onPostExecute(String responseCart) { super.onPostExecute(responseCart); try {/* www.j a va 2s. c om*/ if (responseCart != null && responseCart.length() != 0) { if (0 == responseCart.compareTo(Integer.toString(Constants.ApiResponseCode.UNAUTHORIZED_ACCESS))) { mListener.onAuthenticationFailed(); } else { mListener.onTaskSuccessful(new Gson().fromJson(responseCart, CartModel.class)); } } } catch (NullPointerException e) { e.printStackTrace(); } catch (JsonParseException e) { e.printStackTrace(); mListener.onTaskFailed(Constants.ErrorCodes.ERROR_SERVER); } }
From source file:com.smart.network.JsonResponseHelper.java
public boolean IsStatusOK() { String status; try {//from w w w . ja v a2 s . c o m status = new JSONObject(mJsonResult).getString("status"); if (status.compareTo("200") == 0) { mValidStatus = true; } else { mValidStatus = false; } } catch (JSONException e) { // TODO Auto-generated catch block mValidStatus = false; e.printStackTrace(); } return mValidStatus; }
From source file:com.sfs.dao.UserPreferencesDAOImpl.java
/** * Load the UserPreferencesBean for the supplied dn. * * @param dn the dn// ww w . j a va 2 s . c o m * * @return the user preferences bean * * @throws SFSDaoException the SFS dao exception */ @SuppressWarnings("unchecked") public final UserPreferencesBean load(final String dn) throws SFSDaoException { if (dn == null) { throw new SFSDaoException("Error: DN cannot be null"); } if (dn.compareTo("") == 0) { throw new SFSDaoException("Error: DN cannot be an empty string"); } UserPreferencesBean userPreferences = new UserPreferencesBean(); userPreferences.setDN(dn); dataLogger.info("Loading privileges for: " + dn); try { Collection<String[]> indexValue = this.getJdbcTemplateReader().query( this.getSQL().getValue("userPreferences/load"), new Object[] { userPreferences.getDN() }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { final String index = rs.getString("IndexValue"); final String value = rs.getString("Value"); return new String[] { index, value }; } }); for (String[] keyPair : indexValue) { if (keyPair[0] != null) { userPreferences.setOption(keyPair[0], keyPair[1]); } } } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return userPreferences; }
From source file:com.jxt.web.vo.AgentActiveThreadCountList.java
public List<AgentActiveThreadCount> getAgentActiveThreadRepository() { // sort agentId Collections.sort(agentActiveThreadRepository, new Comparator<AgentActiveThreadCount>() { @Override//www .jav a2 s . c o m public int compare(AgentActiveThreadCount o1, AgentActiveThreadCount o2) { final String agentId1 = StringUtils.defaultString(o1.getAgentId(), ""); final String agentId2 = StringUtils.defaultString(o2.getAgentId(), ""); return agentId1.compareTo(agentId2); } }); return agentActiveThreadRepository; }
From source file:com.example.android.actionbarcompat.MainActivity.java
public void bindButton(String button, boolean override) { // TODO Auto-generated method stub if (button.compareTo("volumeup") == 0) { this.volumeupBound = override; } else if (button.compareTo("volumedown") == 0) { this.volumedownBound = override; }//ww w . j av a 2 s . co m }
From source file:jsentvar.DataMapperTest.java
/** * Test of queryLabel method, of class DataMapper. *///from w w w . ja va2 s. com @Test public void testQueryLabel() { System.out.println("queryLabel Test"); String term_uri = "http://glluch.com/ieee_taxonomy#Artificial_intelligence"; DataMapper instance = new DataMapper(); instance.setModel(this.model); String expResult = "SELECT ?label WHERE {<http://glluch.com/ieee_taxonomy#Artificial_intelligence> <http://www.w3.org/2000/01/rdf-schema#label> ?label}"; String result = instance.queryLabel(term_uri).trim(); //System.out.println("Res="+result); //System.out.println("Esp="+expResult); int diff = result.compareTo(expResult); //System.out.println("diff="+diff); assertEquals(diff, 0); //fail("Error testing queryLabel in DataMapper class!!."); }
From source file:de.contentreich.instrumentation.SpringBeansHelper.java
public List<String[]> getSpringBeans(ApplicationContext appContext, String parentId) { logger.debug("Get spring beans for context " + parentId); ArrayList<String[]> beans = new ArrayList<String[]>(); String[] names = appContext.getBeanDefinitionNames(); for (int i = 0; i < names.length; i++) { String beanName = names[i]; DefaultListableBeanFactory beanFactory = getBeanFactory(appContext); Class clazz = getBeanClass(beanName, beanFactory); // DefaultListableBeanFactory beanFactory = (appContext instanceof DefaultListableBeanFactory) ? (DefaultListableBeanFactory) appContext : null; if (clazz != null && beanFactory != null) { // Not abstract BeanDefinition def = beanFactory.getBeanDefinition(beanName); if (!(def.isPrototype() || def.isLazyInit())) { Object bean = appContext.getBean(beanName); if (holdsChildApplicationContext(bean)) { // Semantically not perfect but ok ;) clazz = getApplicationContext(bean).getClass(); }//from ww w. j a va 2 s . c o m } String[] beanEntry = new String[] { beanName, clazz.getName(), parentId }; beans.add(beanEntry); } } Collections.sort(beans, new Comparator() { @Override public int compare(Object o1, Object o2) { String s1 = ((String[]) o1)[0]; String s2 = ((String[]) o2)[0]; return s1.compareTo(s2); } }); logger.debug("Got " + beans.size() + " spring beans"); return beans; }
From source file:de.contentreich.instrumentation.SpringBeansHelper.java
public List<String[]> getPublicMethodSignatures(String className) { logger.debug("Get public method signatures for class " + className); ArrayList<String[]> methodSignatures = new ArrayList<String[]>(); try {//from ww w . j av a 2 s. co m Class clazz = Class.forName(className); List<Method> methods = (List<Method>) Arrays.asList(clazz.getMethods()); // Filtering - a pita in java for (Iterator<Method> iterator = methods.iterator(); iterator.hasNext();) { Method method = iterator.next(); if (!method.getDeclaringClass().getName().startsWith("java") && Modifier.isPublic(method.getModifiers())) { methodSignatures.add(new String[] { method.toString(), method.getDeclaringClass().getName() }); } } Collections.sort(methodSignatures, new Comparator() { @Override public int compare(Object o1, Object o2) { String s1 = ((String[]) o1)[0]; String s2 = ((String[]) o2)[0]; return s1.compareTo(s2); } }); } catch (ClassNotFoundException cnfe) { throw new RuntimeException(cnfe); } return methodSignatures; }
From source file:com.smart.network.JsonResponseHelper.java
/** * Returns the error description associated with the given error code. * * @param result The error code//from w w w . j a v a 2 s . c o m * @param context The <code>Activity</code> * @return The error description associated with the code */ public String GetErrorDescription() { String description = null; String result; try { result = new JSONObject(mJsonResult).getString("status"); if (result.compareTo("408") == 0) { description = Constants.error408; } else if (result.compareTo("451") == 0) { description = Constants.error451; } else if (result.compareTo("452") == 0) { description = Constants.error452; } else if (result.compareTo("453") == 0) { description = Constants.error453; } else if (result.compareTo("454") == 0) { description = Constants.error454; } else if (result.compareTo("455") == 0) { description = Constants.error455; } else if (result.compareTo("456") == 0) { description = Constants.error456; } else if (result.compareTo("457") == 0) { description = Constants.error457; } else if (result.compareTo("458") == 0) { description = Constants.error458; } else if (result.compareTo("459") == 0) { description = Constants.error459; } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return description; }