From c9342aa169e46979815f95de80b55316ee90722f Mon Sep 17 00:00:00 2001 From: Derek DeMoro Date: Mon, 19 Sep 2005 14:44:02 +0000 Subject: [PATCH] RC Release of JEP 55 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2844 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smackx/ReportedData.java | 2 +- .../smackx/search/SimpleUserSearch.java | 21 +++++++++++++++---- .../smackx/search/UserSearch.java | 7 ++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/org/jivesoftware/smackx/ReportedData.java b/source/org/jivesoftware/smackx/ReportedData.java index 6c51bfc93..93e5fd140 100644 --- a/source/org/jivesoftware/smackx/ReportedData.java +++ b/source/org/jivesoftware/smackx/ReportedData.java @@ -230,7 +230,7 @@ public class ReportedData { public Iterator getValues(String variable) { for(Iterator it=getFields();it.hasNext();) { Field field = (Field) it.next(); - if (variable.equals(field.getVariable())) { + if (variable.equalsIgnoreCase(field.getVariable())) { return field.getValues(); } } diff --git a/source/org/jivesoftware/smackx/search/SimpleUserSearch.java b/source/org/jivesoftware/smackx/search/SimpleUserSearch.java index e3497d39a..50e63b29e 100644 --- a/source/org/jivesoftware/smackx/search/SimpleUserSearch.java +++ b/source/org/jivesoftware/smackx/search/SimpleUserSearch.java @@ -28,6 +28,7 @@ import java.util.List; * @author Derek DeMoro */ class SimpleUserSearch extends IQ { + private Form form; private ReportedData data; @@ -55,7 +56,7 @@ class SimpleUserSearch extends IQ { form = Form.getFormFrom(this); } - if(form == null){ + if (form == null) { return ""; } @@ -87,13 +88,14 @@ class SimpleUserSearch extends IQ { List fields = new ArrayList(); while (!done) { - if(parser.getAttributeCount() > 0){ + if (parser.getAttributeCount() > 0) { String jid = parser.getAttributeValue("", "jid"); List valueList = new ArrayList(); valueList.add(jid); ReportedData.Field field = new ReportedData.Field("jid", valueList); fields.add(field); } + int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) { @@ -112,9 +114,20 @@ class SimpleUserSearch extends IQ { ReportedData.Field field = new ReportedData.Field(name, valueList); fields.add(field); + boolean exists = false; + Iterator cols = data.getColumns(); + while (cols.hasNext()) { + ReportedData.Column column = (ReportedData.Column) cols.next(); + if (column.getVariable().equals(name)) { + exists = true; + } + } + // Column name should be the same - ReportedData.Column column = new ReportedData.Column(name, name, "text-single"); - data.addColumn(column); + if (!exists) { + ReportedData.Column column = new ReportedData.Column(name, name, "text-single"); + data.addColumn(column); + } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("query")) { diff --git a/source/org/jivesoftware/smackx/search/UserSearch.java b/source/org/jivesoftware/smackx/search/UserSearch.java index 79c453280..662031ac2 100644 --- a/source/org/jivesoftware/smackx/search/UserSearch.java +++ b/source/org/jivesoftware/smackx/search/UserSearch.java @@ -172,7 +172,7 @@ public class UserSearch extends IQ { while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG && parser.getName().equals("instructions")) { - buildDataForm(simpleUserSearch, parser.getText(), parser); + buildDataForm(simpleUserSearch, parser.nextText(), parser); return simpleUserSearch; } else if (eventType == XmlPullParser.START_TAG && parser.getName().equals("item")) { @@ -203,14 +203,15 @@ public class UserSearch extends IQ { private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception { DataForm dataForm = new DataForm(Form.TYPE_FORM); boolean done = false; + dataForm.setTitle("User Search"); + dataForm.addInstruction(instructions); while (!done) { int eventType = parser.next(); - dataForm.setTitle("User Search"); - dataForm.addInstruction(instructions); if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) { String name = parser.getName(); FormField field = new FormField(name); + field.setLabel(name); field.setType(FormField.TYPE_TEXT_SINGLE); dataForm.addField(field); }