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.batch.domain.FunctionUniqueId.java

@Override
protected void propertySet(String propertyName, Object newValue, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 3355: // id
        setId((Long) newValue);//from w  ww. ja  va  2s  . c o  m
        return;
    case -294460212: // uniqueId
        setUniqueId((String) newValue);
        return;
    }
    super.propertySet(propertyName, newValue, quiet);
}

From source file:com.webbfontaine.valuewebb.action.tt.TtLogger.java

private void addMessageToLogger(String fieldId, String errorMessage, ArrayList<FacesError> facesErrors) {
    boolean isTTOpened = FacesContext.getCurrentInstance().getViewRoot().getViewId().contains("TtGenEdit");

    String actorId = Actor.instance().getId();
    String searchableMessage = errorMessage + " (message is cleared)";
    int msgHashCode = searchableMessage.hashCode();
    searchableMessage = searchableMessage.length() > 1000 ? searchableMessage.substring(0, 1000)
            : searchableMessage;//from  w w  w. jav  a 2s. c o  m

    TtLog ttLog;

    TtGenHome ttGenHome = TtGenHome.getComponentInstance(false);

    if (isTTOpened) {

        TtGen ttGen = ttGenHome.getInstance();
        ttLog = new TtLog(new Date(), actorId, "Add warning message", searchableMessage, DUPLICATION_MESSAGE,
                ttGen);

        ttLog.setMsgHashCode(msgHashCode);

        if (ttGen.getId() == null) {
            ttGen.getLogs().add(ttLog);
        } else {
            persistLog(ttLog);
            reloadLogs(ttLog);
        }
    } else {
        Long ttId = Long.valueOf(facesErrors.get(0).getFieldId());
        TtGen ttGen = ttGenHome.getEntityManager().find(TtGen.class, ttId);
        ttLog = new TtLog(new Date(), actorId, "Add warning message", searchableMessage, DUPLICATION_MESSAGE,
                ttGen);
        ttLog.setMsgHashCode(msgHashCode);

        persistLog(ttLog);
    }

}

From source file:com.budrotech.jukebox.service.RESTMusicService.java

private static String getCachedArtistsFilename(Context context) {
    String s = Util.getRestUrl(context, null);
    return String.format("indexes-%d.ser", Math.abs(s.hashCode()));
}

From source file:com.opengamma.master.security.RawSecurity.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 985253874: // rawData
        return getRawData();
    }/*from  www .  j  a  v a  2 s  . co  m*/
    return super.propertyGet(propertyName, quiet);
}

From source file:com.flipkart.foxtrot.core.querystore.actions.TrendAction.java

@Override
protected String getRequestCacheKey() {
    TrendRequest query = getParameter();
    long filterHashKey = 0L;
    if (query.getFilters() != null) {
        for (Filter filter : query.getFilters()) {
            filterHashKey += 31 * filter.hashCode();
        }//from  w  w w . ja  v  a 2s .  c o  m
    }
    if (query.getValues() != null) {
        for (String value : query.getValues()) {
            filterHashKey += 31 * value.hashCode();
        }
    }

    if (null != query.getUniqueCountOn()) {
        filterHashKey += 31 * query.getUniqueCountOn().hashCode();
    }

    filterHashKey += 31 * query.getPeriod().name().hashCode();
    filterHashKey += 31 * query.getTimestamp().hashCode();
    filterHashKey += 31 * (query.getField() != null ? query.getField().hashCode() : "FIELD".hashCode());

    return String.format("%s-%s-%s-%d", query.getTable(), query.getField(), query.getPeriod(), filterHashKey);
}

From source file:net.pms.util.SubtitleUtils.java

/**
 * Extracts embedded subtitles from video to file in SSA/ASS format, converts external SRT
 * subtitles file to SSA/ASS format and applies fontconfig setting to that converted file
 * and applies timeseeking when required.
 *
 * @param dlna DLNAResource/*from   ww  w . j av  a2s.c  o m*/
 * @param media DLNAMediaInfo
 * @param params Output parameters
 * @param configuration
 * @return Converted subtitle file
 * @throws IOException
 */
