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:io.github.retz.protocol.data.Job.java

public Job(String appName, String cmd, Properties props, int cpu, int memMB) {
    this.appid = appName;
    this.cmd = cmd;
    this.name = Integer.toString(cmd.hashCode());
    this.props = props;
    assert cpu > 0 && memMB >= 32;
    this.cpu = cpu;
    this.memMB = memMB;
    this.gpu = 0;
    this.diskMB = 0;
    this.ports = 0;
    this.state = CREATED;
    this.retry = 0;
    this.priority = 0;
}

From source file:com.feathercoin.wallet.feathercoin.ExchangeRatesProvider.java

@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    final long now = System.currentTimeMillis();

    if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) {
        Map<String, ExchangeRate> newExchangeRates = getFeathercoinCharts();
        if (exchangeRates == null && newExchangeRates == null)
            newExchangeRates = getBlockchainInfo();

        if (newExchangeRates != null) {
            exchangeRates = newExchangeRates;
            lastUpdated = now;//  w w w.j  a  v a  2  s . co m
        }
    }

    if (exchangeRates == null)
        return null;

    final MatrixCursor cursor = new MatrixCursor(
            new String[] { BaseColumns._ID, KEY_CURRENCY_CODE, KEY_RATE, KEY_SOURCE });

    if (selection == null) {
        for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) {
            final ExchangeRate rate = entry.getValue();
            cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate.longValue())
                    .add(rate.source);
        }
    } else if (selection.equals(KEY_CURRENCY_CODE)) {
        final String code = selectionArgs[0];
        final ExchangeRate rate = exchangeRates.get(code);
        try {
            cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate.longValue())
                    .add(rate.source);
        } catch (NullPointerException e) {
            Log.e("Feathercoin", "Unable to add an exchange rate.  NullPointerException.");
        }
    }

    return cursor;
}

From source file:nl.vumc.biomedbridges.galaxy.GalaxyWorkflowEngineTest.java

/**
 * Get the history contents list that corresponds to the workflow output IDs.
 *
 * @param workflowOutputIds the workflow output IDs.
 * @return the history contents list./*from   w  ww .ja  v a  2  s.c  om*/
 */
private List<HistoryContents> getHistoryContentsList(final List<String> workflowOutputIds) {
    final List<HistoryContents> historyContentsList = new ArrayList<>();
    for (final String workflowOutputId : workflowOutputIds) {
        final HistoryContents historyContents = new HistoryContents();
        historyContents.setHid(workflowOutputId.hashCode());
        historyContents.setName("name-for-" + workflowOutputId);
        historyContentsList.add(historyContents);
    }
    return historyContentsList;
}

From source file:info.joseluismartin.gtc.VeCache.java

/**
 * {@inheritDoc}// w w w.j  ava 2  s.c  o m
 */
@Override
protected String getCachePath(Tile tile) {
    VeTile t = (VeTile) tile;
    int x = t.getX();
    int y = t.getY();
    int zoom = t.getZoom() + 2;
    String type = t.getType();
    String layer = t.getLayer();
    String g = t.getG();
    String mkt = t.getMkt();

    String path = getCachePath() + File.separator + getPath();
    if (!StringUtils.isBlank(type)) {
        path += File.separator + type;
    }

    if (!StringUtils.isBlank(layer)) {
        path += File.separator + Integer.toHexString(layer.hashCode());
    }

    if (!StringUtils.isBlank(g))
        path += File.separator + g;

    if (!StringUtils.isBlank(mkt))
        path += File.separator + mkt;

    path += File.separator + zoom + File.separator + x / 1024 + File.separator + x % 1024 + File.separator
            + y / 1024 + File.separator + y % 1024 + ".png";

    return path;
}

From source file:org.slf4j.impl.PiazzaLogger.java

/**
 * Sends the logger payload to pz-logger
 * // www  .  ja v a  2s . com
 * @param loggerPayload
 *            payload
 * 
 */
