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.opengamma.masterdb.security.hibernate.option.SwaptionSecurityBean.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -1289159373: // expiry
        return getExpiry();
    case -1770633379: // underlying
        return getUnderlying();
    case -871053882: // cashSettled
        return getCashSettled();
    case 116685664: // longShort
        return getLongShort();
    case 106443605: // payer
        return getPayer();
    case 575402001: // currency
        return getCurrency();
    case 1585636160: // notional
        return getNotional();
    case -266326457: // optionExerciseType
        return getOptionExerciseType();
    case -295948169: // settlementDate
        return getSettlementDate();
    }/*from ww w .j  av a 2s. c om*/
    return super.propertyGet(propertyName, quiet);
}

From source file:ch.epfl.data.squall.operators.ApproximateCountSketchOperator2.java

@Override
public Long runAggregateFunction(Long value, List<String> tuple) {
    //System.out.println("ZKM: **NOOP** runAggregateFunction(" + value + " " + tuple + ")");

    String tupleHash;
    if (_groupByType == GB_PROJECTION)
        tupleHash = MyUtilities.createHashString(tuple, _groupByColumns, _groupByProjection.getExpressions(),
                _map);//  www .  java 2s  .c om
    else
        tupleHash = MyUtilities.createHashString(tuple, _groupByColumns, _map);

    long hash = tupleHash.hashCode();
    final Long v = _scm.UpdateSketch(hash, 0);
    //   System.out.println("ZKM: runAggregateFunction(" + hash  + ") == " + v);
    return v;
}

From source file:com.ndn.menurandom.ImageDownloader.java

private File getFile(String url) {
    //I identify images by hashcode. Not a perfect solution, good for the demo.
    String filename = String.valueOf(url.hashCode());
    //Another possible solution (thanks to grantland)
    //String filename = URLEncoder.encode(url);
    File f = new File(mCacheDir, filename);
    return f;//  ww  w .  j  a  v  a2 s .co  m
}

From source file:com.opengamma.masterdb.security.hibernate.option.NonDeliverableFXDigitalOptionSecurityBean.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -984864697: // putAmount
        return getPutAmount();
    case 1066661974: // callAmount
        return getCallAmount();
    case -1289159373: // expiry
        return getExpiry();
    case 516393024: // putCurrency
        return getPutCurrency();
    case 643534991: // callCurrency
        return getCallCurrency();
    case -225763273: // paymentCurrency
        return getPaymentCurrency();
    case -295948169: // settlementDate
        return getSettlementDate();
    case -1180327226: // isLong
        return getIsLong();
    case -141503783: // deliverInCallCurrency
        return isDeliverInCallCurrency();
    }//from ww  w. j  av a2  s. c o  m
    return super.propertyGet(propertyName, quiet);
}

From source file:com.opengamma.masterdb.security.hibernate.option.NonDeliverableFXOptionSecurityBean.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -984864697: // putAmount
        return getPutAmount();
    case 1066661974: // callAmount
        return getCallAmount();
    case -1289159373: // expiry
        return getExpiry();
    case 516393024: // putCurrency
        return getPutCurrency();
    case 643534991: // callCurrency
        return getCallCurrency();
    case -295948169: // settlementDate
        return getSettlementDate();
    case -1180327226: // isLong
        return getIsLong();
    case -266326457: // optionExerciseType
        return getOptionExerciseType();
    case -426676942: // isDeliveryInCallCurrency
        return getIsDeliveryInCallCurrency();
    }// w  ww.ja va 2  s .  com
    return super.propertyGet(propertyName, quiet);
}

From source file:com.dragoniade.deviantart.deviation.SearchRss.java

private Long getId(String guid) {
    int lastIndex = guid.lastIndexOf('-');
    try {/*from   www  . ja  v a2 s .c  om*/
        return Long.parseLong(guid.substring(lastIndex + 1));
    } catch (NumberFormatException e) {
        return (long) guid.hashCode();
    }
}

