diff options
author | Tim Robbings <tim.robbings@isode.com> | 2014-10-22 09:06:10 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2014-10-28 10:00:39 (GMT) |
commit | 47cad5fd7883b8c7273ea11073643aa585b485c6 (patch) | |
tree | 1d7bc39fc1c847e0bbe88716257a9a0710ac8745 /src/com/isode/stroke/elements/FormItem.java | |
parent | 244aff320257d178bbe35d87b0e09d939bd2f893 (diff) | |
download | stroke-47cad5fd7883b8c7273ea11073643aa585b485c6.zip stroke-47cad5fd7883b8c7273ea11073643aa585b485c6.tar.bz2 |
Stroke FormField refactoring
Changes to catch up with Swiften changes to FormField in commit 00284e5,
also adds <reported/> and <item/> elements, added to Swiften in commit 83afa3d.
Changes include refactoring of the FormField class, changes to Form parser
and serializer classes and updates to JUnit tests.
Test-information:
Tested using updated JUnit tests, all tests complete successfully.
Change-Id: Ic91ad4a11a335fb3d2b2a2c4a1865f836e2af70b
Reviewer: Alex Clayton <alex.clayton@isode.com>
Reviewer: Gurmeen Bindra <gurmeen.bindra@isode.com>
Diffstat (limited to 'src/com/isode/stroke/elements/FormItem.java')
-rw-r--r-- | src/com/isode/stroke/elements/FormItem.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/FormItem.java b/src/com/isode/stroke/elements/FormItem.java new file mode 100644 index 0000000..3081c87 --- /dev/null +++ b/src/com/isode/stroke/elements/FormItem.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2014 Isode Limited, London, England. + * All rights reserved. + */ +package com.isode.stroke.elements; + +import java.util.ArrayList; +import java.util.List; + +/** + * Class representing a XEP-0004 data form <item/> element. + * @author tr + * + */ +public class FormItem { + + private List<FormField> itemFields_ = new ArrayList<FormField>(); + + public FormItem() {} + + /** + * Add a single FormField to this FormItem. + * @param itemField FormField, should not be null + */ + public void addItemField(FormField itemField) { + if (itemField == null) { + throw new NullPointerException("'itemField' must not be null"); + } + itemFields_.add(itemField); + } + + /** + * Add a list of FormFields to this FormItem. + * @param itemFields List<ForMField>, should not be null + */ + public void addItemFields(List<FormField> itemFields) { + if (itemFields == null) { + throw new NullPointerException("'itemFields' must not be null"); + } + itemFields_.addAll(itemFields); + } + + /** + * Returns a list of FormFields for this FormItem. + * @return List<FormField> list of item, never null + */ + public List<FormField> getItemFields() { + return new ArrayList<FormField>(itemFields_); + } +} |