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.forward.CommodityForwardSecurityBean.java

@SuppressWarnings("unchecked")
@Override//w  w w .ja  v a 2s.com
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -1289159373: // expiry
        setExpiry((ExpiryBean) newValue);
        return;
    case 575402001: // currency
        setCurrency((CurrencyBean) newValue);
        return;
    case 1673913084: // unitAmount
        setUnitAmount((Double) newValue);
        return;
    case -292854225: // unitName
        setUnitName((UnitBean) newValue);
        return;
    case 2053402093: // unitNumber
        setUnitNumber((Double) newValue);
        return;
    case -1770633379: // underlying
        setUnderlying((ExternalIdBean) newValue);
        return;
    case -1396196922: // basket
        setBasket((Set<FutureBundleBean>) newValue);
        return;
    case 1755448466: // firstDeliveryDate
        setFirstDeliveryDate((ZonedDateTimeBean) newValue);
        return;
    case -233366664: // lastDeliveryDate
        setLastDeliveryDate((ZonedDateTimeBean) newValue);
        return;
    case 50511102: // category
        setCategory((ContractCategoryBean) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.developer4droid.contactslister.backend.image_load.EnhancedImageDownloader.java

/**
 * @param url The URL of the image that will be retrieved from the cache.
 * @return The cached bitmap or null if it was not found.
 *//*from ww w.j a  va 2s.  com*/
private Bitmap getBitmapFromCache(String url, ProgressImageView pHolder) {
    // I identify images by hashcode. Not a perfect solution, good for the
    // demo.
    String filename = String.valueOf(url.hashCode());
    File f = new File(cacheDir, filename);

    // from SD cache
    // if file is stored so simply read it, do not resize
    //        if(!loadedBmpList.contains(url)){
    Bitmap bmp = readFile(f);
    if (bmp != null) {
        //                loadedBmpList.add(url);
        pHolder.bitmap = bmp;
        addBitmapToCache(url, pHolder);
    }
    //        }

    // First try the hard reference cache
    synchronized (sHardBitmapCache) {
        final ProgressImageView holder = sHardBitmapCache.get(url);
        if (holder != null) {
            // Bitmap found in hard cache
            // Move element to first position, so that it is removed last
            sHardBitmapCache.remove(url);
            sHardBitmapCache.put(url, holder);
            return holder.bitmap;
        }
    }

    // Then try the soft reference cache
    SoftReference<ProgressImageView> bitmapReference = sSoftBitmapCache.get(url);
    if (bitmapReference != null) {
        final ProgressImageView holder = bitmapReference.get();
        if (holder != null) {
            // Bitmap found in soft cache
            return holder.bitmap;
        } else {
            // Soft reference has been Garbage Collected
            sSoftBitmapCache.remove(url);
        }
    }

    return null;
}

From source file:com.generalbioinformatics.rdf.AbstractTripleStore.java

public RecordStream sparqlSelect(String query) throws StreamException {
    try {/*from  w ww.j ava  2s  .  c  o  m*/
        RecordStream rs;

        long start = System.currentTimeMillis();

        if (cacheDir == null) {
            rs = _sparqlSelectDirect(query);
            long delta = System.currentTimeMillis() - start;
            fireQueryPerformed(query, delta);
        } else {
            if (!cacheDir.exists()) {
                if (!cacheDir.mkdirs())
                    throw new IOException("Could not create cache directory");
            }

            int hashCode = query.hashCode() + 3 * this.hashCode();
            String hashCodeString = String.format("%08x", hashCode);
            File cacheSubdir = new File(cacheDir, hashCodeString.substring(0, 2));
            File out = new File(cacheSubdir, hashCodeString + ".txt.gz");

            if (out.exists()) {
                // merely "touch" the file, so we know the cached file was used recently.
                org.apache.commons.io.FileUtils.touch(out);
            } else {
                // make subdir if it doesn't exist.
                if (!cacheSubdir.exists()) {
                    if (!cacheSubdir.mkdir())
                        throw new IOException("Couldn't create directory " + cacheSubdir);
                }

                File tmp = File.createTempFile(hashCodeString + "-", ".tmp", cacheSubdir);
                try {
                    OutputStream os = new FileOutputStream(tmp);
                    GZIPOutputStream gos = new GZIPOutputStream(os);
                    RecordStream rsx = _sparqlSelectDirect(query);
                    long delta = System.currentTimeMillis() - start;
                    Utils.queryResultsToFile(this, delta, rsx, query, gos);
                    gos.finish();
                    os.close();
                    fireQueryPerformed(query, delta);
                } catch (RuntimeException e) {
                    tmp.delete();
                    throw (e);
                } catch (StreamException e) {
                    tmp.delete();
                    throw (e);
                }
                tmp.renameTo(out);
            }

            InputStream is = HFileUtils.openZipStream(out);
            rs = TsvRecordStream.open(is).filterComments().get();
        }

        return rs;
    } catch (IOException ex) {
        throw new StreamException(ex);
    }
}

From source file:com.opengamma.master.portfolio.ManageablePortfolioNode.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -294460212: // uniqueId
        return getUniqueId();
    case 915246087: // parentNodeId
        return getParentNodeId();
    case -5186429: // portfolioId
        return getPortfolioId();
    case 3373707: // name
        return getName();
    case 1339293429: // childNodes
        return getChildNodes();
    case -137459505: // positionIds
        return getPositionIds();
    }//from w ww. j  ava  2 s.  com
    return super.propertyGet(propertyName, quiet);
}

