List of usage examples for java.lang String hashCode
public int hashCode()
From source file:com.rest4j.TextResource.java
public TextResource(String text) { super("text/plain; charset=utf-8"); this.etag = "\"" + text.hashCode() + "\""; this.reader = new StringReader(text); }
From source file:com.alibaba.cobar.manager.dao.delegate.CobarAdapterKey.java
@Override public int hashCode() { String join = StringUtils.join(new Object[] { ip, port, user, password }, "\r\n"); return join.hashCode(); }
From source file:fr.mycellar.domain.stack.Stack.java
public void setStack(String stack) { this.stack = stack; hashCode = stack.hashCode(); }
From source file:com.opengamma.bbg.referencedata.cache.MongoDBReferenceDataCacheRefresher.java
/** * //from w w w . j a va 2s . co m * @param numberOfSecurities Approximately how many securities to refresh each time * @param id some id number, should increment for each call. Will result in all securities being refreshed after #securities in cache/numberOfSecurities ids. */ public void refreshCaches(final int numberOfSecurities, final long id) { ArgumentChecker.isTrue(numberOfSecurities > 0, "Positive number of securities must be specified"); Set<String> securities = _cache.getAllCachedSecurities(); final int hashBasis = Math.max(securities.size() / numberOfSecurities, 1); Set<String> chosen = new HashSet<String>(numberOfSecurities); for (String candidate : securities) { if (Math.abs(candidate.hashCode() % hashBasis) == id % hashBasis) { chosen.add(candidate); } } refreshCaches(chosen); }
From source file:com.xpn.xwiki.stats.impl.RefererStats.java
/** * @param docName the name of the wiki/space/document. * @param referer the referer.// w ww .j a v a 2 s . c o m * @param periodDate the date of the period. * @param periodType the type of the period. */ public RefererStats(String docName, String referer, Date periodDate, PeriodType periodType) { super(periodDate, periodType); setName(docName); String nb = referer + getPeriod(); setNumber(nb.hashCode()); setReferer(referer); }
From source file:com.searchbox.framework.service.DirectoryService.java
public String createRelativeCachedAttribute(String value) { Integer hash = value.hashCode(); String tempFile = "cached_" + hash + ".jspx"; if (!fileExists(tempFile)) { createFile(tempFile, value);// ww w.j a va 2s . c om } String path = "/" + getApplicationRelativePath(tempFile); LOGGER.info("Saved {} with path: {}", tempFile, path); return path; }
From source file:org.eclipse.thym.core.internal.util.BundleHttpCacheStorage.java
private File getCacheFile(String key) { String fileName = Integer.toHexString(key.hashCode()); File f = new File(cacheDir, fileName); return f;/*from w w w .ja va2 s . co m*/ }
From source file:jetbrick.tools.chm.reader.KeyManager.java
public KeyManager(String key) { this.key = key; this.url = "redirs/" + StringUtils.replace(key, "()", "_") + Math.abs(key.hashCode()) + ".html"; }
From source file:gov.llnl.ontology.text.corpora.UkWacDocumentReader.java
/** * {@inheritDoc}//w w w . j a v a 2s . c om */ public gov.llnl.ontology.text.Document readDocument(String doc, String corpusName) { String[] lines = doc.split("\\n"); // Find the title. int titleStart = lines[0].indexOf("id=\"") + 4; int titleEnd = lines[0].lastIndexOf("\">"); String key = lines[0].substring(titleStart, titleEnd); long id = key.hashCode(); StringBuilder builder = new StringBuilder(); for (int i = 1; i < lines.length - 1; ++i) { // Skip empty lines and xml tags. if (lines[i].length() == 0 || lines[i].endsWith("s>")) continue; lines[i] = StringEscapeUtils.unescapeHtml4(lines[i]); String[] toks = lines[i].split("\\s+"); builder.append(toks[0]).append(" "); } return new SimpleDocument(corpusName, builder.toString(), doc, key, id, key, new HashSet<String>()); }
From source file:it.cnr.isti.thematrix.configuration.LogST.java
/** * Static function to actually log into the file AND onto System.out. Adds trailing "\n"; we want it static. * Synchronized since release 1.28./*from w ww .j a v a 2s. c o m*/ * * @param level * logging level of the message. * @param message * message to be print. */ public synchronized static void logP(int level, String message) { // re-intsatiate instance if it was not if (instance == null) { instance = new LogST(); // instance.startupMessage(); LogST.logP(1, "WARNING: log file open by LogST due to missing singleton initialization\n"); } // we do not shorten the console output try { if (level == 0) writeOnOutStreams(""); if (logLevel >= level) { // log shortening code /* if hash code matches and they are the same */ /* null is actually an error, but let's not be picky here */ if (message.hashCode() == lastHashCode && message != null && lastLine.indexOf(message) == 0 && lastLine.length() == message.length()) { lastLineRepeats++; // and skip printing it for now } else { if (lastLineRepeats != 0) { // we had some repetitions before to give account for String out = "[" + level + "] -+- Previous message repeated " + lastLineRepeats + " times\n"; writeOnOutStreams(out); } lastLineRepeats = 0; lastLine.setLength(0); lastLine.append(message); lastHashCode = message.hashCode(); // the real logging //instance.logStream.write("["+level+"]"+message+"\n"); //instance.logStream.flush(); writeOnOutStreams("[" + level + "]" + message + "\n"); } } } catch (IOException e) { throw new Error("Can't write to " + LogST.logName); } }