private void sendLogs(LoggerPayload payload, String logMessage, Severity severity) {

    // Setting generic fields on logger payload
    payload.setSeverity(severity);
    payload.setMessage(logMessage);
    payload.setMessageId(logMessage.hashCode());
    payload.setTimestamp(new DateTime());

    try {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);

        // Log to console if requested
        try {
            if (logToConsole.booleanValue()) {
                System.out.println(payload.toString());
            }
        } catch (Exception exception) { /* Do nothing. */
            System.out.println(String.format("%s: %s", "Application property is not set", exception));
        }

        // post to pz-logger
        if (PZ_LOGGER_URL != null) {
            String url = String.format("%s/%s", PZ_LOGGER_URL, PZ_LOGGER_ENDPOINT);
            restTemplate.postForEntity(url, new HttpEntity<LoggerPayload>(payload, headers), String.class);
        } else {
            System.out.println(
                    "Cannot log to Pz-Logger because no 'logger.url' property was found in the environment.");
        }
    } catch (Exception exception) {
        System.out.println(String.format("%s: %s", "PiazzaLogger could not log", exception));
    }
}

From source file:com.opengamma.masterdb.security.hibernate.equity.EquitySecurityBean.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 1989774883: // exchange
        setExchange((ExchangeBean) newValue);
        return;/* w w  w .  j a v  a 2s  . c  om*/
    case -2028219097: // shortName
        setShortName((String) newValue);
        return;
    case -508582744: // companyName
        setCompanyName((String) newValue);
        return;
    case 575402001: // currency
        setCurrency((CurrencyBean) newValue);
        return;
    case 762040799: // gicsCode
        setGicsCode((GICSCodeBean) newValue);
        return;
    case -1294005119: // preferred
        setPreferred((Boolean) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

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

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -281470431: // classifier
        return getClassifier();
    case -917704420: // fudgeContext
        return getFudgeContext();
    case -41854233: // logicalServerId
        return getLogicalServerId();
    }// ww  w  .  ja  v a2 s.c o m
    return super.propertyGet(propertyName, quiet);
}

From source file:com.opengamma.masterdb.security.hibernate.fx.FXForwardSecurityBean.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 1652755475: // forwardDate
        setForwardDate((ZonedDateTimeBean) newValue);
        return;/*  w  w  w . j  av a 2  s .  co m*/
    case -934795532: // region
        setRegion((ExternalIdBean) newValue);
        return;
    case -295641895: // payCurrency
        setPayCurrency((CurrencyBean) newValue);
        return;
    case -1338781920: // payAmount
        setPayAmount((Double) newValue);
        return;
    case -1228590060: // receiveCurrency
        setReceiveCurrency((CurrencyBean) newValue);
        return;
    case 984267035: // receiveAmount
        setReceiveAmount((Double) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:de.schildbach.wallet.worldcoin.ExchangeRatesProvider.java

@Override
public Cursor query(final Uri uri, final String[] projection, final String selection,
        final String[] selectionArgs, final String sortOrder) {
    final long now = System.currentTimeMillis();

    if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) {
        Map<String, ExchangeRate> newExchangeRates = getworldcoinCharts();
        if (exchangeRates == null && newExchangeRates == null)
            newExchangeRates = getBlockchainInfo();

        if (newExchangeRates != null) {
            exchangeRates = newExchangeRates;
            lastUpdated = now;//w w w .  j  ava  2s  .  c  om
        }
    }

    if (exchangeRates == null)
        return null;

    final MatrixCursor cursor = new MatrixCursor(
            new String[] { BaseColumns._ID, KEY_CURRENCY_CODE, KEY_RATE, KEY_SOURCE });

    if (selection == null) {
        for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) {
            final ExchangeRate rate = entry.getValue();
            cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate.longValue())
                    .add(rate.source);
        }
    } else if (selection.equals(KEY_CURRENCY_CODE)) {
        final String code = selectionArgs[0];
        final ExchangeRate rate = exchangeRates.get(code);
        try {
            cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate.longValue())
                    .add(rate.source);
        } catch (NullPointerException e) {
            Log.e("worldcoin", "Unable to add an exchange rate.  NullPointerException.");
        }
    }

    return cursor;
}

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

/**
 * Executes GraphViz and return the content of the resulting image (PNG format).
 * //from   www. j  a va  2s .  c  om
 * @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 content of the generated file
 * @throws IOException if writing the input or output files to the disk fails
 */
public byte[] getDotImage(String content, String extension, boolean dot) throws IOException {
    int hashCode = Math.abs(content.hashCode());
    return getDotImage(hashCode, content, extension, dot);
}