1 package be
.nikiroo
.fanfix
.searchable
;
3 import java
.util
.ArrayList
;
7 * This class represents a tag that can be searched on a supported website.
11 public class SearchableTag
{
14 private boolean complete
;
16 private List
<SearchableTag
> children
;
19 * Create a new {@link SearchableTag}.
22 * the ID (usually a way to find the linked stories later on)
24 * the tag name, which can be displayed to the user
26 * TRUE for a {@link SearchableTag} that cannot be "filled" by
27 * the {@link BasicSearchable} in order to get (more?) subtag
30 public SearchableTag(String id
, String name
, boolean complete
) {
33 this.complete
= complete
;
35 children
= new ArrayList
<SearchableTag
>();
38 public String
getId() {
42 public String
getName() {
47 * This tag can still be completed via a "fill" tag operation from a
48 * {@link BasicSearchable}, in order to gain (more?) subtag children.
50 * @return TRUE if it can
52 public boolean isComplete() {
57 * This tag can still be completed via a "fill" tag operation from a
58 * {@link BasicSearchable}, in order to gain (more?) subtag children.
63 public void setComplete(boolean complete
) {
64 this.complete
= complete
;
68 * The number of items that can be found with this tag if it is searched.
70 * Will report the number of subtags by default.
72 * @return the number of items
74 public long getCount() {
75 long count
= this.count
;
77 count
= children
.size();
84 * The number of items that can be found with this tag if it is searched,
87 * Will report the number of subtags by default.
89 * @return the number of items
91 public String
getCountDisplay() {
92 long count
= this.count
;
94 count
= children
.size();
98 return count
/ 1000000 + "M";
102 return count
/ 1000 + "k";
105 return Long
.toString(count
);
109 * The number of items that can be found with this tag if it is searched.
114 public void setCount(long count
) {
119 * The subtag children of this {@link SearchableTag}.
123 * Note that if {@link SearchableTag#isComplete()} returns false, you can
124 * still fill (more?) subtag children with a {@link BasicSearchable}.
126 * @return the subtag children, never NULL
128 public List
<SearchableTag
> getChildren() {
133 * Add the given {@link SearchableTag} as a subtag child.
138 public void add(SearchableTag tag
) {
143 * Display a DEBUG {@link String} representation of this object.
146 public String
toString() {
147 String rep
= name
+ " [" + id
+ "]";
152 if (getCount() > 0) {
153 rep
+= " (" + getCountDisplay() + ")";
156 if (!children
.isEmpty()) {
159 for (SearchableTag tag
: children
) {
160 if (!tags
.isEmpty()) {