public static File getSubtitles(DLNAResource dlna, DLNAMediaInfo media, OutputParams params,
        PmsConfiguration configuration, SubtitleType subtitleType) throws IOException {
    if (media == null || params.sid.getId() == -1 || !params.sid.getType().isText()) {
        return null;
    }

    String dir = configuration.getDataFile(SUB_DIR);
    File subsPath = new File(dir);
    if (!subsPath.exists()) {
        subsPath.mkdirs();
    }

    boolean applyFontConfig = configuration.isFFmpegFontConfig();
    boolean isEmbeddedSource = params.sid.getId() < 100;
    boolean is3D = media.is3d() && !media.stereoscopyIsAnaglyph();

    String filename = isEmbeddedSource ? dlna.getSystemName() : params.sid.getExternalFile().getAbsolutePath();

    String basename;

    long modId = new File(filename).lastModified();
    if (modId != 0) {
        // We have a real file
        basename = FilenameUtils.getBaseName(filename);
    } else {
        // It's something else, e.g. a url or psuedo-url without meaningful
        // lastmodified and (maybe) basename characteristics.
        basename = dlna.getName().replaceAll("[<>:\"\\\\/|?*+\\[\\]\n\r ']", "").trim();
        modId = filename.hashCode();
    }

    File convertedSubs;
    if (applyFontConfig || isEmbeddedSource || is3D || params.sid.getType() != subtitleType) {
        convertedSubs = new File(subsPath.getAbsolutePath() + File.separator + basename + "_ID"
                + params.sid.getId() + "_" + modId + "." + subtitleType.getExtension());
    } else {
        String tmp = params.sid.getExternalFile().getName().replaceAll("[<>:\"\\\\/|?*+\\[\\]\n\r ']", "")
                .trim();
        convertedSubs = new File(subsPath.getAbsolutePath() + File.separator + modId + "_" + tmp);
    }

    if (convertedSubs.canRead()) {
        // subs are already converted
        if (applyFontConfig || isEmbeddedSource || is3D) {
            params.sid.setType(SubtitleType.ASS);
            params.sid.setSubCharacterSet(CHARSET_UTF_8);
            if (is3D) {
                try {
                    convertedSubs = convertASSToASS3D(convertedSubs, media, params);
                } catch (IOException | NullPointerException e) {
                    LOGGER.debug("Converting to ASS3D format ends with error: " + e);
                    return null;
                }
            }
        }

        return convertedSubs;
    }

    boolean isExternalAss = false;
    if (params.sid.getType() == SubtitleType.ASS && params.sid.isExternal() && !isEmbeddedSource) {
        isExternalAss = true;
    }

    File tempSubs;
    if (isExternalAss || (!applyFontConfig && !isEmbeddedSource && (params.sid.getType() == subtitleType)
            && (params.sid.getType() == SubtitleType.SUBRIP || params.sid.getType() == SubtitleType.WEBVTT)
            && !is3D)) {
        tempSubs = params.sid.getExternalFile();
    } else {
        tempSubs = convertSubsToSubtitleType(filename, media, params, configuration, subtitleType);
    }

    if (tempSubs == null) {
        return null;
    }

    if (!FileUtil.isFileUTF8(tempSubs)) {
        try {
            tempSubs = applyCodepageConversion(tempSubs, convertedSubs);
            params.sid.setSubCharacterSet(CHARSET_UTF_8);
        } catch (IOException ex) {
            params.sid.setSubCharacterSet(null);
            LOGGER.warn("Exception during external file charset detection.", ex);
        }
    } else {
        FileUtils.copyFile(tempSubs, convertedSubs);
        tempSubs = convertedSubs;
    }

    // Now we're sure we actually have our own modifiable file
    if (applyFontConfig
            && !(configuration.isUseEmbeddedSubtitlesStyle() && params.sid.getType() == SubtitleType.ASS)) {
        try {
            tempSubs = applyFontconfigToASSTempSubsFile(tempSubs, media, configuration);
            params.sid.setSubCharacterSet(CHARSET_UTF_8);
        } catch (IOException e) {
            LOGGER.debug("Applying subs setting ends with error: " + e);
            return null;
        }
    }

    if (is3D) {
        try {
            tempSubs = convertASSToASS3D(tempSubs, media, params);
        } catch (IOException | NullPointerException e) {
            LOGGER.debug("Converting to ASS3D format ends with error: " + e);
            return null;
        }
    }

    if (isEmbeddedSource) {
        //         params.sid.setExternalFile(tempSubs);
        params.sid.setType(SubtitleType.ASS);
    }

    PMS.get().addTempFile(tempSubs, 30 * 24 * 3600 * 1000);
    return tempSubs;
}

From source file:com.budrotech.jukebox.service.RESTMusicService.java

private static String getCachedMusicFoldersFilename(Context context) {
    String s = Util.getRestUrl(context, null);
    return String.format("musicFolders-%d.ser", Math.abs(s.hashCode()));
}

From source file:lu.lippmann.cdb.graph.GraphUtil.java

/**
 * /* ww w .  jav a2s.co m*/
 */
public static GraphWithOperations buildGraphWithOperationsFromWekaStringLight(final String graphStr)
        throws Exception {
    final Matcher nodeMatch = NODE_PATTERN.matcher(graphStr);
    final Matcher edgeMatch = EDGE_PATTERN.matcher(graphStr);

    final GraphWithOperations gwo = new GraphWithOperations();

    final Map<String, CNode> map = new HashMap<String, CNode>();

    while (nodeMatch.find()) {
        final String id = nodeMatch.group(1);
        final String variableName = nodeMatch.group(2);
        final int pointCharIdx = variableName.indexOf('(');
        final CNode node = new CNode((long) id.hashCode(),
                pointCharIdx > 0 ? variableName.substring(0, pointCharIdx) : variableName);
        map.put(id, node);
        gwo.addVertex(node);
    }

    while (edgeMatch.find()) {
        final String from = edgeMatch.group(1);
        final String to = edgeMatch.group(2);

        final String condition = edgeMatch.group(3);

        final String fromNodeName = map.get(from).getName();

        gwo.superAddEdge(new CEdge(from + " -> " + to, fromNodeName + condition), map.get(from), map.get(to));
    }

    return gwo;
}

From source file:ch.cyberduck.ui.cocoa.model.OutlinePathReference.java

/**
 * @param path//  w  ww . java 2 s. c o  m
 */
private OutlinePathReference(AbstractPath path) {
    String unique = path.unique();
    if (!cache.containsKey(unique)) {
        cache.put(unique, NSString.stringWithString(unique));
    }
    this.reference = cache.get(unique);
    this.hashcode = unique.hashCode();
}

From source file:com.opengamma.component.factory.web.FreemarkerConfigurationComponentFactory.java

@Override
protected Object propertyGet(String propertyName, boolean quiet) {
    switch (propertyName.hashCode()) {
    case 826348548: // templateLocations
        return getTemplateLocations();
    }/*from   w ww.  j  a  va  2 s .  c o m*/
    return super.propertyGet(propertyName, quiet);
}