1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-29 23:42:06 +01:00

RC Release of JEP 55

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2844 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro 2005-09-19 14:44:02 +00:00 committed by derek
parent 64ac585dec
commit c9342aa169
3 changed files with 22 additions and 8 deletions

View file

@ -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();
}
}

View file

@ -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,10 +114,21 @@ 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
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")) {
done = true;

View file

@ -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);
}