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.sillelien.dollar.test.CircleCiParallelRule.java

@Override
public Statement apply(Statement statement, @NotNull Description description) {

    boolean runTest = true;

    final String tName = description.getClassName() + "#" + description.getMethodName();

    final String numNodes = System.getenv("CIRCLE_NODE_TOTAL");
    final String curNode = System.getenv("CIRCLE_NODE_INDEX");

    if (StringUtils.isBlank(numNodes) || StringUtils.isBlank(curNode)) {
        System.out.println("Running locally, so skipping");
    } else {/*from  w w  w.  j a v  a 2  s. c  o m*/
        final int hashCode = Math.abs(tName.hashCode());

        int nodeToRunOn = hashCode % Integer.parseInt(numNodes);
        final int curNodeInt = Integer.parseInt(curNode);

        runTest = nodeToRunOn == curNodeInt;

        System.out.println(
                "currentNode: " + curNodeInt + ", targetNode: " + nodeToRunOn + ", runTest: " + runTest);

        if (!runTest) {
            return new Statement() {
                @Override
                public void evaluate() {
                    Assume.assumeTrue("Skipping test, currentNode: " + curNode + ", targetNode: " + nodeToRunOn,
                            false);
                }
            };
        }
    }

    return statement;
}

From source file:com.xpn.xwiki.plugin.graphviz.GraphVizPlugin.java

/**
 * Executes GraphViz, writes the resulting image (in the requested format) in a temporary file on disk, and returns
 * the filename which can be later used in {@link #outputDotImageFromFile(String, XWikiContext)}.
 * /*  w  ww.  j av  a 2  s .  com*/
 * @param content the dot source code
 * @param extension the output file extension
 * @param dot which engine to execute: {@code dot} if {@code true}, {@code neato} if {@code false}
 * @return the name of the file where the generated output is stored
 * @throws IOException if writing the input or output files to the disk fails
 */
public String writeDotImage(String content, String extension, boolean dot) throws IOException {
    int hashCode = Math.abs(content.hashCode());
    getDotImage(hashCode, content, extension, dot);
    String name = (dot ? DOT_ENGINE : NEATO_ENGINE) + '-';
    return name + hashCode + "." + extension;
}

From source file:net.padlocksoftware.padlock.license.LicenseImpl.java

@Override
public int hashCode() {
    int hash = 11;
    for (String key : propertyNames(props)) {
        hash = hash + key.hashCode() + props.getProperty(key).hashCode();
    }/*from   ww w .  java  2s .co  m*/
    return hash;
}

From source file:org.wso2.emm.agent.api.ApplicationManager.java

/**
 * Creates a webclip on the device home screen.
 * @param url   - URL should be passed in as a String.
 * @param title - Title(Web app title) should be passed in as a String.
 *///  w w  w  . ja v  a  2  s  . c o m
public void manageWebAppBookmark(String url, String title, String operationType) throws AndroidAgentException {
    final Intent bookmarkIntent = new Intent();
    final Intent actionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    long urlHash = url.hashCode();
    long uniqueId = (urlHash << MAX_URL_HASH) | actionIntent.hashCode();

    actionIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, actionIntent);
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
    bookmarkIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
            Intent.ShortcutIconResource.fromContext(context, R.drawable.ic_bookmark));
    if (operationType != null) {
        if (resources.getString(R.string.operation_install).equalsIgnoreCase(operationType)) {
            bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action));
        } else if (resources.getString(R.string.operation_uninstall).equalsIgnoreCase(operationType)) {
            bookmarkIntent
                    .setAction(resources.getString(R.string.application_package_launcher_uninstall_action));
        } else {
            throw new AndroidAgentException("Cannot create webclip due to invalid operation type.");
        }
    } else {
        bookmarkIntent.setAction(resources.getString(R.string.application_package_launcher_install_action));
    }
    context.sendBroadcast(bookmarkIntent);
}

From source file:com.gbcom.system.domain.base.BaseSysRegistration.java

public int hashCode() {
    if (Integer.MIN_VALUE == this.hashCode) {
        if (null == this.getId())
            return super.hashCode();
        else {/*from w w w . j a va2 s .  co m*/
            String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
            this.hashCode = hashStr.hashCode();
        }
    }
    return this.hashCode;
}

From source file:org.sylvani.bot.util.HttpUtil.java

public File download(String url) throws IOException {
    HttpClient httpClient = null;//from w w  w.  j  a  v  a  2 s  .  c  o m
    HttpGet httpget = new HttpGet(url);
    HttpResponse response = httpClient.execute(httpget);
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        long len = entity.getContentLength();
        InputStream inputStream = entity.getContent();
        // How do I write it?
        File tmpFile = File.createTempFile(String.valueOf(url.hashCode()), "tmp");
        try (FileOutputStream oStream = new FileOutputStream(tmpFile)) {
            IOUtils.copy(inputStream, oStream);
        }
        return tmpFile;
    }
    return null;
}

From source file:com.sastix.cms.server.services.content.impl.HashedDirectoryServiceImpl.java

/**
 * Generates a new filename based  on the input filename.
 *
 * @param hash a String with the hash/*ww w  .j  a v  a  2s  .c  om*/
 * @return a String with the new filepath
 */
private String getFilename(String hash) {
    final int hashcode = hash.hashCode();
    final int mask = 255;
    final int[] directories = new int[DIRECTORY_DEPTH];
    for (int i = 0; i < DIRECTORY_DEPTH; i++) {
        directories[i] = (hashcode >> 8 * i) & mask;
    }
    final StringBuilder path = new StringBuilder(File.separator);
    for (int directory : directories) {
        path.append(String.format("%03d", directory));
        path.append(File.separator);
    }
    path.append(hash);
    return path.toString();
}

From source file:com.opengamma.core.position.impl.SimplePortfolio.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -294460212: // uniqueId
        return getUniqueId();
    case 3373707: // name
        return getName();
    case -167026172: // rootNode
        return getRootNode();
    case 405645655: // attributes
        return getAttributes();
    }//  ww w  .jav a  2s  . co  m
    return super.propertyGet(propertyName, quiet);
}

From source file:com.opengamma.component.factory.engine.EngineConfigurationComponentFactory.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -281470431: // classifier
        setClassifier((String) newValue);
        return;//from w  w  w . j  av  a  2  s .  c  o m
    case -917704420: // fudgeContext
        setFudgeContext((FudgeContext) newValue);
        return;
    case -41854233: // logicalServerId
        setLogicalServerId((String) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.opengamma.masterdb.security.hibernate.cash.CashSecurityBean.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 575402001: // currency
        return getCurrency();
    case -934795532: // region
        return getRegion();
    case 109757538: // start
        return getStart();
    case 313843601: // maturity
        return getMaturity();
    case 1905311443: // dayCount
        return getDayCount();
    case 3493088: // rate
        return getRate();
    case -1413853096: // amount
        return getAmount();
    }//  www .  j a  v a  2s. c  om
    return super.propertyGet(propertyName, quiet);
}