/** * Does the passed status match the filter pattern? This method checks the status text and the * expanded url entities * * @param status Status to check * @return True if the filter expression matches, false otherwise */ private boolean matchesFilter(Status status) { boolean shouldFilter = false; if (filterPattern != null) { Matcher m = filterPattern.matcher(status.getText()); if (m.matches()) shouldFilter = true; if (status.getURLEntities() != null) { for (URLEntity ue : status.getURLEntities()) { URL expUrl = ue.getExpandedURL(); if (expUrl != null && expUrl.toString() != null) { m = filterPattern.matcher(expUrl.toString()); if (m.matches()) shouldFilter = true; } } } } return shouldFilter; }
private static Record buildURLEntity(Schema schemaURLObject, URLEntity urlEntity) { GenericRecordBuilder builderURLObject = new GenericRecordBuilder(schemaURLObject); builderURLObject.set("url", urlEntity.getURL()); builderURLObject.set("text", urlEntity.getText()); builderURLObject.set("expanded_url", urlEntity.getExpandedURL()); builderURLObject.set("display_url", urlEntity.getDisplayURL()); builderURLObject.set("start", urlEntity.getStart()); builderURLObject.set("end", urlEntity.getEnd()); return builderURLObject.build(); }