1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Modifies the instructions element to allow multiple instructions (JEP updated)

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2299 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2004-04-26 02:33:06 +00:00 committed by gdombiak
parent 693d0013ac
commit 5289b67214
3 changed files with 53 additions and 19 deletions

View file

@ -69,7 +69,7 @@ public class DataForm implements PacketExtension {
private String type;
private String title;
private String instructions;
private List instructions = new ArrayList();
private ReportedData reportedData;
private List items = new ArrayList();
private List fields = new ArrayList();
@ -109,12 +109,17 @@ public class DataForm implements PacketExtension {
}
/**
* Returns the instructions that explain how to fill out the form and what the form is about.
* Returns an Iterator for the list of instructions that explain how to fill out the form and
* what the form is about. The dataform could include multiple instructions since each
* instruction could not contain newlines characters. Join the instructions together in order
* to show them to the user.
*
* @return instructions that explain how to fill out the form.
* @return an Iterator for the list of instructions that explain how to fill out the form.
*/
public String getInstructions() {
return instructions;
public Iterator getInstructions() {
synchronized (instructions) {
return Collections.unmodifiableList(new ArrayList(instructions)).iterator();
}
}
/**
@ -167,11 +172,13 @@ public class DataForm implements PacketExtension {
}
/**
* Sets instructions that explain how to fill out the form and what the form is about.
* Sets the list of instructions that explain how to fill out the form and what the form is
* about. The dataform could include multiple instructions since each instruction could not
* contain newlines characters.
*
* @param instructions instructions that explain how to fill out the form.
* @param instructions list of instructions that explain how to fill out the form.
*/
public void setInstructions(String instructions) {
public void setInstructions(List instructions) {
this.instructions = instructions;
}
@ -195,6 +202,19 @@ public class DataForm implements PacketExtension {
}
}
/**
* Adds a new instruction to the list of instructions that explain how to fill out the form
* and what the form is about. The dataform could include multiple instructions since each
* instruction could not contain newlines characters.
*
* @param instruction the new instruction that explain how to fill out the form.
*/
public void addInstruction(String instruction) {
synchronized (instructions) {
instructions.add(instruction);
}
}
/**
* Adds a new item returned from a search.
*
@ -213,8 +233,8 @@ public class DataForm implements PacketExtension {
if (getTitle() != null) {
buf.append("<title>").append(getTitle()).append("</title>");
}
if (getInstructions() != null) {
buf.append("<instructions>").append(getInstructions()).append("</instructions>");
for (Iterator it=getInstructions(); it.hasNext();) {
buf.append("<instructions>").append(it.next()).append("</instructions>");
}
// Append the list of fields returned from a search
if (getReportedData() != null) {