Example usage for java.lang String hashCode

List of usage examples for java.lang String hashCode

Introduction

In this page you can find the example usage for java.lang String hashCode.

Prototype

public int hashCode() 

Source Link

Document

Returns a hash code for this string.

Usage

From source file:com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.EntryNodeMapVisitorTest.java

public static CacheKey generateRandomCacheKey() {
    final String randomString = RandomStringUtils.random(10);
    return new CacheKey() {
        @Override/*from ww w.j  av  a 2  s  .  c o m*/
        public String getUri() {
            return randomString;
        }

        @Override
        public String getHierarchyResourcePath() {
            return randomString;
        }

        @Override
        public boolean isInvalidatedBy(CacheKey cacheKey) {
            return false;
        }

        public int hashCode() {
            return randomString.hashCode();
        }

        public String toString() {
            return randomString;
        }

        public boolean equals(Object o) {
            return false;
        }
    };
}

From source file:cn.ipanel.apps.portalBackOffice.util.CommonsFiend.java

private static String getUniqueId(int length, int maxrandom) {
    String tmpstr = "";
    String thread = (new SimpleDateFormat("yyyyMMddhhmmssSSS")).format(new Date())
            + Integer.toString(getRandom(maxrandom));
    thread = Integer.toString(thread.hashCode());
    if (thread.indexOf("-") >= 0)
        thread = thread.substring(thread.indexOf("-") + 1);
    if (thread.length() < length) {
        for (int i = thread.length(); i < length; i++)
            tmpstr = tmpstr + "0";

        thread = tmpstr + thread;// w w w. ja v  a 2 s  .com
    }
    return thread;
}

From source file:com.bizosys.dataservice.util.StringUtils.java

public static String getId(String text) {
    if (isEmpty(text))
        return text;
    return new Integer(text.hashCode()).toString();
}

From source file:com.jk.util.JKObjectUtil.java

/**
 * Hash.// www  . j  a  v a 2  s  .c o m
 *
 * @param name
 *            the name
 * @return the int
 */
public static int hash(String name) {
    return name.hashCode();
}

From source file:net.sourceforge.atunes.kernel.modules.audioscrobbler.AudioScrobblerCache.java

/**
 * Artist Info Filename/*from  w  w w . j  a va  2s . c o  m*/
 * 
 * @param artist
 * @return
 */
private static String getFileNameForArtistInfo(String artist) {
    return StringUtils.getString(artist.hashCode(), ".xml");
}

From source file:net.sourceforge.atunes.kernel.modules.audioscrobbler.AudioScrobblerCache.java

/**
 * Artist Similar Filename/*from  w w  w .  j a  v  a2 s.c o  m*/
 * 
 * @param artist
 * @return
 */
private static String getFileNameForArtistSimilar(String artist) {
    return StringUtils.getString(artist.hashCode(), ".xml");
}

From source file:net.sourceforge.atunes.kernel.modules.audioscrobbler.AudioScrobblerCache.java

/**
 * Artist Info Filename// w w  w. j  av  a 2  s  .co  m
 * 
 * @param artist
 * @return
 */
private static String getFileNameForArtistWiki(String artist) {
    return StringUtils.getString(artist.hashCode(), ".xml");
}

From source file:net.sourceforge.atunes.kernel.modules.audioscrobbler.AudioScrobblerCache.java

/**
 * Album Cover Filename//ww w . j a  va 2s  .c  o m
 * 
 * @param album
 * @return
 */
private static String getFileNameForAlbumInfo(String artist, String album) {
    return StringUtils.getString(artist.hashCode(), album.hashCode(), ".xml");
}

From source file:com.edmunds.etm.netscaler.NetScalerLoadBalancer.java

private static String getMonitorName(String serverName) {
    final String[] split = serverName.split("_");

    String value = "";
    if (split.length == 6 && !split[4].isEmpty()) {
        value = split[4];//w ww .  j a  va  2 s.c  o  m
    }

    if (value.isEmpty()) {
        value = "etm";
    }

    if (value.length() >= 16) {
        value = value.substring(0, 16);
    }

    return value + "-" + Integer.toString(serverName.hashCode());
}

From source file:com.icloud.framework.http.heritrix.ArchiveUtils.java

/**
 * Generate a long UID based on the given class and version number.
 * Using this instead of the default will assume serialization
 * compatibility across class changes unless version number is
 * intentionally bumped.//from w w w.ja  v  a  2  s  .  com
 *
 * @param class1
 * @param version
 * @return UID based off class and version number.
 */
public static long classnameBasedUID(Class<?> class1, int version) {
    String callingClassname = class1.getName();
    return (long) callingClassname.hashCode() << 32 + version;
}