1 package jp.naist.se.stigmata.format.xml;
\r
7 import java.io.PrintWriter;
\r
8 import java.util.Iterator;
\r
10 import jp.naist.se.stigmata.Birthmark;
\r
11 import jp.naist.se.stigmata.BirthmarkElement;
\r
12 import jp.naist.se.stigmata.BirthmarkSet;
\r
13 import jp.naist.se.stigmata.format.AbstractBirthmarkExtractionResultFormat;
\r
19 * @author Haruaki TAMADA
\r
20 * @version $Revision$ $Date$
\r
22 public class BirthmarkExtractionListXmlFormat extends AbstractBirthmarkExtractionResultFormat{
\r
23 public void printResult(PrintWriter out, BirthmarkSet[] holders){
\r
24 out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
\r
25 out.println("<stigmata>");
\r
26 out.println(" <extracted-birthmarks>");
\r
27 for(int i = 0; i < holders.length; i++){
\r
28 printBirthmarkHolder(out, holders[i]);
\r
30 out.println(" </extracted-birthmarks>");
\r
31 out.println("</stigmata>");
\r
34 protected void printBirthmarkHolder(PrintWriter out, BirthmarkSet holder){
\r
35 out.println(" <extracted-birthmark>");
\r
36 out.print(" <class-name>");
\r
37 out.print(holder.getClassName());
\r
38 out.println("<class-name>");
\r
39 out.print(" <location>");
\r
40 out.print(holder.getLocation());
\r
41 out.println("</location>");
\r
42 for(Iterator<String> i = holder.birthmarkTypes(); i.hasNext(); ){
\r
43 String type = i.next();
\r
44 Birthmark birthmark = holder.getBirthmark(type);
\r
45 out.print(" <birthmark type=\"");
\r
46 out.print(birthmark.getType());
\r
47 out.print("\" count=\"");
\r
48 out.print(birthmark.getElementCount());
\r
50 for(Iterator<BirthmarkElement> elements = birthmark.iterator(); elements.hasNext(); ){
\r
51 out.print(" <element>");
\r
52 out.print(elements.next());
\r
53 out.println("</element>");
\r
55 out.println(" </extracted-birthmark>");
\r
57 out.println(" </target>");
\r