From source file:com.opengamma.component.factory.provider.DelegatingHistoricalTimeSeriesProviderComponentFactory.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -281470431: // classifier
        setClassifier((String) newValue);
        return;/* ww w .  ja  v  a2s.  c o m*/
    case -614707837: // publishRest
        setPublishRest((Boolean) newValue);
        return;
    case -547571616: // provider1
        setProvider1((ComponentInfo) newValue);
        return;
    case -547571615: // provider2
        setProvider2((ComponentInfo) newValue);
        return;
    case -547571614: // provider3
        setProvider3((ComponentInfo) newValue);
        return;
    case -547571613: // provider4
        setProvider4((ComponentInfo) newValue);
        return;
    case -547571612: // provider5
        setProvider5((ComponentInfo) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:eu.annocultor.tagger.vocabularies.AbstractVocabulary.java

File makeCacheFileName(String prefix, String signature, List<String> locations, String query, File cacheDir) {
    File cacheFileTerms = new File(cacheDir, prefix + signature + ".q" + query.hashCode() + ".f"
            + StringUtils.join(locations, ";").hashCode() + ".txt");
    return cacheFileTerms;
}

From source file:de.langerhans.wallet.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();
    int provider = config.getExchangeProvider();
    boolean forceRefresh = config.getExchangeForceRefresh();
    if (forceRefresh) {
        config.setExchangeForceRefresh(false);
    }/*from  ww  w.  j a v a2  s  .  c om*/

    final boolean offline = uri.getQueryParameter(QUERY_PARAM_OFFLINE) != null;

    if (!offline && (lastUpdated == 0 || now - lastUpdated > UPDATE_FREQ_MS) || forceRefresh) {
        double newDogeBtcConversion = -1;
        if ((dogeBtcConversion == -1 && newDogeBtcConversion == -1) || forceRefresh)
            newDogeBtcConversion = requestDogeBtcConversion(provider);

        if (newDogeBtcConversion != -1)
            dogeBtcConversion = newDogeBtcConversion;

        if (dogeBtcConversion == -1)
            return null;

        Map<String, ExchangeRate> newExchangeRates = null;
        if (newExchangeRates == null)
            newExchangeRates = requestExchangeRates(BITCOINAVERAGE_URL, dogeBtcConversion, userAgent,
                    BITCOINAVERAGE_SOURCE, BITCOINAVERAGE_FIELDS);
        if (newExchangeRates == null)
            newExchangeRates = requestExchangeRates(BLOCKCHAININFO_URL, dogeBtcConversion, userAgent,
                    BLOCKCHAININFO_SOURCE, BLOCKCHAININFO_FIELDS);

        if (newExchangeRates != null) {
            String providerUrl;
            switch (provider) {
            case 0:
                providerUrl = "http://www.cryptsy.com";
                break;
            case 1:
                providerUrl = "http://www.bter.com";
                break;
            default:
                providerUrl = "";
                break;
            }
            double mBTCRate = dogeBtcConversion * 1000;
            String strmBTCRate = String.format(Locale.US, "%.4f", mBTCRate).replace(',', '.');
            newExchangeRates.put("mBTC",
                    new ExchangeRate(
                            new com.dogecoin.dogecoinj.utils.ExchangeRate(Fiat.parseFiat("mBTC", strmBTCRate)),
                            providerUrl));
            newExchangeRates.put("DOGE",
                    new ExchangeRate(new com.dogecoin.dogecoinj.utils.ExchangeRate(Fiat.parseFiat("DOGE", "1")),
                            "priceofdoge.com"));
            exchangeRates = newExchangeRates;
            lastUpdated = now;

            final ExchangeRate exchangeRateToCache = bestExchangeRate(config.getExchangeCurrencyCode());
            if (exchangeRateToCache != null)
                config.setCachedExchangeRate(exchangeRateToCache);
        }
    }

    if (exchangeRates == null || dogeBtcConversion == -1)
        return null;

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

    if (selection == null) {
        for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) {
            final ExchangeRate exchangeRate = entry.getValue();
            final com.dogecoin.dogecoinj.utils.ExchangeRate rate = exchangeRate.rate;
            final String currencyCode = exchangeRate.getCurrencyCode();
            cursor.newRow().add(currencyCode.hashCode()).add(currencyCode).add(rate.coin.value)
                    .add(rate.fiat.value).add(exchangeRate.source);
        }
    } else if (selection.equals(QUERY_PARAM_Q)) {
        final String selectionArg = selectionArgs[0].toLowerCase(Locale.US);
        for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) {
            final ExchangeRate exchangeRate = entry.getValue();
            final com.dogecoin.dogecoinj.utils.ExchangeRate rate = exchangeRate.rate;
            final String currencyCode = exchangeRate.getCurrencyCode();
            final String currencySymbol = GenericUtils.currencySymbol(currencyCode);
            if (currencyCode.toLowerCase(Locale.US).contains(selectionArg)
                    || currencySymbol.toLowerCase(Locale.US).contains(selectionArg))
                cursor.newRow().add(currencyCode.hashCode()).add(currencyCode).add(rate.coin.value)
                        .add(rate.fiat.value).add(exchangeRate.source);
        }
    } else if (selection.equals(KEY_CURRENCY_CODE)) {
        final String selectionArg = selectionArgs[0];
        final ExchangeRate exchangeRate = bestExchangeRate(selectionArg);
        if (exchangeRate != null) {
            final com.dogecoin.dogecoinj.utils.ExchangeRate rate = exchangeRate.rate;
            final String currencyCode = exchangeRate.getCurrencyCode();
            cursor.newRow().add(currencyCode.hashCode()).add(currencyCode).add(rate.coin.value)
                    .add(rate.fiat.value).add(exchangeRate.source);
        }
    }

    return cursor;
}

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

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -294460212: // uniqueId
        return getUniqueId();
    case -1285004149: // quantity
        return getQuantity();
    case 807992154: // securityLink
        return getSecurityLink();
    case -865715313: // trades
        return getTrades();
    case 405645655: // attributes
        return getAttributes();
    }//from  ww  w  . ja  va 2  s . com
    return super.propertyGet(propertyName, quiet);
}