/** * Find Tags item for specified String. * * @param tag String value to find Tags item for * @return Tags item for specified String, null otherwise */ private static Tags findTag(String tag) { for (Tags tags : Tags.values()) { if (tag.compareTo(tags.tag()) == 0) { return tags; } } return null; }
@Test public void testShowTags() { String access_token = "2.00d5evFEnhnsoBc45cd025fencuzbE"; // get token code from <code>OAuth4Code.java</code> String uid = "2552134982"; Tags tm = new Tags(); tm.client.setToken(access_token); try { List<Tag> wbTags = tm.getTags(uid); for (Tag tag : wbTags) { Log.logInfo(tag.toString()); } } catch (WeiboException e) { e.printStackTrace(); } }
/* */ public CompiledEstimator(ObjectInput in) /* */ throws ClassNotFoundException, IOException /* */ { /* 144 */ this.mTokenCategorizer = ((TokenCategorizer) in.readObject()); /* */ /* 146 */ this.mTagSymbolTable = ((SymbolTable) in.readObject()); /* 147 */ this.mTokenSymbolTable = ((SymbolTable) in.readObject()); /* */ /* 150 */ this.mTagTrie = new EstimatorTrie(in); /* 151 */ this.mTokenTrie = new EstimatorTrie(in); /* 152 */ this.mLogUniformVocabEstimate = in.readDouble(); /* */ /* 154 */ int numSymbols = this.mTagSymbolTable.numSymbols(); /* 155 */ this.mConvertToInterior = new int[numSymbols]; /* 156 */ this.mCannotFollow = new boolean[numSymbols][numSymbols]; /* 157 */ int numTags = this.mTagSymbolTable.numSymbols(); /* 158 */ List starts = new ArrayList(); /* 159 */ List interiors = new ArrayList(); /* 160 */ for (int tagID = 0; tagID < numTags; tagID++) { /* 161 */ String tag = idToTag(tagID); /* 162 */ this.mConvertToInterior[tagID] = tagToInteriorID(tag); /* 163 */ if (tagID != this.mConvertToInterior[tagID]) { /* 164 */ interiors.add(Integer.valueOf(this.mConvertToInterior[tagID])); /* 165 */ starts.add(Integer.valueOf(tagID)); /* */ } /* 167 */ for (int tagMinus1ID = 0; tagMinus1ID < numTags; tagMinus1ID++) { /* 168 */ this.mCannotFollow[tagID][tagMinus1ID] = Tags.illegalSequence(idToTag(tagMinus1ID), tag); /* */ } /* */ } /* 171 */ this.mStart = convertToIntArray(starts); /* 172 */ this.mInterior = convertToIntArray(interiors); /* */ }
public void pass(Tag tag, final CallbackWithFallback<String> callback) { if (tags.hasFrameFor(tag)) { textBodyFor(tag, first -> callback.call(first.getText())); } else { callback.fallback(); } }
/** * Create ChatMessage from Hashtable generated by Hessian-decoder * * @param hash Hashtable containing ChatMessage parameters */ public void createFromHashtable(Hashtable<String, Object> hash) { LogUtils.logI("Conversation.createFromHashtable() hash[" + hash.toString() + "]"); Enumeration<String> e = hash.keys(); while (e.hasMoreElements()) { String key = e.nextElement(); Tags tag = Tags.findTag(key); if (tag != null) { setValue(tag, hash.get(key)); } } }
/** * Create Comment from HashTable generated by Hessian-decoder * * @param Hashtable representing Comment Item * @return Comment created from Hashtable */ public static Comment createFromHashtable(Hashtable<String, Object> hash) { Comment comment = new Comment(); Enumeration<String> e = hash.keys(); while (e.hasMoreElements()) { String key = e.nextElement(); Object value = hash.get(key); Tags tag = Tags.findTag(key); comment.setValue(tag, value); } return comment; }
/** * Populate Identity from supplied Hashtable. * * @param hash Hashtable containing identity details. * @return Identity instance. */ public Identity createFromHashtable(Hashtable<String, Object> hash) { Enumeration<String> e = hash.keys(); while (e.hasMoreElements()) { String key = e.nextElement(); Object value = hash.get(key); Tags tag = Tags.findTag(key); if (tag != null) setValue(tag, value); } return this; }
/** * Create ActivityItem from HashTable generated by Hessian-decoder * * @param hash Hashtable representing ActivityItem * @return ActivityItem created from Hashtable */ public static IdentitiesTextResponse createFromHashtable(Hashtable<String, Object> hash) { IdentitiesTextResponse identityListResponse = new IdentitiesTextResponse(); Enumeration<String> e = hash.keys(); while (e.hasMoreElements()) { String key = e.nextElement(); Object value = hash.get(key); // Log.d("Get Identity Text", "createFromHashtable: Key " + key + "value: " + value); Tags tag = Tags.findTag(key); identityListResponse.setValue(tag, value); } return identityListResponse; }
/** * Returns true if the server has the given tags. A server of either * type @code{ServerType.StandAlone} or * * @code{ServerType.ShardRouter} is considered to have all tags, so this method will always return * true for instances of either of those types. * @param desiredTags the tags * @return true if this server has the given tags */ public boolean hasTags(final Tags desiredTags) { if (!ok) { return false; } if (type == StandAlone || type == ShardRouter) { return true; } for (Map.Entry<String, String> tag : desiredTags.entrySet()) { if (!tag.getValue().equals(getTags().get(tag.getKey()))) { return false; } } return true; }
public String getShortDescription() { return "{" + "address=" + address + ", type=" + type + (tags.isEmpty() ? "" : tags) + (state == Connected ? (", averagePingTime=" + NANOSECONDS.convert(averagePingTimeNanos, MILLISECONDS) + " ms") : "") + ", state=" + state + '}'; }
@Override public int hashCode() { int result = address.hashCode(); result = 31 * result + type.hashCode(); result = 31 * result + hosts.hashCode(); result = 31 * result + passives.hashCode(); result = 31 * result + arbiters.hashCode(); result = 31 * result + (primary != null ? primary.hashCode() : 0); result = 31 * result + maxDocumentSize; result = 31 * result + maxMessageSize; result = 31 * result + tags.hashCode(); result = 31 * result + (setName != null ? setName.hashCode() : 0); result = 31 * result + (setVersion != null ? setVersion.hashCode() : 0); result = 31 * result + (ok ? 1 : 0); result = 31 * result + state.hashCode(); result = 31 * result + version.hashCode(); result = 31 * result + minWireVersion; result = 31 * result + maxWireVersion; return result; }
@RequestMapping(value = "/view-news.jsp", method = RequestMethod.GET) public ModelAndView showNews( @RequestParam(value = "month", required = false) Integer month, @RequestParam(value = "year", required = false) Integer year, @RequestParam(value = "section", required = false) Integer sectionid, @RequestParam(value = "group", required = false) Integer groupid, @RequestParam(value = "tag", required = false) String tag, @RequestParam(value = "offset", required = false) Integer offset, HttpServletResponse response) throws Exception { Connection db = null; Map<String, Object> params = new HashMap<String, Object>(); try { if (month == null) { response.setDateHeader("Expires", System.currentTimeMillis() + 60 * 1000); response.setDateHeader("Last-Modified", System.currentTimeMillis()); } else { long expires = System.currentTimeMillis() + 30 * 24 * 60 * 60 * 1000L; if (year == null) { throw new ServletParameterMissingException("year"); } params.put("year", year); params.put("month", month); Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, 1); calendar.add(Calendar.MONTH, 1); long lastmod = calendar.getTimeInMillis(); if (lastmod < System.currentTimeMillis()) { response.setDateHeader("Expires", expires); response.setDateHeader("Last-Modified", lastmod); } else { response.setDateHeader("Expires", System.currentTimeMillis() + 60 * 1000); response.setDateHeader("Last-Modified", System.currentTimeMillis()); } } db = LorDataSource.getConnection(); Section section = null; if (sectionid != null) { section = new Section(db, sectionid); params.put("section", section); } Group group = null; if (groupid != null) { group = new Group(db, groupid); if (group.getSectionId() != sectionid) { throw new ScriptErrorException( "группа #" + groupid + " не принадлежит разделу #" + sectionid); } params.put("group", group); } if (tag != null) { Tags.checkTag(tag); params.put("tag", tag); } if (section == null && tag == null) { throw new ServletParameterException("section or tag required"); } String navtitle; if (section != null) { navtitle = section.getName(); } else { navtitle = tag; } if (group != null) { navtitle = "<a href=\"view-news.jsp?section=" + section.getId() + "\">" + section.getName() + "</a> - " + group.getTitle(); } String ptitle; if (month == null) { if (section != null) { ptitle = section.getName(); if (group != null) { ptitle += " - " + group.getTitle(); } if (tag != null) { ptitle += " - " + tag; } } else { ptitle = tag; } } else { ptitle = "Архив: " + section.getName(); if (group != null) { ptitle += " - " + group.getTitle(); } if (tag != null) { ptitle += " - " + tag; } ptitle += ", " + year + ", " + DateUtil.getMonth(month); navtitle += " - Архив " + year + ", " + DateUtil.getMonth(month); } params.put("ptitle", ptitle); params.put("navtitle", navtitle); NewsViewer newsViewer = new NewsViewer(); if (section != null) { newsViewer.addSection(sectionid); } if (group != null) { newsViewer.setGroup(group.getId()); } if (tag != null) { newsViewer.setTag(tag); } offset = fixOffset(offset); if (month != null) { newsViewer.setDatelimit( "postdate>='" + year + '-' + month + "-01'::timestamp AND (postdate<'" + year + '-' + month + "-01'::timestamp+'1 month'::interval)"); } else if (tag == null) { if (section.isPremoderated()) { newsViewer.setDatelimit("(commitdate>(CURRENT_TIMESTAMP-'6 month'::interval))"); } else { newsViewer.setDatelimit("(postdate>(CURRENT_TIMESTAMP-'6 month'::interval))"); } newsViewer.setLimit("LIMIT 20" + (offset > 0 ? (" OFFSET " + offset) : "")); } else { newsViewer.setLimit("LIMIT 20" + (offset > 0 ? (" OFFSET " + offset) : "")); } params.put("messages", newsViewer.getMessagesCached(db)); params.put("offsetNavigation", month == null); params.put("offset", offset); if (section != null) { String rssLink = "section-rss.jsp?section=" + section.getId(); if (group != null) { rssLink += "&group=" + group.getId(); } params.put("rssLink", rssLink); } return new ModelAndView("view-news", params); } finally { if (db != null) { db.close(); } } }
public Builder fromTags(Tags in) { return this.fingerprint(in.getFingerprint()).items(in.getItems()); }
public static class Builder { private ServerAddress address; private ServerType type = Unknown; private Set<String> hosts = Collections.emptySet(); private Set<String> passives = Collections.emptySet(); private Set<String> arbiters = Collections.emptySet(); private String primary; private int maxDocumentSize = DEFAULT_MAX_DOCUMENT_SIZE; private int maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE; private Tags tags = Tags.freeze(new Tags()); private String setName; private Integer setVersion; private long averagePingTimeNanos; private boolean ok; private ServerConnectionState state; private ServerVersion version = new ServerVersion(); private int minWireVersion = 0; private int maxWireVersion = 0; // CHECKSTYLE:OFF public Builder address(final ServerAddress address) { this.address = address; return this; } public Builder type(final ServerType type) { this.type = notNull("type", type); return this; } public Builder hosts(final Set<String> hosts) { this.hosts = hosts == null ? Collections.<String>emptySet() : Collections.unmodifiableSet(new HashSet<String>(hosts)); return this; } public Builder passives(final Set<String> passives) { this.passives = passives == null ? Collections.<String>emptySet() : Collections.unmodifiableSet(new HashSet<String>(passives)); return this; } public Builder arbiters(final Set<String> arbiters) { this.arbiters = arbiters == null ? Collections.<String>emptySet() : Collections.unmodifiableSet(new HashSet<String>(arbiters)); return this; } public Builder primary(final String primary) { this.primary = primary; return this; } public Builder maxDocumentSize(final int maxBSONObjectSize) { this.maxDocumentSize = maxBSONObjectSize; return this; } public Builder maxMessageSize(final int maxMessageSize) { this.maxMessageSize = maxMessageSize; return this; } public Builder tags(final Tags tags) { this.tags = tags == null ? Tags.freeze(new Tags()) : Tags.freeze(tags); return this; } public Builder averagePingTime(final long averagePingTime, final TimeUnit timeUnit) { this.averagePingTimeNanos = timeUnit.toNanos(averagePingTime); return this; } public Builder setName(final String setName) { this.setName = setName; return this; } public Builder setVersion(final Integer setVersion) { this.setVersion = setVersion; return this; } public Builder ok(final boolean ok) { this.ok = ok; return this; } public Builder state(final ServerConnectionState state) { this.state = state; return this; } public Builder version(final ServerVersion version) { notNull("version", version); this.version = version; return this; } public Builder minWireVersion(final int minWireVersion) { this.minWireVersion = minWireVersion; return this; } public Builder maxWireVersion(final int maxWireVersion) { this.maxWireVersion = maxWireVersion; return this; } public ServerDescription build() { return new ServerDescription(this); } // CHECKSTYLE:ON }
/** * Returns true if this instance is equals to @code{o}. Note that equality is defined to NOT * include the average ping time. * * @param o the object to compare to * @return true if this instance is equals to @code{o} */ @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final ServerDescription that = (ServerDescription) o; if (maxDocumentSize != that.maxDocumentSize) { return false; } if (maxMessageSize != that.maxMessageSize) { return false; } if (ok != that.ok) { return false; } if (!address.equals(that.address)) { return false; } if (!arbiters.equals(that.arbiters)) { return false; } if (!hosts.equals(that.hosts)) { return false; } if (!passives.equals(that.passives)) { return false; } if (primary != null ? !primary.equals(that.primary) : that.primary != null) { return false; } if (setName != null ? !setName.equals(that.setName) : that.setName != null) { return false; } if (setVersion != null ? !setVersion.equals(that.setVersion) : that.setVersion != null) { return false; } if (state != that.state) { return false; } if (!tags.equals(that.tags)) { return false; } if (type != that.type) { return false; } if (!version.equals(that.version)) { return false; } if (minWireVersion != that.minWireVersion) { return false; } if (maxWireVersion != that.maxWireVersion) { return false; } return true; }
public Mp3(MP3File mp3File) { this.mp3File = mp3File; this.tags = Tags.ExtractFrom(mp3File); }
public void drop(Tag tag) { tags.dropFrameFor(tag); }
public void dumpAllTags() { tags.dumpTagsTo(System.out); }
private FrameBodyTRCK getTrackTag() { AbstractTagFrameBody box = tags.createFrameFor(Tag.Track); return (FrameBodyTRCK) box; }
private void textBodyFor(Tag tag, Callback<AbstractFrameBodyTextInfo> callback) { AbstractTagFrameBody body1 = tags.createFrameFor(tag); callback.call((AbstractFrameBodyTextInfo) body1); }
public Builder tags(final Tags tags) { this.tags = tags == null ? Tags.freeze(new Tags()) : Tags.freeze(tags); return this; }
/* */ private int tagToInteriorID(String tag) /* */ { /* 409 */ return tagToID(Tags.toInnerTag(tag)); /* */ }