List of usage examples for java.lang String hashCode
public int hashCode()
From source file:net.sourceforge.processdash.data.util.ResultSet.java
private static String fixupName(String name) { return "anonymousChart" + name.hashCode(); }
From source file:com.wuman.androidimageloader.ImageLoader.java
private static String urlToKey(String url) { return Integer.toHexString(url.hashCode()); }
From source file:ca.oson.json.util.ObjectUtil.java
public static int hashCode(Object obj, Class valueType) { int hash = 7; try {//from ww w .j a va 2 s . c o m if (obj == null) { hash = valueType.hashCode(); } else { hash = obj.hashCode(); } } catch (Exception ex) { } if (obj != null && Math.abs(hash) < 100) { String str = obj.toString(); hash += str.hashCode(); } return hash; }
From source file:com.amazon.carbonado.layout.LayoutFactory.java
/** * Returns an annotation hash code using a algorithm similar to the * default. The difference is in the handling of class and enum values. The * name is chosen for the hash code component instead of the instance * because it is stable between invocations of the JVM. *//*from w w w . j a v a 2 s . com*/ private static int annHashCode(Annotation ann) { int hash = 0; Method[] methods = ann.getClass().getDeclaredMethods(); for (Method m : methods) { if (m.getReturnType() == null || m.getReturnType() == void.class) { continue; } if (m.getParameterTypes().length != 0) { continue; } String name = m.getName(); if (name.equals("hashCode") || name.equals("toString") || name.equals("annotationType")) { continue; } Object value; try { value = m.invoke(ann); } catch (InvocationTargetException e) { continue; } catch (IllegalAccessException e) { continue; } hash += (127 * name.hashCode()) ^ annValueHashCode(value); } return hash; }
From source file:org.esupportail.portlet.filemanager.utils.MemoryMapPathEncodingUtils.java
public String encodeDir(String path) { String encPath = PREFIX_CODE + path.hashCode(); if (!idsPathes.containsKey(encPath)) idsPathes.put(encPath, path);// ww w .ja v a2 s. c om return encPath; }
From source file:com.microsoft.Malmo.Utils.TextureHelper.java
public static void glBindTexture(int target, int texture) { // The Minecraft render code is selecting a texture. // If we are producing a colour map, this is our opportunity to activate our special fragment shader, // which will ignore the texture and use a solid colour - either the colour we pass in, or a colour based // on the texture coords (if using the block texture atlas). if (isProducingColourMap && colourmapFrame) { if (shaderID != -1) { // Have we encountered this texture before? Integer col = texturesToColours.get(texture); if (col == null) { // No - are we drawing an entity? if (currentEntity != null) { // Has the user requested a specific mapping? if (idealMobColours != null) { // Yes, in which case use black unless a mapping is found: col = 0;/*from w ww .j a v a 2s . co m*/ String entName = EntityList.getKey(currentEntity).toString(); for (String ent : idealMobColours.keySet()) { if (entName.equals(ent)) { col = idealMobColours.get(ent); } } } else { // Provide a default mapping from entity to colour String ent = EntityList.getEntityString(currentEntity); if (ent == null) // Happens if, for example, currentEntity is of type EntityOtherPlayerMP. ent = currentEntity.getClass().getName(); col = (ent.hashCode()) % 0xffffff; } texturesToColours.put(texture, col); } else { // Not drawing an entity. Check the misc mappings: for (String resID : miscTexturesToColours.keySet()) { ITextureObject tex = Minecraft.getMinecraft().getTextureManager() .getTexture(new ResourceLocation(resID)); if (tex != null && tex.getGlTextureId() == texture) { // Match col = miscTexturesToColours.get(resID); } } if (col == null) { // Still no match. // Finally, see if this is the block atlas texture: ITextureObject blockatlas = Minecraft.getMinecraft().getTextureManager() .getTexture(new ResourceLocation("textures/atlas/blocks.png")); if (blockatlas != null && blockatlas.getGlTextureId() == texture) { col = -1; } } if (col != null) // Put this in the map for easy access next time. texturesToColours.put(texture, col); } } if (col != null) { OpenGlHelper.glUseProgram(shaderID); int entColUniformLocR = OpenGlHelper.glGetUniformLocation(shaderID, "entityColourR"); int entColUniformLocG = OpenGlHelper.glGetUniformLocation(shaderID, "entityColourG"); int entColUniformLocB = OpenGlHelper.glGetUniformLocation(shaderID, "entityColourB"); if (entColUniformLocR != -1 && entColUniformLocG != -1 && entColUniformLocB != -1) { OpenGlHelper.glUniform1i(entColUniformLocR, col != -1 ? (col >> 16) & 0xff : -1); OpenGlHelper.glUniform1i(entColUniformLocG, col != -1 ? (col >> 8) & 0xff : -1); OpenGlHelper.glUniform1i(entColUniformLocB, col != -1 ? col & 0xff : -1); } } else OpenGlHelper.glUseProgram(0); } } // Finally, pass call on to OpenGL: GL11.glBindTexture(target, texture); }
From source file:com.cloudera.recordbreaker.hive.CSVSerDe.java
GenericData.Record deserializeRowBlob(Writable blob) { String rowStr = ((Text) blob).toString(); if (("" + rowStr.hashCode()).compareTo(headerRowHash) == 0) { return null; }// w w w .jav a2 s .c om return rowParser.parseRow(rowStr); }
From source file:org.arrow.runtime.meta.MapProcessMetaDataRepository.java
/** * {@inheritDoc} */ @Override public ProcessMetaData findById(String processId) { return MAP.get(processId.hashCode()); }
From source file:net.sf.ehcache.constructs.concurrent.ConcurrencyUtilTest.java
/** * Tests that stripes are evently distributed */// ww w .j a va 2s. c o m public void testStripingDistribution() { int[] lockIndexes = new int[2048]; for (int i = 0; i < 20480 * 3; i++) { String key = "" + i * 3 / 2 + i; key += key.hashCode(); int lock = ConcurrencyUtil.selectLock(key, 2048); lockIndexes[lock]++; } int outliers = 0; for (int i = 0; i < 2048; i++) { if (20 <= lockIndexes[i] && lockIndexes[i] <= 40) { continue; } LOG.info(i + ": " + lockIndexes[i]); outliers++; } assertTrue(outliers <= 128); }
From source file:ColorHelper.java
public int getColorIndexFor(String ident) { return Math.abs(ident.hashCode()) % staticColors.size(); }