X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsearchable%2FSearchableTag.java;h=338f84daa950b39eb4cac62ec487120738faa35b;hb=3bf5c19b7144e236249afe1fa3f311bf7768c771;hp=af1ce0f1a50c1571a4a2841c9733ad32998445e6;hpb=76ec935e19dbd00dfbcaaeabfc187125f727b5ac;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/searchable/SearchableTag.java b/src/be/nikiroo/fanfix/searchable/SearchableTag.java index af1ce0f..338f84d 100644 --- a/src/be/nikiroo/fanfix/searchable/SearchableTag.java +++ b/src/be/nikiroo/fanfix/searchable/SearchableTag.java @@ -13,6 +13,8 @@ public class SearchableTag { private String name; private boolean complete; private long count; + + private SearchableTag parent; private List children; /** @@ -41,7 +43,7 @@ public class SearchableTag { * the tag is a leaf tag, that is, it will not return subtags * with {@link BasicSearchable#fillTag(SearchableTag)} but will * return stories with - * {@link BasicSearchable#search(SearchableTag)} + * {@link BasicSearchable#search(SearchableTag, int)} */ public SearchableTag(String id, String name, boolean leaf) { this(id, name, leaf, true); @@ -58,14 +60,14 @@ public class SearchableTag { * the tag is a leaf tag, that is, it will not return subtags * with {@link BasicSearchable#fillTag(SearchableTag)} but will * return stories with - * {@link BasicSearchable#search(SearchableTag)} + * {@link BasicSearchable#search(SearchableTag, int)} * @param complete * the tag {@link SearchableTag#isComplete()} or not */ public SearchableTag(String id, String name, boolean leaf, boolean complete) { this.id = id; this.name = name; - this.complete = complete; + this.complete = leaf || complete; setLeaf(leaf); @@ -90,12 +92,27 @@ public class SearchableTag { return name; } + /** + * The fully qualified tag name, which can be displayed to the user. + *

+ * It will display all the tags that lead to this one as well as this one. + * + * @return the fully qualified name + */ + public String getFqName() { + if (parent != null) { + return parent.getFqName() + " / " + name; + } + + return name; + } + /** * Non-complete, non-leaf tags can still be completed via a * {@link BasicSearchable#fillTag(SearchableTag)} operation from a * {@link BasicSearchable}, in order to gain (more?) subtag children. *

- * This method does not make sense for leaf tags. + * Leaf tags are always considered complete. * * @return TRUE if it is complete */ @@ -108,13 +125,13 @@ public class SearchableTag { * {@link BasicSearchable#fillTag(SearchableTag)} operation from a * {@link BasicSearchable}, in order to gain (more?) subtag children. *

- * This method does not make sense for leaf tags. + * Leaf tags are always considered complete. * * @param complete * TRUE if it is complete */ public void setComplete(boolean complete) { - this.complete = complete; + this.complete = isLeaf() || complete; } /** @@ -133,31 +150,6 @@ public class SearchableTag { return count; } - /** - * The number of items that can be found with this tag if it is searched, - * displayable format. - *

- * Will report the number of subtags by default. - * - * @return the number of items - */ - public String getCountDisplay() { - long count = this.count; - if (count <= 0) { - count = children.size(); - } - - if (count > 999999) { - return count / 1000000 + "M"; - } - - if (count > 2000) { - return count / 1000 + "k"; - } - - return Long.toString(count); - } - /** * The number of items that can be found with this tag if it is searched. * @@ -194,7 +186,7 @@ public class SearchableTag { /** * This tag is a leaf tag, that is, it will not return other subtags with * {@link BasicSearchable#fillTag(SearchableTag)} but will return stories - * with {@link BasicSearchable#search(SearchableTag)}. + * with {@link BasicSearchable#search(SearchableTag, int)}. * * @return TRUE if it is */ @@ -205,7 +197,7 @@ public class SearchableTag { /** * This tag is a leaf tag, that is, it will not return other subtags with * {@link BasicSearchable#fillTag(SearchableTag)} but will return stories - * with {@link BasicSearchable#search(SearchableTag)}. + * with {@link BasicSearchable#search(SearchableTag, int)}. *

* Will reset the number of pages to -1. * @@ -214,6 +206,9 @@ public class SearchableTag { */ public void setLeaf(boolean leaf) { pages = leaf ? -1 : -2; + if (leaf) { + complete = true; + } } /** @@ -238,6 +233,16 @@ public class SearchableTag { */ public void add(SearchableTag tag) { children.add(tag); + tag.parent = this; + } + + /** + * This {@link SearchableTag} parent tag, or NULL if none. + * + * @return the parent or NULL + */ + public SearchableTag getParent() { + return parent; } /** @@ -251,7 +256,7 @@ public class SearchableTag { } if (getCount() > 0) { - rep += " (" + getCountDisplay() + ")"; + rep += " (" + getCount() + ")"; } if (!children.isEmpty()) {