//# 0 errors, 209 messages
//#
/*
    //#tag.java:1:1: class: net.sourceforge.pebble.domain.Tag
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.domain;

import net.sourceforge.pebble.util.StringUtils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.*;

/**
 * Represents a tag.
 *
 * @author    Simon Brown
 */
public class Tag implements Permalinkable, Comparable {

  /** the log used by this class */
  private static final Log log = LogFactory.getLog(Tag.class);
    //#tag.java:49: method: net.sourceforge.pebble.domain.Tag.net.sourceforge.pebble.domain.Tag__static_init
    //#tag.java:49: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Tag
    //#    method: net.sourceforge.pebble.domain.Tag__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Descendant_Table[net/sourceforge/pebble/domain/Tag]
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.compareTo(Ljava/lang/Object;)I
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.getPermalink()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.getRank()I
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.hashCode()I
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.setName(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.toString()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.Tag__static_init): log
    //#output(net.sourceforge.pebble.domain.Tag__static_init): net/sourceforge/pebble/domain/Permalinkable.__Descendant_Table[net/sourceforge/pebble/domain/Tag]
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Descendant_Table[net/sourceforge/pebble/domain/Tag] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.domain.Tag__static_init): net/sourceforge/pebble/domain/Permalinkable.__Descendant_Table[net/sourceforge/pebble/domain/Tag] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.compareTo(Ljava/lang/Object;)I == &compareTo
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z == &equals
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.getPermalink()Ljava/lang/String; == &getPermalink
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.getRank()I == &getRank
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.hashCode()I == &hashCode
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.setName(Ljava/lang/String;)V == &setName
    //#post(net.sourceforge.pebble.domain.Tag__static_init): __Dispatch_Table.toString()Ljava/lang/String; == &toString
    //#post(net.sourceforge.pebble.domain.Tag__static_init): init'ed(log)
    //#tag.java:49: end of method: net.sourceforge.pebble.domain.Tag.net.sourceforge.pebble.domain.Tag__static_init

  /** the owning blog */
  private Blog blog;

  /** the name of the tag */
  private String name = "";

  /** the rank for this tag */
  protected int rank;

  /**
   * Creates a new tag with the specified properties.
   *
   * @param name    the name
   * @param blog    a Blog instance
   */
  public Tag(String name, Blog blog) {
    //#tag.java:66: method: void net.sourceforge.pebble.domain.Tag.net.sourceforge.pebble.domain.Tag(String, Blog)
    //#tag.java:66: Warning: suspicious precondition
    //#    the precondition for this.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.domain.Tag
    //#    method: void net.sourceforge.pebble.domain.Tag(String, Blog)
    //#    suspicious precondition index: [4]
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): __Descendant_Table[net/sourceforge/pebble/domain/Tag]
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): __Descendant_Table[net/sourceforge/pebble/index/IndexedTag]
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): __Descendant_Table[others]
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): __Dispatch_Table.setName(Ljava/lang/String;)V
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): blog
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): name
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): net/sourceforge/pebble/index/IndexedTag.__Dispatch_Table.setName(Ljava/lang/String;)V
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): this
    //#input(void net.sourceforge.pebble.domain.Tag(String, Blog)): this.__Tag
    //#output(void net.sourceforge.pebble.domain.Tag(String, Blog)): this.blog
    //#output(void net.sourceforge.pebble.domain.Tag(String, Blog)): this.name
    //#pre[4] (void net.sourceforge.pebble.domain.Tag(String, Blog)): this.__Tag in {net/sourceforge/pebble/domain/Tag, net/sourceforge/pebble/index/IndexedTag}
    //#post(void net.sourceforge.pebble.domain.Tag(String, Blog)): this.blog == blog
    //#post(void net.sourceforge.pebble.domain.Tag(String, Blog)): init'ed(this.blog)
    //#post(void net.sourceforge.pebble.domain.Tag(String, Blog)): this.name != null
    //#unanalyzed(void net.sourceforge.pebble.domain.Tag(String, Blog)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(void net.sourceforge.pebble.domain.Tag(String, Blog)): Effects-of-calling:java.lang.String:toLowerCase
    //#unanalyzed(void net.sourceforge.pebble.domain.Tag(String, Blog)): Effects-of-calling:java.lang.String:replaceAll
    setName(name);
    this.blog = blog;
  }
    //#tag.java:69: end of method: void net.sourceforge.pebble.domain.Tag.net.sourceforge.pebble.domain.Tag(String, Blog)

  /**
   * Gets the name of this tag.
   *
   * @return    the name as a String
   */
  public String getName() {
    return name;
    //#tag.java:77: method: String net.sourceforge.pebble.domain.Tag.getName()
    //#input(String getName()): this
    //#input(String getName()): this.name
    //#output(String getName()): return_value
    //#pre[2] (String getName()): init'ed(this.name)
    //#post(String getName()): return_value == this.name
    //#post(String getName()): init'ed(return_value)
    //#tag.java:77: end of method: String net.sourceforge.pebble.domain.Tag.getName()
  }

  /**
   * Sets the name of this tag.
   *
   * @param name    the new tag name
   */
  public void setName(String name) {
    this.name = Tag.encode(name);
    //#tag.java:86: method: void net.sourceforge.pebble.domain.Tag.setName(String)
    //#input(void setName(String)): name
    //#input(void setName(String)): this
    //#output(void setName(String)): this.name
    //#post(void setName(String)): this.name != null
    //#unanalyzed(void setName(String)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(void setName(String)): Effects-of-calling:java.lang.String:toLowerCase
    //#unanalyzed(void setName(String)): Effects-of-calling:java.lang.String:replaceAll
  }
    //#tag.java:87: end of method: void net.sourceforge.pebble.domain.Tag.setName(String)

  /**
   * Gets the permalink for this object.
   *
   * @return  a URL as a String
   */
  public String getPermalink() {
    return blog.getUrl() + "tags/" + name + "/";
    //#tag.java:95: method: String net.sourceforge.pebble.domain.Tag.getPermalink()
    //#input(String getPermalink()): net/sourceforge/pebble/Configuration.__Descendant_Table[net/sourceforge/pebble/Configuration]
    //#input(String getPermalink()): net/sourceforge/pebble/Configuration.__Descendant_Table[others]
    //#input(String getPermalink()): net/sourceforge/pebble/Configuration.__Dispatch_Table.getUrl()Ljava/lang/String;
    //#input(String getPermalink()): net/sourceforge/pebble/Configuration.__Dispatch_Table.isVirtualHostingEnabled()Z
    //#input(String getPermalink()): net/sourceforge/pebble/domain/Blog.__Descendant_Table[net/sourceforge/pebble/domain/Blog]
    //#input(String getPermalink()): net/sourceforge/pebble/domain/Blog.__Descendant_Table[others]
    //#input(String getPermalink()): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getId()Ljava/lang/String;
    //#input(String getPermalink()): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getUrl()Ljava/lang/String;
    //#input(String getPermalink()): net/sourceforge/pebble/domain/BlogManager.__Descendant_Table[net/sourceforge/pebble/domain/BlogManager]
    //#input(String getPermalink()): net/sourceforge/pebble/domain/BlogManager.__Descendant_Table[others]
    //#input(String getPermalink()): net/sourceforge/pebble/domain/BlogManager.__Dispatch_Table.isMultiBlog()Z
    //#input(String getPermalink()): net/sourceforge/pebble/domain/BlogManager.instance
    //#input(String getPermalink()): net/sourceforge/pebble/domain/BlogManager.instance.__Tag
    //#input(String getPermalink()): net/sourceforge/pebble/domain/BlogManager.instance.multiBlog
    //#input(String getPermalink()): this
    //#input(String getPermalink()): this.blog
    //#input(String getPermalink()): this.blog.__Tag
    //#input(String getPermalink()): this.blog.id
    //#input(String getPermalink()): this.name
    //#output(String getPermalink()): return_value
    //#pre[5] (String getPermalink()): this.blog != null
    //#pre[6] (String getPermalink()): this.blog.__Tag == net/sourceforge/pebble/domain/Blog
    //#pre[8] (String getPermalink()): init'ed(this.name)
    //#pre[1] (String getPermalink()): (soft) net/sourceforge/pebble/domain/BlogManager.instance != null
    //#pre[2] (String getPermalink()): (soft) net/sourceforge/pebble/domain/BlogManager.instance.__Tag == net/sourceforge/pebble/domain/BlogManager
    //#pre[3] (String getPermalink()): (soft) init'ed(net/sourceforge/pebble/domain/BlogManager.instance.multiBlog)
    //#pre[7] (String getPermalink()): (soft) init'ed(this.blog.id)
    //#post(String getPermalink()): return_value != null
    //#unanalyzed(String getPermalink()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(String getPermalink()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(String getPermalink()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(String getPermalink()): Effects-of-calling:java.lang.String:valueOf
    //#unanalyzed(String getPermalink()): Effects-of-calling:java.lang.String:indexOf
    //#unanalyzed(String getPermalink()): Effects-of-calling:net.sourceforge.pebble.PebbleContext:getInstance
    //#unanalyzed(String getPermalink()): Effects-of-calling:net.sourceforge.pebble.PebbleContext:getConfiguration
    //#unanalyzed(String getPermalink()): Effects-of-calling:java.lang.String:length
    //#unanalyzed(String getPermalink()): Effects-of-calling:java.lang.String:substring
    //#tag.java:95: end of method: String net.sourceforge.pebble.domain.Tag.getPermalink()
  }

  /**
   * Gets the hashcode of this object.
   *
   * @return  the hashcode as an int
   */
  public int hashCode() {
    return name.hashCode();
    //#tag.java:104: method: int net.sourceforge.pebble.domain.Tag.hashCode()
    //#input(int hashCode()): this
    //#input(int hashCode()): this.name
    //#output(int hashCode()): return_value
    //#pre[2] (int hashCode()): this.name != null
    //#post(int hashCode()): init'ed(return_value)
    //#tag.java:104: end of method: int net.sourceforge.pebble.domain.Tag.hashCode()
  }

  /**
   * Determines whether the specified object is equal to this one.
   *
   * @param o   the object to compare against
   * @return    true if Object o represents the same tag, false otherwise
   */
  public boolean equals(Object o) {
    if (!(o instanceof Tag)) {
    //#tag.java:114: method: bool net.sourceforge.pebble.domain.Tag.equals(Object)
    //#input(bool equals(Object)): __Descendant_Table[net/sourceforge/pebble/domain/Tag]
    //#input(bool equals(Object)): __Descendant_Table[net/sourceforge/pebble/index/IndexedTag]
    //#input(bool equals(Object)): __Descendant_Table[others]
    //#input(bool equals(Object)): __Dispatch_Table.getName()Ljava/lang/String;
    //#input(bool equals(Object)): net/sourceforge/pebble/index/IndexedTag.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(bool equals(Object)): o
    //#input(bool equals(Object)): o.__Tag
    //#input(bool equals(Object)): o.name
    //#input(bool equals(Object)): this
    //#input(bool equals(Object)): this.name
    //#output(bool equals(Object)): return_value
    //#pre[3] (bool equals(Object)): (soft) o.name != null
    //#pre[5] (bool equals(Object)): (soft) init'ed(this.name)
    //#post(bool equals(Object)): init'ed(return_value)
      return false;
    }

    Tag tag = (Tag)o;
    return tag.getName().equals(name);
    //#tag.java:119: end of method: bool net.sourceforge.pebble.domain.Tag.equals(Object)
  }

  /**
   * Compares this object with the specified object for order.  Returns a
   * negative integer, zero, or a positive integer as this object is less
   * than, equal to, or greater than the specified object.<p>
   *
   * @param   o the Object to be compared.
   * @return  a negative integer, zero, or a positive integer as this object
   *		is less than, equal to, or greater than the specified object.
   *
   * @throws ClassCastException if the specified object's type prevents it
   *         from being compared to this Object.
   */
  public int compareTo(Object o) {
    Tag tag = (Tag)o;
    //#tag.java:135: method: int net.sourceforge.pebble.domain.Tag.compareTo(Object)
    //#tag.java:135: Warning: suspicious precondition
    //#    the precondition for o.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.domain.Tag
    //#    method: int compareTo(Object)
    //#    suspicious precondition index: [2]
    //#tag.java:135: Warning: suspicious precondition
    //#    the precondition for this.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.domain.Tag
    //#    method: int compareTo(Object)
    //#    suspicious precondition index: [5]
    //#input(int compareTo(Object)): __Descendant_Table[net/sourceforge/pebble/domain/Tag]
    //#input(int compareTo(Object)): __Descendant_Table[net/sourceforge/pebble/index/IndexedTag]
    //#input(int compareTo(Object)): __Descendant_Table[others]
    //#input(int compareTo(Object)): __Dispatch_Table.getName()Ljava/lang/String;
    //#input(int compareTo(Object)): net/sourceforge/pebble/index/IndexedTag.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(int compareTo(Object)): o
    //#input(int compareTo(Object)): o.__Tag
    //#input(int compareTo(Object)): o.name
    //#input(int compareTo(Object)): this
    //#input(int compareTo(Object)): this.__Tag
    //#input(int compareTo(Object)): this.name
    //#output(int compareTo(Object)): return_value
    //#pre[1] (int compareTo(Object)): o != null
    //#pre[2] (int compareTo(Object)): o.__Tag in {net/sourceforge/pebble/domain/Tag, net/sourceforge/pebble/index/IndexedTag}
    //#pre[3] (int compareTo(Object)): init'ed(o.name)
    //#pre[5] (int compareTo(Object)): this.__Tag in {net/sourceforge/pebble/domain/Tag, net/sourceforge/pebble/index/IndexedTag}
    //#pre[6] (int compareTo(Object)): this.name != null
    //#post(int compareTo(Object)): init'ed(return_value)
    return getName().compareTo(tag.getName());
    //#tag.java:136: end of method: int net.sourceforge.pebble.domain.Tag.compareTo(Object)
  }

  /**
   * Returns a String representation of this object.
   *
   * @return  a String
   */
  public String toString() {
    return this.name;
    //#tag.java:145: method: String net.sourceforge.pebble.domain.Tag.toString()
    //#input(String toString()): this
    //#input(String toString()): this.name
    //#output(String toString()): return_value
    //#pre[2] (String toString()): init'ed(this.name)
    //#post(String toString()): return_value == this.name
    //#post(String toString()): init'ed(return_value)
    //#tag.java:145: end of method: String net.sourceforge.pebble.domain.Tag.toString()
  }

  /**
   * Gets the rank for this tag.
   *
   * @return  an int between 1 and 10;
   */
  public int getRank() {
    return this.rank;
    //#tag.java:154: method: int net.sourceforge.pebble.domain.Tag.getRank()
    //#input(int getRank()): this
    //#input(int getRank()): this.rank
    //#output(int getRank()): return_value
    //#pre[2] (int getRank()): init'ed(this.rank)
    //#post(int getRank()): return_value == this.rank
    //#post(int getRank()): init'ed(return_value)
    //#tag.java:154: end of method: int net.sourceforge.pebble.domain.Tag.getRank()
  }

  /**
   * Given a string containing whitespace separated tags, this method returns a
   * List containing the tags.
   *
   * @param tags    a whitespace separated list of tags
   * @return        a List of Tag instances
   */
  public static List<Tag> parse(Blog blog, String tags) {
    List<Tag> list = new ArrayList<Tag>();
    //#tag.java:165: method: List net.sourceforge.pebble.domain.Tag.parse(Blog, String)
    //#input(List parse(Blog, String)): __Descendant_Table[net/sourceforge/pebble/domain/Tag]
    //#input(List parse(Blog, String)): __Descendant_Table[net/sourceforge/pebble/index/IndexedTag]
    //#input(List parse(Blog, String)): __Descendant_Table[others]
    //#input(List parse(Blog, String)): __Dispatch_Table.setName(Ljava/lang/String;)V
    //#input(List parse(Blog, String)): blog
    //#input(List parse(Blog, String)): net/sourceforge/pebble/index/IndexedTag.__Dispatch_Table.setName(Ljava/lang/String;)V
    //#input(List parse(Blog, String)): tags
    //#output(List parse(Blog, String)): new ArrayList(parse#1) num objects
    //#output(List parse(Blog, String)): return_value
    //#new obj(List parse(Blog, String)): new ArrayList(parse#1)
    //#presumption(List parse(Blog, String)): s.length@168 <= 4_294_967_295
    //#presumption(List parse(Blog, String)): s[i]@168 != null
    //#post(List parse(Blog, String)): return_value == &new ArrayList(parse#1)
    //#post(List parse(Blog, String)): new ArrayList(parse#1) num objects == 1
    //#unanalyzed(List parse(Blog, String)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(List parse(Blog, String)): Effects-of-calling:java.lang.String:toLowerCase
    //#unanalyzed(List parse(Blog, String)): Effects-of-calling:java.lang.String:replaceAll
    //#test_vector(List parse(Blog, String)): tags: Addr_Set{null}, Inverse{null}
    //#test_vector(List parse(Blog, String)): java.lang.String:length(...)@167: {0}, {1..4_294_967_295}
    //#test_vector(List parse(Blog, String)): java.util.List:contains(...)@171: {1}, {0}

    if (tags != null && tags.trim().length() > 0) {
      String s[] = tags.trim().split(" ");
      for (int i = 0; i < s.length; i++) {
        Tag tag = new Tag(StringUtils.transformHTML(s[i].trim()), blog);
    //#tag.java:170: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.util.StringUtils:transformHTML(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.domain.Tag
    //#    method: List parse(Blog, String)
    //#    unanalyzed callee: String net.sourceforge.pebble.util.StringUtils:transformHTML(String)
        if (!list.contains(tag)) {
          list.add(tag);
        }
      }
    }

    return list;
    //#tag.java:177: end of method: List net.sourceforge.pebble.domain.Tag.parse(Blog, String)
  }

  /**
   * Given a list of tags, this method formats them into a comma separated list.
   *
   * @param tags    a List of tags
   * @return  a comma separated String
   */
  public static String format(List<Tag> tags) {
    StringBuilder builder = new StringBuilder();
    //#tag.java:187: method: String net.sourceforge.pebble.domain.Tag.format(List)
    //#input(String format(List)): __Descendant_Table[net/sourceforge/pebble/domain/Tag]
    //#input(String format(List)): __Descendant_Table[net/sourceforge/pebble/index/IndexedTag]
    //#input(String format(List)): __Descendant_Table[others]
    //#input(String format(List)): __Dispatch_Table.getName()Ljava/lang/String;
    //#input(String format(List)): net/sourceforge/pebble/index/IndexedTag.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(String format(List)): tags
    //#output(String format(List)): return_value
    //#presumption(String format(List)): java.util.Iterator:next(...).__Tag@192 in {net/sourceforge/pebble/domain/Tag, net/sourceforge/pebble/index/IndexedTag}
    //#presumption(String format(List)): java.util.Iterator:next(...)@192 != null
    //#post(String format(List)): return_value != null
    //#test_vector(String format(List)): tags: Addr_Set{null}, Inverse{null}
    //#test_vector(String format(List)): java.util.Iterator:hasNext(...)@191: {1}, {0}
    //#test_vector(String format(List)): java.util.Iterator:hasNext(...)@194: {0}, {1}

    if (tags != null) {
      Iterator it = tags.iterator();
      while (it.hasNext()) {
        Tag tag = (Tag)it.next();
        builder.append(tag.getName());
        if (it.hasNext()) {
          builder.append(", ");
        }
      }
    }

    return builder.toString();
    //#tag.java:200: end of method: String net.sourceforge.pebble.domain.Tag.format(List)
  }

  /**
   * Encodes a tag.
   *
   * @param tag   a String
   */
  public static String encode(String tag) {
    if (tag == null) {
    //#tag.java:209: method: String net.sourceforge.pebble.domain.Tag.encode(String)
    //#input(String encode(String)): tag
    //#output(String encode(String)): return_value
    //#post(String encode(String)): return_value != null
    //#test_vector(String encode(String)): tag: Inverse{null}, Addr_Set{null}
      return "";
    } else {
      String encodedTag = tag.trim().toLowerCase();
      encodedTag = encodedTag.replaceAll("\\+", " ");
      return encodedTag;
    //#tag.java:214: end of method: String net.sourceforge.pebble.domain.Tag.encode(String)
    }
  }

}
    //#tag.java:: end of class: net.sourceforge.pebble.domain.Tag
