List of usage examples for java.util Map hashCode
int hashCode();
From source file:org.xwiki.office.viewer.internal.DefaultOfficeResourceViewer.java
private String getCacheKey(DocumentReference ownerDocument, String resource, Map<String, ?> parameters) { return this.serializer.serialize(ownerDocument) + '/' + resource + '/' + parameters.hashCode(); }
From source file:uk.me.viv.logmyride.KMLFile.java
/** * @todo push this down into a MotionX specific KML class * @return/*w w w. ja v a2s. c om*/ */ public Map<String, String> getDescription() { String[] descriptionProperties = { "Date", "Distance", "Elapsed Time", "Avg Speed", "Max Speed", "Avg Pace", "Min Altitude", "Max Altitude", "Start Time", "Finish Time", }; Map<String, String> description = new HashMap<>(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(this.kml)); try { Document doc = builder.parse(is); XPathFactory xPathfactory = XPathFactory.newInstance(); XPath xpath = xPathfactory.newXPath(); description.put("Name", xpath.evaluate("//Document/name/text()", doc)); for (String property : descriptionProperties) { description.put(property, xpath.evaluate("//td[text()=\"" + property + ":\"]/following::td[1]/text()", doc)); } description.put("Filename", this.getFilename()); description.put("ID", DigestUtils.shaHex(Integer.toString(description.hashCode()))); } catch (SAXException ex) { Logger.getLogger(KMLFile.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(KMLFile.class.getName()).log(Level.SEVERE, null, ex); } catch (XPathExpressionException ex) { Logger.getLogger(KMLFile.class.getName()).log(Level.SEVERE, null, ex); } } catch (ParserConfigurationException ex) { Logger.getLogger(KMLFile.class.getName()).log(Level.SEVERE, null, ex); } return description; }
From source file:uniko.west.topology.bolts.TweetIndexBolt.java
@Override public void execute(Tuple input) { // Retrieve hash map tuple object from Tuple input at index 0, index 1 // will be message delivery tag (not used here) @SuppressWarnings("unchecked") Map<Object, Object> inputMap = (HashMap<Object, Object>) input.getValue(0); // Get JSON object from the HashMap from the Collections.singletonList @SuppressWarnings("unchecked") Map<String, Object> message = (Map<String, Object>) inputMap.get("message"); this.collector.ack(input); if (!message.containsKey("created_at")) { return; // skip delete messages }/* w w w . j a v a 2 s . co m*/ // only consider tweets that include a text element if (!message.containsKey("text")) { return; } // extract tweet text String messageText = (String) message.get("text"); // check the language in which the tweet was written Detector detector; String langDetected; try { detector = DetectorFactory.create(); detector.append(messageText); langDetected = detector.detect(); // only consider tweets written in Enlglish if (!langDetected.equals("en")) { return; } } catch (LangDetectException e) { e.printStackTrace(); // return if language could not be determined return; } // create indices for calling the topic model predictor Text text = new Text(messageText); String messageTextIndices = ""; text.stem = true; Iterator<String> iterator = text.getTerms(); String term; while (iterator.hasNext()) { term = iterator.next(); if (dictionary.contains(term)) { if (!messageTextIndices.isEmpty()) { messageTextIndices += " "; } messageTextIndices += dictionary.getID(term); } } ArrayList<Object> result = new ArrayList<Object>(); message.put("messageTextIndices", messageTextIndices); result.add((Object) message); this.collector.emit(result); // test printout try (PrintStream testOut = new PrintStream( new File("/home/martin/test/tweetIndexBolt/location" + message.hashCode() + ".log"), "UTF8")) { testOut.println("text: " + messageText); testOut.println("detected language: " + langDetected); testOut.println("indicies: " + messageTextIndices); } catch (FileNotFoundException ex) { Logger.getLogger(TweetIndexBolt.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedEncodingException ex) { Logger.getLogger(TweetIndexBolt.class.getName()).log(Level.SEVERE, null, ex); } }