View Javadoc
1 /* 2 Bloof - visualize the evolution of your software project 3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de> 4 http://bloof.sf.net/ 5 6 This program is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along with 15 this program; if not, write to the Free Software Foundation, Inc., 16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 $RCSfile: ResultTimeLine.java,v $ 19 Created on $Date: 2003/08/21 09:44:02 $ 20 */ 21 package net.sf.bloof.metrics; 22 23 import java.io.ByteArrayOutputStream; 24 import java.io.IOException; 25 import java.text.SimpleDateFormat; 26 import java.util.ArrayList; 27 import java.util.Date; 28 import java.util.Iterator; 29 30 import net.n3.nanoxml.XMLElement; 31 import net.n3.nanoxml.XMLWriter; 32 import net.sf.bloof.util.intl.Messages; 33 import net.sf.bloof.util.intl.Text; 34 35 /*** 36 * Container for a Result of a time line metric 37 * @author Lukasz Pekacki <pekacki@users.sourceforge.net> 38 * @version $Id: ResultTimeLine.java,v 1.2 2003/08/21 09:44:02 pekacki Exp $ 39 */ 40 public class ResultTimeLine { 41 42 /*** 43 * Default constructor 44 */ 45 public ResultTimeLine() { 46 mTimeTable = new ArrayList(); 47 } 48 49 /*** 50 * Adds a TimeValue to the result 51 * @param aTimeValue TimeValue to add 52 */ 53 public void addEntry(TimeValue aTimeValue) { 54 mTimeTable.add(aTimeValue); 55 } 56 57 /*** 58 * Returns an Iterator on the time line result containing TimeValue objects 59 * @return Iterator 60 */ 61 public Iterator getDataIterator() { 62 return mTimeTable.iterator(); 63 } 64 /*** 65 * Returns the Result coded as XML-Document 66 * @return String of the XML Document 67 */ 68 public XMLElement getResultXml() { 69 XMLElement data = new XMLElement(); 70 data.setName("data"); 71 SimpleDateFormat df = new SimpleDateFormat(Messages.getString(Text.TIMESTAMP_FORMAT)); 72 for (Iterator iter = mTimeTable.iterator(); iter.hasNext();) { 73 TimeValue element = (TimeValue) iter.next(); 74 XMLElement datapoint = new XMLElement(); 75 datapoint.setName("datapoint"); 76 Date d = element.getMoment(); 77 datapoint.setAttribute("time", df.format(d)); 78 datapoint.setAttribute("value", element.getValue().toString()); 79 data.addChild(datapoint); 80 } 81 return data; 82 } 83 84 /*** 85 * Return result as XML encoded string 86 * @return XML encoded string 87 */ 88 public String getResultXMLString() { 89 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 90 XMLWriter writer = new XMLWriter(bos); 91 try { 92 writer.write(getResultXml()); 93 } catch (IOException e) { 94 // nothing can happen 95 } 96 return bos.toString(); 97 } 98 99 private ArrayList mTimeTable; 100 }

This page was automatically generated by Maven