package com.amazonaws.a2s.model;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 <p>Java class for anonymous complex type.
 
 <p>The following schema fragment specifies the expected content contained within this class.
 
 <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="DistinctTags" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="DistinctItems" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="DistinctUsers" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="TotalUsages" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="FirstTagging" type="{http://webservices.amazon.com/AWSECommerceService/2007-10-29}Tagging" minOccurs="0"/>
 *         &lt;element name="LastTagging" type="{http://webservices.amazon.com/AWSECommerceService/2007-10-29}Tagging" minOccurs="0"/>
 *         &lt;element ref="{http://webservices.amazon.com/AWSECommerceService/2007-10-29}Tag" maxOccurs="unbounded" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 </pre>
 * Generated by AWS Code Generator
 <p/>
 * Thu Jan 10 05:27:59 PST 2008
 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "distinctTags",
    "distinctItems",
    "distinctUsers",
    "totalUsages",
    "firstTagging",
    "lastTagging",
    "tag"
})
@XmlRootElement(name = "Tags")
public class Tags {

    @XmlElement(name = "DistinctTags")
    protected String distinctTags;
    @XmlElement(name = "DistinctItems")
    protected String distinctItems;
    @XmlElement(name = "DistinctUsers")
    protected String distinctUsers;
    @XmlElement(name = "TotalUsages")
    protected String totalUsages;
    @XmlElement(name = "FirstTagging")
    protected Tagging firstTagging;
    @XmlElement(name = "LastTagging")
    protected Tagging lastTagging;
    @XmlElement(name = "Tag")
    protected List<Tag> tag;

    /**
     * Gets the value of the distinctTags property.
     
     @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getDistinctTags() {
        return distinctTags;
    }

    /**
     * Sets the value of the distinctTags property.
     
     @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDistinctTags(String value) {
        this.distinctTags = value;
    }

    public boolean isSetDistinctTags() {
        return (this.distinctTags!= null);
    }

    /**
     * Gets the value of the distinctItems property.
     
     @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getDistinctItems() {
        return distinctItems;
    }

    /**
     * Sets the value of the distinctItems property.
     
     @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDistinctItems(String value) {
        this.distinctItems = value;
    }

    public boolean isSetDistinctItems() {
        return (this.distinctItems!= null);
    }

    /**
     * Gets the value of the distinctUsers property.
     
     @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getDistinctUsers() {
        return distinctUsers;
    }

    /**
     * Sets the value of the distinctUsers property.
     
     @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDistinctUsers(String value) {
        this.distinctUsers = value;
    }

    public boolean isSetDistinctUsers() {
        return (this.distinctUsers!= null);
    }

    /**
     * Gets the value of the totalUsages property.
     
     @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTotalUsages() {
        return totalUsages;
    }

    /**
     * Sets the value of the totalUsages property.
     
     @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTotalUsages(String value) {
        this.totalUsages = value;
    }

    public boolean isSetTotalUsages() {
        return (this.totalUsages!= null);
    }

    /**
     * Gets the value of the firstTagging property.
     
     @return
     *     possible object is
     *     {@link Tagging }
     *     
     */
    public Tagging getFirstTagging() {
        return firstTagging;
    }

    /**
     * Sets the value of the firstTagging property.
     
     @param value
     *     allowed object is
     *     {@link Tagging }
     *     
     */
    public void setFirstTagging(Tagging value) {
        this.firstTagging = value;
    }

    public boolean isSetFirstTagging() {
        return (this.firstTagging!= null);
    }

    /**
     * Gets the value of the lastTagging property.
     
     @return
     *     possible object is
     *     {@link Tagging }
     *     
     */
    public Tagging getLastTagging() {
        return lastTagging;
    }

    /**
     * Sets the value of the lastTagging property.
     
     @param value
     *     allowed object is
     *     {@link Tagging }
     *     
     */
    public void setLastTagging(Tagging value) {
        this.lastTagging = value;
    }

    public boolean isSetLastTagging() {
        return (this.lastTagging!= null);
    }

    /**
     * Gets the value of the tag property.
     
     <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the tag property.
     
     <p>
     * For example, to add a new item, do as follows:
     <pre>
     *    getTag().add(newItem);
     </pre>
     
     
     <p>
     * Objects of the following type(s) are allowed in the list
     {@link Tag }
     
     
     */
    public List<Tag> getTag() {
        if (tag == null) {
            tag = new ArrayList<Tag>();
        }
        return this.tag;
    }

