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:org.slc.sli.dashboard.util.UserCacheKeyGenerator.java

@Override
public Object generate(Object target, Method method, Object... params) {

    String token = SecurityUtil.getToken();

    int hashCode = 17;
    hashCode = 31 * hashCode + (token == null ? NULL_PARAM_KEY : token.hashCode());
    hashCode = 31 * hashCode + method.getDeclaringClass().hashCode();
    hashCode = 31 * hashCode + method.getName().hashCode();

    for (Object object : params) {
        hashCode = 31 * hashCode + (object == null ? NULL_PARAM_KEY : object.hashCode());
    }/* w  w  w  .  j av a  2 s.  co m*/
    return Integer.valueOf(hashCode);
}

From source file:com.eyc.statusBarNotification.StatusBarNotification.java

/**
 * Cancels a single notification by tag.
 *
 * @param tag Notification tag to cancel.
 *//*w  ww .  ja  v a 2s. c om*/
public void clearNotification(String tag) {
    mNotificationManager.cancel(tag.hashCode());
}

From source file:org.arrow.service.DefaultExecutionScriptService.java

/**
 * {@inheritDoc}//from   w w w .j ava2  s  .  c  o  m
 */
@Override
public Object evaluateCompiledGroovy(ScriptSource source, ScriptEvaluationContext context) {

    try {
        final String script = source.getScriptAsString();

        if (GROOVY_SCRIPT_CACHE.containsKey(script.hashCode())) {
            return GROOVY_SCRIPT_CACHE.get(script.hashCode()).run();
        }

        GroovyShell shell = new GroovyShell();
        context.getArguments().forEach((k, v) -> shell.setVariable((String) k, v));
        Script gs = shell.parse(new StringReader(source.getScriptAsString()));

        GROOVY_SCRIPT_CACHE.put(script.hashCode(), gs);
        return gs.run();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

}

From source file:com.frostwire.frostclick.TorrentPromotionSearchResult.java

@Override
public int uid() {
    if (uid == -1) {
        String key = getDisplayName() + getDetailsUrl() + getSource() + getHash();
        uid = key.hashCode();
    }//from   w  ww.  j a v  a2 s  . c om
    return uid;
}

From source file:eu.esdihumboldt.hale.io.geoserver.template.Templates.java

private String createRandomTemplateName(String templateResource) {
    return "template" + templateResource.hashCode() + System.currentTimeMillis() + ".vm";
}

From source file:com.thoughtworks.go.security.GoCipher.java

public int passwordHashcode(String cipherText) {
    try {/*from w  ww  . j a  va 2  s . c  o m*/
        String decrypt = decrypt(cipherText);
        return decrypt.hashCode();
    } catch (CryptoException e) {
        return ("bad-password-" + cipherText).hashCode();
    }
}

From source file:com.example.android.donebar.DoneBarActivity.java

public int generateId() {
    UUID idOne = UUID.randomUUID();
    String str = "" + idOne;
    int uid = str.hashCode();
    String filterStr = "" + uid;
    str = filterStr.replaceAll("-", "");
    return Integer.parseInt(str);
}

From source file:edu.northwestern.bioinformatics.studycalendar.web.template.period.PeriodActivitiesGridRowKey.java

@Override
public int hashCode() {
    int result;/* w  w  w  .j av  a 2  s. co  m*/
    result = (activityId != null ? activityId.hashCode() : 0);
    result = 31 * result + (details != null ? details.hashCode() : 0);
    result = 31 * result + (condition != null ? condition.hashCode() : 0);
    String thisLabels = getComparableLabels();
    result = 31 * result + (thisLabels != null ? thisLabels.hashCode() : 0);
    result = 31 * result + (weight != null ? weight.hashCode() : 0);
    return result;
}

From source file:org.jasig.cas.adaptors.ldap.services.LdapServiceRegistryDao.java

public RegisteredService save(final RegisteredService rs) {
    final RegisteredServiceImpl registeredService = (RegisteredServiceImpl) rs;
    if (registeredService.getId() != -1) {
        return update(registeredService);
    }/*from  ww  w. java  2  s  .  c  o  m*/
    final DirContextAdapter ctx = this.ldapServiceMapper.createCtx(this.serviceBaseDn, registeredService);
    final String dn = ctx.getNameInNamespace();
    registeredService.setId(dn.hashCode());
    this.ldapServiceMapper.doMapToContext(registeredService, ctx);
    this.ldapTemplate.bind(ctx.getNameInNamespace(), ctx, null);
    return registeredService;
}

From source file:org.apache.drill.exec.store.mpjdbc.MPJdbcFormatConfig.java

@Override
public int hashCode() {
    ObjectMapper mapper = new ObjectMapper();
    try {//from w w w .  ja v a2s .  c  o m
        String outval = mapper.writeValueAsString(this);
        logger.info("FormatConfigHashCode:" + outval);

        return outval.hashCode();
    } catch (JsonProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return uri.hashCode();
    }
}