List of usage examples for java.lang String hashCode
public int hashCode()
From source file:com.opengamma.core.position.impl.SimplePosition.java
@SuppressWarnings("unchecked") @Override/*from ww w . j a va 2 s. c o m*/ protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -294460212: // uniqueId setUniqueId((UniqueId) newValue); return; case -1285004149: // quantity setQuantity((BigDecimal) newValue); return; case 807992154: // securityLink setSecurityLink((SecurityLink) newValue); return; case -865715313: // trades setTrades((Collection<Trade>) newValue); return; case 405645655: // attributes setAttributes((Map<String, String>) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:eu.europeana.enrichment.tagger.vocabularies.AbstractVocabulary.java
File makeCacheFileName(String prefix, String signature, List<String> locations, String query, File cacheDir) throws Exception { File cacheFileTerms = new File(cacheDir, prefix + signature + ".q" + query.hashCode() + ".f" + StringUtils.join(locations, ";").hashCode() + ".txt"); return cacheFileTerms; }
From source file:com.dtolabs.rundeck.core.resources.URLResourceModelSource.java
private String hashURL(final String url) { try {/* w w w . j a v a 2 s .c o m*/ MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.reset(); digest.update(url.getBytes(Charset.forName("UTF-8"))); return new String(Hex.encodeHex(digest.digest())); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return Integer.toString(url.hashCode()); }
From source file:au.edu.unsw.soacourse.controller.UserController.java
@RequestMapping(value = "/processLogin") public String processLogin(ModelMap model, HttpServletRequest req) throws Exception { String email = req.getParameter("email"); String password = req.getParameter("password"); RegisteredUsersDao dao = new RegisteredUsersDao(); dao.getRegisteredUsers();/*from www .j av a 2s . c o m*/ RegisteredUser user = dao.getUser(email, password); if (user != null && !user.getRole().equalsIgnoreCase("app-manager") && !user.getRole().equals("app-reviewer")) { String role = user.getRole(); req.getSession().setAttribute("profileId", Math.abs(email.hashCode())); req.getSession().setAttribute("role", role); String queryString = "/user/" + Math.abs(email.hashCode()); WebClient client = WebClient.create(REST_URI + queryString); System.out.println(REST_URI + queryString); client.header("SecurityKey", SECURITY_KEY); client.header("ShortKey", role); client.accept(MediaType.APPLICATION_JSON); Response response = client.get(); ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(response.readEntity(String.class)); JsonNode personalDetailsNode = node.get("personalDetails"); User u = new User(); PersonalDetails pd = new PersonalDetails(); pd.setAddress(personalDetailsNode.get("address").getTextValue()); pd.setEmail(personalDetailsNode.get("email").getTextValue()); pd.setAddress(personalDetailsNode.get("address").getTextValue()); pd.setFirstName(personalDetailsNode.get("firstName").getTextValue()); pd.setLastName(personalDetailsNode.get("lastName").getTextValue()); pd.setDriverLicenseNo(personalDetailsNode.get("driverLicenseNo").getTextValue()); u.setCurrentPosition(node.get("currentPosition").getTextValue()); u.setSkills(node.get("skills").getTextValue()); u.setExperience(node.get("experience").getTextValue()); u.setEducation(node.get("education").getTextValue()); u.setProfileId(node.get("profileId").getIntValue()); u.setPersonalDetails(pd); req.getSession().setAttribute("user", u); if (role.equalsIgnoreCase("app-candidate")) { return "candidateHome"; } else if (role.equalsIgnoreCase("app-manager")) { return "managerHome"; } else if (role.equalsIgnoreCase("app-reviewer")) { return "hiringTeamHome"; } } else { model.addAttribute("loginfail", 1); } return "login"; }
From source file:com.poloniumarts.utils.ImageDownloader.java
Bitmap downloadBitmap(String url) { if (bitmapCachePath != null) { File file;/* www. j av a 2 s . co m*/ String fileName; fileName = url.hashCode() + ".jpg"; file = new File(bitmapCachePath, fileName); if (file.exists()) { Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); sHardBitmapCache.remove(url); sHardBitmapCache.put(url, bitmap); return bitmap; } } final AndroidHttpClient client = AndroidHttpClient.newInstance("Android"); final HttpGet getRequest = new HttpGet(url); try { HttpResponse response = client.execute(getRequest); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Log.w("ImageDownloader", "Error " + statusCode + " while retrieving bitmap from " + url); client.close(); return null; } final HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputStream = null; try { inputStream = entity.getContent(); // return BitmapFactory.decodeStream(inputStream); // Bug on slow connections, fixed in future release. BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.RGB_565; options.inSampleSize = 1; // Bitmap bm = BitmapFactory.decodeStream(new // FlushedInputStream(inputStream), null, null); Bitmap bm = null; if (bitmapCachePath != null) { File path = new File(bitmapCachePath); if (!path.exists()) { path.mkdirs(); } File file; file = new File(bitmapCachePath, url.hashCode() + ".jpg"); FileOutputStream fOut = new FileOutputStream(file); int read = 0; byte[] bytes = new byte[1024]; while ((read = inputStream.read(bytes)) != -1) { fOut.write(bytes, 0, read); } // bm.compress(Bitmap.CompressFormat.JPEG, 50, fOut); fOut.flush(); fOut.close(); String tmp = file.getCanonicalPath(); bm = BitmapFactory.decodeFile(file.getCanonicalPath(), options); client.close(); return bm; } else { client.close(); return BitmapFactory.decodeStream(inputStream, null, null); } } finally { if (inputStream != null) { inputStream.close(); } entity.consumeContent(); } } } catch (IOException e) { getRequest.abort(); Log.w(LOG_TAG, "I/O error while retrieving bitmap from " + url, e); } catch (IllegalStateException e) { getRequest.abort(); Log.w(LOG_TAG, "Incorrect URL: " + url); } catch (Exception e) { getRequest.abort(); Log.w(LOG_TAG, "Error while retrieving bitmap from " + url, e); } finally { client.close(); } return null; }
From source file:com.aujur.ebookreader.sync.PageTurnerWebProgressService.java
@Override public void storeProgress(String fileName, int index, int progress, int percentage) { if (!config.isSyncEnabled()) { return;//from w w w.j a v a 2 s .co m } String key = computeKey(fileName); HttpPost post = new HttpPost(getSyncServerURL() + key); String filePart = fileName; if (fileName.indexOf("/") != -1) { filePart = fileName.substring(fileName.lastIndexOf('/')); } try { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("bookIndex", "" + index)); pairs.add(new BasicNameValuePair("progress", "" + progress)); pairs.add(new BasicNameValuePair("title", Integer.toHexString(filePart.hashCode()))); pairs.add(new BasicNameValuePair("deviceName", this.config.getDeviceName())); pairs.add(new BasicNameValuePair("percentage", "" + percentage)); pairs.add(new BasicNameValuePair("userId", Integer.toHexString(this.config.getSynchronizationEmail().hashCode()))); pairs.add(new BasicNameValuePair("accessKey", this.config.getSynchronizationAccessKey())); post.setEntity(new UrlEncodedFormEntity(pairs)); post.setHeader("User-Agent", config.getUserAgent()); HttpResponse response = client.execute(post, this.httpContext); if (response.getStatusLine().getStatusCode() == HTTP_FORBIDDEN) { throw new AccessException(EntityUtils.toString(response.getEntity())); } LOG.debug("Got status " + response.getStatusLine().getStatusCode() + " from server."); } catch (Exception io) { LOG.error("Got error while POSTing update:", io); //fail silently } }
From source file:com.android.isoma.sync.PageTurnerWebProgressService.java
public void storeProgress(String fileName, int index, int progress, int percentage) { if ("".equals(this.userId)) { return;// w w w . jav a2 s . c o m } String key = computeKey(fileName); HttpPost post = new HttpPost(BASE_URL + key); String filePart = fileName; if (fileName.indexOf("/") != -1) { filePart = fileName.substring(fileName.lastIndexOf('/')); } try { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("bookIndex", "" + index)); pairs.add(new BasicNameValuePair("progress", "" + progress)); pairs.add(new BasicNameValuePair("title", Integer.toHexString(filePart.hashCode()))); pairs.add(new BasicNameValuePair("deviceName", this.deviceId)); pairs.add(new BasicNameValuePair("percentage", "" + percentage)); pairs.add(new BasicNameValuePair("userId", Integer.toHexString(this.userId.hashCode()))); post.setEntity(new UrlEncodedFormEntity(pairs)); HttpResponse response = client.execute(post, this.context); LOG.debug("Got status " + response.getStatusLine().getStatusCode() + " from server."); } catch (Exception io) { LOG.error("Got error while POSTing update:", io); //fail silently } }
From source file:com.opengamma.component.factory.livedata.PriorityResolvingCombiningLiveDataServerComponentFactory.java
@Override protected Object propertyGet(String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 39794031: // dbConnector return getDbConnector(); case -1452875317: // cacheManager return getCacheManager(); case 1984149838: // server1 return getServer1(); case 1984149839: // server2 return getServer2(); case 1984149840: // server3 return getServer3(); case 1984149841: // server4 return getServer4(); case 1984149842: // server5 return getServer5(); case 1984149843: // server6 return getServer6(); }//from w w w . j a v a 2 s . c om return super.propertyGet(propertyName, quiet); }
From source file:eagle.log.entity.meta.IndexDefinition.java
/** * Check if the query is suitable to go through index. If true, then return the value of index fields in order. Otherwise return null. * TODO: currently index fields should be string type. * //from w w w . j a va 2 s . co m * @param query query expression after re-write * @param rowkeys if the query can go through the index, all rowkeys will be added into rowkeys. * @return true if the query can go through the index, otherwise return false */ public IndexType canGoThroughIndex(ORExpression query, List<byte[]> rowkeys) { if (query == null || query.getANDExprList() == null || query.getANDExprList().isEmpty()) return IndexType.NON_CLUSTER_INDEX; if (rowkeys != null) { rowkeys.clear(); } final Map<String, String> indexfieldMap = new HashMap<String, String>(); for (ANDExpression andExpr : query.getANDExprList()) { indexfieldMap.clear(); for (AtomicExpression ae : andExpr.getAtomicExprList()) { // TODO temporarily ignore those fields which are not for attributes final String fieldName = parseEntityAttribute(ae.getKey()); if (fieldName != null && ComparisonOperator.EQUAL.equals(ae.getOp())) { indexfieldMap.put(fieldName, ae.getValue()); } } final String[] partitions = entityDef.getPartitions(); int[] partitionValueHashs = null; if (partitions != null) { partitionValueHashs = new int[partitions.length]; for (int i = 0; i < partitions.length; ++i) { final String value = indexfieldMap.get(partitions[i]); if (value == null) { throw new IllegalArgumentException( "Partition " + partitions[i] + " is not defined in the query: " + query.toString()); } partitionValueHashs[i] = value.hashCode(); } } final byte[][] indexFieldValues = new byte[columns.length][]; for (int i = 0; i < columns.length; ++i) { final IndexColumn col = columns[i]; if (!indexfieldMap.containsKey(col.getColumnName())) { // If we have to use scan anyway, there's no need to go through index return IndexType.NON_INDEX; } final String value = indexfieldMap.get(col.getColumnName()); indexFieldValues[i] = value.getBytes(); } final byte[] rowkey = generateUniqueIndexRowkey(indexFieldValues, partitionValueHashs, null); if (rowkeys != null) { rowkeys.add(rowkey); } } if (index.unique()) { return IndexType.UNIQUE_INDEX; } return IndexType.NON_CLUSTER_INDEX; }
From source file:com.opengamma.masterdb.security.hibernate.forward.CommodityForwardSecurityBean.java
@Override protected Object propertyGet(String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -1289159373: // expiry return getExpiry(); case 575402001: // currency return getCurrency(); case 1673913084: // unitAmount return getUnitAmount(); case -292854225: // unitName return getUnitName(); case 2053402093: // unitNumber return getUnitNumber(); case -1770633379: // underlying return getUnderlying(); case -1396196922: // basket return getBasket(); case 1755448466: // firstDeliveryDate return getFirstDeliveryDate(); case -233366664: // lastDeliveryDate return getLastDeliveryDate(); case 50511102: // category return getCategory(); }/*from w w w . ja va2s . c o m*/ return super.propertyGet(propertyName, quiet); }