    public boolean isSetTag() {
        return ((this.tag!= null)&&(!this.tag.isEmpty()));
    }

    public void unsetTag() {
        this.tag = null;
    }

    /**
     * Sets the value of the DistinctTags property.
     
     @param value
     @return
     *     this instance
     */
    public Tags withDistinctTags(String value) {
        setDistinctTags(value);
        return this;
    }

    /**
     * Sets the value of the DistinctItems property.
     
     @param value
     @return
     *     this instance
     */
    public Tags withDistinctItems(String value) {
        setDistinctItems(value);
        return this;
    }

    /**
     * Sets the value of the DistinctUsers property.
     
     @param value
     @return
     *     this instance
     */
    public Tags withDistinctUsers(String value) {
        setDistinctUsers(value);
        return this;
    }

    /**
     * Sets the value of the TotalUsages property.
     
     @param value
     @return
     *     this instance
     */
    public Tags withTotalUsages(String value) {
        setTotalUsages(value);
        return this;
    }

    /**
     * Sets the value of the FirstTagging property.
     
     @param value
     @return
     *     this instance
     */
    public Tags withFirstTagging(Tagging value) {
        setFirstTagging(value);
        return this;
    }

    /**
     * Sets the value of the LastTagging property.
     
     @param value
     @return
     *     this instance
     */
    public Tags withLastTagging(Tagging value) {
        setLastTagging(value);
        return this;
    }

    /**
     * Sets the value of the Tag property.
     
     @param values
     @return
     *     this instance
     */
    public Tags withTag(Tag... values) {
        for (Tag value: values) {
            getTag().add(value);
        }
        return this;
    }

    /**
     * Sets the value of the tag property.
     
     @param tag
     *     allowed object is
     *     {@link Tag }
     *     
     */
    public void setTag(List<Tag> tag) {
        this.tag = tag;
    }
    

    /**
     
     * XML fragment representation of this object
     
     @return XML fragment for this object. Name for outer
     * tag expected to be set by calling method. This fragment
     * returns inner properties representation only
     */
    protected String toXMLFragment() {
        StringBuffer xml = new StringBuffer();
        if (isSetDistinctTags()) {
            xml.append("<DistinctTags>");
            xml.append(escapeXML(getDistinctTags()));
            xml.append("</DistinctTags>");
        }
        if (isSetDistinctItems()) {
            xml.append("<DistinctItems>");
            xml.append(escapeXML(getDistinctItems()));
            xml.append("</DistinctItems>");
        }
        if (isSetDistinctUsers()) {
            xml.append("<DistinctUsers>");
            xml.append(escapeXML(getDistinctUsers()));
            xml.append("</DistinctUsers>");
        }
        if (isSetTotalUsages()) {
            xml.append("<TotalUsages>");
            xml.append(escapeXML(getTotalUsages()));
            xml.append("</TotalUsages>");
        }
        if (isSetFirstTagging()) {
            Tagging  firstTagging = getFirstTagging();
            xml.append("<FirstTagging>");
            xml.append(firstTagging.toXMLFragment());
            xml.append("</FirstTagging>");
        
        if (isSetLastTagging()) {
            Tagging  lastTagging = getLastTagging();
            xml.append("<LastTagging>");
            xml.append(lastTagging.toXMLFragment());
            xml.append("</LastTagging>");
        
        java.util.List<Tag> tagList = getTag();
        for (Tag tag : tagList) {
            xml.append("<Tag>");
            xml.append(tag.toXMLFragment());
            xml.append("</Tag>");
        }
        return xml.toString();
    }

    /**
     
     * Escape XML special characters
     */
    private String escapeXML(String string) {
        StringBuffer sb = new StringBuffer();
        int length = string.length();
        for (int i = 0; i < length; ++i) {
            char c = string.charAt(i);
            switch (c) {
            case '&':
                sb.append("&amp;");
                break;
            case '<':
                sb.append("&lt;");
                break;
            case '>':
                sb.append("&gt;");
                break;
            case '\'':
                sb.append("&#039;");
                break;
            case '"':
                sb.append("&quot;");
                break;
            default:
                sb.append(c);
            }
        }
        return sb.toString();
    }


}