List of usage examples for java.lang String hashCode
public int hashCode()
From source file:it.polimi.modaclouds.cloudapp.mic.servlet.RegisterServlet.java
private void parseReq(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { try {/*from w w w. j a v a2 s . c om*/ MF mf = MF.getFactory(); req.setCharacterEncoding("UTF-8"); ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iterator = upload.getItemIterator(req); HashMap<String, String> map = new HashMap<String, String>(); while (iterator.hasNext()) { FileItemStream item = iterator.next(); InputStream stream = item.openStream(); if (item.isFormField()) { String field = item.getFieldName(); String value = Streams.asString(stream); map.put(field, value); stream.close(); } else { String filename = item.getName(); String[] extension = filename.split("\\."); String mail = map.get("mail"); if (mail != null) { filename = mail + "_" + String.valueOf(filename.hashCode()) + "." + extension[extension.length - 1]; } else { filename = String.valueOf(filename.hashCode()) + "." + extension[extension.length - 1]; } map.put("filename", filename); byte[] buffer = IOUtils.toByteArray(stream); mf.getBlobManagerFactory().createCloudBlobManager().uploadBlob(buffer, filename); stream.close(); } } String email = map.get("mail"); String firstName = map.get("firstName"); String lastName = map.get("lastName"); String dayS = map.get("day"); String monthS = map.get("month"); String yearS = map.get("year"); String password = map.get("password"); String filename = map.get("filename"); String date = yearS + "-" + monthS + "-" + dayS; char gender = map.get("gender").charAt(0); RequestDispatcher disp; Connection c = mf.getSQLService().getConnection(); String stm = "INSERT INTO UserProfile VALUES('" + email + "', '" + password + "', '" + firstName + "', '" + lastName + "', '" + date + "', '" + gender + "', '" + filename + "')"; Statement statement = c.createStatement(); statement.executeUpdate(stm); statement.close(); c.close(); req.getSession(true).setAttribute("actualUser", email); req.getSession(true).setAttribute("edit", "false"); disp = req.getRequestDispatcher("SelectTopic.jsp"); disp.forward(req, response); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } catch (FileUploadException e) { e.printStackTrace(); } }
From source file:org.springmodules.util.ObjectsTests.java
public void testNullSafeHashCodeWithObject() { String str = "Luke"; assertEquals(str.hashCode(), Objects.nullSafeHashCode(str)); }
From source file:com.opengamma.masterdb.security.hibernate.option.EquityIndexOptionSecurityBean.java
@Override protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -266326457: // optionExerciseType setOptionExerciseType((OptionExerciseType) newValue); return;// w ww.j a v a 2s.c om case 1373587791: // optionType setOptionType((OptionType) newValue); return; case -891985998: // strike setStrike((Double) newValue); return; case -1289159373: // expiry setExpiry((ExpiryBean) newValue); return; case 575402001: // currency setCurrency((CurrencyBean) newValue); return; case 1989774883: // exchange setExchange((ExchangeBean) newValue); return; case 1257391553: // pointValue setPointValue((Double) newValue); return; case -1770633379: // underlying setUnderlying((ExternalIdBean) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:eu.delving.sip.xml.SourceConverter.java
private String anonymizeString(String string) { if (moreNumbersThanLetters(string)) return string; StringBuilder out = new StringBuilder(string.length()); Random random = new Random(string.hashCode()); for (char c : string.toCharArray()) { if (Character.isLowerCase(c)) { out.append((char) ('a' + (Math.abs(random.nextInt()) % 26))); } else if (Character.isUpperCase(c)) { out.append((char) ('A' + (Math.abs(random.nextInt()) % 26))); } else {//from ww w .j a va 2 s .c o m out.append(c); } } return out.toString(); }
From source file:com.opengamma.masterdb.security.hibernate.option.FXDigitalOptionSecurityBean.java
@Override protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -984864697: // putAmount setPutAmount((Double) newValue); return;//ww w. j av a2 s .c o m case 1066661974: // callAmount setCallAmount((Double) newValue); return; case -1289159373: // expiry setExpiry((ExpiryBean) newValue); return; case 516393024: // putCurrency setPutCurrency((CurrencyBean) newValue); return; case 643534991: // callCurrency setCallCurrency((CurrencyBean) newValue); return; case -225763273: // paymentCurrency setPaymentCurrency((CurrencyBean) newValue); return; case -295948169: // settlementDate setSettlementDate((ZonedDateTimeBean) newValue); return; case -1180327226: // isLong setIsLong((Boolean) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:com.opengamma.masterdb.security.hibernate.option.FXOptionSecurityBean.java
@Override protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -984864697: // putAmount setPutAmount((Double) newValue); return;/*w w w . java2 s . com*/ case 1066661974: // callAmount setCallAmount((Double) newValue); return; case -1289159373: // expiry setExpiry((ExpiryBean) newValue); return; case 516393024: // putCurrency setPutCurrency((CurrencyBean) newValue); return; case 643534991: // callCurrency setCallCurrency((CurrencyBean) newValue); return; case -295948169: // settlementDate setSettlementDate((ZonedDateTimeBean) newValue); return; case -1180327226: // isLong setIsLong((Boolean) newValue); return; case -266326457: // optionExerciseType setOptionExerciseType((OptionExerciseType) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:com.pivotal.gemfire.tools.pulse.testbed.driver.TomcatHelper.java
public static Tomcat startTomcat(String bindAddress, int port, String context, String path) throws Exception { Tomcat tomcat = new Tomcat(); // Set up logging - first we're going to remove all existing handlers. Don't do this before Tomcat is // instantiated otherwise there isn't anything to remove. /*//from ww w . ja va 2 s .c om Logger globalLogger = Logger.getLogger(""); for (Handler handler : globalLogger.getHandlers()) { globalLogger.removeHandler(handler); } // Now let's add our handler Handler gfHandler = new GemFireHandler((LogWriterImpl) log); Logger logger = Logger.getLogger(""); logger.addHandler(gfHandler); */ // Set up for commons-logging which is used by Spring. // This forces JCL to use the JDK logger otherwise it defaults to trying to use Log4J. if (System.getProperty("org.apache.commons.logging.Log") == null) { System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger"); } if (bindAddress != null && bindAddress.length() > 0) { Connector c = tomcat.getConnector(); IntrospectionUtils.setProperty(c, "address", bindAddress); } tomcat.setPort(port); // Working (scratch) dir String scratch = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "Pulse_" + ((bindAddress == null || bindAddress.length() == 0) ? "0.0.0.0" : bindAddress) + "_" + port + "_" + String.format("%x", path.hashCode()); tomcat.setBaseDir(scratch); StandardHost stdHost = (StandardHost) tomcat.getHost(); //stdHost.setUnpackWARs(false); //tomcat.addContext(context, path); tomcat.addWebapp(stdHost, context, path); stdHost.setDeployOnStartup(true); tomcat.start(); return tomcat; }
From source file:com.example.jumpnote.web.server.JumpNoteServlet.java
public void enqueueDeviceMessage(PersistenceManager pm, UserInfo userInfo, String clientDeviceId) { Query query = pm.newQuery(DeviceRegistration.class); query.setFilter("ownerKey == ownerKeyParam"); query.declareParameters(Key.class.getName() + " ownerKeyParam"); @SuppressWarnings("unchecked") List<DeviceRegistration> registrations = (List<DeviceRegistration>) query.execute(userInfo.getKey()); int numDeviceMessages = 0; for (DeviceRegistration registration : registrations) { if (registration.getDeviceId().equals(clientDeviceId) || registration.getRegistrationToken() == null) continue; if (DEVICE_TYPE_ANDROID.equals(registration.getDeviceType())) { ++numDeviceMessages;//w w w .j a v a 2s .c om String email = userInfo.getEmail(); String collapseKey = Long.toHexString(email.hashCode()); try { C2DMessaging.get(getServletContext()).sendWithRetry(registration.getRegistrationToken(), collapseKey, AllConfig.C2DM_MESSAGE_EXTRA, AllConfig.C2DM_MESSAGE_SYNC, AllConfig.C2DM_ACCOUNT_EXTRA, email); } catch (IOException ex) { log.severe("Can't send C2DM message, next manual sync " + "will get the changes."); } } } log.info("Scheduled " + numDeviceMessages + " C2DM device messages for user " + userInfo.getEmail() + "."); }
From source file:com.thomaztwofast.uhc.commands.CmdUhc.java
private String getSettings(boolean a, String b) { Sc c = new Sc(); if (a) {//from w ww . j a v a2s. c om c.setConsole(); } switch (b.hashCode()) { case 50: c.setTitle("ULTRA HARDCORE 1.8 - SETTINGS \u00a78\u00a7l[\u00a7a\u00a7l2 - 5\u00a78\u00a7l]"); c.addHeader("Game"); c.addListLn("Mode", (cA.mC.cGa ? "Team" : "Solo")); if (cA.mC.cGa) { c.addListLn("Max Team Player", "" + cA.mC.cGb); c.addListLn("Friendly Fire", stat(cA.mC.cGd)); c.addListLn("See Friendly Invisibles", stat(cA.mC.cGd)); c.addListLn("Name Tag Visibility", teamTag(cA.mC.cGf)); c.addListLn("Player Collision", teamCol(cA.mC.cGg)); } c.addHeader("Server"); if (cA.mC.cFa) { c.addListLn("Server ID", "" + cA.mC.cFc); if (cA.mC.cGa) { c.addListLn("Minimum Teams To Start", "" + cA.mC.cFe); } else { c.addListLn("Minimum Players To Start", "" + cA.mC.cFd); } c.addListLn("Countdown", "" + cA.mC.cFf); c.addListLn("BungeeCord", stat(cA.mC.cFv)); if (cA.mC.cFv) { c.addListLn("Fallback Server", cA.mC.cFw); } break; } c.addListLn("Status", "Off"); break; case 51: c.setTitle("ULTRA HARDCORE 1.8 - SETTINGS \u00a78\u00a7l[\u00a7a\u00a7l3 - 5\u00a78\u00a7l]"); c.addHeader("Marker"); if (cA.mC.cNa.length() != 0 || cA.mC.cNb != 0) { c.addListLn("Message", cA.mC.cNa); c.addListLn("Delay", asClock(cA.mC.cNb * 60)); } else { c.addListLn("Status", "Off"); } c.addHeader("Freezing Starting Players"); c.addListLn("Status", stat(cA.mC.cMa)); if (cA.mC.cMa) { c.addListLn("Size", "" + cA.mC.cMb); } c.addHeader("Disconnected Ingame Players"); c.addListLn("Max Timeout", asClock(cA.mC.cPa * 60)); c.addListLn("Message", cA.mC.cPb); break; case 52: c.setTitle("ULTRA HARDCORE 1.8 - SETTINGS \u00a78\u00a7l[\u00a7a\u00a7l4 - 5\u00a78\u00a7l]"); c.addHeader("Golden Head"); if (cA.mC.cLa) { c.addListLn("Default Apple", stat(cA.mC.cLb)); c.addListLn("Golden Head Apple", stat(cA.mC.cLc)); } else { c.addListLn("Status", "Off"); } c.addHeader("Global Chat"); if (cA.mC.cQa) { c.addListLn("Default Chat", stat(cA.mC.cQb.length() != 0)); if (cA.mC.cGa) { c.addListLn("Team Chat", stat(cA.mC.cQd.length() != 0)); c.addListLn("Private Team Chat", stat(cA.mC.cQe.length() != 0)); } c.addListLn("Spectator Chat", stat(cA.mC.cQc.length() != 0)); } else { c.addListLn("Status", "Off"); } c.addHeader("Other"); c.addListLn("Damage Logger", stat(cA.mC.cOa)); c.addListLn("UHC Book", stat(cA.mC.cKa)); break; case 53: c.setTitle("ULTRA HARDCORE 1.8 - SETTINGS \u00a78\u00a7l[\u00a7a\u00a7l5 - 5\u00a78\u00a7l]"); c.addHeader("Minecraft Gamerules"); c.addListLn("Daylight Cycle", stat(cA.mC.cEa)); c.addListLn("Entity Drops", stat(cA.mC.cEb)); c.addListLn("Fire Tick", stat(cA.mC.cEc)); c.addListLn("Mob Loot", stat(cA.mC.cEd)); c.addListLn("Mob Spawning", stat(cA.mC.cEe)); c.addListLn("Tile Dropse", stat(cA.mC.cEf)); c.addListLn("Max Entity Cramming", "" + cA.mC.cEh); c.addListLn("Mob Griefing", stat(cA.mC.cEi)); c.addListLn("Random Tick Speed", "" + cA.mC.cEj); c.addListLn("Reduced Debug Info", stat(cA.mC.cEk)); c.addListLn("Spectators Generate Chunks", stat(cA.mC.cEl)); c.addListLn("Spawn Radius", "" + cA.mC.cEm); c.addListLn("Weather Cycle", "" + cA.mC.cEg); break; default: c.setTitle("ULTRA HARDCORE 1.8 - SETTINGS \u00a78\u00a7l[\u00a7a\u00a7l1 - 5\u00a78\u00a7l]"); c.addHeader("World"); c.addListLn("Sun Time", asRealClock(cA.mC.cIc)); c.addListLn("Difficulty", wDif(cA.mC.cIa)); c.addListLn("Arena Radius Size", "" + cA.mC.cIb); c.addHeader("WorldBorder"); if (cA.mC.cJd != 0) { if (cA.mC.cJa != 0) { c.addListLn("Start Delay", "" + cA.mC.cJa); } c.addListLn("Start Position", "" + cA.mC.cJb); c.addListLn("Stop Position", "" + cA.mC.cJc); c.addListLn("Shrinks Time", asClock(cA.mC.cJd)); break; } c.addListLn("Start Position", "" + cA.mC.cJb); break; } return c.o(); }
From source file:org.wso2.app.catalog.api.ApplicationManager.java
/** * Creates a webclip on the device home screen. * * @param url - URL should be passed in as a String. * @param title - Title(Web app title) should be passed in as a String. *///from w w w.ja v a2s . c o m public void manageWebAppBookmark(String url, String title, String operationType) throws AppCatalogException { final Intent bookmarkIntent = new Intent(); final Intent actionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); long urlHash = url.hashCode(); long uniqueId = (urlHash << MAX_URL_HASH) | actionIntent.hashCode(); actionIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId)); bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent); bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.ic_bookmark)); if (operationType != null) { if (resources.getString(R.string.operation_install).equalsIgnoreCase(operationType)) { bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action)); } else if (resources.getString(R.string.operation_uninstall).equalsIgnoreCase(operationType)) { bookmarkIntent .setAction(resources.getString(R.string.application_package_launcher_uninstall_action)); } else { throw new AppCatalogException("Cannot create webclip due to invalid operation type."); } } else { bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action)); } context.sendBroadcast(bookmarkIntent); }