From source file:com.opengamma.masterdb.security.hibernate.capfloor.CapFloorSecurityBean.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 575402001: // currency
        setCurrency((CurrencyBean) newValue);
        return;//w w  w .j a  v a2s  .co  m
    case 1905311443: // dayCount
        setDayCount((DayCountBean) newValue);
        return;
    case -70023844: // frequency
        setFrequency((FrequencyBean) newValue);
        return;
    case 98258: // cap
        setCap((Boolean) newValue);
        return;
    case 3225788: // ibor
        setIbor((Boolean) newValue);
        return;
    case 106443605: // payer
        setPayer((Boolean) newValue);
        return;
    case -414641441: // maturityDate
        setMaturityDate((ZonedDateTimeBean) newValue);
        return;
    case 1585636160: // notional
        setNotional((Double) newValue);
        return;
    case -2129778896: // startDate
        setStartDate((ZonedDateTimeBean) newValue);
        return;
    case -891985998: // strike
        setStrike((Double) newValue);
        return;
    case 368639974: // underlyingIdentifier
        setUnderlyingIdentifier((ExternalIdBean) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.opengamma.masterdb.security.hibernate.capfloor.CapFloorCMSSpreadSecurityBean.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 575402001: // currency
        setCurrency((CurrencyBean) newValue);
        return;/*w  ww.j  av a2 s.c  o  m*/
    case 1905311443: // dayCount
        setDayCount((DayCountBean) newValue);
        return;
    case -70023844: // frequency
        setFrequency((FrequencyBean) newValue);
        return;
    case 98258: // cap
        setCap((Boolean) newValue);
        return;
    case 106443605: // payer
        setPayer((Boolean) newValue);
        return;
    case 18113605: // longIdentifier
        setLongIdentifier((ExternalIdBean) newValue);
        return;
    case -414641441: // maturityDate
        setMaturityDate((ZonedDateTimeBean) newValue);
        return;
    case 1585636160: // notional
        setNotional((Double) newValue);
        return;
    case -2054053307: // shortIdentifier
        setShortIdentifier((ExternalIdBean) newValue);
        return;
    case -2129778896: // startDate
        setStartDate((ZonedDateTimeBean) newValue);
        return;
    case -891985998: // strike
        setStrike((Double) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

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

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 663363412: // annualizationFactor
        setAnnualizationFactor((Double) newValue);
        return;//  w  w w .  ja  v  a 2s.  c  o m
    case 575402001: // currency
        setCurrency((CurrencyBean) newValue);
        return;
    case -1644595926: // firstObservationDate
        setFirstObservationDate((ZonedDateTimeBean) newValue);
        return;
    case -1362285436: // lastObservationDate
        setLastObservationDate((ZonedDateTimeBean) newValue);
        return;
    case 1585636160: // notional
        setNotional((Double) newValue);
        return;
    case -213041520: // observationFrequency
        setObservationFrequency((FrequencyBean) newValue);
        return;
    case -752533291: // parameterisedAsVariance
        setParameterisedAsVariance((Boolean) newValue);
        return;
    case -934795532: // region
        setRegion((ExternalIdBean) newValue);
        return;
    case -295948169: // settlementDate
        setSettlementDate((ZonedDateTimeBean) newValue);
        return;
    case -714106872: // spotUnderlyingIdentifier
        setSpotUnderlyingIdentifier((ExternalIdBean) newValue);
        return;
    case -891985998: // strike
        setStrike((Double) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.pactera.edg.am.metamanager.extractor.adapter.mapping.impl.CommonMappingServiceImpl.java

private void genMetaModels(List<Element> elements, MMMetadata parentMetadata, MMMetaModel parentMetaModel) {

    // list???,???,???
    Collections.reverse(elements);
    /**//from w w w  .  ja  va2s .c  o m
     * ??,CODE???
     */
    Set<String> duplicateElement = new HashSet<String>();
    for (Element element : elements) {
        String modelId = element.attributeValue("class");

        String code = element.selectSingleNode("./attributes/instancecode").getText();
        if (code == null || code.equals("")) {
            log.warn(new StringBuilder("Code!").append(",:").append(modelId).toString());
            continue;
        }

        String duplicateString = new StringBuilder().append(code.hashCode()).append("_")
                .append(modelId.hashCode()).toString();

        if (duplicateElement.contains(duplicateString)) {
            // ?,?CODE?,??
            log.warn(new StringBuilder("??Element:").append(code).append(":").append(modelId)
                    .toString());
            continue;
        }

        duplicateElement.add(duplicateString);

        MMMetaModel cntMetaModel = getMetaModel(parentMetaModel, element);
        MMMetadata metadata = genMetadata(parentMetadata, cntMetaModel, element);
        //         cntMetaModel.addMetadata(metadata);
        //         cntMetaModel.setHasMetadata(true);
        List<Element> childElements = element.selectNodes("./instances/instance");
        if (childElements != null && childElements.size() > 0) {
            genMetaModels(childElements, metadata, cntMetaModel);
            //            cntMetaModel.setHasChildMetaModel(true);
        }
    }
}

From source file:it.acubelab.batframework.systemPlugins.AIDAAnnotator.java

@Override
public Set<ScoredAnnotation> solveSa2W(String text) throws AnnotationException {

    /* Lazy connection if the connection made by the constructor failed.*/
    if (!AidaRMIClientManager.isConnected())
        setupConnection();//from w  w  w .ja  v a2s.c  om

    Set<AIDATag> res = new HashSet<AIDATag>();
    List<String> titlesToPrefetch = new Vector<String>();

    //lastTime = Calendar.getInstance().getTimeInMillis();
    AidaParsePackage input = new AidaParsePackage(text, "" + text.hashCode(), settings);
    AidaResultsPackage result = null;
    try {
        result = AidaRMIClientManager.parse(input);
    } catch (java.lang.NullPointerException e) {
        System.out
                .println("Caught exception while processing text:\n [text beginning]\n" + text + "[text end]");
        throw e;
    } catch (Exception e) {
        System.out
                .println("Caught exception while processing text:\n [text beginning]\n" + text + "[text end]");
        e.printStackTrace();
        throw new AnnotationException(e.getMessage());
    }
    //lastTime = Calendar.getInstance().getTimeInMillis() - lastTime;
    //System.out.println(result.getOverallRunTime()+ "\t" + lastTime+"ms");

    if (result == null) {
        String noSpaceText = CharUtils.trim(text).toString();
        System.out.println("NULL RESULT: " + noSpaceText.substring(0, Math.min(10, noSpaceText.length())));
    }
    if (result != null) {
        Matcher time1 = Pattern.compile("^(\\d*)ms$").matcher(result.getOverallRunTime());
        Matcher time2 = Pattern.compile("^(\\d*)s, (\\d*)ms$").matcher(result.getOverallRunTime());
        Matcher time3 = Pattern.compile("^(\\d*)m, (\\d*)s, (\\d*)ms$").matcher(result.getOverallRunTime());
        Matcher time4 = Pattern.compile("^(\\d*)h, (\\d*)m, (\\d*)s, (\\d*)ms$")
                .matcher(result.getOverallRunTime());
        Matcher time5 = Pattern.compile("^(\\d*)d, (\\d*)h, (\\d*)m, (\\d*)s, (\\d*)ms$")
                .matcher(result.getOverallRunTime());
        if (time1.matches())
            lastTime = Integer.parseInt(time1.group(1));
        else if (time2.matches())
            lastTime = Integer.parseInt(time2.group(1)) * 1000 + Integer.parseInt(time2.group(2));
        else if (time3.matches())
            lastTime = Integer.parseInt(time3.group(1)) * 1000 * 60 + Integer.parseInt(time3.group(2)) * 1000
                    + Integer.parseInt(time3.group(3));
        else if (time4.matches())
            lastTime = Integer.parseInt(time4.group(1)) * 1000 * 60 * 60
                    + Integer.parseInt(time4.group(2)) * 1000 * 60 + Integer.parseInt(time4.group(3)) * 1000
                    + Integer.parseInt(time4.group(4));
        else if (time5.matches())
            lastTime = Integer.parseInt(time5.group(1)) * 1000 * 60 * 60 * 24
                    + Integer.parseInt(time5.group(2)) * 1000 * 60 * 60
                    + Integer.parseInt(time5.group(3)) * 1000 * 60 + Integer.parseInt(time5.group(4)) * 1000
                    + Integer.parseInt(time5.group(5));
        else
            throw new AnnotationException("Time value returned by AIDA [" + result.getOverallRunTime()
                    + "] does not match the pattern.");

        DisambiguationResults disRes = result.getDisambiguationResults();
        for (ResultMention mention : disRes.getResultMentions()) {
            ResultEntity resEntity = disRes.getBestEntity(mention);

            int position = mention.getCharacterOffset();
            int length = mention.getMention().length();
            String pageTitleEscaped = resEntity.getEntity();
            String pageTitleUnescaped = StringEscapeUtils.unescapeJava(pageTitleEscaped);
            float score = (float) resEntity.getDisambiguationScore();
            if (pageTitleEscaped.equals("--NME--")) //Aida could not identify the topic.
                break;

            res.add(new AIDATag(position, length, pageTitleUnescaped, score));
            titlesToPrefetch.add(pageTitleUnescaped);
        }
    }

    /** Prefetch wids of titles*/
    try {
        api.prefetchTitles(titlesToPrefetch);
    } catch (Exception e) {
        e.printStackTrace();
        throw new AnnotationException(e.getMessage());
    }

    /** Convert to Scored Tags*/
    Set<ScoredAnnotation> resScoredAnnotations = new HashSet<ScoredAnnotation>();
    for (AIDATag t : res) {
        int wid;
        try {
            wid = api.getIdByTitle(t.title);
        } catch (IOException e) {
            e.printStackTrace();
            throw new AnnotationException(e.getMessage());
        }
        if (wid != -1)
            resScoredAnnotations.add(new ScoredAnnotation(t.position, t.length, wid, t.score));
    }
    return resScoredAnnotations;
}

From source file:com.opengamma.master.portfolio.ManageablePortfolioNode.java

@SuppressWarnings("unchecked")
@Override//from   w ww .  java 2 s  .co m
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case -294460212: // uniqueId
        setUniqueId((UniqueId) newValue);
        return;
    case 915246087: // parentNodeId
        setParentNodeId((UniqueId) newValue);
        return;
    case -5186429: // portfolioId
        setPortfolioId((UniqueId) newValue);
        return;
    case 3373707: // name
        setName((String) newValue);
        return;
    case 1339293429: // childNodes
        setChildNodes((List<ManageablePortfolioNode>) newValue);
        return;
    case -137459505: // positionIds
        setPositionIds((List<ObjectId>) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}