[3952] | 1 | /* |
---|
| 2 | * Jeti, a Java Jabber client, Copyright (C) 2003 E.S. de Boer |
---|
| 3 | * |
---|
| 4 | * This program is free software; you can redistribute it and/or modify |
---|
| 5 | * it under the terms of the GNU General Public License as published by |
---|
| 6 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | * (at your option) any later version. |
---|
| 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 |
---|
| 15 | * along with this program; if not, write to the Free Software |
---|
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | * |
---|
| 18 | * For questions, comments etc, |
---|
| 19 | * use the website at http://jeti.jabberstudio.org |
---|
| 20 | * or mail/IM me at jeti@jabber.org |
---|
| 21 | * |
---|
| 22 | * Created on 26-jul-2003 |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | package nu.fw.jeti.jabber.elements; |
---|
| 26 | |
---|
| 27 | import java.util.LinkedList; |
---|
| 28 | import java.util.List; |
---|
| 29 | |
---|
| 30 | import nu.fw.jeti.util.I18N; |
---|
| 31 | |
---|
| 32 | /** |
---|
| 33 | * @author E.S. de Boer |
---|
| 34 | * |
---|
| 35 | */ |
---|
| 36 | public class XDataBuilder |
---|
| 37 | { |
---|
| 38 | private String instructions; //multi add line end |
---|
| 39 | public String title; |
---|
| 40 | public String type; |
---|
| 41 | private List fields; |
---|
| 42 | private List reportedFields; |
---|
| 43 | private List items; |
---|
| 44 | |
---|
| 45 | public XDataBuilder() |
---|
| 46 | { |
---|
| 47 | reset(); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | public void reset() |
---|
| 51 | { |
---|
| 52 | instructions = null; |
---|
| 53 | title = null; |
---|
| 54 | type = null; |
---|
| 55 | fields = null; |
---|
| 56 | reportedFields = null; |
---|
| 57 | items = null; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * adds instructions (multiple calls wil be added with an added end of line) |
---|
| 62 | * @param instructions |
---|
| 63 | */ |
---|
| 64 | public void addInstructions(String instructions) |
---|
| 65 | { |
---|
| 66 | if(this.instructions == null) this.instructions = instructions; |
---|
| 67 | else |
---|
| 68 | { |
---|
| 69 | this.instructions = this.instructions + "\n" + instructions; |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | public String getInstructions() |
---|
| 74 | { |
---|
| 75 | return instructions; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | public void addField(XDataField field) |
---|
| 79 | { |
---|
| 80 | if(fields== null) fields = new LinkedList(); |
---|
| 81 | fields.add(field); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | public void addReportedField(XDataField field) |
---|
| 85 | { |
---|
| 86 | if(reportedFields== null) reportedFields = new LinkedList(); |
---|
| 87 | reportedFields.add(field); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | public void addItem(List item) |
---|
| 91 | { |
---|
| 92 | if(items==null)items = new LinkedList(); |
---|
| 93 | items.add(item); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | public List getFields() |
---|
| 97 | { |
---|
| 98 | return fields; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | public List getReported() |
---|
| 102 | { |
---|
| 103 | return reportedFields; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | public List getItems() |
---|
| 107 | { |
---|
| 108 | return items; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | public XData build() throws InstantiationException |
---|
| 112 | { |
---|
| 113 | if (type==null) throw new InstantiationException(I18N.gettext("main.error.No_type")); |
---|
| 114 | else if(type.equals("cancel") || type.equals("form") || type.equals("result") || type.equals("submit")); |
---|
| 115 | else throw new InstantiationException("Wrong type"); |
---|
| 116 | return new XData(this); |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | /* |
---|
| 120 | * Overrides for emacs |
---|
| 121 | * Local variables: |
---|
| 122 | * tab-width: 4 |
---|
| 123 | * End: |
---|
| 124 | */ |
---|