List of usage examples for java.lang String hashCode
public int hashCode()
From source file:com.jana.android.net.Headers.java
public void parseHeader(CharArrayBuffer buffer) { int pos = CharArrayBuffers.setLowercaseIndexOf(buffer, ':'); if (pos == -1) { return;/*from w ww . ja v a 2 s. c o m*/ } String name = buffer.substringTrimmed(0, pos); if (name.length() == 0) { return; } pos++; String val = buffer.substringTrimmed(pos, buffer.length()); if (HttpLog.LOGV) { HttpLog.v("hdr " + buffer.length() + " " + buffer); } switch (name.hashCode()) { case HASH_TRANSFER_ENCODING: if (name.equals(TRANSFER_ENCODING)) { mHeaders[IDX_TRANSFER_ENCODING] = val; HeaderElement[] encodings = BasicHeaderValueParser.DEFAULT.parseElements(buffer, new ParserCursor(pos, buffer.length())); // The chunked encoding must be the last one applied RFC2616, // 14.41 int len = encodings.length; if (HTTP.IDENTITY_CODING.equalsIgnoreCase(val)) { transferEncoding = ContentLengthStrategy.IDENTITY; } else if ((len > 0) && (HTTP.CHUNK_CODING.equalsIgnoreCase(encodings[len - 1].getName()))) { transferEncoding = ContentLengthStrategy.CHUNKED; } else { transferEncoding = ContentLengthStrategy.IDENTITY; } } break; case HASH_CONTENT_LEN: if (name.equals(CONTENT_LEN)) { mHeaders[IDX_CONTENT_LEN] = val; try { contentLength = Long.parseLong(val); } catch (NumberFormatException e) { if (false) { Log.v(LOGTAG, "Headers.headers(): error parsing" + " content length: " + buffer.toString()); } } } break; case HASH_CONTENT_TYPE: if (name.equals(CONTENT_TYPE)) { mHeaders[IDX_CONTENT_TYPE] = val; } break; case HASH_CONTENT_ENCODING: if (name.equals(CONTENT_ENCODING)) { mHeaders[IDX_CONTENT_ENCODING] = val; } break; case HASH_CONN_DIRECTIVE: if (name.equals(CONN_DIRECTIVE)) { mHeaders[IDX_CONN_DIRECTIVE] = val; setConnectionType(buffer, pos); } break; case HASH_LOCATION: if (name.equals(LOCATION)) { mHeaders[IDX_LOCATION] = val; } break; case HASH_PROXY_CONNECTION: if (name.equals(PROXY_CONNECTION)) { mHeaders[IDX_PROXY_CONNECTION] = val; setConnectionType(buffer, pos); } break; case HASH_WWW_AUTHENTICATE: if (name.equals(WWW_AUTHENTICATE)) { mHeaders[IDX_WWW_AUTHENTICATE] = val; } break; case HASH_PROXY_AUTHENTICATE: if (name.equals(PROXY_AUTHENTICATE)) { mHeaders[IDX_PROXY_AUTHENTICATE] = val; } break; case HASH_CONTENT_DISPOSITION: if (name.equals(CONTENT_DISPOSITION)) { mHeaders[IDX_CONTENT_DISPOSITION] = val; } break; case HASH_ACCEPT_RANGES: if (name.equals(ACCEPT_RANGES)) { mHeaders[IDX_ACCEPT_RANGES] = val; } break; case HASH_EXPIRES: if (name.equals(EXPIRES)) { mHeaders[IDX_EXPIRES] = val; } break; case HASH_CACHE_CONTROL: if (name.equals(CACHE_CONTROL)) { // In case where we receive more than one header, create a ',' // separated list. // This should be ok, according to RFC 2616 chapter 4.2 if (mHeaders[IDX_CACHE_CONTROL] != null && mHeaders[IDX_CACHE_CONTROL].length() > 0) { mHeaders[IDX_CACHE_CONTROL] += (',' + val); } else { mHeaders[IDX_CACHE_CONTROL] = val; } } break; case HASH_LAST_MODIFIED: if (name.equals(LAST_MODIFIED)) { mHeaders[IDX_LAST_MODIFIED] = val; } break; case HASH_ETAG: if (name.equals(ETAG)) { mHeaders[IDX_ETAG] = val; } break; case HASH_SET_COOKIE: if (name.equals(SET_COOKIE)) { mHeaders[IDX_SET_COOKIE] = val; cookies.add(val); } break; case HASH_PRAGMA: if (name.equals(PRAGMA)) { mHeaders[IDX_PRAGMA] = val; } break; case HASH_REFRESH: if (name.equals(REFRESH)) { mHeaders[IDX_REFRESH] = val; } break; case HASH_X_PERMITTED_CROSS_DOMAIN_POLICIES: if (name.equals(X_PERMITTED_CROSS_DOMAIN_POLICIES)) { mHeaders[IDX_X_PERMITTED_CROSS_DOMAIN_POLICIES] = val; } break; default: mExtraHeaderNames.add(name); mExtraHeaderValues.add(val); } }
From source file:org.mycard.net.network.Headers.java
public void parseHeader(CharArrayBuffer buffer) { int pos = CharArrayBuffers.setLowercaseIndexOf(buffer, ':'); if (pos == -1) { return;/*from w w w.ja v a2 s . com*/ } String name = buffer.substringTrimmed(0, pos); if (name.length() == 0) { return; } pos++; String val = buffer.substringTrimmed(pos, buffer.length()); // if (HttpLog.LOGV) { // HttpLog.v("hdr " + buffer.length() + " " + buffer); // } switch (name.hashCode()) { case HASH_TRANSFER_ENCODING: if (name.equals(TRANSFER_ENCODING)) { mHeaders[IDX_TRANSFER_ENCODING] = val; HeaderElement[] encodings = BasicHeaderValueParser.DEFAULT.parseElements(buffer, new ParserCursor(pos, buffer.length())); // The chunked encoding must be the last one applied RFC2616, // 14.41 int len = encodings.length; if (HTTP.IDENTITY_CODING.equalsIgnoreCase(val)) { transferEncoding = ContentLengthStrategy.IDENTITY; } else if ((len > 0) && (HTTP.CHUNK_CODING.equalsIgnoreCase(encodings[len - 1].getName()))) { transferEncoding = ContentLengthStrategy.CHUNKED; } else { transferEncoding = ContentLengthStrategy.IDENTITY; } } break; case HASH_CONTENT_LEN: if (name.equals(CONTENT_LEN)) { mHeaders[IDX_CONTENT_LEN] = val; try { contentLength = Long.parseLong(val); } catch (NumberFormatException e) { //if (Config.LOGV) { // Log.v(LOGTAG, "Headers.headers(): error parsing" // + " content length: " + buffer.toString()); // } } } break; case HASH_CONTENT_TYPE: if (name.equals(CONTENT_TYPE)) { mHeaders[IDX_CONTENT_TYPE] = val; } break; case HASH_CONTENT_ENCODING: if (name.equals(CONTENT_ENCODING)) { mHeaders[IDX_CONTENT_ENCODING] = val; } break; case HASH_CONN_DIRECTIVE: if (name.equals(CONN_DIRECTIVE)) { mHeaders[IDX_CONN_DIRECTIVE] = val; setConnectionType(buffer, pos); } break; case HASH_LOCATION: if (name.equals(LOCATION)) { mHeaders[IDX_LOCATION] = val; } break; case HASH_PROXY_CONNECTION: if (name.equals(PROXY_CONNECTION)) { mHeaders[IDX_PROXY_CONNECTION] = val; setConnectionType(buffer, pos); } break; case HASH_WWW_AUTHENTICATE: if (name.equals(WWW_AUTHENTICATE)) { mHeaders[IDX_WWW_AUTHENTICATE] = val; } break; case HASH_PROXY_AUTHENTICATE: if (name.equals(PROXY_AUTHENTICATE)) { mHeaders[IDX_PROXY_AUTHENTICATE] = val; } break; case HASH_CONTENT_DISPOSITION: if (name.equals(CONTENT_DISPOSITION)) { mHeaders[IDX_CONTENT_DISPOSITION] = val; } break; case HASH_ACCEPT_RANGES: if (name.equals(ACCEPT_RANGES)) { mHeaders[IDX_ACCEPT_RANGES] = val; } break; case HASH_EXPIRES: if (name.equals(EXPIRES)) { mHeaders[IDX_EXPIRES] = val; } break; case HASH_CACHE_CONTROL: if (name.equals(CACHE_CONTROL)) { mHeaders[IDX_CACHE_CONTROL] = val; } break; case HASH_LAST_MODIFIED: if (name.equals(LAST_MODIFIED)) { mHeaders[IDX_LAST_MODIFIED] = val; } break; case HASH_ETAG: if (name.equals(ETAG)) { mHeaders[IDX_ETAG] = val; } break; case HASH_SET_COOKIE: if (name.equals(SET_COOKIE)) { mHeaders[IDX_SET_COOKIE] = val; cookies.add(val); } break; case HASH_PRAGMA: if (name.equals(PRAGMA)) { mHeaders[IDX_PRAGMA] = val; } break; case HASH_REFRESH: if (name.equals(REFRESH)) { mHeaders[IDX_REFRESH] = val; } break; default: mExtraHeaderNames.add(name); mExtraHeaderValues.add(val); } }
From source file:lcmc.data.ResourceAgent.java
/** * Prepares a new <code>ResourceAgent</code> object. *//* w w w . j a v a 2 s .c o m*/ public ResourceAgent(final String name, final String provider, final String resourceClass) { this.name = name; this.provider = provider; this.resourceClass = resourceClass; operations.addAll(Arrays.asList(ClusterBrowser.HB_OPERATIONS)); hash = (name == null ? 0 : name.hashCode() * 31) + (resourceClass == null ? 0 : resourceClass.hashCode()); if (HEARTBEAT_PROVIDER.equals(provider)) { menuName = name; } else { menuName = provider + ":" + name; } /* info fields */ String section = "Resource"; if (isClone()) { section = "Set"; } else if (isGroup()) { section = "Group"; } pingService = "ping".equals(name) || "pingd".equals(name); addParameter(ServiceInfo.GUI_ID); sectionMap.put(ServiceInfo.GUI_ID, section); paramRequired.add(ServiceInfo.GUI_ID); paramShortDesc.put(ServiceInfo.GUI_ID, "Name"); paramLongDesc.put(ServiceInfo.GUI_ID, "Name"); addInfoParameter(section, ServiceInfo.PCMK_ID, "new...", "Id", "Id"); if (!isClone() && !isGroup()) { addInfoParameter("Resource", "ra", getRAString(), "Resource Agent", "Resource Agent"); } }
From source file:com.opengamma.integration.timeseries.snapshot.RedisHtsSnapshotJobDetailComponentFactory.java
@Override protected Object propertyGet(String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -281470431: // classifier return getClassifier(); case 3373707: // name return getName(); case -332642308: // baseDir return getBaseDir(); case 98629247: // group return getGroup(); case -160710469: // scheduler return getScheduler(); case 1272470629: // dataSource return getDataSource(); case 650692196: // normalizationRuleSetId return getNormalizationRuleSetId(); case -747889643: // globalPrefix return getGlobalPrefix(); case -1707859415: // htsMaster return getHtsMaster(); case -745461486: // redisConnector return getRedisConnector(); case 836243736: // schemeBlackList return getSchemeBlackList(); case 1058119597: // dataFieldBlackList return getDataFieldBlackList(); }//from w ww . jav a2 s . c om return super.propertyGet(propertyName, quiet); }
From source file:it.mb.whatshare.MainActivity.java
/** * Returns whether the argument <tt>deviceID</tt> is valid. * // ww w . j a v a2s. c o m * @param deviceID * the ID to be checked * @return <code>true</code> if <tt>deviceID</tt> is a non-empty string that * matches {@link #VALID_DEVICE_NAME} and is not in use for any * other inbound device. */ public boolean isValidChoice(String deviceID) { if (deviceID == null || deviceID.isEmpty() || !deviceID.matches(VALID_DEVICE_NAME)) return false; int hashed = deviceID.hashCode(); for (PairedDevice device : inboundDevices) { if (hashed == device.name.hashCode()) { return false; } } return true; }
From source file:com.aujur.ebookreader.Configuration.java
private SharedPreferences getPrefsForBook(String fileName) { String bookHash = Integer.toHexString(fileName.hashCode()); return context.getSharedPreferences(bookHash, 0); }
From source file:com.github.stephanarts.cas.ticket.registry.provider.GetTicketsMethodTest.java
@Test public void testGetMultipleTickets() throws Exception { final HashMap<Integer, Ticket> map = new HashMap<Integer, Ticket>(); final JSONObject params = new JSONObject(); final IMethod method = new GetTicketsMethod(map); JSONObject result;/*from w w w . jav a2 s. c o m*/ JSONArray tickets; final String ticketId1 = "ST-1234567890ABCDEFGHIJKL-crud1"; final ServiceTicket ticket1 = mock(ServiceTicket.class, withSettings().serializable()); when(ticket1.getId()).thenReturn(ticketId1); final String ticketId2 = "ST-1234567890ABCDEFGHIJKL-crud2"; final ServiceTicket ticket2 = mock(ServiceTicket.class, withSettings().serializable()); when(ticket2.getId()).thenReturn(ticketId2); final String ticketId3 = "ST-1234567890ABCDEFGHIJKL-crud3"; final ServiceTicket ticket3 = mock(ServiceTicket.class, withSettings().serializable()); when(ticket3.getId()).thenReturn(ticketId3); map.put(ticketId1.hashCode(), ticket1); try { result = method.execute(params); if (!result.has("tickets")) { Assert.fail("key: tickets missing from result-set"); } tickets = result.getJSONArray("tickets"); Assert.assertEquals(1, tickets.length()); } catch (final JSONRPCException e) { Assert.fail(e.getMessage()); } catch (final Exception e) { throw new Exception(e); } map.put(ticketId2.hashCode(), ticket2); try { result = method.execute(params); if (!result.has("tickets")) { Assert.fail("key: tickets missing from result-set"); } tickets = result.getJSONArray("tickets"); Assert.assertEquals(2, tickets.length()); } catch (final JSONRPCException e) { Assert.fail(e.getMessage()); } catch (final Exception e) { throw new Exception(e); } map.put(ticketId3.hashCode(), ticket3); try { result = method.execute(params); if (!result.has("tickets")) { Assert.fail("key: tickets missing from result-set"); } tickets = result.getJSONArray("tickets"); Assert.assertEquals(3, tickets.length()); } catch (final JSONRPCException e) { Assert.fail(e.getMessage()); } catch (final Exception e) { throw new Exception(e); } }
From source file:com.opengamma.integration.timeseries.snapshot.RedisHtsSnapshotJobDetailComponentFactory.java
@Override protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case -281470431: // classifier setClassifier((String) newValue); return;//from ww w . j ava2s. c o m case 3373707: // name setName((String) newValue); return; case -332642308: // baseDir setBaseDir((String) newValue); return; case 98629247: // group setGroup((String) newValue); return; case -160710469: // scheduler setScheduler((Scheduler) newValue); return; case 1272470629: // dataSource setDataSource((String) newValue); return; case 650692196: // normalizationRuleSetId setNormalizationRuleSetId((String) newValue); return; case -747889643: // globalPrefix setGlobalPrefix((String) newValue); return; case -1707859415: // htsMaster setHtsMaster((HistoricalTimeSeriesMaster) newValue); return; case -745461486: // redisConnector setRedisConnector((RedisConnector) newValue); return; case 836243736: // schemeBlackList setSchemeBlackList((String) newValue); return; case 1058119597: // dataFieldBlackList setDataFieldBlackList((String) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:gov.nih.nci.evs.browser.utils.ViewInHierarchyUtils.java
private String replaceNodeID(String code) { /*//from w ww . j a v a 2 s . c o m code = code.replaceAll(":", "cCc"); code = code.replaceAll("-", "cDc"); code = code.replaceAll("_", "cUc"); code = code.replaceAll("/", "cSc"); code = code.replaceAll(".", "cEc"); return code; */ String s = "" + code.hashCode(); s = s.replace("-", "n"); return s + generateRandomString(); }
From source file:com.opengamma.core.position.impl.SimpleTrade.java
@Override protected Object propertyGet(String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -294460212: // uniqueId return getUniqueId(); case -1285004149: // quantity return getQuantity(); case 807992154: // securityLink return getSecurityLink(); case -1651301782: // counterparty return getCounterparty(); case 752419634: // tradeDate return getTradeDate(); case 752903761: // tradeTime return getTradeTime(); case -318452137: // premium return getPremium(); case 1136581512: // premiumCurrency return getPremiumCurrency(); case 651701925: // premiumDate return getPremiumDate(); case 652186052: // premiumTime return getPremiumTime(); case 405645655: // attributes return getAttributes(); }/*from w w w . jav a 2s. c om*/ return super.propertyGet(propertyName, quiet); }