2007-03-08 00:38:36 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright 2003-2007 Jive Software.
|
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2007-03-08 00:38:36 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.jivesoftware.smackx.workgroup.settings;
|
|
|
|
|
2017-06-14 17:12:43 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2007-03-08 00:38:36 +01:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
|
|
|
import org.jivesoftware.smack.provider.IQProvider;
|
2015-09-25 13:43:20 +02:00
|
|
|
import org.jivesoftware.smack.util.StringUtils;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2007-03-08 00:38:36 +01:00
|
|
|
import org.xmlpull.v1.XmlPullParser;
|
2014-10-07 21:15:20 +02:00
|
|
|
import org.xmlpull.v1.XmlPullParserException;
|
2007-03-08 00:38:36 +01:00
|
|
|
|
|
|
|
public class GenericSettings extends IQ {
|
|
|
|
|
2017-12-13 23:10:11 +01:00
|
|
|
private Map<String, String> map = new HashMap<>();
|
2007-03-08 00:38:36 +01:00
|
|
|
|
|
|
|
private String query;
|
|
|
|
|
|
|
|
public String getQuery() {
|
|
|
|
return query;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setQuery(String query) {
|
|
|
|
this.query = query;
|
|
|
|
}
|
|
|
|
|
2012-10-26 12:47:55 +02:00
|
|
|
public Map<String, String> getMap() {
|
2007-03-08 00:38:36 +01:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2012-10-26 12:47:55 +02:00
|
|
|
public void setMap(Map<String, String> map) {
|
2007-03-08 00:38:36 +01:00
|
|
|
this.map = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Element name of the stanza extension.
|
2007-03-08 00:38:36 +01:00
|
|
|
*/
|
|
|
|
public static final String ELEMENT_NAME = "generic-metadata";
|
|
|
|
|
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Namespace of the stanza extension.
|
2007-03-08 00:38:36 +01:00
|
|
|
*/
|
|
|
|
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
public GenericSettings() {
|
|
|
|
super(ELEMENT_NAME, NAMESPACE);
|
|
|
|
}
|
2007-03-08 00:38:36 +01:00
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
@Override
|
|
|
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
|
2015-07-21 08:19:15 +02:00
|
|
|
buf.append('>');
|
2015-09-25 13:43:20 +02:00
|
|
|
if (StringUtils.isNotEmpty(getQuery())) {
|
2007-03-08 00:38:36 +01:00
|
|
|
buf.append("<query>" + getQuery() + "</query>");
|
|
|
|
}
|
2014-11-07 21:12:01 +01:00
|
|
|
return buf;
|
2007-03-08 00:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-23 21:06:35 +02:00
|
|
|
* Stanza extension provider for SoundSetting Packets.
|
2007-03-08 00:38:36 +01:00
|
|
|
*/
|
2014-10-07 21:15:20 +02:00
|
|
|
public static class InternalProvider extends IQProvider<GenericSettings> {
|
2007-03-08 00:38:36 +01:00
|
|
|
|
2014-10-07 21:15:20 +02:00
|
|
|
@Override
|
|
|
|
public GenericSettings parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
2007-03-08 00:38:36 +01:00
|
|
|
GenericSettings setting = new GenericSettings();
|
|
|
|
|
|
|
|
boolean done = false;
|
|
|
|
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
|
|
|
if ((eventType == XmlPullParser.START_TAG) && ("entry".equals(parser.getName()))) {
|
|
|
|
eventType = parser.next();
|
|
|
|
String name = parser.nextText();
|
|
|
|
eventType = parser.next();
|
|
|
|
String value = parser.nextText();
|
|
|
|
setting.getMap().put(name, value);
|
|
|
|
}
|
|
|
|
else if (eventType == XmlPullParser.END_TAG && ELEMENT_NAME.equals(parser.getName())) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return setting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|