/* * Jeti, a Java Jabber client, Copyright (C) 2003 E.S. de Boer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For questions, comments etc, * use the website at http://jeti.jabberstudio.org * or mail/IM me at jeti@jabber.org * * Created on 26-jul-2003 */ package nu.fw.jeti.jabber.elements; import java.util.LinkedList; import java.util.List; import nu.fw.jeti.util.I18N; /** * @author E.S. de Boer * */ public class XDataBuilder { private String instructions; //multi add line end public String title; public String type; private List fields; private List reportedFields; private List items; public XDataBuilder() { reset(); } public void reset() { instructions = null; title = null; type = null; fields = null; reportedFields = null; items = null; } /** * adds instructions (multiple calls wil be added with an added end of line) * @param instructions */ public void addInstructions(String instructions) { if(this.instructions == null) this.instructions = instructions; else { this.instructions = this.instructions + "\n" + instructions; } } public String getInstructions() { return instructions; } public void addField(XDataField field) { if(fields== null) fields = new LinkedList(); fields.add(field); } public void addReportedField(XDataField field) { if(reportedFields== null) reportedFields = new LinkedList(); reportedFields.add(field); } public void addItem(List item) { if(items==null)items = new LinkedList(); items.add(item); } public List getFields() { return fields; } public List getReported() { return reportedFields; } public List getItems() { return items; } public XData build() throws InstantiationException { if (type==null) throw new InstantiationException(I18N.gettext("main.error.No_type")); else if(type.equals("cancel") || type.equals("form") || type.equals("result") || type.equals("submit")); else throw new InstantiationException("Wrong type"); return new XData(this); } } /* * Overrides for emacs * Local variables: * tab-width: 4 * End: */