/*
 * FindBugs - Find Bugs in Java programs
 * Copyright (C) 2005, University of Maryland
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.findbugs;

import java.io.IOException;

import edu.umd.cs.findbugs.xml.XMLAttributeList;
import edu.umd.cs.findbugs.xml.XMLOutput;
import edu.umd.cs.findbugs.xml.XMLWriteable;

/**
 * A version of an analyzed application.
 * Application versions are uniquely identified by a sequence number,
 * which represents a run of FindBugs on the application.
 * Timestamp is when FindBugs was run (according to System.currentTimeMillis()),
 * and the release name is available if the user provided it.
 * 
 * @author David Hovemeyer
 */
public class AppVersion implements XMLWriteable, Cloneable {
	/**
	 * XML element name for a stored AppVersion object.
	 */
	public static final String ELEMENT_NAME = "AppVersion";
	
	private long sequence;
	private long timestamp;
	private String releaseName;
	
	public AppVersion(long sequence) {
		this.sequence = sequence;
		this.timestamp = -1;
		this.releaseName = "";
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#clone()
	 */
	//@Override
	public Object clone() {
		try {
			return super.clone();
		} catch (CloneNotSupportedException e) {
			throw new IllegalStateException();
		}
	}
	
	/**
	 * @return Returns the sequence.
	 */
	public long getSequenceNumber() {
		return sequence;
	}
	
	/**
	 * @return Returns the timestamp.
	 */
	public long getTimestamp() {
		return timestamp;
	}
	
	/**
	 * @return Returns the releaseName.
	 */
	public String getReleaseName() {
		return releaseName;
	}
	
	/**
	 * @param timestamp The timestamp to set.
	 */
	public AppVersion setTimestamp(long timestamp) {
		this.timestamp = timestamp;
		return this;
	}
	
	/**
	 * @param releaseName The releaseName to set.
	 */
	public AppVersion setReleaseName(String releaseName) {
		this.releaseName = releaseName;
		return this;
	}
	
	/* (non-Javadoc)
	 * @see edu.umd.cs.findbugs.xml.XMLWriteable#writeXML(edu.umd.cs.findbugs.xml.XMLOutput)
	 */
	public void writeXML(XMLOutput xmlOutput) throws IOException {
		xmlOutput.openCloseTag(ELEMENT_NAME, new XMLAttributeList()
				.addAttribute("sequence", String.valueOf(sequence))
				.addAttribute("timestamp", String.valueOf(timestamp))
				.addAttribute("release", releaseName));
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	//@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append(String.valueOf(sequence));
		buf.append(',');
		buf.append(String.valueOf(timestamp));
		buf.append(',');
		buf.append(releaseName);
		return buf.toString();
	}
}

@@ -887,16 +887,39 @@
 ception;
+%0Aimport java.util.Date;
 %0A%0Aimport
@@ -1663,16 +1663,312 @@
 Name;%0A%09%0A
+%09public AppVersion(long sequence, long time, String name) %7B%0A%09%09this.sequence = sequence;%0A%09%09this.timestamp = time;%0A%09%09this.releaseName = name;%0A%09%7D%0A%09public AppVersion(long sequence, Date time, String name) %7B%0A%09%09this.sequence = sequence;%0A%09%09this.timestamp = time.getTime();%0A%09%09this.releaseName = name;%0A%09%7D%0A
 %09public 

Add additional constructors