List of usage examples for java.util Arrays hashCode
public static int hashCode(Object a[])
From source file:org.evosuite.testcase.ArrayStatement.java
/** {@inheritDoc} */ @Override/* w w w . j a v a 2s . c o m*/ public int hashCode() { final int prime = 31; int result = retval.hashCode(); result = prime * result + Arrays.hashCode(lengths); return result; }
From source file:de.tudarmstadt.ukp.dkpro.argumentation.io.annotations.SpanAnnotationGraph.java
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + Arrays.hashCode(relationTransitionTable); result = prime * result + (spanAnnotationVector == null ? 0 : spanAnnotationVector.hashCode()); return result; }
From source file:org.loklak.api.server.push.GeoJsonPushServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RemoteAccess.Post post = RemoteAccess.evaluate(request); String remoteHash = Integer.toHexString(Math.abs(post.getClientHost().hashCode())); // manage DoS if (post.isDoS_blackout()) { response.sendError(503, "your request frequency is too high"); return;// w ww.j a v a 2 s. c o m } String url = post.get("url", ""); String map_type = post.get("map_type", ""); String source_type_str = post.get("source_type", ""); if ("".equals(source_type_str) || !SourceType.hasValue(source_type_str)) { DAO.log("invalid or missing source_type value : " + source_type_str); source_type_str = SourceType.IMPORT.name(); } SourceType sourceType = SourceType.valueOf(source_type_str); if (url == null || url.length() == 0) { response.sendError(400, "your request does not contain an url to your data object"); return; } String screen_name = post.get("screen_name", ""); if (screen_name == null || screen_name.length() == 0) { response.sendError(400, "your request does not contain required screen_name parameter"); return; } // parse json retrieved from url final List<Map<String, Object>> features; byte[] jsonText; try { jsonText = ClientConnection.download(url); Map<String, Object> map = DAO.jsonMapper.readValue(jsonText, DAO.jsonTypeRef); Object features_obj = map.get("features"); features = features_obj instanceof List<?> ? (List<Map<String, Object>>) features_obj : null; } catch (Exception e) { response.sendError(400, "error reading json file from url"); return; } if (features == null) { response.sendError(400, "geojson format error : member 'features' missing."); return; } // parse maptype Map<String, List<String>> mapRules = new HashMap<>(); if (!"".equals(map_type)) { try { String[] mapRulesArray = map_type.split(","); for (String rule : mapRulesArray) { String[] splitted = rule.split(":", 2); if (splitted.length != 2) { throw new Exception("Invalid format"); } List<String> valuesList = mapRules.get(splitted[0]); if (valuesList == null) { valuesList = new ArrayList<>(); mapRules.put(splitted[0], valuesList); } valuesList.add(splitted[1]); } } catch (Exception e) { response.sendError(400, "error parsing map_type : " + map_type + ". Please check its format"); return; } } List<Map<String, Object>> rawMessages = new ArrayList<>(); ObjectWriter ow = new ObjectMapper().writerWithDefaultPrettyPrinter(); PushReport nodePushReport = new PushReport(); for (Map<String, Object> feature : features) { Object properties_obj = feature.get("properties"); @SuppressWarnings("unchecked") Map<String, Object> properties = properties_obj instanceof Map<?, ?> ? (Map<String, Object>) properties_obj : null; Object geometry_obj = feature.get("geometry"); @SuppressWarnings("unchecked") Map<String, Object> geometry = geometry_obj instanceof Map<?, ?> ? (Map<String, Object>) geometry_obj : null; if (properties == null) { properties = new HashMap<>(); } if (geometry == null) { geometry = new HashMap<>(); } Map<String, Object> message = new HashMap<>(); // add mapped properties Map<String, Object> mappedProperties = convertMapRulesProperties(mapRules, properties); message.putAll(mappedProperties); if (!"".equals(sourceType)) { message.put("source_type", sourceType.name()); } else { message.put("source_type", SourceType.IMPORT); } message.put("provider_type", MessageEntry.ProviderType.GEOJSON.name()); message.put("provider_hash", remoteHash); message.put("location_point", geometry.get("coordinates")); message.put("location_mark", geometry.get("coordinates")); message.put("location_source", LocationSource.USER.name()); message.put("place_context", PlaceContext.FROM.name()); if (message.get("text") == null) { message.put("text", ""); } // append rich-text attachment String jsonToText = ow.writeValueAsString(properties); message.put("text", message.get("text") + MessageEntry.RICH_TEXT_SEPARATOR + jsonToText); if (properties.get("mtime") == null) { String existed = PushServletHelper.checkMessageExistence(message); // message known if (existed != null) { nodePushReport.incrementKnownCount(existed); continue; } // updated message -> save with new mtime value message.put("mtime", Long.toString(System.currentTimeMillis())); } try { message.put("id_str", PushServletHelper.computeMessageId(message, sourceType)); } catch (Exception e) { DAO.log("Problem computing id : " + e.getMessage()); nodePushReport.incrementErrorCount(); } rawMessages.add(message); } PushReport report = PushServletHelper.saveMessagesAndImportProfile(rawMessages, Arrays.hashCode(jsonText), post, sourceType, screen_name); String res = PushServletHelper.buildJSONResponse(post.get("callback", ""), report); post.setResponse(response, "application/javascript"); response.getOutputStream().println(res); DAO.log(request.getServletPath() + " -> records = " + report.getRecordCount() + ", new = " + report.getNewCount() + ", known = " + report.getKnownCount() + ", error = " + report.getErrorCount() + ", from host hash " + remoteHash); }
From source file:org.uma.jmetal.util.point.impl.ArrayPointTest.java
@Test public void shouldHashCodeReturnTheCorrectValue() { int dimension = 5; Point point = new ArrayPoint(dimension); point.setDimensionValue(0, 1.0);//from www . jav a2s .co m point.setDimensionValue(1, -2.0); point.setDimensionValue(2, 45.5); point.setDimensionValue(3, -323.234); point.setDimensionValue(4, Double.MAX_VALUE); double[] array = { 1.0, -2.0, 45.5, -323.234, Double.MAX_VALUE }; assertEquals(Arrays.hashCode(array), point.hashCode()); }
From source file:org.knime.al.util.noveltydetection.knfst.MultiClassKNFST.java
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + Arrays.hashCode(m_labels); return result; }
From source file:com.opengamma.analytics.financial.interestrate.payments.derivative.CouponIborRatchet.java
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + Arrays.hashCode(_capCoefficients); result = prime * result + Arrays.hashCode(_floorCoefficients); result = prime * result + ((_index == null) ? 0 : _index.hashCode()); result = prime * result + Arrays.hashCode(_mainCoefficients); return result; }
From source file:com.eryansky.common.utils.TimeUtils.java
public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + Arrays.hashCode(fields); return result; }
From source file:com.android.tv.data.Program.java
@Override public int hashCode() { return Objects.hash(mChannelId, mStartTimeUtcMillis, mEndTimeUtcMillis, mTitle, mEpisodeTitle, mDescription, mVideoWidth, mVideoHeight, mPosterArtUri, mThumbnailUri, Arrays.hashCode(mContentRatings), Arrays.hashCode(mCanonicalGenreIds), mSeasonNumber, mSeasonTitle, mEpisodeNumber); }
From source file:com.opengamma.analytics.math.minimization.UncoupledParameterTransforms.java
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + Arrays.hashCode(_freeParameters); result = prime * result + _startValues.hashCode(); result = prime * result + Arrays.hashCode(_transforms); return result; }
From source file:org.nuclos.server.dblayer.structure.DbColumnType.java
@Override public int hashCode() { return Arrays .hashCode(new Object[] { genericType != null ? genericType : typeName, length, precision, scale }); }