本文整理汇总了Java中org.jivesoftware.smackx.FormField.setType方法的典型用法代码示例。如果您正苦于以下问题:Java FormField.setType方法的具体用法?Java FormField.setType怎么用?Java FormField.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.FormField
的用法示例。
在下文中一共展示了FormField.setType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
protected void setUp() throws Exception {
//SmackConfiguration.DEBUG = false;
super.setUp();
room = "[email protected]" + getMUCDomain();
try {
// User1 creates the room
muc = new MultiUserChat(getConnection(0), room);
muc.create("testbot");
// User1 sends an empty room configuration form which indicates that we want
// an instant room
Form form = new Form(Form.TYPE_SUBMIT);
FormField field = new FormField("muc#roomconfig_whois");
field.setType("list-single");
form.addField(field);
form.setAnswer("muc#roomconfig_whois", Arrays.asList("moderators"));
muc.sendConfigurationForm(form);
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
示例2: testSubscribeConfigRequired
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
public void testSubscribeConfigRequired() throws Exception
{
ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open);
// Openfire specific field - nothing in the spec yet
FormField required = new FormField("pubsub#subscription_required");
required.setType(FormField.TYPE_BOOLEAN);
form.addField(required);
form.setAnswer("pubsub#subscription_required", true);
LeafNode node = (LeafNode)getManager().createNode("Pubnode" + System.currentTimeMillis(), form);
Subscription sub = node.subscribe(getJid());
assertEquals(getJid(), sub.getJid());
assertNotNull(sub.getId());
assertEquals(node.getId(), sub.getNode());
assertEquals(true, sub.isConfigRequired());
}
示例3: addField
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
private void addField(ConfigureNodeFields nodeField, String type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);
field.setType(type);
addField(field);
}
}
示例4: addField
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
private void addField(SubscribeOptionFields nodeField, String type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);
field.setType(type);
addField(field);
}
}
示例5: createDefaultInitiationForm
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
private DataForm createDefaultInitiationForm() {
DataForm form = new DataForm(Form.TYPE_FORM);
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
field.setType(FormField.TYPE_LIST_MULTI);
if (!IBB_ONLY) {
field.addOption(new FormField.Option(Socks5BytestreamManager.NAMESPACE));
}
field.addOption(new FormField.Option(InBandBytestreamManager.NAMESPACE));
form.addField(field);
return form;
}
示例6: parseField
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
private FormField parseField(XmlPullParser parser) throws Exception {
boolean done = false;
FormField formField = new FormField(parser.getAttributeValue("", "var"));
formField.setLabel(parser.getAttributeValue("", "label"));
formField.setType(parser.getAttributeValue("", "type"));
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("desc")) {
formField.setDescription(parser.nextText());
}
else if (parser.getName().equals("value")) {
formField.addValue(parser.nextText());
}
else if (parser.getName().equals("required")) {
formField.setRequired(true);
}
else if (parser.getName().equals("option")) {
formField.addOption(parseOption(parser));
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("field")) {
done = true;
}
}
}
return formField;
}
示例7: createDefaultInitiationForm
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
private DataForm createDefaultInitiationForm() {
DataForm form = new DataForm(Form.TYPE_FORM);
FormField field = new FormField(STREAM_DATA_FIELD_NAME);
field.setType(FormField.TYPE_LIST_SINGLE);
if (!IBB_ONLY) {
field.addOption(new FormField.Option(Socks5BytestreamManager.NAMESPACE));
}
field.addOption(new FormField.Option(InBandBytestreamManager.NAMESPACE));
form.addField(field);
return form;
}
示例8: joinQueue
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
/**
* <p>Joins the workgroup queue to wait to be routed to an agent. After joining
* the queue, queue status events will be sent to indicate the user's position and
* estimated time left in the queue. Once joining the queue, there are three ways
* the user can leave the queue: <ul>
* <p/>
* <li>The user is routed to an agent, which triggers a GroupChat invitation.
* <li>The user asks to leave the queue by calling the {@link #departQueue} method.
* <li>A server error occurs, or an administrator explicitly removes the user
* from the queue.
* </ul>
* <p/>
* A user cannot request to join the queue again if already in the queue. Therefore,
* this method will throw an IllegalStateException if the user is already in the queue.<p>
* <p/>
* Some servers may be configured to require certain meta-data in order to
* join the queue.<p>
* <p/>
* The server tracks the conversations that a user has with agents over time. By
* default, that tracking is done using the user's JID. However, this is not always
* possible. For example, when the user is logged in anonymously using a web client.
* In that case the user ID might be a randomly generated value put into a persistent
* cookie or a username obtained via the session. When specified, that userID will
* be used instead of the user's JID to track conversations. The server will ignore a
* manually specified userID if the user's connection to the server is not anonymous.
*
* @param metadata metadata to create a dataform from.
* @param userID String that represents the ID of the user when using anonymous sessions
* or <tt>null</tt> if a userID should not be used.
* @throws XMPPException if an error occured joining the queue. An error may indicate
* that a connection failure occured or that the server explicitly rejected the
* request to join the queue.
*/
public void joinQueue(Map metadata, String userID) throws XMPPException {
// If already in the queue ignore the join request.
if (inQueue) {
throw new IllegalStateException("Already in queue " + workgroupJID);
}
// Build dataform from metadata
Form form = new Form(Form.TYPE_SUBMIT);
Iterator iter = metadata.keySet().iterator();
while (iter.hasNext()) {
String name = (String)iter.next();
String value = (String)metadata.get(name).toString();
String escapedName = StringUtils.escapeForXML(name);
String escapedValue = StringUtils.escapeForXML(value);
FormField field = new FormField(escapedName);
field.setType(FormField.TYPE_TEXT_SINGLE);
form.addField(field);
form.setAnswer(escapedName, escapedValue);
}
joinQueue(form, userID);
}
示例9: buildDataForm
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
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();
if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
String name = parser.getName();
FormField field = new FormField(name);
// Handle hard coded values.
if(name.equals("first")){
field.setLabel("First Name");
}
else if(name.equals("last")){
field.setLabel("Last Name");
}
else if(name.equals("email")){
field.setLabel("Email Address");
}
else if(name.equals("nick")){
field.setLabel("Nickname");
}
field.setType(FormField.TYPE_TEXT_SINGLE);
dataForm.addField(field);
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("query")) {
done = true;
}
}
else if (eventType == XmlPullParser.START_TAG && parser.getNamespace().equals("jabber:x:data")) {
search.addExtension(PacketParserUtils.parsePacketExtension(parser.getName(),
parser.getNamespace(), parser));
done = true;
}
}
if (search.getExtension("x", "jabber:x:data") == null) {
search.addExtension(dataForm);
}
}
示例10: joinQueue
import org.jivesoftware.smackx.FormField; //导入方法依赖的package包/类
/**
* <p>Joins the workgroup queue to wait to be routed to an agent. After joining
* the queue, queue status events will be sent to indicate the user's position and
* estimated time left in the queue. Once joining the queue, there are three ways
* the user can leave the queue: <ul>
* <p/>
* <li>The user is routed to an agent, which triggers a GroupChat invitation.
* <li>The user asks to leave the queue by calling the {@link #departQueue} method.
* <li>A server error occurs, or an administrator explicitly removes the user
* from the queue.
* </ul>
* <p/>
* A user cannot request to join the queue again if already in the queue. Therefore,
* this method will throw an IllegalStateException if the user is already in the queue.<p>
* <p/>
* Some servers may be configured to require certain meta-data in order to
* join the queue.<p>
* <p/>
* The server tracks the conversations that a user has with agents over time. By
* default, that tracking is done using the user's JID. However, this is not always
* possible. For example, when the user is logged in anonymously using a web client.
* In that case the user ID might be a randomly generated value put into a persistent
* cookie or a username obtained via the session. When specified, that userID will
* be used instead of the user's JID to track conversations. The server will ignore a
* manually specified userID if the user's connection to the server is not anonymous.
*
* @param metadata metadata to create a dataform from.
* @param userID String that represents the ID of the user when using anonymous sessions
* or <tt>null</tt> if a userID should not be used.
* @throws XMPPException if an error occured joining the queue. An error may indicate
* that a connection failure occured or that the server explicitly rejected the
* request to join the queue.
*/
public void joinQueue(Map<String,Object> metadata, String userID) throws XMPPException {
// If already in the queue ignore the join request.
if (inQueue) {
throw new IllegalStateException("Already in queue " + workgroupJID);
}
// Build dataform from metadata
Form form = new Form(Form.TYPE_SUBMIT);
Iterator<String> iter = metadata.keySet().iterator();
while (iter.hasNext()) {
String name = iter.next();
String value = metadata.get(name).toString();
String escapedName = StringUtils.escapeForXML(name);
String escapedValue = StringUtils.escapeForXML(value);
FormField field = new FormField(escapedName);
field.setType(FormField.TYPE_TEXT_SINGLE);
form.addField(field);
form.setAnswer(escapedName, escapedValue);
}
joinQueue(form, userID);
}