id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
27,000
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.createNode
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null); NodeExtension elem = reply.getExtension("create", PubSubNamespace.basic.getXmlns()); LeafNode newNode = new LeafNode(this, elem.getNode()); nodeMap.put(newNode.getId(), newNode); return newNode; }
java
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null); NodeExtension elem = reply.getExtension("create", PubSubNamespace.basic.getXmlns()); LeafNode newNode = new LeafNode(this, elem.getNode()); nodeMap.put(newNode.getId(), newNode); return newNode; }
[ "public", "LeafNode", "createNode", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "PubSub", "reply", "=", "sendPubsubPacket", "(", "Type", ".", "set", ",", "new", "NodeExtension", "(", "PubSubElementType", ".", "CREATE", ")", ",", "null", ")", ";", "NodeExtension", "elem", "=", "reply", ".", "getExtension", "(", "\"create\"", ",", "PubSubNamespace", ".", "basic", ".", "getXmlns", "(", ")", ")", ";", "LeafNode", "newNode", "=", "new", "LeafNode", "(", "this", ",", "elem", ".", "getNode", "(", ")", ")", ";", "nodeMap", ".", "put", "(", "newNode", ".", "getId", "(", ")", ",", "newNode", ")", ";", "return", "newNode", ";", "}" ]
Creates an instant node, if supported. @return The node that was created @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Creates", "an", "instant", "node", "if", "supported", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L197-L205
27,001
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.createNode
public LeafNode createNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return (LeafNode) createNode(nodeId, null); }
java
public LeafNode createNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return (LeafNode) createNode(nodeId, null); }
[ "public", "LeafNode", "createNode", "(", "String", "nodeId", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "(", "LeafNode", ")", "createNode", "(", "nodeId", ",", "null", ")", ";", "}" ]
Creates a node with default configuration. @param nodeId The id of the node, which must be unique within the pubsub service @return The node that was created @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Creates", "a", "node", "with", "default", "configuration", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L218-L220
27,002
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.createNode
public Node createNode(String nodeId, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId)); boolean isLeafNode = true; if (config != null) { request.addExtension(new FormNode(FormNodeType.CONFIGURE, config)); FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName()); if (nodeTypeField != null) isLeafNode = nodeTypeField.getValues().get(0).toString().equals(NodeType.leaf.toString()); } // Errors will cause exceptions in getReply, so it only returns // on success. sendPubsubPacket(request); Node newNode = isLeafNode ? new LeafNode(this, nodeId) : new CollectionNode(this, nodeId); nodeMap.put(newNode.getId(), newNode); return newNode; }
java
public Node createNode(String nodeId, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId)); boolean isLeafNode = true; if (config != null) { request.addExtension(new FormNode(FormNodeType.CONFIGURE, config)); FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName()); if (nodeTypeField != null) isLeafNode = nodeTypeField.getValues().get(0).toString().equals(NodeType.leaf.toString()); } // Errors will cause exceptions in getReply, so it only returns // on success. sendPubsubPacket(request); Node newNode = isLeafNode ? new LeafNode(this, nodeId) : new CollectionNode(this, nodeId); nodeMap.put(newNode.getId(), newNode); return newNode; }
[ "public", "Node", "createNode", "(", "String", "nodeId", ",", "Form", "config", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "PubSub", "request", "=", "PubSub", ".", "createPubsubPacket", "(", "pubSubService", ",", "Type", ".", "set", ",", "new", "NodeExtension", "(", "PubSubElementType", ".", "CREATE", ",", "nodeId", ")", ")", ";", "boolean", "isLeafNode", "=", "true", ";", "if", "(", "config", "!=", "null", ")", "{", "request", ".", "addExtension", "(", "new", "FormNode", "(", "FormNodeType", ".", "CONFIGURE", ",", "config", ")", ")", ";", "FormField", "nodeTypeField", "=", "config", ".", "getField", "(", "ConfigureNodeFields", ".", "node_type", ".", "getFieldName", "(", ")", ")", ";", "if", "(", "nodeTypeField", "!=", "null", ")", "isLeafNode", "=", "nodeTypeField", ".", "getValues", "(", ")", ".", "get", "(", "0", ")", ".", "toString", "(", ")", ".", "equals", "(", "NodeType", ".", "leaf", ".", "toString", "(", ")", ")", ";", "}", "// Errors will cause exceptions in getReply, so it only returns", "// on success.", "sendPubsubPacket", "(", "request", ")", ";", "Node", "newNode", "=", "isLeafNode", "?", "new", "LeafNode", "(", "this", ",", "nodeId", ")", ":", "new", "CollectionNode", "(", "this", ",", "nodeId", ")", ";", "nodeMap", ".", "put", "(", "newNode", ".", "getId", "(", ")", ",", "newNode", ")", ";", "return", "newNode", ";", "}" ]
Creates a node with specified configuration. Note: This is the only way to create a collection node. @param nodeId The name of the node, which must be unique within the pubsub service @param config The configuration for the node @return The node that was created @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Creates", "a", "node", "with", "specified", "configuration", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L236-L255
27,003
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.getNode
public Node getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException { Node node = nodeMap.get(id); if (node == null) { DiscoverInfo info = new DiscoverInfo(); info.setTo(pubSubService); info.setNode(id); DiscoverInfo infoReply = connection().createStanzaCollectorAndSend(info).nextResultOrThrow(); if (infoReply.hasIdentity(PubSub.ELEMENT, "leaf")) { node = new LeafNode(this, id); } else if (infoReply.hasIdentity(PubSub.ELEMENT, "collection")) { node = new CollectionNode(this, id); } else { throw new PubSubException.NotAPubSubNodeException(id, infoReply); } nodeMap.put(id, node); } return node; }
java
public Node getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException { Node node = nodeMap.get(id); if (node == null) { DiscoverInfo info = new DiscoverInfo(); info.setTo(pubSubService); info.setNode(id); DiscoverInfo infoReply = connection().createStanzaCollectorAndSend(info).nextResultOrThrow(); if (infoReply.hasIdentity(PubSub.ELEMENT, "leaf")) { node = new LeafNode(this, id); } else if (infoReply.hasIdentity(PubSub.ELEMENT, "collection")) { node = new CollectionNode(this, id); } else { throw new PubSubException.NotAPubSubNodeException(id, infoReply); } nodeMap.put(id, node); } return node; }
[ "public", "Node", "getNode", "(", "String", "id", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", ",", "NotAPubSubNodeException", "{", "Node", "node", "=", "nodeMap", ".", "get", "(", "id", ")", ";", "if", "(", "node", "==", "null", ")", "{", "DiscoverInfo", "info", "=", "new", "DiscoverInfo", "(", ")", ";", "info", ".", "setTo", "(", "pubSubService", ")", ";", "info", ".", "setNode", "(", "id", ")", ";", "DiscoverInfo", "infoReply", "=", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "info", ")", ".", "nextResultOrThrow", "(", ")", ";", "if", "(", "infoReply", ".", "hasIdentity", "(", "PubSub", ".", "ELEMENT", ",", "\"leaf\"", ")", ")", "{", "node", "=", "new", "LeafNode", "(", "this", ",", "id", ")", ";", "}", "else", "if", "(", "infoReply", ".", "hasIdentity", "(", "PubSub", ".", "ELEMENT", ",", "\"collection\"", ")", ")", "{", "node", "=", "new", "CollectionNode", "(", "this", ",", "id", ")", ";", "}", "else", "{", "throw", "new", "PubSubException", ".", "NotAPubSubNodeException", "(", "id", ",", "infoReply", ")", ";", "}", "nodeMap", ".", "put", "(", "id", ",", "node", ")", ";", "}", "return", "node", ";", "}" ]
Retrieves the requested node, if it exists. It will throw an exception if it does not. @param id - The unique id of the node @return the node @throws XMPPErrorException The node does not exist @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException @throws NotAPubSubNodeException
[ "Retrieves", "the", "requested", "node", "if", "it", "exists", ".", "It", "will", "throw", "an", "exception", "if", "it", "does", "not", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L270-L292
27,004
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.getOrCreateLeafNode
public LeafNode getOrCreateLeafNode(final String id) throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotALeafNodeException { try { return getLeafNode(id); } catch (NotAPubSubNodeException e) { return createNode(id); } catch (XMPPErrorException e1) { if (e1.getStanzaError().getCondition() == Condition.item_not_found) { try { return createNode(id); } catch (XMPPErrorException e2) { if (e2.getStanzaError().getCondition() == Condition.conflict) { // The node was created in the meantime, re-try getNode(). Note that this case should be rare. try { return getLeafNode(id); } catch (NotAPubSubNodeException e) { // Should not happen throw new IllegalStateException(e); } } throw e2; } } if (e1.getStanzaError().getCondition() == Condition.service_unavailable) { // This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not // answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or // collection node. LOGGER.warning("The PubSub service " + pubSubService + " threw an DiscoInfoNodeAssertionError, trying workaround for Prosody bug #805 (https://prosody.im/issues/issue/805)"); return getOrCreateLeafNodeProsodyWorkaround(id); } throw e1; } }
java
public LeafNode getOrCreateLeafNode(final String id) throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotALeafNodeException { try { return getLeafNode(id); } catch (NotAPubSubNodeException e) { return createNode(id); } catch (XMPPErrorException e1) { if (e1.getStanzaError().getCondition() == Condition.item_not_found) { try { return createNode(id); } catch (XMPPErrorException e2) { if (e2.getStanzaError().getCondition() == Condition.conflict) { // The node was created in the meantime, re-try getNode(). Note that this case should be rare. try { return getLeafNode(id); } catch (NotAPubSubNodeException e) { // Should not happen throw new IllegalStateException(e); } } throw e2; } } if (e1.getStanzaError().getCondition() == Condition.service_unavailable) { // This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not // answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or // collection node. LOGGER.warning("The PubSub service " + pubSubService + " threw an DiscoInfoNodeAssertionError, trying workaround for Prosody bug #805 (https://prosody.im/issues/issue/805)"); return getOrCreateLeafNodeProsodyWorkaround(id); } throw e1; } }
[ "public", "LeafNode", "getOrCreateLeafNode", "(", "final", "String", "id", ")", "throws", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", ",", "XMPPErrorException", ",", "NotALeafNodeException", "{", "try", "{", "return", "getLeafNode", "(", "id", ")", ";", "}", "catch", "(", "NotAPubSubNodeException", "e", ")", "{", "return", "createNode", "(", "id", ")", ";", "}", "catch", "(", "XMPPErrorException", "e1", ")", "{", "if", "(", "e1", ".", "getStanzaError", "(", ")", ".", "getCondition", "(", ")", "==", "Condition", ".", "item_not_found", ")", "{", "try", "{", "return", "createNode", "(", "id", ")", ";", "}", "catch", "(", "XMPPErrorException", "e2", ")", "{", "if", "(", "e2", ".", "getStanzaError", "(", ")", ".", "getCondition", "(", ")", "==", "Condition", ".", "conflict", ")", "{", "// The node was created in the meantime, re-try getNode(). Note that this case should be rare.", "try", "{", "return", "getLeafNode", "(", "id", ")", ";", "}", "catch", "(", "NotAPubSubNodeException", "e", ")", "{", "// Should not happen", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}", "throw", "e2", ";", "}", "}", "if", "(", "e1", ".", "getStanzaError", "(", ")", ".", "getCondition", "(", ")", "==", "Condition", ".", "service_unavailable", ")", "{", "// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not", "// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or", "// collection node.", "LOGGER", ".", "warning", "(", "\"The PubSub service \"", "+", "pubSubService", "+", "\" threw an DiscoInfoNodeAssertionError, trying workaround for Prosody bug #805 (https://prosody.im/issues/issue/805)\"", ")", ";", "return", "getOrCreateLeafNodeProsodyWorkaround", "(", "id", ")", ";", "}", "throw", "e1", ";", "}", "}" ]
Try to get a leaf node and create one if it does not already exist. @param id The unique ID of the node. @return the leaf node. @throws NoResponseException @throws NotConnectedException @throws InterruptedException @throws XMPPErrorException @throws NotALeafNodeException in case the node already exists as collection node. @since 4.2.1
[ "Try", "to", "get", "a", "leaf", "node", "and", "create", "one", "if", "it", "does", "not", "already", "exist", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L306-L343
27,005
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.getLeafNode
public LeafNode getLeafNode(String id) throws NotALeafNodeException, NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotAPubSubNodeException { Node node; try { node = getNode(id); } catch (XMPPErrorException e) { if (e.getStanzaError().getCondition() == Condition.service_unavailable) { // This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not // answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or // collection node. return getLeafNodeProsodyWorkaround(id); } throw e; } if (node instanceof LeafNode) { return (LeafNode) node; } throw new PubSubException.NotALeafNodeException(id, pubSubService); }
java
public LeafNode getLeafNode(String id) throws NotALeafNodeException, NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotAPubSubNodeException { Node node; try { node = getNode(id); } catch (XMPPErrorException e) { if (e.getStanzaError().getCondition() == Condition.service_unavailable) { // This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not // answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or // collection node. return getLeafNodeProsodyWorkaround(id); } throw e; } if (node instanceof LeafNode) { return (LeafNode) node; } throw new PubSubException.NotALeafNodeException(id, pubSubService); }
[ "public", "LeafNode", "getLeafNode", "(", "String", "id", ")", "throws", "NotALeafNodeException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", ",", "XMPPErrorException", ",", "NotAPubSubNodeException", "{", "Node", "node", ";", "try", "{", "node", "=", "getNode", "(", "id", ")", ";", "}", "catch", "(", "XMPPErrorException", "e", ")", "{", "if", "(", "e", ".", "getStanzaError", "(", ")", ".", "getCondition", "(", ")", "==", "Condition", ".", "service_unavailable", ")", "{", "// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not", "// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or", "// collection node.", "return", "getLeafNodeProsodyWorkaround", "(", "id", ")", ";", "}", "throw", "e", ";", "}", "if", "(", "node", "instanceof", "LeafNode", ")", "{", "return", "(", "LeafNode", ")", "node", ";", "}", "throw", "new", "PubSubException", ".", "NotALeafNodeException", "(", "id", ",", "pubSubService", ")", ";", "}" ]
Try to get a leaf node with the given node ID. @param id the node ID. @return the requested leaf node. @throws NotALeafNodeException in case the node exists but is a collection node. @throws NoResponseException @throws NotConnectedException @throws InterruptedException @throws XMPPErrorException @throws NotAPubSubNodeException @since 4.2.1
[ "Try", "to", "get", "a", "leaf", "node", "with", "the", "given", "node", "ID", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L358-L379
27,006
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.discoverNodes
public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverItems items = new DiscoverItems(); if (nodeId != null) items.setNode(nodeId); items.setTo(pubSubService); DiscoverItems nodeItems = connection().createStanzaCollectorAndSend(items).nextResultOrThrow(); return nodeItems; }
java
public DiscoverItems discoverNodes(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverItems items = new DiscoverItems(); if (nodeId != null) items.setNode(nodeId); items.setTo(pubSubService); DiscoverItems nodeItems = connection().createStanzaCollectorAndSend(items).nextResultOrThrow(); return nodeItems; }
[ "public", "DiscoverItems", "discoverNodes", "(", "String", "nodeId", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "DiscoverItems", "items", "=", "new", "DiscoverItems", "(", ")", ";", "if", "(", "nodeId", "!=", "null", ")", "items", ".", "setNode", "(", "nodeId", ")", ";", "items", ".", "setTo", "(", "pubSubService", ")", ";", "DiscoverItems", "nodeItems", "=", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "items", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "nodeItems", ";", "}" ]
Get all the nodes that currently exist as a child of the specified collection node. If the service does not support collection nodes then all nodes will be returned. To retrieve contents of the root collection node (if it exists), or there is no root collection node, pass null as the nodeId. @param nodeId - The id of the collection node for which the child nodes will be returned. @return {@link DiscoverItems} representing the existing nodes @throws XMPPErrorException @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Get", "all", "the", "nodes", "that", "currently", "exist", "as", "a", "child", "of", "the", "specified", "collection", "node", ".", "If", "the", "service", "does", "not", "support", "collection", "nodes", "then", "all", "nodes", "will", "be", "returned", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L461-L469
27,007
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.getSubscriptions
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null); SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns()); return subElem.getSubscriptions(); }
java
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null); SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns()); return subElem.getSubscriptions(); }
[ "public", "List", "<", "Subscription", ">", "getSubscriptions", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "Stanza", "reply", "=", "sendPubsubPacket", "(", "Type", ".", "get", ",", "new", "NodeExtension", "(", "PubSubElementType", ".", "SUBSCRIPTIONS", ")", ",", "null", ")", ";", "SubscriptionsExtension", "subElem", "=", "reply", ".", "getExtension", "(", "PubSubElementType", ".", "SUBSCRIPTIONS", ".", "getElementName", "(", ")", ",", "PubSubElementType", ".", "SUBSCRIPTIONS", ".", "getNamespace", "(", ")", ".", "getXmlns", "(", ")", ")", ";", "return", "subElem", ".", "getSubscriptions", "(", ")", ";", "}" ]
Gets the subscriptions on the root node. @return List of exceptions @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Gets", "the", "subscriptions", "on", "the", "root", "node", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L480-L484
27,008
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.getAffiliations
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null); AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS); return listElem.getAffiliations(); }
java
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null); AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS); return listElem.getAffiliations(); }
[ "public", "List", "<", "Affiliation", ">", "getAffiliations", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "PubSub", "reply", "=", "sendPubsubPacket", "(", "Type", ".", "get", ",", "new", "NodeExtension", "(", "PubSubElementType", ".", "AFFILIATIONS", ")", ",", "null", ")", ";", "AffiliationsExtension", "listElem", "=", "reply", ".", "getExtension", "(", "PubSubElementType", ".", "AFFILIATIONS", ")", ";", "return", "listElem", ".", "getAffiliations", "(", ")", ";", "}" ]
Gets the affiliations on the root node. @return List of affiliations @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Gets", "the", "affiliations", "on", "the", "root", "node", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L496-L500
27,009
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.deleteNode
public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { boolean res = true; try { sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace()); } catch (XMPPErrorException e) { if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) { res = false; } else { throw e; } } nodeMap.remove(nodeId); return res; }
java
public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { boolean res = true; try { sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace()); } catch (XMPPErrorException e) { if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) { res = false; } else { throw e; } } nodeMap.remove(nodeId); return res; }
[ "public", "boolean", "deleteNode", "(", "String", "nodeId", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "boolean", "res", "=", "true", ";", "try", "{", "sendPubsubPacket", "(", "Type", ".", "set", ",", "new", "NodeExtension", "(", "PubSubElementType", ".", "DELETE", ",", "nodeId", ")", ",", "PubSubElementType", ".", "DELETE", ".", "getNamespace", "(", ")", ")", ";", "}", "catch", "(", "XMPPErrorException", "e", ")", "{", "if", "(", "e", ".", "getStanzaError", "(", ")", ".", "getCondition", "(", ")", "==", "StanzaError", ".", "Condition", ".", "item_not_found", ")", "{", "res", "=", "false", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "nodeMap", ".", "remove", "(", "nodeId", ")", ";", "return", "res", ";", "}" ]
Delete the specified node. @param nodeId @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException @return <code>true</code> if this node existed and was deleted and <code>false</code> if this node did not exist.
[ "Delete", "the", "specified", "node", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L512-L525
27,010
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.getDefaultConfiguration
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Errors will cause exceptions in getReply, so it only returns // on success. PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace()); return NodeUtils.getFormFromPacket(reply, PubSubElementType.DEFAULT); }
java
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Errors will cause exceptions in getReply, so it only returns // on success. PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace()); return NodeUtils.getFormFromPacket(reply, PubSubElementType.DEFAULT); }
[ "public", "ConfigureForm", "getDefaultConfiguration", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "// Errors will cause exceptions in getReply, so it only returns", "// on success.", "PubSub", "reply", "=", "sendPubsubPacket", "(", "Type", ".", "get", ",", "new", "NodeExtension", "(", "PubSubElementType", ".", "DEFAULT", ")", ",", "PubSubElementType", ".", "DEFAULT", ".", "getNamespace", "(", ")", ")", ";", "return", "NodeUtils", ".", "getFormFromPacket", "(", "reply", ",", "PubSubElementType", ".", "DEFAULT", ")", ";", "}" ]
Returns the default settings for Node configuration. @return configuration form containing the default settings. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "default", "settings", "for", "Node", "configuration", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L536-L541
27,011
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.supportsAutomaticNodeCreation
public boolean supportsAutomaticNodeCreation() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); return sdm.supportsFeature(pubSubService, AUTO_CREATE_FEATURE); }
java
public boolean supportsAutomaticNodeCreation() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); return sdm.supportsFeature(pubSubService, AUTO_CREATE_FEATURE); }
[ "public", "boolean", "supportsAutomaticNodeCreation", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "ServiceDiscoveryManager", "sdm", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ";", "return", "sdm", ".", "supportsFeature", "(", "pubSubService", ",", "AUTO_CREATE_FEATURE", ")", ";", "}" ]
Check if the PubSub service supports automatic node creation. @return true if the PubSub service supports automatic node creation. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @since 4.2.1 @see <a href="https://xmpp.org/extensions/xep-0060.html#publisher-publish-autocreate">XEP-0060 § 7.1.4 Automatic Node Creation</a>
[ "Check", "if", "the", "PubSub", "service", "supports", "automatic", "node", "creation", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L578-L582
27,012
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
PubSubManager.getPubSubService
public static DomainBareJid getPubSubService(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection).findService(PubSub.NAMESPACE, true, "pubsub", "service"); }
java
public static DomainBareJid getPubSubService(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection).findService(PubSub.NAMESPACE, true, "pubsub", "service"); }
[ "public", "static", "DomainBareJid", "getPubSubService", "(", "XMPPConnection", "connection", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ".", "findService", "(", "PubSub", ".", "NAMESPACE", ",", "true", ",", "\"pubsub\"", ",", "\"service\"", ")", ";", "}" ]
Get the "default" PubSub service for a given XMPP connection. The default PubSub service is simply an arbitrary XMPP service with the PubSub feature and an identity of category "pubsub" and type "service". @param connection @return the default PubSub service or <code>null</code>. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @see <a href="http://xmpp.org/extensions/xep-0060.html#entity-features">XEP-60 § 5.1 Discover Features</a>
[ "Get", "the", "default", "PubSub", "service", "for", "a", "given", "XMPP", "connection", ".", "The", "default", "PubSub", "service", "is", "simply", "an", "arbitrary", "XMPP", "service", "with", "the", "PubSub", "feature", "and", "an", "identity", "of", "category", "pubsub", "and", "type", "service", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java#L662-L667
27,013
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java
TransportResolver.triggerCandidateAdded
protected void triggerCandidateAdded(TransportCandidate cand) throws NotConnectedException, InterruptedException { Iterator<TransportResolverListener> iter = getListenersList().iterator(); while (iter.hasNext()) { TransportResolverListener trl = iter.next(); if (trl instanceof TransportResolverListener.Resolver) { TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; LOGGER.fine("triggerCandidateAdded : " + cand.getLocalIp()); li.candidateAdded(cand); } } }
java
protected void triggerCandidateAdded(TransportCandidate cand) throws NotConnectedException, InterruptedException { Iterator<TransportResolverListener> iter = getListenersList().iterator(); while (iter.hasNext()) { TransportResolverListener trl = iter.next(); if (trl instanceof TransportResolverListener.Resolver) { TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; LOGGER.fine("triggerCandidateAdded : " + cand.getLocalIp()); li.candidateAdded(cand); } } }
[ "protected", "void", "triggerCandidateAdded", "(", "TransportCandidate", "cand", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "Iterator", "<", "TransportResolverListener", ">", "iter", "=", "getListenersList", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "TransportResolverListener", "trl", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "trl", "instanceof", "TransportResolverListener", ".", "Resolver", ")", "{", "TransportResolverListener", ".", "Resolver", "li", "=", "(", "TransportResolverListener", ".", "Resolver", ")", "trl", ";", "LOGGER", ".", "fine", "(", "\"triggerCandidateAdded : \"", "+", "cand", ".", "getLocalIp", "(", ")", ")", ";", "li", ".", "candidateAdded", "(", "cand", ")", ";", "}", "}", "}" ]
Trigger a new candidate added event. @param cand The candidate added to the list of candidates. @throws NotConnectedException @throws InterruptedException
[ "Trigger", "a", "new", "candidate", "added", "event", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java#L217-L227
27,014
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java
TransportResolver.triggerResolveInit
private void triggerResolveInit() { Iterator<TransportResolverListener> iter = getListenersList().iterator(); while (iter.hasNext()) { TransportResolverListener trl = iter.next(); if (trl instanceof TransportResolverListener.Resolver) { TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; li.init(); } } }
java
private void triggerResolveInit() { Iterator<TransportResolverListener> iter = getListenersList().iterator(); while (iter.hasNext()) { TransportResolverListener trl = iter.next(); if (trl instanceof TransportResolverListener.Resolver) { TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; li.init(); } } }
[ "private", "void", "triggerResolveInit", "(", ")", "{", "Iterator", "<", "TransportResolverListener", ">", "iter", "=", "getListenersList", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "TransportResolverListener", "trl", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "trl", "instanceof", "TransportResolverListener", ".", "Resolver", ")", "{", "TransportResolverListener", ".", "Resolver", "li", "=", "(", "TransportResolverListener", ".", "Resolver", ")", "trl", ";", "li", ".", "init", "(", ")", ";", "}", "}", "}" ]
Trigger a event notifying the initialization of the resolution process.
[ "Trigger", "a", "event", "notifying", "the", "initialization", "of", "the", "resolution", "process", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java#L232-L241
27,015
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java
TransportResolver.triggerResolveEnd
private void triggerResolveEnd() { Iterator<TransportResolverListener> iter = getListenersList().iterator(); while (iter.hasNext()) { TransportResolverListener trl = iter.next(); if (trl instanceof TransportResolverListener.Resolver) { TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; li.end(); } } }
java
private void triggerResolveEnd() { Iterator<TransportResolverListener> iter = getListenersList().iterator(); while (iter.hasNext()) { TransportResolverListener trl = iter.next(); if (trl instanceof TransportResolverListener.Resolver) { TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl; li.end(); } } }
[ "private", "void", "triggerResolveEnd", "(", ")", "{", "Iterator", "<", "TransportResolverListener", ">", "iter", "=", "getListenersList", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "TransportResolverListener", "trl", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "trl", "instanceof", "TransportResolverListener", ".", "Resolver", ")", "{", "TransportResolverListener", ".", "Resolver", "li", "=", "(", "TransportResolverListener", ".", "Resolver", ")", "trl", ";", "li", ".", "end", "(", ")", ";", "}", "}", "}" ]
Trigger a event notifying the obtainment of all the candidates.
[ "Trigger", "a", "event", "notifying", "the", "obtainment", "of", "all", "the", "candidates", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java#L246-L255
27,016
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java
TransportResolver.addCandidate
protected void addCandidate(TransportCandidate cand) throws NotConnectedException, InterruptedException { synchronized (candidates) { if (!candidates.contains(cand)) candidates.add(cand); } // Notify the listeners triggerCandidateAdded(cand); }
java
protected void addCandidate(TransportCandidate cand) throws NotConnectedException, InterruptedException { synchronized (candidates) { if (!candidates.contains(cand)) candidates.add(cand); } // Notify the listeners triggerCandidateAdded(cand); }
[ "protected", "void", "addCandidate", "(", "TransportCandidate", "cand", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "synchronized", "(", "candidates", ")", "{", "if", "(", "!", "candidates", ".", "contains", "(", "cand", ")", ")", "candidates", ".", "add", "(", "cand", ")", ";", "}", "// Notify the listeners", "triggerCandidateAdded", "(", "cand", ")", ";", "}" ]
Add a new transport candidate @param cand The candidate to add @throws NotConnectedException @throws InterruptedException
[ "Add", "a", "new", "transport", "candidate" ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java#L275-L283
27,017
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java
TransportResolver.getPreferredCandidate
public TransportCandidate getPreferredCandidate() { TransportCandidate result = null; ArrayList<ICECandidate> cands = new ArrayList<>(); for (TransportCandidate tpcan : getCandidatesList()) { if (tpcan instanceof ICECandidate) cands.add((ICECandidate) tpcan); } // (ArrayList<ICECandidate>) getCandidatesList(); if (cands.size() > 0) { Collections.sort(cands); // Return the last candidate result = cands.get(cands.size() - 1); LOGGER.fine("Result: " + result.getIp()); } return result; }
java
public TransportCandidate getPreferredCandidate() { TransportCandidate result = null; ArrayList<ICECandidate> cands = new ArrayList<>(); for (TransportCandidate tpcan : getCandidatesList()) { if (tpcan instanceof ICECandidate) cands.add((ICECandidate) tpcan); } // (ArrayList<ICECandidate>) getCandidatesList(); if (cands.size() > 0) { Collections.sort(cands); // Return the last candidate result = cands.get(cands.size() - 1); LOGGER.fine("Result: " + result.getIp()); } return result; }
[ "public", "TransportCandidate", "getPreferredCandidate", "(", ")", "{", "TransportCandidate", "result", "=", "null", ";", "ArrayList", "<", "ICECandidate", ">", "cands", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "TransportCandidate", "tpcan", ":", "getCandidatesList", "(", ")", ")", "{", "if", "(", "tpcan", "instanceof", "ICECandidate", ")", "cands", ".", "add", "(", "(", "ICECandidate", ")", "tpcan", ")", ";", "}", "// (ArrayList<ICECandidate>) getCandidatesList();", "if", "(", "cands", ".", "size", "(", ")", ">", "0", ")", "{", "Collections", ".", "sort", "(", "cands", ")", ";", "// Return the last candidate", "result", "=", "cands", ".", "get", "(", "cands", ".", "size", "(", ")", "-", "1", ")", ";", "LOGGER", ".", "fine", "(", "\"Result: \"", "+", "result", ".", "getIp", "(", ")", ")", ";", "}", "return", "result", ";", "}" ]
Get the candidate with the highest preference. @return The best candidate, according to the preference order.
[ "Get", "the", "candidate", "with", "the", "highest", "preference", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java#L301-L319
27,018
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java
TransportResolver.getCandidate
public TransportCandidate getCandidate(int i) { TransportCandidate cand; synchronized (candidates) { cand = candidates.get(i); } return cand; }
java
public TransportCandidate getCandidate(int i) { TransportCandidate cand; synchronized (candidates) { cand = candidates.get(i); } return cand; }
[ "public", "TransportCandidate", "getCandidate", "(", "int", "i", ")", "{", "TransportCandidate", "cand", ";", "synchronized", "(", "candidates", ")", "{", "cand", "=", "candidates", ".", "get", "(", "i", ")", ";", "}", "return", "cand", ";", "}" ]
Get the n-th candidate. @return a transport candidate
[ "Get", "the", "n", "-", "th", "candidate", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java#L352-L359
27,019
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java
TransportResolver.initializeAndWait
public void initializeAndWait() throws XMPPException, SmackException, InterruptedException { this.initialize(); try { LOGGER.fine("Initializing transport resolver..."); while (!this.isInitialized()) { LOGGER.fine("Resolver init still pending"); Thread.sleep(1000); } LOGGER.fine("Transport resolved"); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } }
java
public void initializeAndWait() throws XMPPException, SmackException, InterruptedException { this.initialize(); try { LOGGER.fine("Initializing transport resolver..."); while (!this.isInitialized()) { LOGGER.fine("Resolver init still pending"); Thread.sleep(1000); } LOGGER.fine("Transport resolved"); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } }
[ "public", "void", "initializeAndWait", "(", ")", "throws", "XMPPException", ",", "SmackException", ",", "InterruptedException", "{", "this", ".", "initialize", "(", ")", ";", "try", "{", "LOGGER", ".", "fine", "(", "\"Initializing transport resolver...\"", ")", ";", "while", "(", "!", "this", ".", "isInitialized", "(", ")", ")", "{", "LOGGER", ".", "fine", "(", "\"Resolver init still pending\"", ")", ";", "Thread", ".", "sleep", "(", "1000", ")", ";", "}", "LOGGER", ".", "fine", "(", "\"Transport resolved\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"exception\"", ",", "e", ")", ";", "}", "}" ]
Initialize Transport Resolver and wait until it is completely uninitialized. @throws SmackException @throws InterruptedException
[ "Initialize", "Transport", "Resolver", "and", "wait", "until", "it", "is", "completely", "uninitialized", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportResolver.java#L366-L379
27,020
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/dns/DNSResolver.java
DNSResolver.lookupSRVRecords
public final List<SRVRecord> lookupSRVRecords(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) { checkIfDnssecRequestedAndSupported(dnssecMode); return lookupSRVRecords0(name, failedAddresses, dnssecMode); }
java
public final List<SRVRecord> lookupSRVRecords(DnsName name, List<HostAddress> failedAddresses, DnssecMode dnssecMode) { checkIfDnssecRequestedAndSupported(dnssecMode); return lookupSRVRecords0(name, failedAddresses, dnssecMode); }
[ "public", "final", "List", "<", "SRVRecord", ">", "lookupSRVRecords", "(", "DnsName", "name", ",", "List", "<", "HostAddress", ">", "failedAddresses", ",", "DnssecMode", "dnssecMode", ")", "{", "checkIfDnssecRequestedAndSupported", "(", "dnssecMode", ")", ";", "return", "lookupSRVRecords0", "(", "name", ",", "failedAddresses", ",", "dnssecMode", ")", ";", "}" ]
Gets a list of service records for the specified service. @param name The symbolic name of the service. @param failedAddresses list of failed addresses. @param dnssecMode security mode. @return The list of SRV records mapped to the service name.
[ "Gets", "a", "list", "of", "service", "records", "for", "the", "specified", "service", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/dns/DNSResolver.java#L51-L54
27,021
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/DiscussionHistory.java
DiscussionHistory.getMUCHistory
MUCInitialPresence.History getMUCHistory() { // Return null if the history was not properly configured if (!isConfigured()) { return null; } return new MUCInitialPresence.History(maxChars, maxStanzas, seconds, since); }
java
MUCInitialPresence.History getMUCHistory() { // Return null if the history was not properly configured if (!isConfigured()) { return null; } return new MUCInitialPresence.History(maxChars, maxStanzas, seconds, since); }
[ "MUCInitialPresence", ".", "History", "getMUCHistory", "(", ")", "{", "// Return null if the history was not properly configured", "if", "(", "!", "isConfigured", "(", ")", ")", "{", "return", "null", ";", "}", "return", "new", "MUCInitialPresence", ".", "History", "(", "maxChars", ",", "maxStanzas", ",", "seconds", ",", "since", ")", ";", "}" ]
Returns the History that manages the amount of discussion history provided on entering a room. @return the History that manages the amount of discussion history provided on entering a room.
[ "Returns", "the", "History", "that", "manages", "the", "amount", "of", "discussion", "history", "provided", "on", "entering", "a", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/DiscussionHistory.java#L149-L156
27,022
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/filter/ToMatchesFilter.java
ToMatchesFilter.create
public static ToMatchesFilter create(Jid address) { return new ToMatchesFilter(address, address != null ? address.hasNoResource() : false) ; }
java
public static ToMatchesFilter create(Jid address) { return new ToMatchesFilter(address, address != null ? address.hasNoResource() : false) ; }
[ "public", "static", "ToMatchesFilter", "create", "(", "Jid", "address", ")", "{", "return", "new", "ToMatchesFilter", "(", "address", ",", "address", "!=", "null", "?", "address", ".", "hasNoResource", "(", ")", ":", "false", ")", ";", "}" ]
Creates a filter matching on the "to" field. If the filter address is bare, compares the filter address with the bare from address. Otherwise, compares the filter address with the full from address. @param address The address to filter for. If <code>null</code> is given, the stanza must not have a from address. @return filter matching the "to" address.
[ "Creates", "a", "filter", "matching", "on", "the", "to", "field", ".", "If", "the", "filter", "address", "is", "bare", "compares", "the", "filter", "address", "with", "the", "bare", "from", "address", ".", "Otherwise", "compares", "the", "filter", "address", "with", "the", "full", "from", "address", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/filter/ToMatchesFilter.java#L40-L42
27,023
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java
AudioMediaSession.createSession
public static MediaSession createSession(String localhost, int localPort, String remoteHost, int remotePort, MediaSessionListener eventHandler, int quality, boolean secure, boolean micOn) throws NoProcessorException, UnsupportedFormatException, IOException, GeneralSecurityException { SpeexFormat.setFramesPerPacket(1); /** * The master key. Hardcoded for now. */ byte[] masterKey = new byte[] {(byte) 0xE1, (byte) 0xF9, 0x7A, 0x0D, 0x3E, 0x01, (byte) 0x8B, (byte) 0xE0, (byte) 0xD6, 0x4F, (byte) 0xA3, 0x2C, 0x06, (byte) 0xDE, 0x41, 0x39}; /** * The master salt. Hardcoded for now. */ byte[] masterSalt = new byte[] {0x0E, (byte) 0xC6, 0x75, (byte) 0xAD, 0x49, (byte) 0x8A, (byte) 0xFE, (byte) 0xEB, (byte) 0xB6, (byte) 0x96, 0x0B, 0x3A, (byte) 0xAB, (byte) 0xE6}; DatagramSocket[] localPorts = MediaSession.getLocalPorts(InetAddress.getByName(localhost), localPort); MediaSession session = MediaSession.createInstance(remoteHost, remotePort, localPorts, quality, secure, masterKey, masterSalt); session.setListener(eventHandler); session.setSourceDescription(new SourceDescription[] {new SourceDescription(SourceDescription.SOURCE_DESC_NAME, "Superman", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_EMAIL, "cdcie.tester@je.jfcom.mil", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_LOC, InetAddress.getByName(localhost) + " Port " + session.getLocalDataPort(), 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_TOOL, "JFCOM CDCIE Audio Chat", 1, false)}); return session; }
java
public static MediaSession createSession(String localhost, int localPort, String remoteHost, int remotePort, MediaSessionListener eventHandler, int quality, boolean secure, boolean micOn) throws NoProcessorException, UnsupportedFormatException, IOException, GeneralSecurityException { SpeexFormat.setFramesPerPacket(1); /** * The master key. Hardcoded for now. */ byte[] masterKey = new byte[] {(byte) 0xE1, (byte) 0xF9, 0x7A, 0x0D, 0x3E, 0x01, (byte) 0x8B, (byte) 0xE0, (byte) 0xD6, 0x4F, (byte) 0xA3, 0x2C, 0x06, (byte) 0xDE, 0x41, 0x39}; /** * The master salt. Hardcoded for now. */ byte[] masterSalt = new byte[] {0x0E, (byte) 0xC6, 0x75, (byte) 0xAD, 0x49, (byte) 0x8A, (byte) 0xFE, (byte) 0xEB, (byte) 0xB6, (byte) 0x96, 0x0B, 0x3A, (byte) 0xAB, (byte) 0xE6}; DatagramSocket[] localPorts = MediaSession.getLocalPorts(InetAddress.getByName(localhost), localPort); MediaSession session = MediaSession.createInstance(remoteHost, remotePort, localPorts, quality, secure, masterKey, masterSalt); session.setListener(eventHandler); session.setSourceDescription(new SourceDescription[] {new SourceDescription(SourceDescription.SOURCE_DESC_NAME, "Superman", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_EMAIL, "cdcie.tester@je.jfcom.mil", 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_LOC, InetAddress.getByName(localhost) + " Port " + session.getLocalDataPort(), 1, false), new SourceDescription(SourceDescription.SOURCE_DESC_TOOL, "JFCOM CDCIE Audio Chat", 1, false)}); return session; }
[ "public", "static", "MediaSession", "createSession", "(", "String", "localhost", ",", "int", "localPort", ",", "String", "remoteHost", ",", "int", "remotePort", ",", "MediaSessionListener", "eventHandler", ",", "int", "quality", ",", "boolean", "secure", ",", "boolean", "micOn", ")", "throws", "NoProcessorException", ",", "UnsupportedFormatException", ",", "IOException", ",", "GeneralSecurityException", "{", "SpeexFormat", ".", "setFramesPerPacket", "(", "1", ")", ";", "/**\n * The master key. Hardcoded for now.\n */", "byte", "[", "]", "masterKey", "=", "new", "byte", "[", "]", "{", "(", "byte", ")", "0xE1", ",", "(", "byte", ")", "0xF9", ",", "0x7A", ",", "0x0D", ",", "0x3E", ",", "0x01", ",", "(", "byte", ")", "0x8B", ",", "(", "byte", ")", "0xE0", ",", "(", "byte", ")", "0xD6", ",", "0x4F", ",", "(", "byte", ")", "0xA3", ",", "0x2C", ",", "0x06", ",", "(", "byte", ")", "0xDE", ",", "0x41", ",", "0x39", "}", ";", "/**\n * The master salt. Hardcoded for now.\n */", "byte", "[", "]", "masterSalt", "=", "new", "byte", "[", "]", "{", "0x0E", ",", "(", "byte", ")", "0xC6", ",", "0x75", ",", "(", "byte", ")", "0xAD", ",", "0x49", ",", "(", "byte", ")", "0x8A", ",", "(", "byte", ")", "0xFE", ",", "(", "byte", ")", "0xEB", ",", "(", "byte", ")", "0xB6", ",", "(", "byte", ")", "0x96", ",", "0x0B", ",", "0x3A", ",", "(", "byte", ")", "0xAB", ",", "(", "byte", ")", "0xE6", "}", ";", "DatagramSocket", "[", "]", "localPorts", "=", "MediaSession", ".", "getLocalPorts", "(", "InetAddress", ".", "getByName", "(", "localhost", ")", ",", "localPort", ")", ";", "MediaSession", "session", "=", "MediaSession", ".", "createInstance", "(", "remoteHost", ",", "remotePort", ",", "localPorts", ",", "quality", ",", "secure", ",", "masterKey", ",", "masterSalt", ")", ";", "session", ".", "setListener", "(", "eventHandler", ")", ";", "session", ".", "setSourceDescription", "(", "new", "SourceDescription", "[", "]", "{", "new", "SourceDescription", "(", "SourceDescription", ".", "SOURCE_DESC_NAME", ",", "\"Superman\"", ",", "1", ",", "false", ")", ",", "new", "SourceDescription", "(", "SourceDescription", ".", "SOURCE_DESC_EMAIL", ",", "\"cdcie.tester@je.jfcom.mil\"", ",", "1", ",", "false", ")", ",", "new", "SourceDescription", "(", "SourceDescription", ".", "SOURCE_DESC_LOC", ",", "InetAddress", ".", "getByName", "(", "localhost", ")", "+", "\" Port \"", "+", "session", ".", "getLocalDataPort", "(", ")", ",", "1", ",", "false", ")", ",", "new", "SourceDescription", "(", "SourceDescription", ".", "SOURCE_DESC_TOOL", ",", "\"JFCOM CDCIE Audio Chat\"", ",", "1", ",", "false", ")", "}", ")", ";", "return", "session", ";", "}" ]
Create a Session using Speex Codec. @param localhost localHost @param localPort localPort @param remoteHost remoteHost @param remotePort remotePort @param eventHandler eventHandler @param quality quality @param secure secure @param micOn micOn @return MediaSession @throws NoProcessorException @throws UnsupportedFormatException @throws IOException @throws GeneralSecurityException
[ "Create", "a", "Session", "using", "Speex", "Codec", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java#L76-L95
27,024
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java
AudioMediaSession.startTransmit
@Override public void startTransmit() { try { LOGGER.fine("start"); mediaSession.start(true); this.mediaReceived(""); } catch (IOException e) { LOGGER.log(Level.WARNING, "exception", e); } }
java
@Override public void startTransmit() { try { LOGGER.fine("start"); mediaSession.start(true); this.mediaReceived(""); } catch (IOException e) { LOGGER.log(Level.WARNING, "exception", e); } }
[ "@", "Override", "public", "void", "startTransmit", "(", ")", "{", "try", "{", "LOGGER", ".", "fine", "(", "\"start\"", ")", ";", "mediaSession", ".", "start", "(", "true", ")", ";", "this", ".", "mediaReceived", "(", "\"\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"exception\"", ",", "e", ")", ";", "}", "}" ]
Starts transmission and for NAT Traversal reasons start receiving also.
[ "Starts", "transmission", "and", "for", "NAT", "Traversal", "reasons", "start", "receiving", "also", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/AudioMediaSession.java#L169-L179
27,025
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java
AbstractHttpOverXmppProvider.parseHeaders
protected HeadersExtension parseHeaders(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException { HeadersExtension headersExtension = null; /* We are either at start of headers, start of data or end of req/res */ if (parser.next() == XmlPullParser.START_TAG && parser.getName().equals(HeadersExtension.ELEMENT)) { headersExtension = HeadersProvider.INSTANCE.parse(parser); parser.next(); } return headersExtension; }
java
protected HeadersExtension parseHeaders(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException { HeadersExtension headersExtension = null; /* We are either at start of headers, start of data or end of req/res */ if (parser.next() == XmlPullParser.START_TAG && parser.getName().equals(HeadersExtension.ELEMENT)) { headersExtension = HeadersProvider.INSTANCE.parse(parser); parser.next(); } return headersExtension; }
[ "protected", "HeadersExtension", "parseHeaders", "(", "XmlPullParser", "parser", ")", "throws", "IOException", ",", "XmlPullParserException", ",", "SmackParsingException", "{", "HeadersExtension", "headersExtension", "=", "null", ";", "/* We are either at start of headers, start of data or end of req/res */", "if", "(", "parser", ".", "next", "(", ")", "==", "XmlPullParser", ".", "START_TAG", "&&", "parser", ".", "getName", "(", ")", ".", "equals", "(", "HeadersExtension", ".", "ELEMENT", ")", ")", "{", "headersExtension", "=", "HeadersProvider", ".", "INSTANCE", ".", "parse", "(", "parser", ")", ";", "parser", ".", "next", "(", ")", ";", "}", "return", "headersExtension", ";", "}" ]
Parses HeadersExtension element if any. @param parser parser @return HeadersExtension or null if no headers @throws XmlPullParserException @throws IOException @throws SmackParsingException
[ "Parses", "HeadersExtension", "element", "if", "any", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java#L63-L72
27,026
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java
AbstractHttpOverXmppProvider.parseData
protected AbstractHttpOverXmpp.Data parseData(XmlPullParser parser) throws XmlPullParserException, IOException { NamedElement child = null; boolean done = false; AbstractHttpOverXmpp.Data data = null; /* We are either at start of data or end of req/res */ if (parser.getEventType() == XmlPullParser.START_TAG) { while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { switch (parser.getName()) { case ELEMENT_TEXT: child = parseText(parser); break; case ELEMENT_BASE_64: child = parseBase64(parser); break; case ELEMENT_CHUNKED_BASE_64: child = parseChunkedBase64(parser); break; case ELEMENT_XML: child = parseXml(parser); break; case ELEMENT_IBB: child = parseIbb(parser); break; case ELEMENT_SIPUB: // TODO: sipub is allowed by xep-0332, but is not // implemented yet throw new UnsupportedOperationException("sipub is not supported yet"); case ELEMENT_JINGLE: // TODO: jingle is allowed by xep-0332, but is not // implemented yet throw new UnsupportedOperationException("jingle is not supported yet"); default: // other elements are not allowed throw new IllegalArgumentException("unsupported child tag: " + parser.getName()); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals(ELEMENT_DATA)) { done = true; } } } data = new AbstractHttpOverXmpp.Data(child); } return data; }
java
protected AbstractHttpOverXmpp.Data parseData(XmlPullParser parser) throws XmlPullParserException, IOException { NamedElement child = null; boolean done = false; AbstractHttpOverXmpp.Data data = null; /* We are either at start of data or end of req/res */ if (parser.getEventType() == XmlPullParser.START_TAG) { while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { switch (parser.getName()) { case ELEMENT_TEXT: child = parseText(parser); break; case ELEMENT_BASE_64: child = parseBase64(parser); break; case ELEMENT_CHUNKED_BASE_64: child = parseChunkedBase64(parser); break; case ELEMENT_XML: child = parseXml(parser); break; case ELEMENT_IBB: child = parseIbb(parser); break; case ELEMENT_SIPUB: // TODO: sipub is allowed by xep-0332, but is not // implemented yet throw new UnsupportedOperationException("sipub is not supported yet"); case ELEMENT_JINGLE: // TODO: jingle is allowed by xep-0332, but is not // implemented yet throw new UnsupportedOperationException("jingle is not supported yet"); default: // other elements are not allowed throw new IllegalArgumentException("unsupported child tag: " + parser.getName()); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals(ELEMENT_DATA)) { done = true; } } } data = new AbstractHttpOverXmpp.Data(child); } return data; }
[ "protected", "AbstractHttpOverXmpp", ".", "Data", "parseData", "(", "XmlPullParser", "parser", ")", "throws", "XmlPullParserException", ",", "IOException", "{", "NamedElement", "child", "=", "null", ";", "boolean", "done", "=", "false", ";", "AbstractHttpOverXmpp", ".", "Data", "data", "=", "null", ";", "/* We are either at start of data or end of req/res */", "if", "(", "parser", ".", "getEventType", "(", ")", "==", "XmlPullParser", ".", "START_TAG", ")", "{", "while", "(", "!", "done", ")", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "if", "(", "eventType", "==", "XmlPullParser", ".", "START_TAG", ")", "{", "switch", "(", "parser", ".", "getName", "(", ")", ")", "{", "case", "ELEMENT_TEXT", ":", "child", "=", "parseText", "(", "parser", ")", ";", "break", ";", "case", "ELEMENT_BASE_64", ":", "child", "=", "parseBase64", "(", "parser", ")", ";", "break", ";", "case", "ELEMENT_CHUNKED_BASE_64", ":", "child", "=", "parseChunkedBase64", "(", "parser", ")", ";", "break", ";", "case", "ELEMENT_XML", ":", "child", "=", "parseXml", "(", "parser", ")", ";", "break", ";", "case", "ELEMENT_IBB", ":", "child", "=", "parseIbb", "(", "parser", ")", ";", "break", ";", "case", "ELEMENT_SIPUB", ":", "// TODO: sipub is allowed by xep-0332, but is not", "// implemented yet", "throw", "new", "UnsupportedOperationException", "(", "\"sipub is not supported yet\"", ")", ";", "case", "ELEMENT_JINGLE", ":", "// TODO: jingle is allowed by xep-0332, but is not", "// implemented yet", "throw", "new", "UnsupportedOperationException", "(", "\"jingle is not supported yet\"", ")", ";", "default", ":", "// other elements are not allowed", "throw", "new", "IllegalArgumentException", "(", "\"unsupported child tag: \"", "+", "parser", ".", "getName", "(", ")", ")", ";", "}", "}", "else", "if", "(", "eventType", "==", "XmlPullParser", ".", "END_TAG", ")", "{", "if", "(", "parser", ".", "getName", "(", ")", ".", "equals", "(", "ELEMENT_DATA", ")", ")", "{", "done", "=", "true", ";", "}", "}", "}", "data", "=", "new", "AbstractHttpOverXmpp", ".", "Data", "(", "child", ")", ";", "}", "return", "data", ";", "}" ]
Parses Data element if any. @param parser parser @return Data or null if no data @throws XmlPullParserException @throws IOException
[ "Parses", "Data", "element", "if", "any", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/hoxt/provider/AbstractHttpOverXmppProvider.java#L83-L130
27,027
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/multi/MultiMediaManager.java
MultiMediaManager.getPayloads
@Override public List<PayloadType> getPayloads() { List<PayloadType> list = new ArrayList<>(); if (preferredPayloadType != null) list.add(preferredPayloadType); for (JingleMediaManager manager : managers) { for (PayloadType payloadType : manager.getPayloads()) { if (!list.contains(payloadType) && !payloadType.equals(preferredPayloadType)) list.add(payloadType); } } return list; }
java
@Override public List<PayloadType> getPayloads() { List<PayloadType> list = new ArrayList<>(); if (preferredPayloadType != null) list.add(preferredPayloadType); for (JingleMediaManager manager : managers) { for (PayloadType payloadType : manager.getPayloads()) { if (!list.contains(payloadType) && !payloadType.equals(preferredPayloadType)) list.add(payloadType); } } return list; }
[ "@", "Override", "public", "List", "<", "PayloadType", ">", "getPayloads", "(", ")", "{", "List", "<", "PayloadType", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "preferredPayloadType", "!=", "null", ")", "list", ".", "add", "(", "preferredPayloadType", ")", ";", "for", "(", "JingleMediaManager", "manager", ":", "managers", ")", "{", "for", "(", "PayloadType", "payloadType", ":", "manager", ".", "getPayloads", "(", ")", ")", "{", "if", "(", "!", "list", ".", "contains", "(", "payloadType", ")", "&&", "!", "payloadType", ".", "equals", "(", "preferredPayloadType", ")", ")", "list", ".", "add", "(", "payloadType", ")", ";", "}", "}", "return", "list", ";", "}" ]
Return all supported Payloads for this Manager. @return The Payload List
[ "Return", "all", "supported", "Payloads", "for", "this", "Manager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/multi/MultiMediaManager.java#L61-L72
27,028
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.isServiceEnabled
public static boolean isServiceEnabled(XMPPConnection connection, Jid userID) throws XMPPException, SmackException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(userID, Jingle.NAMESPACE); }
java
public static boolean isServiceEnabled(XMPPConnection connection, Jid userID) throws XMPPException, SmackException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection).supportsFeature(userID, Jingle.NAMESPACE); }
[ "public", "static", "boolean", "isServiceEnabled", "(", "XMPPConnection", "connection", ",", "Jid", "userID", ")", "throws", "XMPPException", ",", "SmackException", ",", "InterruptedException", "{", "return", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ".", "supportsFeature", "(", "userID", ",", "Jingle", ".", "NAMESPACE", ")", ";", "}" ]
Returns true if the specified user handles Jingle messages. @param connection the connection to use to perform the service discovery @param userID the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com @return a boolean indicating whether the specified user handles Jingle messages @throws SmackException if there was no response from the server. @throws XMPPException @throws InterruptedException
[ "Returns", "true", "if", "the", "specified", "user", "handles", "Jingle", "messages", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L309-L311
27,029
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.addJingleSessionRequestListener
public synchronized void addJingleSessionRequestListener(final JingleSessionRequestListener jingleSessionRequestListener) { if (jingleSessionRequestListener != null) { if (jingleSessionRequestListeners == null) { initJingleSessionRequestListeners(); } synchronized (jingleSessionRequestListeners) { jingleSessionRequestListeners.add(jingleSessionRequestListener); } } }
java
public synchronized void addJingleSessionRequestListener(final JingleSessionRequestListener jingleSessionRequestListener) { if (jingleSessionRequestListener != null) { if (jingleSessionRequestListeners == null) { initJingleSessionRequestListeners(); } synchronized (jingleSessionRequestListeners) { jingleSessionRequestListeners.add(jingleSessionRequestListener); } } }
[ "public", "synchronized", "void", "addJingleSessionRequestListener", "(", "final", "JingleSessionRequestListener", "jingleSessionRequestListener", ")", "{", "if", "(", "jingleSessionRequestListener", "!=", "null", ")", "{", "if", "(", "jingleSessionRequestListeners", "==", "null", ")", "{", "initJingleSessionRequestListeners", "(", ")", ";", "}", "synchronized", "(", "jingleSessionRequestListeners", ")", "{", "jingleSessionRequestListeners", ".", "add", "(", "jingleSessionRequestListener", ")", ";", "}", "}", "}" ]
Add a Jingle session request listenerJingle to listen to incoming session requests. @param jingleSessionRequestListener an implemented JingleSessionRequestListener @see #removeJingleSessionRequestListener(JingleSessionRequestListener) @see JingleListener
[ "Add", "a", "Jingle", "session", "request", "listenerJingle", "to", "listen", "to", "incoming", "session", "requests", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L339-L348
27,030
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.triggerSessionCreated
public void triggerSessionCreated(JingleSession jingleSession) { jingleSessions.add(jingleSession); jingleSession.addListener(this); for (CreatedJingleSessionListener createdJingleSessionListener : creationListeners) { try { createdJingleSessionListener.sessionCreated(jingleSession); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } } }
java
public void triggerSessionCreated(JingleSession jingleSession) { jingleSessions.add(jingleSession); jingleSession.addListener(this); for (CreatedJingleSessionListener createdJingleSessionListener : creationListeners) { try { createdJingleSessionListener.sessionCreated(jingleSession); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } } }
[ "public", "void", "triggerSessionCreated", "(", "JingleSession", "jingleSession", ")", "{", "jingleSessions", ".", "add", "(", "jingleSession", ")", ";", "jingleSession", ".", "addListener", "(", "this", ")", ";", "for", "(", "CreatedJingleSessionListener", "createdJingleSessionListener", ":", "creationListeners", ")", "{", "try", "{", "createdJingleSessionListener", ".", "sessionCreated", "(", "jingleSession", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"exception\"", ",", "e", ")", ";", "}", "}", "}" ]
Trigger CreatedJingleSessionListeners that a session was created. @param jingleSession
[ "Trigger", "CreatedJingleSessionListeners", "that", "a", "session", "was", "created", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L391-L401
27,031
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.initJingleSessionRequestListeners
private void initJingleSessionRequestListeners() { StanzaFilter initRequestFilter = new StanzaFilter() { // Return true if we accept this packet @Override public boolean accept(Stanza pin) { if (pin instanceof IQ) { IQ iq = (IQ) pin; if (iq.getType().equals(IQ.Type.set)) { if (iq instanceof Jingle) { Jingle jin = (Jingle) pin; if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) { return true; } } } } return false; } }; jingleSessionRequestListeners = new ArrayList<>(); // Start a packet listener for session initiation requests connection.addAsyncStanzaListener(new StanzaListener() { @Override public void processStanza(Stanza packet) { triggerSessionRequested((Jingle) packet); } }, initRequestFilter); }
java
private void initJingleSessionRequestListeners() { StanzaFilter initRequestFilter = new StanzaFilter() { // Return true if we accept this packet @Override public boolean accept(Stanza pin) { if (pin instanceof IQ) { IQ iq = (IQ) pin; if (iq.getType().equals(IQ.Type.set)) { if (iq instanceof Jingle) { Jingle jin = (Jingle) pin; if (jin.getAction().equals(JingleActionEnum.SESSION_INITIATE)) { return true; } } } } return false; } }; jingleSessionRequestListeners = new ArrayList<>(); // Start a packet listener for session initiation requests connection.addAsyncStanzaListener(new StanzaListener() { @Override public void processStanza(Stanza packet) { triggerSessionRequested((Jingle) packet); } }, initRequestFilter); }
[ "private", "void", "initJingleSessionRequestListeners", "(", ")", "{", "StanzaFilter", "initRequestFilter", "=", "new", "StanzaFilter", "(", ")", "{", "// Return true if we accept this packet", "@", "Override", "public", "boolean", "accept", "(", "Stanza", "pin", ")", "{", "if", "(", "pin", "instanceof", "IQ", ")", "{", "IQ", "iq", "=", "(", "IQ", ")", "pin", ";", "if", "(", "iq", ".", "getType", "(", ")", ".", "equals", "(", "IQ", ".", "Type", ".", "set", ")", ")", "{", "if", "(", "iq", "instanceof", "Jingle", ")", "{", "Jingle", "jin", "=", "(", "Jingle", ")", "pin", ";", "if", "(", "jin", ".", "getAction", "(", ")", ".", "equals", "(", "JingleActionEnum", ".", "SESSION_INITIATE", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}", "}", ";", "jingleSessionRequestListeners", "=", "new", "ArrayList", "<>", "(", ")", ";", "// Start a packet listener for session initiation requests", "connection", ".", "addAsyncStanzaListener", "(", "new", "StanzaListener", "(", ")", "{", "@", "Override", "public", "void", "processStanza", "(", "Stanza", "packet", ")", "{", "triggerSessionRequested", "(", "(", "Jingle", ")", "packet", ")", ";", "}", "}", ",", "initRequestFilter", ")", ";", "}" ]
Register the listenerJingles, waiting for a Jingle stanza that tries to establish a new session.
[ "Register", "the", "listenerJingles", "waiting", "for", "a", "Jingle", "stanza", "that", "tries", "to", "establish", "a", "new", "session", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L442-L471
27,032
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.disconnectAllSessions
public void disconnectAllSessions() { List<JingleSession> sessions = jingleSessions.subList(0, jingleSessions.size()); for (JingleSession jingleSession : sessions) try { jingleSession.terminate(); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } sessions.clear(); }
java
public void disconnectAllSessions() { List<JingleSession> sessions = jingleSessions.subList(0, jingleSessions.size()); for (JingleSession jingleSession : sessions) try { jingleSession.terminate(); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } sessions.clear(); }
[ "public", "void", "disconnectAllSessions", "(", ")", "{", "List", "<", "JingleSession", ">", "sessions", "=", "jingleSessions", ".", "subList", "(", "0", ",", "jingleSessions", ".", "size", "(", ")", ")", ";", "for", "(", "JingleSession", "jingleSession", ":", "sessions", ")", "try", "{", "jingleSession", ".", "terminate", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"exception\"", ",", "e", ")", ";", "}", "sessions", ".", "clear", "(", ")", ";", "}" ]
Disconnect all Jingle Sessions.
[ "Disconnect", "all", "Jingle", "Sessions", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L476-L488
27,033
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.triggerSessionRequested
void triggerSessionRequested(Jingle initJin) { JingleSessionRequestListener[] jingleSessionRequestListeners; // Make a synchronized copy of the listenerJingles synchronized (this.jingleSessionRequestListeners) { jingleSessionRequestListeners = new JingleSessionRequestListener[this.jingleSessionRequestListeners.size()]; this.jingleSessionRequestListeners.toArray(jingleSessionRequestListeners); } // ... and let them know of the event JingleSessionRequest request = new JingleSessionRequest(this, initJin); for (int i = 0; i < jingleSessionRequestListeners.length; i++) { jingleSessionRequestListeners[i].sessionRequested(request); } }
java
void triggerSessionRequested(Jingle initJin) { JingleSessionRequestListener[] jingleSessionRequestListeners; // Make a synchronized copy of the listenerJingles synchronized (this.jingleSessionRequestListeners) { jingleSessionRequestListeners = new JingleSessionRequestListener[this.jingleSessionRequestListeners.size()]; this.jingleSessionRequestListeners.toArray(jingleSessionRequestListeners); } // ... and let them know of the event JingleSessionRequest request = new JingleSessionRequest(this, initJin); for (int i = 0; i < jingleSessionRequestListeners.length; i++) { jingleSessionRequestListeners[i].sessionRequested(request); } }
[ "void", "triggerSessionRequested", "(", "Jingle", "initJin", ")", "{", "JingleSessionRequestListener", "[", "]", "jingleSessionRequestListeners", ";", "// Make a synchronized copy of the listenerJingles", "synchronized", "(", "this", ".", "jingleSessionRequestListeners", ")", "{", "jingleSessionRequestListeners", "=", "new", "JingleSessionRequestListener", "[", "this", ".", "jingleSessionRequestListeners", ".", "size", "(", ")", "]", ";", "this", ".", "jingleSessionRequestListeners", ".", "toArray", "(", "jingleSessionRequestListeners", ")", ";", "}", "// ... and let them know of the event", "JingleSessionRequest", "request", "=", "new", "JingleSessionRequest", "(", "this", ",", "initJin", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "jingleSessionRequestListeners", ".", "length", ";", "i", "++", ")", "{", "jingleSessionRequestListeners", "[", "i", "]", ".", "sessionRequested", "(", "request", ")", ";", "}", "}" ]
Activates the listenerJingles on a Jingle session request. @param initJin the stanza that must be passed to the jingleSessionRequestListener.
[ "Activates", "the", "listenerJingles", "on", "a", "Jingle", "session", "request", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L495-L510
27,034
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.createOutgoingJingleSession
public JingleSession createOutgoingJingleSession(EntityFullJid responder) throws XMPPException { JingleSession session = new JingleSession(connection, null, connection.getUser(), responder, jingleMediaManagers); triggerSessionCreated(session); return session; }
java
public JingleSession createOutgoingJingleSession(EntityFullJid responder) throws XMPPException { JingleSession session = new JingleSession(connection, null, connection.getUser(), responder, jingleMediaManagers); triggerSessionCreated(session); return session; }
[ "public", "JingleSession", "createOutgoingJingleSession", "(", "EntityFullJid", "responder", ")", "throws", "XMPPException", "{", "JingleSession", "session", "=", "new", "JingleSession", "(", "connection", ",", "null", ",", "connection", ".", "getUser", "(", ")", ",", "responder", ",", "jingleMediaManagers", ")", ";", "triggerSessionCreated", "(", "session", ")", ";", "return", "session", ";", "}" ]
Creates an Jingle session to start a communication with another user. @param responder the fully qualified jabber ID with resource of the other user. @return The session on which the negotiation can be run.
[ "Creates", "an", "Jingle", "session", "to", "start", "a", "communication", "with", "another", "user", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L521-L527
27,035
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.createIncomingJingleSession
public JingleSession createIncomingJingleSession(JingleSessionRequest request) throws XMPPException { if (request == null) { throw new NullPointerException("Received request cannot be null"); } JingleSession session = new JingleSession(connection, request, request.getFrom(), connection.getUser(), jingleMediaManagers); triggerSessionCreated(session); return session; }
java
public JingleSession createIncomingJingleSession(JingleSessionRequest request) throws XMPPException { if (request == null) { throw new NullPointerException("Received request cannot be null"); } JingleSession session = new JingleSession(connection, request, request.getFrom(), connection.getUser(), jingleMediaManagers); triggerSessionCreated(session); return session; }
[ "public", "JingleSession", "createIncomingJingleSession", "(", "JingleSessionRequest", "request", ")", "throws", "XMPPException", "{", "if", "(", "request", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Received request cannot be null\"", ")", ";", "}", "JingleSession", "session", "=", "new", "JingleSession", "(", "connection", ",", "request", ",", "request", ".", "getFrom", "(", ")", ",", "connection", ".", "getUser", "(", ")", ",", "jingleMediaManagers", ")", ";", "triggerSessionCreated", "(", "session", ")", ";", "return", "session", ";", "}" ]
When the session request is acceptable, this method should be invoked. It will create an JingleSession which allows the negotiation to procede. @param request the remote request that is being accepted. @return the session which manages the rest of the negotiation.
[ "When", "the", "session", "request", "is", "acceptable", "this", "method", "should", "be", "invoked", ".", "It", "will", "create", "an", "JingleSession", "which", "allows", "the", "negotiation", "to", "procede", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L547-L557
27,036
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java
JingleManager.getSession
public JingleSession getSession(String jid) { for (JingleSession jingleSession : jingleSessions) { if (jingleSession.getResponder().equals(jid)) { return jingleSession; } } return null; }
java
public JingleSession getSession(String jid) { for (JingleSession jingleSession : jingleSessions) { if (jingleSession.getResponder().equals(jid)) { return jingleSession; } } return null; }
[ "public", "JingleSession", "getSession", "(", "String", "jid", ")", "{", "for", "(", "JingleSession", "jingleSession", ":", "jingleSessions", ")", "{", "if", "(", "jingleSession", ".", "getResponder", "(", ")", ".", "equals", "(", "jid", ")", ")", "{", "return", "jingleSession", ";", "}", "}", "return", "null", ";", "}" ]
Get a session with the informed JID. If no session is found, return null. @param jid @return the JingleSession
[ "Get", "a", "session", "with", "the", "informed", "JID", ".", "If", "no", "session", "is", "found", "return", "null", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleManager.java#L582-L589
27,037
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/trust/OmemoFingerprint.java
OmemoFingerprint.blocksOf8Chars
public String blocksOf8Chars() { StringBuilder pretty = new StringBuilder(); for (int i = 0; i < 8; i++) { if (i != 0) pretty.append(' '); pretty.append(this.fingerprintString.substring(8 * i, 8 * (i + 1))); } return pretty.toString(); }
java
public String blocksOf8Chars() { StringBuilder pretty = new StringBuilder(); for (int i = 0; i < 8; i++) { if (i != 0) pretty.append(' '); pretty.append(this.fingerprintString.substring(8 * i, 8 * (i + 1))); } return pretty.toString(); }
[ "public", "String", "blocksOf8Chars", "(", ")", "{", "StringBuilder", "pretty", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "8", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "pretty", ".", "append", "(", "'", "'", ")", ";", "pretty", ".", "append", "(", "this", ".", "fingerprintString", ".", "substring", "(", "8", "*", "i", ",", "8", "*", "(", "i", "+", "1", ")", ")", ")", ";", "}", "return", "pretty", ".", "toString", "(", ")", ";", "}" ]
Split the fingerprint in blocks of 8 characters with spaces between. @return Block representation of the fingerprint.
[ "Split", "the", "fingerprint", "in", "blocks", "of", "8", "characters", "with", "spaces", "between", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/trust/OmemoFingerprint.java#L61-L68
27,038
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java
IoTDataManager.getInstanceFor
public static synchronized IoTDataManager getInstanceFor(XMPPConnection connection) { IoTDataManager manager = INSTANCES.get(connection); if (manager == null) { manager = new IoTDataManager(connection); INSTANCES.put(connection, manager); } return manager; }
java
public static synchronized IoTDataManager getInstanceFor(XMPPConnection connection) { IoTDataManager manager = INSTANCES.get(connection); if (manager == null) { manager = new IoTDataManager(connection); INSTANCES.put(connection, manager); } return manager; }
[ "public", "static", "synchronized", "IoTDataManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "IoTDataManager", "manager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "manager", "==", "null", ")", "{", "manager", "=", "new", "IoTDataManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "manager", ")", ";", "}", "return", "manager", ";", "}" ]
Get the manger instance responsible for the given connection. @param connection the XMPP connection. @return a manager instance.
[ "Get", "the", "manger", "instance", "responsible", "for", "the", "given", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java#L80-L87
27,039
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java
IoTDataManager.requestMomentaryValuesReadOut
public List<IoTFieldsExtension> requestMomentaryValuesReadOut(EntityFullJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { final XMPPConnection connection = connection(); final int seqNr = nextSeqNr.incrementAndGet(); IoTDataRequest iotDataRequest = new IoTDataRequest(seqNr, true); iotDataRequest.setTo(jid); StanzaFilter doneFilter = new IoTFieldsExtensionFilter(seqNr, true); StanzaFilter dataFilter = new IoTFieldsExtensionFilter(seqNr, false); // Setup the IoTFieldsExtension message collectors before sending the IQ to avoid a data race. StanzaCollector doneCollector = connection.createStanzaCollector(doneFilter); StanzaCollector.Configuration dataCollectorConfiguration = StanzaCollector.newConfiguration().setStanzaFilter( dataFilter).setCollectorToReset(doneCollector); StanzaCollector dataCollector = connection.createStanzaCollector(dataCollectorConfiguration); try { connection.createStanzaCollectorAndSend(iotDataRequest).nextResultOrThrow(); // Wait until a message with an IoTFieldsExtension and the done flag comes in. doneCollector.nextResult(); } finally { // Canceling dataCollector will also cancel the doneCollector since it is configured as dataCollector's // collector to reset. dataCollector.cancel(); } int collectedCount = dataCollector.getCollectedCount(); List<IoTFieldsExtension> res = new ArrayList<>(collectedCount); for (int i = 0; i < collectedCount; i++) { Message message = dataCollector.pollResult(); IoTFieldsExtension iotFieldsExtension = IoTFieldsExtension.from(message); res.add(iotFieldsExtension); } return res; }
java
public List<IoTFieldsExtension> requestMomentaryValuesReadOut(EntityFullJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { final XMPPConnection connection = connection(); final int seqNr = nextSeqNr.incrementAndGet(); IoTDataRequest iotDataRequest = new IoTDataRequest(seqNr, true); iotDataRequest.setTo(jid); StanzaFilter doneFilter = new IoTFieldsExtensionFilter(seqNr, true); StanzaFilter dataFilter = new IoTFieldsExtensionFilter(seqNr, false); // Setup the IoTFieldsExtension message collectors before sending the IQ to avoid a data race. StanzaCollector doneCollector = connection.createStanzaCollector(doneFilter); StanzaCollector.Configuration dataCollectorConfiguration = StanzaCollector.newConfiguration().setStanzaFilter( dataFilter).setCollectorToReset(doneCollector); StanzaCollector dataCollector = connection.createStanzaCollector(dataCollectorConfiguration); try { connection.createStanzaCollectorAndSend(iotDataRequest).nextResultOrThrow(); // Wait until a message with an IoTFieldsExtension and the done flag comes in. doneCollector.nextResult(); } finally { // Canceling dataCollector will also cancel the doneCollector since it is configured as dataCollector's // collector to reset. dataCollector.cancel(); } int collectedCount = dataCollector.getCollectedCount(); List<IoTFieldsExtension> res = new ArrayList<>(collectedCount); for (int i = 0; i < collectedCount; i++) { Message message = dataCollector.pollResult(); IoTFieldsExtension iotFieldsExtension = IoTFieldsExtension.from(message); res.add(iotFieldsExtension); } return res; }
[ "public", "List", "<", "IoTFieldsExtension", ">", "requestMomentaryValuesReadOut", "(", "EntityFullJid", "jid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "final", "XMPPConnection", "connection", "=", "connection", "(", ")", ";", "final", "int", "seqNr", "=", "nextSeqNr", ".", "incrementAndGet", "(", ")", ";", "IoTDataRequest", "iotDataRequest", "=", "new", "IoTDataRequest", "(", "seqNr", ",", "true", ")", ";", "iotDataRequest", ".", "setTo", "(", "jid", ")", ";", "StanzaFilter", "doneFilter", "=", "new", "IoTFieldsExtensionFilter", "(", "seqNr", ",", "true", ")", ";", "StanzaFilter", "dataFilter", "=", "new", "IoTFieldsExtensionFilter", "(", "seqNr", ",", "false", ")", ";", "// Setup the IoTFieldsExtension message collectors before sending the IQ to avoid a data race.", "StanzaCollector", "doneCollector", "=", "connection", ".", "createStanzaCollector", "(", "doneFilter", ")", ";", "StanzaCollector", ".", "Configuration", "dataCollectorConfiguration", "=", "StanzaCollector", ".", "newConfiguration", "(", ")", ".", "setStanzaFilter", "(", "dataFilter", ")", ".", "setCollectorToReset", "(", "doneCollector", ")", ";", "StanzaCollector", "dataCollector", "=", "connection", ".", "createStanzaCollector", "(", "dataCollectorConfiguration", ")", ";", "try", "{", "connection", ".", "createStanzaCollectorAndSend", "(", "iotDataRequest", ")", ".", "nextResultOrThrow", "(", ")", ";", "// Wait until a message with an IoTFieldsExtension and the done flag comes in.", "doneCollector", ".", "nextResult", "(", ")", ";", "}", "finally", "{", "// Canceling dataCollector will also cancel the doneCollector since it is configured as dataCollector's", "// collector to reset.", "dataCollector", ".", "cancel", "(", ")", ";", "}", "int", "collectedCount", "=", "dataCollector", ".", "getCollectedCount", "(", ")", ";", "List", "<", "IoTFieldsExtension", ">", "res", "=", "new", "ArrayList", "<>", "(", "collectedCount", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "collectedCount", ";", "i", "++", ")", "{", "Message", "message", "=", "dataCollector", ".", "pollResult", "(", ")", ";", "IoTFieldsExtension", "iotFieldsExtension", "=", "IoTFieldsExtension", ".", "from", "(", "message", ")", ";", "res", ".", "add", "(", "iotFieldsExtension", ")", ";", "}", "return", "res", ";", "}" ]
Try to read out a things momentary values. @param jid the full JID of the thing to read data from. @return a list with the read out data. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Try", "to", "read", "out", "a", "things", "momentary", "values", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/IoTDataManager.java#L172-L209
27,040
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java
BlockingCommandManager.getInstanceFor
public static synchronized BlockingCommandManager getInstanceFor(XMPPConnection connection) { BlockingCommandManager blockingCommandManager = INSTANCES.get(connection); if (blockingCommandManager == null) { blockingCommandManager = new BlockingCommandManager(connection); INSTANCES.put(connection, blockingCommandManager); } return blockingCommandManager; }
java
public static synchronized BlockingCommandManager getInstanceFor(XMPPConnection connection) { BlockingCommandManager blockingCommandManager = INSTANCES.get(connection); if (blockingCommandManager == null) { blockingCommandManager = new BlockingCommandManager(connection); INSTANCES.put(connection, blockingCommandManager); } return blockingCommandManager; }
[ "public", "static", "synchronized", "BlockingCommandManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "BlockingCommandManager", "blockingCommandManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "blockingCommandManager", "==", "null", ")", "{", "blockingCommandManager", "=", "new", "BlockingCommandManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "blockingCommandManager", ")", ";", "}", "return", "blockingCommandManager", ";", "}" ]
Get the singleton instance of BlockingCommandManager. @param connection @return the instance of BlockingCommandManager
[ "Get", "the", "singleton", "instance", "of", "BlockingCommandManager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java#L78-L87
27,041
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java
BlockingCommandManager.getBlockList
public List<Jid> getBlockList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (blockListCached == null) { BlockListIQ blockListIQ = new BlockListIQ(); BlockListIQ blockListIQResult = connection().createStanzaCollectorAndSend(blockListIQ).nextResultOrThrow(); blockListCached = blockListIQResult.getBlockedJidsCopy(); } return Collections.unmodifiableList(blockListCached); }
java
public List<Jid> getBlockList() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (blockListCached == null) { BlockListIQ blockListIQ = new BlockListIQ(); BlockListIQ blockListIQResult = connection().createStanzaCollectorAndSend(blockListIQ).nextResultOrThrow(); blockListCached = blockListIQResult.getBlockedJidsCopy(); } return Collections.unmodifiableList(blockListCached); }
[ "public", "List", "<", "Jid", ">", "getBlockList", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "if", "(", "blockListCached", "==", "null", ")", "{", "BlockListIQ", "blockListIQ", "=", "new", "BlockListIQ", "(", ")", ";", "BlockListIQ", "blockListIQResult", "=", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "blockListIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "blockListCached", "=", "blockListIQResult", ".", "getBlockedJidsCopy", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "blockListCached", ")", ";", "}" ]
Returns the block list. @return the blocking list @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "block", "list", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java#L183-L193
27,042
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java
BlockingCommandManager.blockContacts
public void blockContacts(List<Jid> jids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { BlockContactsIQ blockContactIQ = new BlockContactsIQ(jids); connection().createStanzaCollectorAndSend(blockContactIQ).nextResultOrThrow(); }
java
public void blockContacts(List<Jid> jids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { BlockContactsIQ blockContactIQ = new BlockContactsIQ(jids); connection().createStanzaCollectorAndSend(blockContactIQ).nextResultOrThrow(); }
[ "public", "void", "blockContacts", "(", "List", "<", "Jid", ">", "jids", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "BlockContactsIQ", "blockContactIQ", "=", "new", "BlockContactsIQ", "(", "jids", ")", ";", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "blockContactIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Block contacts. @param jids @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Block", "contacts", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java#L204-L208
27,043
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java
BlockingCommandManager.unblockContacts
public void unblockContacts(List<Jid> jids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(jids); connection().createStanzaCollectorAndSend(unblockContactIQ).nextResultOrThrow(); }
java
public void unblockContacts(List<Jid> jids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(jids); connection().createStanzaCollectorAndSend(unblockContactIQ).nextResultOrThrow(); }
[ "public", "void", "unblockContacts", "(", "List", "<", "Jid", ">", "jids", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "UnblockContactsIQ", "unblockContactIQ", "=", "new", "UnblockContactsIQ", "(", "jids", ")", ";", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "unblockContactIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Unblock contacts. @param jids @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Unblock", "contacts", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java#L219-L223
27,044
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java
BlockingCommandManager.unblockAll
public void unblockAll() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(); connection().createStanzaCollectorAndSend(unblockContactIQ).nextResultOrThrow(); }
java
public void unblockAll() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(); connection().createStanzaCollectorAndSend(unblockContactIQ).nextResultOrThrow(); }
[ "public", "void", "unblockAll", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "UnblockContactsIQ", "unblockContactIQ", "=", "new", "UnblockContactsIQ", "(", ")", ";", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "unblockContactIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Unblock all. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Unblock", "all", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java#L233-L237
27,045
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/commands/RemoteCommand.java
RemoteCommand.execute
public void execute(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { executeAction(Action.execute, form); }
java
public void execute(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { executeAction(Action.execute, form); }
[ "public", "void", "execute", "(", "Form", "form", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "executeAction", "(", "Action", ".", "execute", ",", "form", ")", ";", "}" ]
Executes the default action of the command with the information provided in the Form. This form must be the answer form of the previous stage. If there is a problem executing the command it throws an XMPPException. @param form the form answer of the previous stage. @throws XMPPErrorException if an error occurs. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Executes", "the", "default", "action", "of", "the", "command", "with", "the", "information", "provided", "in", "the", "Form", ".", "This", "form", "must", "be", "the", "answer", "form", "of", "the", "previous", "stage", ".", "If", "there", "is", "a", "problem", "executing", "the", "command", "it", "throws", "an", "XMPPException", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/commands/RemoteCommand.java#L103-L105
27,046
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioReceiver.java
AudioReceiver.controllerUpdate
@Override public synchronized void controllerUpdate(ControllerEvent ce) { Player p = (Player) ce.getSourceController(); if (p == null) return; // Get this when the internal players are realized. if (ce instanceof RealizeCompleteEvent) { p.start(); } if (ce instanceof ControllerErrorEvent) { p.removeControllerListener(this); LOGGER.severe("Receiver internal error: " + ce); } }
java
@Override public synchronized void controllerUpdate(ControllerEvent ce) { Player p = (Player) ce.getSourceController(); if (p == null) return; // Get this when the internal players are realized. if (ce instanceof RealizeCompleteEvent) { p.start(); } if (ce instanceof ControllerErrorEvent) { p.removeControllerListener(this); LOGGER.severe("Receiver internal error: " + ce); } }
[ "@", "Override", "public", "synchronized", "void", "controllerUpdate", "(", "ControllerEvent", "ce", ")", "{", "Player", "p", "=", "(", "Player", ")", "ce", ".", "getSourceController", "(", ")", ";", "if", "(", "p", "==", "null", ")", "return", ";", "// Get this when the internal players are realized.", "if", "(", "ce", "instanceof", "RealizeCompleteEvent", ")", "{", "p", ".", "start", "(", ")", ";", "}", "if", "(", "ce", "instanceof", "ControllerErrorEvent", ")", "{", "p", ".", "removeControllerListener", "(", "this", ")", ";", "LOGGER", ".", "severe", "(", "\"Receiver internal error: \"", "+", "ce", ")", ";", "}", "}" ]
ControllerListener for the Players.
[ "ControllerListener", "for", "the", "Players", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioReceiver.java#L152-L170
27,047
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java
HashManager.addAlgorithmsToFeatures
public void addAlgorithmsToFeatures(List<ALGORITHM> algorithms) { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); for (ALGORITHM algo : algorithms) { sdm.addFeature(asFeature(algo)); } }
java
public void addAlgorithmsToFeatures(List<ALGORITHM> algorithms) { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); for (ALGORITHM algo : algorithms) { sdm.addFeature(asFeature(algo)); } }
[ "public", "void", "addAlgorithmsToFeatures", "(", "List", "<", "ALGORITHM", ">", "algorithms", ")", "{", "ServiceDiscoveryManager", "sdm", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ";", "for", "(", "ALGORITHM", "algo", ":", "algorithms", ")", "{", "sdm", ".", "addFeature", "(", "asFeature", "(", "algo", ")", ")", ";", "}", "}" ]
Announce support for the given list of algorithms. @param algorithms
[ "Announce", "support", "for", "the", "given", "list", "of", "algorithms", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java#L113-L118
27,048
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java
HashManager.getInstanceFor
public static synchronized HashManager getInstanceFor(XMPPConnection connection) { HashManager hashManager = INSTANCES.get(connection); if (hashManager == null) { hashManager = new HashManager(connection); INSTANCES.put(connection, hashManager); } return hashManager; }
java
public static synchronized HashManager getInstanceFor(XMPPConnection connection) { HashManager hashManager = INSTANCES.get(connection); if (hashManager == null) { hashManager = new HashManager(connection); INSTANCES.put(connection, hashManager); } return hashManager; }
[ "public", "static", "synchronized", "HashManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "HashManager", "hashManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "hashManager", "==", "null", ")", "{", "hashManager", "=", "new", "HashManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "hashManager", ")", ";", "}", "return", "hashManager", ";", "}" ]
Get an instance of the HashManager for the given connection. @param connection @return the manager for the given connection.
[ "Get", "an", "instance", "of", "the", "HashManager", "for", "the", "given", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/hashes/HashManager.java#L125-L132
27,049
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java
FileTransferManager.createOutgoingFileTransfer
public OutgoingFileTransfer createOutgoingFileTransfer(EntityFullJid userID) { // We need to create outgoing file transfers with a full JID since this method will later // use XEP-0095 to negotiate the stream. This is done with IQ stanzas that need to be addressed to a full JID // in order to reach an client entity. if (userID == null) { throw new IllegalArgumentException("userID was null"); } return new OutgoingFileTransfer(connection().getUser(), userID, FileTransferNegotiator.getNextStreamID(), fileTransferNegotiator); }
java
public OutgoingFileTransfer createOutgoingFileTransfer(EntityFullJid userID) { // We need to create outgoing file transfers with a full JID since this method will later // use XEP-0095 to negotiate the stream. This is done with IQ stanzas that need to be addressed to a full JID // in order to reach an client entity. if (userID == null) { throw new IllegalArgumentException("userID was null"); } return new OutgoingFileTransfer(connection().getUser(), userID, FileTransferNegotiator.getNextStreamID(), fileTransferNegotiator); }
[ "public", "OutgoingFileTransfer", "createOutgoingFileTransfer", "(", "EntityFullJid", "userID", ")", "{", "// We need to create outgoing file transfers with a full JID since this method will later", "// use XEP-0095 to negotiate the stream. This is done with IQ stanzas that need to be addressed to a full JID", "// in order to reach an client entity.", "if", "(", "userID", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"userID was null\"", ")", ";", "}", "return", "new", "OutgoingFileTransfer", "(", "connection", "(", ")", ".", "getUser", "(", ")", ",", "userID", ",", "FileTransferNegotiator", ".", "getNextStreamID", "(", ")", ",", "fileTransferNegotiator", ")", ";", "}" ]
Creates an OutgoingFileTransfer to send a file to another user. @param userID The fully qualified jabber ID (i.e. full JID) with resource of the user to send the file to. @return The send file object on which the negotiated transfer can be run. @exception IllegalArgumentException if userID is null or not a full JID
[ "Creates", "an", "OutgoingFileTransfer", "to", "send", "a", "file", "to", "another", "user", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java#L122-L133
27,050
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java
FileTransferManager.createIncomingFileTransfer
protected IncomingFileTransfer createIncomingFileTransfer( FileTransferRequest request) { if (request == null) { throw new NullPointerException("ReceiveRequest cannot be null"); } IncomingFileTransfer transfer = new IncomingFileTransfer(request, fileTransferNegotiator); transfer.setFileInfo(request.getFileName(), request.getFileSize()); return transfer; }
java
protected IncomingFileTransfer createIncomingFileTransfer( FileTransferRequest request) { if (request == null) { throw new NullPointerException("ReceiveRequest cannot be null"); } IncomingFileTransfer transfer = new IncomingFileTransfer(request, fileTransferNegotiator); transfer.setFileInfo(request.getFileName(), request.getFileSize()); return transfer; }
[ "protected", "IncomingFileTransfer", "createIncomingFileTransfer", "(", "FileTransferRequest", "request", ")", "{", "if", "(", "request", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"ReceiveRequest cannot be null\"", ")", ";", "}", "IncomingFileTransfer", "transfer", "=", "new", "IncomingFileTransfer", "(", "request", ",", "fileTransferNegotiator", ")", ";", "transfer", ".", "setFileInfo", "(", "request", ".", "getFileName", "(", ")", ",", "request", ".", "getFileSize", "(", ")", ")", ";", "return", "transfer", ";", "}" ]
When the file transfer request is acceptable, this method should be invoked. It will create an IncomingFileTransfer which allows the transmission of the file to proceed. @param request The remote request that is being accepted. @return The IncomingFileTransfer which manages the download of the file from the transfer initiator.
[ "When", "the", "file", "transfer", "request", "is", "acceptable", "this", "method", "should", "be", "invoked", ".", "It", "will", "create", "an", "IncomingFileTransfer", "which", "allows", "the", "transmission", "of", "the", "file", "to", "proceed", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java#L145-L156
27,051
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java
Offer.accept
public void accept() throws NotConnectedException, InterruptedException { Stanza acceptPacket = new AcceptPacket(this.session.getWorkgroupJID()); connection.sendStanza(acceptPacket); // TODO: listen for a reply. accepted = true; }
java
public void accept() throws NotConnectedException, InterruptedException { Stanza acceptPacket = new AcceptPacket(this.session.getWorkgroupJID()); connection.sendStanza(acceptPacket); // TODO: listen for a reply. accepted = true; }
[ "public", "void", "accept", "(", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "Stanza", "acceptPacket", "=", "new", "AcceptPacket", "(", "this", ".", "session", ".", "getWorkgroupJID", "(", ")", ")", ";", "connection", ".", "sendStanza", "(", "acceptPacket", ")", ";", "// TODO: listen for a reply.", "accepted", "=", "true", ";", "}" ]
Accepts the offer. @throws NotConnectedException @throws InterruptedException
[ "Accepts", "the", "offer", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java#L87-L92
27,052
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java
Offer.reject
public void reject() throws NotConnectedException, InterruptedException { RejectPacket rejectPacket = new RejectPacket(this.session.getWorkgroupJID()); connection.sendStanza(rejectPacket); // TODO: listen for a reply. rejected = true; }
java
public void reject() throws NotConnectedException, InterruptedException { RejectPacket rejectPacket = new RejectPacket(this.session.getWorkgroupJID()); connection.sendStanza(rejectPacket); // TODO: listen for a reply. rejected = true; }
[ "public", "void", "reject", "(", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "RejectPacket", "rejectPacket", "=", "new", "RejectPacket", "(", "this", ".", "session", ".", "getWorkgroupJID", "(", ")", ")", ";", "connection", ".", "sendStanza", "(", "rejectPacket", ")", ";", "// TODO: listen for a reply.", "rejected", "=", "true", ";", "}" ]
Rejects the offer. @throws NotConnectedException @throws InterruptedException
[ "Rejects", "the", "offer", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Offer.java#L99-L104
27,053
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/packet/MessageEvent.java
MessageEvent.toXML
@Override public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { StringBuilder buf = new StringBuilder(); buf.append('<').append(getElementName()).append(" xmlns=\"").append(getNamespace()).append( "\">"); // Note: Cancellation events don't specify any tag. They just send the packetID // Add the offline tag if the sender requests to be notified of offline events or if // the target is offline if (isOffline()) buf.append('<').append(MessageEvent.OFFLINE).append("/>"); // Add the delivered tag if the sender requests to be notified when the message is // delivered or if the target notifies that the message has been delivered if (isDelivered()) buf.append('<').append(MessageEvent.DELIVERED).append("/>"); // Add the displayed tag if the sender requests to be notified when the message is // displayed or if the target notifies that the message has been displayed if (isDisplayed()) buf.append('<').append(MessageEvent.DISPLAYED).append("/>"); // Add the composing tag if the sender requests to be notified when the target is // composing a reply or if the target notifies that he/she is composing a reply if (isComposing()) buf.append('<').append(MessageEvent.COMPOSING).append("/>"); // Add the id tag only if the MessageEvent is a notification message (not a request) if (getStanzaId() != null) buf.append("<id>").append(getStanzaId()).append("</id>"); buf.append("</").append(getElementName()).append('>'); return buf.toString(); }
java
@Override public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { StringBuilder buf = new StringBuilder(); buf.append('<').append(getElementName()).append(" xmlns=\"").append(getNamespace()).append( "\">"); // Note: Cancellation events don't specify any tag. They just send the packetID // Add the offline tag if the sender requests to be notified of offline events or if // the target is offline if (isOffline()) buf.append('<').append(MessageEvent.OFFLINE).append("/>"); // Add the delivered tag if the sender requests to be notified when the message is // delivered or if the target notifies that the message has been delivered if (isDelivered()) buf.append('<').append(MessageEvent.DELIVERED).append("/>"); // Add the displayed tag if the sender requests to be notified when the message is // displayed or if the target notifies that the message has been displayed if (isDisplayed()) buf.append('<').append(MessageEvent.DISPLAYED).append("/>"); // Add the composing tag if the sender requests to be notified when the target is // composing a reply or if the target notifies that he/she is composing a reply if (isComposing()) buf.append('<').append(MessageEvent.COMPOSING).append("/>"); // Add the id tag only if the MessageEvent is a notification message (not a request) if (getStanzaId() != null) buf.append("<id>").append(getStanzaId()).append("</id>"); buf.append("</").append(getElementName()).append('>'); return buf.toString(); }
[ "@", "Override", "public", "String", "toXML", "(", "org", ".", "jivesoftware", ".", "smack", ".", "packet", ".", "XmlEnvironment", "enclosingNamespace", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "buf", ".", "append", "(", "'", "'", ")", ".", "append", "(", "getElementName", "(", ")", ")", ".", "append", "(", "\" xmlns=\\\"\"", ")", ".", "append", "(", "getNamespace", "(", ")", ")", ".", "append", "(", "\"\\\">\"", ")", ";", "// Note: Cancellation events don't specify any tag. They just send the packetID", "// Add the offline tag if the sender requests to be notified of offline events or if", "// the target is offline", "if", "(", "isOffline", "(", ")", ")", "buf", ".", "append", "(", "'", "'", ")", ".", "append", "(", "MessageEvent", ".", "OFFLINE", ")", ".", "append", "(", "\"/>\"", ")", ";", "// Add the delivered tag if the sender requests to be notified when the message is", "// delivered or if the target notifies that the message has been delivered", "if", "(", "isDelivered", "(", ")", ")", "buf", ".", "append", "(", "'", "'", ")", ".", "append", "(", "MessageEvent", ".", "DELIVERED", ")", ".", "append", "(", "\"/>\"", ")", ";", "// Add the displayed tag if the sender requests to be notified when the message is", "// displayed or if the target notifies that the message has been displayed", "if", "(", "isDisplayed", "(", ")", ")", "buf", ".", "append", "(", "'", "'", ")", ".", "append", "(", "MessageEvent", ".", "DISPLAYED", ")", ".", "append", "(", "\"/>\"", ")", ";", "// Add the composing tag if the sender requests to be notified when the target is", "// composing a reply or if the target notifies that he/she is composing a reply", "if", "(", "isComposing", "(", ")", ")", "buf", ".", "append", "(", "'", "'", ")", ".", "append", "(", "MessageEvent", ".", "COMPOSING", ")", ".", "append", "(", "\"/>\"", ")", ";", "// Add the id tag only if the MessageEvent is a notification message (not a request)", "if", "(", "getStanzaId", "(", ")", "!=", "null", ")", "buf", ".", "append", "(", "\"<id>\"", ")", ".", "append", "(", "getStanzaId", "(", ")", ")", ".", "append", "(", "\"</id>\"", ")", ";", "buf", ".", "append", "(", "\"</\"", ")", ".", "append", "(", "getElementName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Returns the XML representation of a Message Event according the specification. Usually the XML representation will be inside of a Message XML representation like in the following examples:<p> Request to be notified when displayed: <pre> &lt;message to='romeo@montague.net/orchard' from='juliet@capulet.com/balcony' id='message22'&gt; &lt;x xmlns='jabber:x:event'&gt; &lt;displayed/&gt; &lt;/x&gt; &lt;/message&gt; </pre> Notification of displayed: <pre> &lt;message from='romeo@montague.net/orchard' to='juliet@capulet.com/balcony'&gt; &lt;x xmlns='jabber:x:event'&gt; &lt;displayed/&gt; &lt;id&gt;message22&lt;/id&gt; &lt;/x&gt; &lt;/message&gt; </pre>
[ "Returns", "the", "XML", "representation", "of", "a", "Message", "Event", "according", "the", "specification", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/xevent/packet/MessageEvent.java#L308-L336
27,054
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java
DirectoryRosterStore.init
public static DirectoryRosterStore init(final File baseDir) { DirectoryRosterStore store = new DirectoryRosterStore(baseDir); if (store.setRosterVersion("")) { return store; } else { return null; } }
java
public static DirectoryRosterStore init(final File baseDir) { DirectoryRosterStore store = new DirectoryRosterStore(baseDir); if (store.setRosterVersion("")) { return store; } else { return null; } }
[ "public", "static", "DirectoryRosterStore", "init", "(", "final", "File", "baseDir", ")", "{", "DirectoryRosterStore", "store", "=", "new", "DirectoryRosterStore", "(", "baseDir", ")", ";", "if", "(", "store", ".", "setRosterVersion", "(", "\"\"", ")", ")", "{", "return", "store", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Creates a new roster store on disk. @param baseDir The directory to create the store in. The directory should be empty @return A {@link DirectoryRosterStore} instance if successful, <code>null</code> else.
[ "Creates", "a", "new", "roster", "store", "on", "disk", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java#L89-L97
27,055
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java
DirectoryRosterStore.open
public static DirectoryRosterStore open(final File baseDir) { DirectoryRosterStore store = new DirectoryRosterStore(baseDir); String s = FileUtils.readFile(store.getVersionFile()); if (s != null && s.startsWith(STORE_ID + "\n")) { return store; } else { return null; } }
java
public static DirectoryRosterStore open(final File baseDir) { DirectoryRosterStore store = new DirectoryRosterStore(baseDir); String s = FileUtils.readFile(store.getVersionFile()); if (s != null && s.startsWith(STORE_ID + "\n")) { return store; } else { return null; } }
[ "public", "static", "DirectoryRosterStore", "open", "(", "final", "File", "baseDir", ")", "{", "DirectoryRosterStore", "store", "=", "new", "DirectoryRosterStore", "(", "baseDir", ")", ";", "String", "s", "=", "FileUtils", ".", "readFile", "(", "store", ".", "getVersionFile", "(", ")", ")", ";", "if", "(", "s", "!=", "null", "&&", "s", ".", "startsWith", "(", "STORE_ID", "+", "\"\\n\"", ")", ")", "{", "return", "store", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Opens a roster store. @param baseDir The directory containing the roster store. @return A {@link DirectoryRosterStore} instance if successful, <code>null</code> else.
[ "Opens", "a", "roster", "store", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java#L106-L115
27,056
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBHash.java
BoBHash.fromSrc
public static BoBHash fromSrc(String src) { String hashType = src.substring(src.lastIndexOf("cid:") + 4, src.indexOf("+")); String hash = src.substring(src.indexOf("+") + 1, src.indexOf("@bob.xmpp.org")); return new BoBHash(hash, hashType); }
java
public static BoBHash fromSrc(String src) { String hashType = src.substring(src.lastIndexOf("cid:") + 4, src.indexOf("+")); String hash = src.substring(src.indexOf("+") + 1, src.indexOf("@bob.xmpp.org")); return new BoBHash(hash, hashType); }
[ "public", "static", "BoBHash", "fromSrc", "(", "String", "src", ")", "{", "String", "hashType", "=", "src", ".", "substring", "(", "src", ".", "lastIndexOf", "(", "\"cid:\"", ")", "+", "4", ",", "src", ".", "indexOf", "(", "\"+\"", ")", ")", ";", "String", "hash", "=", "src", ".", "substring", "(", "src", ".", "indexOf", "(", "\"+\"", ")", "+", "1", ",", "src", ".", "indexOf", "(", "\"@bob.xmpp.org\"", ")", ")", ";", "return", "new", "BoBHash", "(", "hash", ",", "hashType", ")", ";", "}" ]
Get BoB hash from src attribute string. @param src @return the BoB hash
[ "Get", "BoB", "hash", "from", "src", "attribute", "string", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBHash.java#L103-L107
27,057
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBHash.java
BoBHash.fromCid
public static BoBHash fromCid(String cid) { String hashType = cid.substring(0, cid.indexOf("+")); String hash = cid.substring(cid.indexOf("+") + 1, cid.indexOf("@bob.xmpp.org")); return new BoBHash(hash, hashType); }
java
public static BoBHash fromCid(String cid) { String hashType = cid.substring(0, cid.indexOf("+")); String hash = cid.substring(cid.indexOf("+") + 1, cid.indexOf("@bob.xmpp.org")); return new BoBHash(hash, hashType); }
[ "public", "static", "BoBHash", "fromCid", "(", "String", "cid", ")", "{", "String", "hashType", "=", "cid", ".", "substring", "(", "0", ",", "cid", ".", "indexOf", "(", "\"+\"", ")", ")", ";", "String", "hash", "=", "cid", ".", "substring", "(", "cid", ".", "indexOf", "(", "\"+\"", ")", "+", "1", ",", "cid", ".", "indexOf", "(", "\"@bob.xmpp.org\"", ")", ")", ";", "return", "new", "BoBHash", "(", "hash", ",", "hashType", ")", ";", "}" ]
Get BoB hash from cid attribute string. @param cid @return the BoB hash
[ "Get", "BoB", "hash", "from", "cid", "attribute", "string", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBHash.java#L115-L119
27,058
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/RosterUtil.java
RosterUtil.preApproveSubscriptionIfRequiredAndPossible
public static void preApproveSubscriptionIfRequiredAndPossible(Roster roster, BareJid jid) throws NotLoggedInException, NotConnectedException, InterruptedException { if (!roster.isSubscriptionPreApprovalSupported()) { return; } RosterEntry entry = roster.getEntry(jid); if (entry == null || (!entry.canSeeMyPresence() && !entry.isApproved())) { try { roster.preApprove(jid); } catch (FeatureNotSupportedException e) { // Should never happen since we checked for the feature above. throw new AssertionError(e); } } }
java
public static void preApproveSubscriptionIfRequiredAndPossible(Roster roster, BareJid jid) throws NotLoggedInException, NotConnectedException, InterruptedException { if (!roster.isSubscriptionPreApprovalSupported()) { return; } RosterEntry entry = roster.getEntry(jid); if (entry == null || (!entry.canSeeMyPresence() && !entry.isApproved())) { try { roster.preApprove(jid); } catch (FeatureNotSupportedException e) { // Should never happen since we checked for the feature above. throw new AssertionError(e); } } }
[ "public", "static", "void", "preApproveSubscriptionIfRequiredAndPossible", "(", "Roster", "roster", ",", "BareJid", "jid", ")", "throws", "NotLoggedInException", ",", "NotConnectedException", ",", "InterruptedException", "{", "if", "(", "!", "roster", ".", "isSubscriptionPreApprovalSupported", "(", ")", ")", "{", "return", ";", "}", "RosterEntry", "entry", "=", "roster", ".", "getEntry", "(", "jid", ")", ";", "if", "(", "entry", "==", "null", "||", "(", "!", "entry", ".", "canSeeMyPresence", "(", ")", "&&", "!", "entry", ".", "isApproved", "(", ")", ")", ")", "{", "try", "{", "roster", ".", "preApprove", "(", "jid", ")", ";", "}", "catch", "(", "FeatureNotSupportedException", "e", ")", "{", "// Should never happen since we checked for the feature above.", "throw", "new", "AssertionError", "(", "e", ")", ";", "}", "}", "}" ]
Pre-approve the subscription if it is required and possible. @param roster The roster which should be used for the pre-approval. @param jid The XMPP address which should be pre-approved. @throws NotLoggedInException @throws NotConnectedException @throws InterruptedException @since 4.2.2
[ "Pre", "-", "approve", "the", "subscription", "if", "it", "is", "required", "and", "possible", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterUtil.java#L100-L115
27,059
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedTransportManager.java
BridgedTransportManager.createResolver
@Override protected TransportResolver createResolver(JingleSession session) { BridgedResolver bridgedResolver = new BridgedResolver(this.xmppConnection); return bridgedResolver; }
java
@Override protected TransportResolver createResolver(JingleSession session) { BridgedResolver bridgedResolver = new BridgedResolver(this.xmppConnection); return bridgedResolver; }
[ "@", "Override", "protected", "TransportResolver", "createResolver", "(", "JingleSession", "session", ")", "{", "BridgedResolver", "bridgedResolver", "=", "new", "BridgedResolver", "(", "this", ".", "xmppConnection", ")", ";", "return", "bridgedResolver", ";", "}" ]
Return the correspondent resolver @param session correspondent Jingle Session @return resolver
[ "Return", "the", "correspondent", "resolver" ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedTransportManager.java#L50-L54
27,060
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/DNSUtil.java
DNSUtil.sortSRVRecords
private static List<HostAddress> sortSRVRecords(List<SRVRecord> records) { // RFC 2782, Usage rules: "If there is precisely one SRV RR, and its Target is "." // (the root domain), abort." if (records.size() == 1 && records.get(0).getFQDN().isRootLabel()) return Collections.emptyList(); // sorting the records improves the performance of the bisection later Collections.sort(records); // create the priority buckets SortedMap<Integer, List<SRVRecord>> buckets = new TreeMap<Integer, List<SRVRecord>>(); for (SRVRecord r : records) { Integer priority = r.getPriority(); List<SRVRecord> bucket = buckets.get(priority); // create the list of SRVRecords if it doesn't exist if (bucket == null) { bucket = new LinkedList<SRVRecord>(); buckets.put(priority, bucket); } bucket.add(r); } List<HostAddress> res = new ArrayList<HostAddress>(records.size()); for (Integer priority : buckets.keySet()) { List<SRVRecord> bucket = buckets.get(priority); int bucketSize; while ((bucketSize = bucket.size()) > 0) { int[] totals = new int[bucketSize]; int running_total = 0; int count = 0; int zeroWeight = 1; for (SRVRecord r : bucket) { if (r.getWeight() > 0) { zeroWeight = 0; break; } } for (SRVRecord r : bucket) { running_total += (r.getWeight() + zeroWeight); totals[count] = running_total; count++; } int selectedPos; if (running_total == 0) { // If running total is 0, then all weights in this priority // group are 0. So we simply select one of the weights randomly // as the other 'normal' algorithm is unable to handle this case selectedPos = (int) (Math.random() * bucketSize); } else { double rnd = Math.random() * running_total; selectedPos = bisect(totals, rnd); } // add the SRVRecord that was randomly chosen on it's weight // to the start of the result list SRVRecord chosenSRVRecord = bucket.remove(selectedPos); res.add(chosenSRVRecord); } } return res; }
java
private static List<HostAddress> sortSRVRecords(List<SRVRecord> records) { // RFC 2782, Usage rules: "If there is precisely one SRV RR, and its Target is "." // (the root domain), abort." if (records.size() == 1 && records.get(0).getFQDN().isRootLabel()) return Collections.emptyList(); // sorting the records improves the performance of the bisection later Collections.sort(records); // create the priority buckets SortedMap<Integer, List<SRVRecord>> buckets = new TreeMap<Integer, List<SRVRecord>>(); for (SRVRecord r : records) { Integer priority = r.getPriority(); List<SRVRecord> bucket = buckets.get(priority); // create the list of SRVRecords if it doesn't exist if (bucket == null) { bucket = new LinkedList<SRVRecord>(); buckets.put(priority, bucket); } bucket.add(r); } List<HostAddress> res = new ArrayList<HostAddress>(records.size()); for (Integer priority : buckets.keySet()) { List<SRVRecord> bucket = buckets.get(priority); int bucketSize; while ((bucketSize = bucket.size()) > 0) { int[] totals = new int[bucketSize]; int running_total = 0; int count = 0; int zeroWeight = 1; for (SRVRecord r : bucket) { if (r.getWeight() > 0) { zeroWeight = 0; break; } } for (SRVRecord r : bucket) { running_total += (r.getWeight() + zeroWeight); totals[count] = running_total; count++; } int selectedPos; if (running_total == 0) { // If running total is 0, then all weights in this priority // group are 0. So we simply select one of the weights randomly // as the other 'normal' algorithm is unable to handle this case selectedPos = (int) (Math.random() * bucketSize); } else { double rnd = Math.random() * running_total; selectedPos = bisect(totals, rnd); } // add the SRVRecord that was randomly chosen on it's weight // to the start of the result list SRVRecord chosenSRVRecord = bucket.remove(selectedPos); res.add(chosenSRVRecord); } } return res; }
[ "private", "static", "List", "<", "HostAddress", ">", "sortSRVRecords", "(", "List", "<", "SRVRecord", ">", "records", ")", "{", "// RFC 2782, Usage rules: \"If there is precisely one SRV RR, and its Target is \".\"", "// (the root domain), abort.\"", "if", "(", "records", ".", "size", "(", ")", "==", "1", "&&", "records", ".", "get", "(", "0", ")", ".", "getFQDN", "(", ")", ".", "isRootLabel", "(", ")", ")", "return", "Collections", ".", "emptyList", "(", ")", ";", "// sorting the records improves the performance of the bisection later", "Collections", ".", "sort", "(", "records", ")", ";", "// create the priority buckets", "SortedMap", "<", "Integer", ",", "List", "<", "SRVRecord", ">", ">", "buckets", "=", "new", "TreeMap", "<", "Integer", ",", "List", "<", "SRVRecord", ">", ">", "(", ")", ";", "for", "(", "SRVRecord", "r", ":", "records", ")", "{", "Integer", "priority", "=", "r", ".", "getPriority", "(", ")", ";", "List", "<", "SRVRecord", ">", "bucket", "=", "buckets", ".", "get", "(", "priority", ")", ";", "// create the list of SRVRecords if it doesn't exist", "if", "(", "bucket", "==", "null", ")", "{", "bucket", "=", "new", "LinkedList", "<", "SRVRecord", ">", "(", ")", ";", "buckets", ".", "put", "(", "priority", ",", "bucket", ")", ";", "}", "bucket", ".", "add", "(", "r", ")", ";", "}", "List", "<", "HostAddress", ">", "res", "=", "new", "ArrayList", "<", "HostAddress", ">", "(", "records", ".", "size", "(", ")", ")", ";", "for", "(", "Integer", "priority", ":", "buckets", ".", "keySet", "(", ")", ")", "{", "List", "<", "SRVRecord", ">", "bucket", "=", "buckets", ".", "get", "(", "priority", ")", ";", "int", "bucketSize", ";", "while", "(", "(", "bucketSize", "=", "bucket", ".", "size", "(", ")", ")", ">", "0", ")", "{", "int", "[", "]", "totals", "=", "new", "int", "[", "bucketSize", "]", ";", "int", "running_total", "=", "0", ";", "int", "count", "=", "0", ";", "int", "zeroWeight", "=", "1", ";", "for", "(", "SRVRecord", "r", ":", "bucket", ")", "{", "if", "(", "r", ".", "getWeight", "(", ")", ">", "0", ")", "{", "zeroWeight", "=", "0", ";", "break", ";", "}", "}", "for", "(", "SRVRecord", "r", ":", "bucket", ")", "{", "running_total", "+=", "(", "r", ".", "getWeight", "(", ")", "+", "zeroWeight", ")", ";", "totals", "[", "count", "]", "=", "running_total", ";", "count", "++", ";", "}", "int", "selectedPos", ";", "if", "(", "running_total", "==", "0", ")", "{", "// If running total is 0, then all weights in this priority", "// group are 0. So we simply select one of the weights randomly", "// as the other 'normal' algorithm is unable to handle this case", "selectedPos", "=", "(", "int", ")", "(", "Math", ".", "random", "(", ")", "*", "bucketSize", ")", ";", "}", "else", "{", "double", "rnd", "=", "Math", ".", "random", "(", ")", "*", "running_total", ";", "selectedPos", "=", "bisect", "(", "totals", ",", "rnd", ")", ";", "}", "// add the SRVRecord that was randomly chosen on it's weight", "// to the start of the result list", "SRVRecord", "chosenSRVRecord", "=", "bucket", ".", "remove", "(", "selectedPos", ")", ";", "res", ".", "add", "(", "chosenSRVRecord", ")", ";", "}", "}", "return", "res", ";", "}" ]
Sort a given list of SRVRecords as described in RFC 2782 Note that we follow the RFC with one exception. In a group of the same priority, only the first entry is calculated by random. The others are ore simply ordered by their priority. @param records @return the list of resolved HostAddresses
[ "Sort", "a", "given", "list", "of", "SRVRecords", "as", "described", "in", "RFC", "2782", "Note", "that", "we", "follow", "the", "RFC", "with", "one", "exception", ".", "In", "a", "group", "of", "the", "same", "priority", "only", "the", "first", "entry", "is", "calculated", "by", "random", ".", "The", "others", "are", "ore", "simply", "ordered", "by", "their", "priority", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/DNSUtil.java#L195-L258
27,061
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/FileUtils.java
FileUtils.getClassLoaders
public static List<ClassLoader> getClassLoaders() { ClassLoader[] classLoaders = new ClassLoader[2]; classLoaders[0] = FileUtils.class.getClassLoader(); classLoaders[1] = Thread.currentThread().getContextClassLoader(); // Clean up possible null values. Note that #getClassLoader may return a null value. List<ClassLoader> loaders = new ArrayList<ClassLoader>(classLoaders.length); for (ClassLoader classLoader : classLoaders) { if (classLoader != null) { loaders.add(classLoader); } } return loaders; }
java
public static List<ClassLoader> getClassLoaders() { ClassLoader[] classLoaders = new ClassLoader[2]; classLoaders[0] = FileUtils.class.getClassLoader(); classLoaders[1] = Thread.currentThread().getContextClassLoader(); // Clean up possible null values. Note that #getClassLoader may return a null value. List<ClassLoader> loaders = new ArrayList<ClassLoader>(classLoaders.length); for (ClassLoader classLoader : classLoaders) { if (classLoader != null) { loaders.add(classLoader); } } return loaders; }
[ "public", "static", "List", "<", "ClassLoader", ">", "getClassLoaders", "(", ")", "{", "ClassLoader", "[", "]", "classLoaders", "=", "new", "ClassLoader", "[", "2", "]", ";", "classLoaders", "[", "0", "]", "=", "FileUtils", ".", "class", ".", "getClassLoader", "(", ")", ";", "classLoaders", "[", "1", "]", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "// Clean up possible null values. Note that #getClassLoader may return a null value.", "List", "<", "ClassLoader", ">", "loaders", "=", "new", "ArrayList", "<", "ClassLoader", ">", "(", "classLoaders", ".", "length", ")", ";", "for", "(", "ClassLoader", "classLoader", ":", "classLoaders", ")", "{", "if", "(", "classLoader", "!=", "null", ")", "{", "loaders", ".", "add", "(", "classLoader", ")", ";", "}", "}", "return", "loaders", ";", "}" ]
Returns default classloaders. @return a List of ClassLoader instances.
[ "Returns", "default", "classloaders", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/FileUtils.java#L75-L88
27,062
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/FileUtils.java
FileUtils.readFileOrThrow
@SuppressWarnings("DefaultCharset") public static String readFileOrThrow(File file) throws IOException { try (Reader reader = new FileReader(file)) { char[] buf = new char[8192]; int len; StringBuilder s = new StringBuilder(); while ((len = reader.read(buf)) >= 0) { s.append(buf, 0, len); } return s.toString(); } }
java
@SuppressWarnings("DefaultCharset") public static String readFileOrThrow(File file) throws IOException { try (Reader reader = new FileReader(file)) { char[] buf = new char[8192]; int len; StringBuilder s = new StringBuilder(); while ((len = reader.read(buf)) >= 0) { s.append(buf, 0, len); } return s.toString(); } }
[ "@", "SuppressWarnings", "(", "\"DefaultCharset\"", ")", "public", "static", "String", "readFileOrThrow", "(", "File", "file", ")", "throws", "IOException", "{", "try", "(", "Reader", "reader", "=", "new", "FileReader", "(", "file", ")", ")", "{", "char", "[", "]", "buf", "=", "new", "char", "[", "8192", "]", ";", "int", "len", ";", "StringBuilder", "s", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "(", "len", "=", "reader", ".", "read", "(", "buf", ")", ")", ">=", "0", ")", "{", "s", ".", "append", "(", "buf", ",", "0", ",", "len", ")", ";", "}", "return", "s", ".", "toString", "(", ")", ";", "}", "}" ]
Reads the contents of a File. @param file @return the content of file or null in case of an error @throws IOException
[ "Reads", "the", "contents", "of", "a", "File", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/FileUtils.java#L114-L125
27,063
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java
OfferRequestProvider.parse
@Override public OfferRequestPacket parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { int eventType = parser.getEventType(); String sessionID = null; int timeout = -1; OfferContent content = null; boolean done = false; Map<String, List<String>> metaData = new HashMap<>(); if (eventType != XmlPullParser.START_TAG) { // throw exception } Jid userJID = ParserUtils.getJidAttribute(parser); // Default userID to the JID. Jid userID = userJID; while (!done) { eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { String elemName = parser.getName(); if ("timeout".equals(elemName)) { timeout = Integer.parseInt(parser.nextText()); } else if (MetaData.ELEMENT_NAME.equals(elemName)) { metaData = MetaDataUtils.parseMetaData(parser); } else if (SessionID.ELEMENT_NAME.equals(elemName)) { sessionID = parser.getAttributeValue("", "id"); } else if (UserID.ELEMENT_NAME.equals(elemName)) { userID = ParserUtils.getJidAttribute(parser, "id"); } else if ("user-request".equals(elemName)) { content = UserRequest.getInstance(); } else if (RoomInvitation.ELEMENT_NAME.equals(elemName)) { RoomInvitation invitation = (RoomInvitation) PacketParserUtils .parseExtensionElement(RoomInvitation.ELEMENT_NAME, RoomInvitation.NAMESPACE, parser, xmlEnvironment); content = new InvitationRequest(invitation.getInviter(), invitation.getRoom(), invitation.getReason()); } else if (RoomTransfer.ELEMENT_NAME.equals(elemName)) { RoomTransfer transfer = (RoomTransfer) PacketParserUtils .parseExtensionElement(RoomTransfer.ELEMENT_NAME, RoomTransfer.NAMESPACE, parser, xmlEnvironment); content = new TransferRequest(transfer.getInviter(), transfer.getRoom(), transfer.getReason()); } } else if (eventType == XmlPullParser.END_TAG) { if ("offer".equals(parser.getName())) { done = true; } } } OfferRequestPacket offerRequest = new OfferRequestPacket(userJID, userID, timeout, metaData, sessionID, content); offerRequest.setType(IQ.Type.set); return offerRequest; }
java
@Override public OfferRequestPacket parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { int eventType = parser.getEventType(); String sessionID = null; int timeout = -1; OfferContent content = null; boolean done = false; Map<String, List<String>> metaData = new HashMap<>(); if (eventType != XmlPullParser.START_TAG) { // throw exception } Jid userJID = ParserUtils.getJidAttribute(parser); // Default userID to the JID. Jid userID = userJID; while (!done) { eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { String elemName = parser.getName(); if ("timeout".equals(elemName)) { timeout = Integer.parseInt(parser.nextText()); } else if (MetaData.ELEMENT_NAME.equals(elemName)) { metaData = MetaDataUtils.parseMetaData(parser); } else if (SessionID.ELEMENT_NAME.equals(elemName)) { sessionID = parser.getAttributeValue("", "id"); } else if (UserID.ELEMENT_NAME.equals(elemName)) { userID = ParserUtils.getJidAttribute(parser, "id"); } else if ("user-request".equals(elemName)) { content = UserRequest.getInstance(); } else if (RoomInvitation.ELEMENT_NAME.equals(elemName)) { RoomInvitation invitation = (RoomInvitation) PacketParserUtils .parseExtensionElement(RoomInvitation.ELEMENT_NAME, RoomInvitation.NAMESPACE, parser, xmlEnvironment); content = new InvitationRequest(invitation.getInviter(), invitation.getRoom(), invitation.getReason()); } else if (RoomTransfer.ELEMENT_NAME.equals(elemName)) { RoomTransfer transfer = (RoomTransfer) PacketParserUtils .parseExtensionElement(RoomTransfer.ELEMENT_NAME, RoomTransfer.NAMESPACE, parser, xmlEnvironment); content = new TransferRequest(transfer.getInviter(), transfer.getRoom(), transfer.getReason()); } } else if (eventType == XmlPullParser.END_TAG) { if ("offer".equals(parser.getName())) { done = true; } } } OfferRequestPacket offerRequest = new OfferRequestPacket(userJID, userID, timeout, metaData, sessionID, content); offerRequest.setType(IQ.Type.set); return offerRequest; }
[ "@", "Override", "public", "OfferRequestPacket", "parse", "(", "XmlPullParser", "parser", ",", "int", "initialDepth", ",", "XmlEnvironment", "xmlEnvironment", ")", "throws", "XmlPullParserException", ",", "IOException", ",", "SmackParsingException", "{", "int", "eventType", "=", "parser", ".", "getEventType", "(", ")", ";", "String", "sessionID", "=", "null", ";", "int", "timeout", "=", "-", "1", ";", "OfferContent", "content", "=", "null", ";", "boolean", "done", "=", "false", ";", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "metaData", "=", "new", "HashMap", "<>", "(", ")", ";", "if", "(", "eventType", "!=", "XmlPullParser", ".", "START_TAG", ")", "{", "// throw exception", "}", "Jid", "userJID", "=", "ParserUtils", ".", "getJidAttribute", "(", "parser", ")", ";", "// Default userID to the JID.", "Jid", "userID", "=", "userJID", ";", "while", "(", "!", "done", ")", "{", "eventType", "=", "parser", ".", "next", "(", ")", ";", "if", "(", "eventType", "==", "XmlPullParser", ".", "START_TAG", ")", "{", "String", "elemName", "=", "parser", ".", "getName", "(", ")", ";", "if", "(", "\"timeout\"", ".", "equals", "(", "elemName", ")", ")", "{", "timeout", "=", "Integer", ".", "parseInt", "(", "parser", ".", "nextText", "(", ")", ")", ";", "}", "else", "if", "(", "MetaData", ".", "ELEMENT_NAME", ".", "equals", "(", "elemName", ")", ")", "{", "metaData", "=", "MetaDataUtils", ".", "parseMetaData", "(", "parser", ")", ";", "}", "else", "if", "(", "SessionID", ".", "ELEMENT_NAME", ".", "equals", "(", "elemName", ")", ")", "{", "sessionID", "=", "parser", ".", "getAttributeValue", "(", "\"\"", ",", "\"id\"", ")", ";", "}", "else", "if", "(", "UserID", ".", "ELEMENT_NAME", ".", "equals", "(", "elemName", ")", ")", "{", "userID", "=", "ParserUtils", ".", "getJidAttribute", "(", "parser", ",", "\"id\"", ")", ";", "}", "else", "if", "(", "\"user-request\"", ".", "equals", "(", "elemName", ")", ")", "{", "content", "=", "UserRequest", ".", "getInstance", "(", ")", ";", "}", "else", "if", "(", "RoomInvitation", ".", "ELEMENT_NAME", ".", "equals", "(", "elemName", ")", ")", "{", "RoomInvitation", "invitation", "=", "(", "RoomInvitation", ")", "PacketParserUtils", ".", "parseExtensionElement", "(", "RoomInvitation", ".", "ELEMENT_NAME", ",", "RoomInvitation", ".", "NAMESPACE", ",", "parser", ",", "xmlEnvironment", ")", ";", "content", "=", "new", "InvitationRequest", "(", "invitation", ".", "getInviter", "(", ")", ",", "invitation", ".", "getRoom", "(", ")", ",", "invitation", ".", "getReason", "(", ")", ")", ";", "}", "else", "if", "(", "RoomTransfer", ".", "ELEMENT_NAME", ".", "equals", "(", "elemName", ")", ")", "{", "RoomTransfer", "transfer", "=", "(", "RoomTransfer", ")", "PacketParserUtils", ".", "parseExtensionElement", "(", "RoomTransfer", ".", "ELEMENT_NAME", ",", "RoomTransfer", ".", "NAMESPACE", ",", "parser", ",", "xmlEnvironment", ")", ";", "content", "=", "new", "TransferRequest", "(", "transfer", ".", "getInviter", "(", ")", ",", "transfer", ".", "getRoom", "(", ")", ",", "transfer", ".", "getReason", "(", ")", ")", ";", "}", "}", "else", "if", "(", "eventType", "==", "XmlPullParser", ".", "END_TAG", ")", "{", "if", "(", "\"offer\"", ".", "equals", "(", "parser", ".", "getName", "(", ")", ")", ")", "{", "done", "=", "true", ";", "}", "}", "}", "OfferRequestPacket", "offerRequest", "=", "new", "OfferRequestPacket", "(", "userJID", ",", "userID", ",", "timeout", ",", "metaData", ",", "sessionID", ",", "content", ")", ";", "offerRequest", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "return", "offerRequest", ";", "}" ]
happen anytime soon.
[ "happen", "anytime", "soon", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java#L54-L116
27,064
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java
ReconnectionManager.getInstanceFor
public static synchronized ReconnectionManager getInstanceFor(AbstractXMPPConnection connection) { ReconnectionManager reconnectionManager = INSTANCES.get(connection); if (reconnectionManager == null) { reconnectionManager = new ReconnectionManager(connection); INSTANCES.put(connection, reconnectionManager); } return reconnectionManager; }
java
public static synchronized ReconnectionManager getInstanceFor(AbstractXMPPConnection connection) { ReconnectionManager reconnectionManager = INSTANCES.get(connection); if (reconnectionManager == null) { reconnectionManager = new ReconnectionManager(connection); INSTANCES.put(connection, reconnectionManager); } return reconnectionManager; }
[ "public", "static", "synchronized", "ReconnectionManager", "getInstanceFor", "(", "AbstractXMPPConnection", "connection", ")", "{", "ReconnectionManager", "reconnectionManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "reconnectionManager", "==", "null", ")", "{", "reconnectionManager", "=", "new", "ReconnectionManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "reconnectionManager", ")", ";", "}", "return", "reconnectionManager", ";", "}" ]
Get a instance of ReconnectionManager for the given connection. @param connection @return a ReconnectionManager for the connection.
[ "Get", "a", "instance", "of", "ReconnectionManager", "for", "the", "given", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java#L67-L74
27,065
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java
ReconnectionManager.enableAutomaticReconnection
public synchronized void enableAutomaticReconnection() { if (automaticReconnectEnabled) { return; } XMPPConnection connection = weakRefConnection.get(); if (connection == null) { throw new IllegalStateException("Connection instance no longer available"); } connection.addConnectionListener(connectionListener); automaticReconnectEnabled = true; }
java
public synchronized void enableAutomaticReconnection() { if (automaticReconnectEnabled) { return; } XMPPConnection connection = weakRefConnection.get(); if (connection == null) { throw new IllegalStateException("Connection instance no longer available"); } connection.addConnectionListener(connectionListener); automaticReconnectEnabled = true; }
[ "public", "synchronized", "void", "enableAutomaticReconnection", "(", ")", "{", "if", "(", "automaticReconnectEnabled", ")", "{", "return", ";", "}", "XMPPConnection", "connection", "=", "weakRefConnection", ".", "get", "(", ")", ";", "if", "(", "connection", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Connection instance no longer available\"", ")", ";", "}", "connection", ".", "addConnectionListener", "(", "connectionListener", ")", ";", "automaticReconnectEnabled", "=", "true", ";", "}" ]
Enable the automatic reconnection mechanism. Does nothing if already enabled.
[ "Enable", "the", "automatic", "reconnection", "mechanism", ".", "Does", "nothing", "if", "already", "enabled", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java#L323-L333
27,066
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java
ReconnectionManager.disableAutomaticReconnection
public synchronized void disableAutomaticReconnection() { if (!automaticReconnectEnabled) { return; } XMPPConnection connection = weakRefConnection.get(); if (connection == null) { throw new IllegalStateException("Connection instance no longer available"); } connection.removeConnectionListener(connectionListener); automaticReconnectEnabled = false; }
java
public synchronized void disableAutomaticReconnection() { if (!automaticReconnectEnabled) { return; } XMPPConnection connection = weakRefConnection.get(); if (connection == null) { throw new IllegalStateException("Connection instance no longer available"); } connection.removeConnectionListener(connectionListener); automaticReconnectEnabled = false; }
[ "public", "synchronized", "void", "disableAutomaticReconnection", "(", ")", "{", "if", "(", "!", "automaticReconnectEnabled", ")", "{", "return", ";", "}", "XMPPConnection", "connection", "=", "weakRefConnection", ".", "get", "(", ")", ";", "if", "(", "connection", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Connection instance no longer available\"", ")", ";", "}", "connection", ".", "removeConnectionListener", "(", "connectionListener", ")", ";", "automaticReconnectEnabled", "=", "false", ";", "}" ]
Disable the automatic reconnection mechanism. Does nothing if already disabled.
[ "Disable", "the", "automatic", "reconnection", "mechanism", ".", "Does", "nothing", "if", "already", "disabled", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java#L338-L348
27,067
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java
ReconnectionManager.reconnect
private synchronized void reconnect() { XMPPConnection connection = this.weakRefConnection.get(); if (connection == null) { LOGGER.fine("Connection is null, will not reconnect"); return; } // Since there is no thread running, creates a new one to attempt // the reconnection. // avoid to run duplicated reconnectionThread -- fd: 16/09/2010 if (reconnectionThread != null && reconnectionThread.isAlive()) return; reconnectionThread = Async.go(reconnectionRunnable, "Smack Reconnection Manager (" + connection.getConnectionCounter() + ')'); }
java
private synchronized void reconnect() { XMPPConnection connection = this.weakRefConnection.get(); if (connection == null) { LOGGER.fine("Connection is null, will not reconnect"); return; } // Since there is no thread running, creates a new one to attempt // the reconnection. // avoid to run duplicated reconnectionThread -- fd: 16/09/2010 if (reconnectionThread != null && reconnectionThread.isAlive()) return; reconnectionThread = Async.go(reconnectionRunnable, "Smack Reconnection Manager (" + connection.getConnectionCounter() + ')'); }
[ "private", "synchronized", "void", "reconnect", "(", ")", "{", "XMPPConnection", "connection", "=", "this", ".", "weakRefConnection", ".", "get", "(", ")", ";", "if", "(", "connection", "==", "null", ")", "{", "LOGGER", ".", "fine", "(", "\"Connection is null, will not reconnect\"", ")", ";", "return", ";", "}", "// Since there is no thread running, creates a new one to attempt", "// the reconnection.", "// avoid to run duplicated reconnectionThread -- fd: 16/09/2010", "if", "(", "reconnectionThread", "!=", "null", "&&", "reconnectionThread", ".", "isAlive", "(", ")", ")", "return", ";", "reconnectionThread", "=", "Async", ".", "go", "(", "reconnectionRunnable", ",", "\"Smack Reconnection Manager (\"", "+", "connection", ".", "getConnectionCounter", "(", ")", "+", "'", "'", ")", ";", "}" ]
Starts a reconnection mechanism if it was configured to do that. The algorithm is been executed when the first connection error is detected.
[ "Starts", "a", "reconnection", "mechanism", "if", "it", "was", "configured", "to", "do", "that", ".", "The", "algorithm", "is", "been", "executed", "when", "the", "first", "connection", "error", "is", "detected", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/ReconnectionManager.java#L374-L388
27,068
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java
MultiMap.remove
public List<V> remove(K key, int num) { List<V> values = map.get(key); if (values == null) { return Collections.emptyList(); } final int resultSize = values.size() > num ? num : values.size(); final List<V> result = new ArrayList<>(resultSize); for (int i = 0; i < resultSize; i++) { result.add(values.get(0)); } if (values.isEmpty()) { map.remove(key); } return result; }
java
public List<V> remove(K key, int num) { List<V> values = map.get(key); if (values == null) { return Collections.emptyList(); } final int resultSize = values.size() > num ? num : values.size(); final List<V> result = new ArrayList<>(resultSize); for (int i = 0; i < resultSize; i++) { result.add(values.get(0)); } if (values.isEmpty()) { map.remove(key); } return result; }
[ "public", "List", "<", "V", ">", "remove", "(", "K", "key", ",", "int", "num", ")", "{", "List", "<", "V", ">", "values", "=", "map", ".", "get", "(", "key", ")", ";", "if", "(", "values", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "final", "int", "resultSize", "=", "values", ".", "size", "(", ")", ">", "num", "?", "num", ":", "values", ".", "size", "(", ")", ";", "final", "List", "<", "V", ">", "result", "=", "new", "ArrayList", "<>", "(", "resultSize", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "resultSize", ";", "i", "++", ")", "{", "result", ".", "add", "(", "values", ".", "get", "(", "0", ")", ")", ";", "}", "if", "(", "values", ".", "isEmpty", "(", ")", ")", "{", "map", ".", "remove", "(", "key", ")", ";", "}", "return", "result", ";", "}" ]
Remove the given number of values for a given key. May return less values then requested. @param key the key to remove from. @param num the number of values to remove. @return a list of the removed values. @since 4.4.0
[ "Remove", "the", "given", "number", "of", "values", "for", "a", "given", "key", ".", "May", "return", "less", "values", "then", "requested", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java#L181-L198
27,069
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java
MultiMap.values
public List<V> values() { List<V> values = new ArrayList<>(size()); for (List<V> list : map.values()) { values.addAll(list); } return values; }
java
public List<V> values() { List<V> values = new ArrayList<>(size()); for (List<V> list : map.values()) { values.addAll(list); } return values; }
[ "public", "List", "<", "V", ">", "values", "(", ")", "{", "List", "<", "V", ">", "values", "=", "new", "ArrayList", "<>", "(", "size", "(", ")", ")", ";", "for", "(", "List", "<", "V", ">", "list", ":", "map", ".", "values", "(", ")", ")", "{", "values", ".", "addAll", "(", "list", ")", ";", "}", "return", "values", ";", "}" ]
Returns a new list containing all values of this multi map. @return a new list with all values.
[ "Returns", "a", "new", "list", "containing", "all", "values", "of", "this", "multi", "map", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java#L219-L225
27,070
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/ScreenShareSession.java
ScreenShareSession.initialize
@Override public void initialize() { JingleSession session = getJingleSession(); if (session != null && session.getInitiator().equals(session.getConnection().getUser())) { // If the initiator of the jingle session is us then we transmit a screen share. try { InetAddress remote = InetAddress.getByName(getRemote().getIp()); transmitter = new ImageTransmitter(new DatagramSocket(getLocal().getPort()), remote, getRemote().getPort(), new Rectangle(0, 0, width, height)); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } } else { // Otherwise we receive a screen share. JFrame window = new JFrame(); JPanel jp = new JPanel(); window.add(jp); window.setLocation(0, 0); window.setSize(600, 600); window.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { receiver.stop(); } }); try { receiver = new ImageReceiver(InetAddress.getByName("0.0.0.0"), getRemote().getPort(), getLocal().getPort(), width, height); LOGGER.fine("Receiving on:" + receiver.getLocalPort()); } catch (UnknownHostException e) { LOGGER.log(Level.WARNING, "exception", e); } jp.add(receiver); receiver.setVisible(true); window.setAlwaysOnTop(true); window.setVisible(true); } }
java
@Override public void initialize() { JingleSession session = getJingleSession(); if (session != null && session.getInitiator().equals(session.getConnection().getUser())) { // If the initiator of the jingle session is us then we transmit a screen share. try { InetAddress remote = InetAddress.getByName(getRemote().getIp()); transmitter = new ImageTransmitter(new DatagramSocket(getLocal().getPort()), remote, getRemote().getPort(), new Rectangle(0, 0, width, height)); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } } else { // Otherwise we receive a screen share. JFrame window = new JFrame(); JPanel jp = new JPanel(); window.add(jp); window.setLocation(0, 0); window.setSize(600, 600); window.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { receiver.stop(); } }); try { receiver = new ImageReceiver(InetAddress.getByName("0.0.0.0"), getRemote().getPort(), getLocal().getPort(), width, height); LOGGER.fine("Receiving on:" + receiver.getLocalPort()); } catch (UnknownHostException e) { LOGGER.log(Level.WARNING, "exception", e); } jp.add(receiver); receiver.setVisible(true); window.setAlwaysOnTop(true); window.setVisible(true); } }
[ "@", "Override", "public", "void", "initialize", "(", ")", "{", "JingleSession", "session", "=", "getJingleSession", "(", ")", ";", "if", "(", "session", "!=", "null", "&&", "session", ".", "getInitiator", "(", ")", ".", "equals", "(", "session", ".", "getConnection", "(", ")", ".", "getUser", "(", ")", ")", ")", "{", "// If the initiator of the jingle session is us then we transmit a screen share.", "try", "{", "InetAddress", "remote", "=", "InetAddress", ".", "getByName", "(", "getRemote", "(", ")", ".", "getIp", "(", ")", ")", ";", "transmitter", "=", "new", "ImageTransmitter", "(", "new", "DatagramSocket", "(", "getLocal", "(", ")", ".", "getPort", "(", ")", ")", ",", "remote", ",", "getRemote", "(", ")", ".", "getPort", "(", ")", ",", "new", "Rectangle", "(", "0", ",", "0", ",", "width", ",", "height", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"exception\"", ",", "e", ")", ";", "}", "}", "else", "{", "// Otherwise we receive a screen share.", "JFrame", "window", "=", "new", "JFrame", "(", ")", ";", "JPanel", "jp", "=", "new", "JPanel", "(", ")", ";", "window", ".", "add", "(", "jp", ")", ";", "window", ".", "setLocation", "(", "0", ",", "0", ")", ";", "window", ".", "setSize", "(", "600", ",", "600", ")", ";", "window", ".", "addWindowListener", "(", "new", "WindowAdapter", "(", ")", "{", "@", "Override", "public", "void", "windowClosed", "(", "WindowEvent", "e", ")", "{", "receiver", ".", "stop", "(", ")", ";", "}", "}", ")", ";", "try", "{", "receiver", "=", "new", "ImageReceiver", "(", "InetAddress", ".", "getByName", "(", "\"0.0.0.0\"", ")", ",", "getRemote", "(", ")", ".", "getPort", "(", ")", ",", "getLocal", "(", ")", ".", "getPort", "(", ")", ",", "width", ",", "height", ")", ";", "LOGGER", ".", "fine", "(", "\"Receiving on:\"", "+", "receiver", ".", "getLocalPort", "(", ")", ")", ";", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"exception\"", ",", "e", ")", ";", "}", "jp", ".", "add", "(", "receiver", ")", ";", "receiver", ".", "setVisible", "(", "true", ")", ";", "window", ".", "setAlwaysOnTop", "(", "true", ")", ";", "window", ".", "setVisible", "(", "true", ")", ";", "}", "}" ]
Initialize the screen share channels.
[ "Initialize", "the", "screen", "share", "channels", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/ScreenShareSession.java#L77-L120
27,071
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java
SpoilerElement.addSpoiler
public static void addSpoiler(Message message, String hint) { message.addExtension(new SpoilerElement(null, hint)); }
java
public static void addSpoiler(Message message, String hint) { message.addExtension(new SpoilerElement(null, hint)); }
[ "public", "static", "void", "addSpoiler", "(", "Message", "message", ",", "String", "hint", ")", "{", "message", ".", "addExtension", "(", "new", "SpoilerElement", "(", "null", ",", "hint", ")", ")", ";", "}" ]
Add a SpoilerElement with a hint to a message. @param message Message to add the Spoiler to. @param hint Hint about the Spoilers content.
[ "Add", "a", "SpoilerElement", "with", "a", "hint", "to", "a", "message", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java#L79-L81
27,072
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java
SpoilerElement.addSpoiler
public static void addSpoiler(Message message, String lang, String hint) { message.addExtension(new SpoilerElement(lang, hint)); }
java
public static void addSpoiler(Message message, String lang, String hint) { message.addExtension(new SpoilerElement(lang, hint)); }
[ "public", "static", "void", "addSpoiler", "(", "Message", "message", ",", "String", "lang", ",", "String", "hint", ")", "{", "message", ".", "addExtension", "(", "new", "SpoilerElement", "(", "lang", ",", "hint", ")", ")", ";", "}" ]
Add a SpoilerElement with a hint in a certain language to a message. @param message Message to add the Spoiler to. @param lang language of the Spoiler hint. @param hint hint.
[ "Add", "a", "SpoilerElement", "with", "a", "hint", "in", "a", "certain", "language", "to", "a", "message", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java#L90-L92
27,073
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java
SpoilerElement.getSpoilers
public static Map<String, String> getSpoilers(Message message) { if (!containsSpoiler(message)) { return Collections.emptyMap(); } List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE); Map<String, String> map = new HashMap<>(); for (ExtensionElement e : spoilers) { SpoilerElement s = (SpoilerElement) e; if (s.getLanguage() == null || s.getLanguage().equals("")) { map.put("", s.getHint()); } else { map.put(s.getLanguage(), s.getHint()); } } return map; }
java
public static Map<String, String> getSpoilers(Message message) { if (!containsSpoiler(message)) { return Collections.emptyMap(); } List<ExtensionElement> spoilers = message.getExtensions(SpoilerElement.ELEMENT, NAMESPACE); Map<String, String> map = new HashMap<>(); for (ExtensionElement e : spoilers) { SpoilerElement s = (SpoilerElement) e; if (s.getLanguage() == null || s.getLanguage().equals("")) { map.put("", s.getHint()); } else { map.put(s.getLanguage(), s.getHint()); } } return map; }
[ "public", "static", "Map", "<", "String", ",", "String", ">", "getSpoilers", "(", "Message", "message", ")", "{", "if", "(", "!", "containsSpoiler", "(", "message", ")", ")", "{", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}", "List", "<", "ExtensionElement", ">", "spoilers", "=", "message", ".", "getExtensions", "(", "SpoilerElement", ".", "ELEMENT", ",", "NAMESPACE", ")", ";", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "ExtensionElement", "e", ":", "spoilers", ")", "{", "SpoilerElement", "s", "=", "(", "SpoilerElement", ")", "e", ";", "if", "(", "s", ".", "getLanguage", "(", ")", "==", "null", "||", "s", ".", "getLanguage", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "map", ".", "put", "(", "\"\"", ",", "s", ".", "getHint", "(", ")", ")", ";", "}", "else", "{", "map", ".", "put", "(", "s", ".", "getLanguage", "(", ")", ",", "s", ".", "getHint", "(", ")", ")", ";", "}", "}", "return", "map", ";", "}" ]
Return a map of all spoilers contained in a message. The map uses the language of a spoiler as key. If a spoiler has no language attribute, its key will be an empty String. @param message message @return map of spoilers
[ "Return", "a", "map", "of", "all", "spoilers", "contained", "in", "a", "message", ".", "The", "map", "uses", "the", "language", "of", "a", "spoiler", "as", "key", ".", "If", "a", "spoiler", "has", "no", "language", "attribute", "its", "key", "will", "be", "an", "empty", "String", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/spoiler/element/SpoilerElement.java#L113-L131
27,074
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getAgentRoster
public AgentRoster getAgentRoster() throws NotConnectedException, InterruptedException { if (agentRoster == null) { agentRoster = new AgentRoster(connection, workgroupJID); } // This might be the first time the user has asked for the roster. If so, we // want to wait up to 2 seconds for the server to send back the list of agents. // This behavior shields API users from having to worry about the fact that the // operation is asynchronous, although they'll still have to listen for changes // to the roster. int elapsed = 0; while (!agentRoster.rosterInitialized && elapsed <= 2000) { try { Thread.sleep(500); } catch (Exception e) { // Ignore } elapsed += 500; } return agentRoster; }
java
public AgentRoster getAgentRoster() throws NotConnectedException, InterruptedException { if (agentRoster == null) { agentRoster = new AgentRoster(connection, workgroupJID); } // This might be the first time the user has asked for the roster. If so, we // want to wait up to 2 seconds for the server to send back the list of agents. // This behavior shields API users from having to worry about the fact that the // operation is asynchronous, although they'll still have to listen for changes // to the roster. int elapsed = 0; while (!agentRoster.rosterInitialized && elapsed <= 2000) { try { Thread.sleep(500); } catch (Exception e) { // Ignore } elapsed += 500; } return agentRoster; }
[ "public", "AgentRoster", "getAgentRoster", "(", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "if", "(", "agentRoster", "==", "null", ")", "{", "agentRoster", "=", "new", "AgentRoster", "(", "connection", ",", "workgroupJID", ")", ";", "}", "// This might be the first time the user has asked for the roster. If so, we", "// want to wait up to 2 seconds for the server to send back the list of agents.", "// This behavior shields API users from having to worry about the fact that the", "// operation is asynchronous, although they'll still have to listen for changes", "// to the roster.", "int", "elapsed", "=", "0", ";", "while", "(", "!", "agentRoster", ".", "rosterInitialized", "&&", "elapsed", "<=", "2000", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "500", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Ignore", "}", "elapsed", "+=", "500", ";", "}", "return", "agentRoster", ";", "}" ]
Returns the agent roster for the workgroup, which contains. @return the AgentRoster @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "agent", "roster", "for", "the", "workgroup", "which", "contains", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L215-L236
27,075
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.setMetaData
public void setMetaData(String key, String val) throws XMPPException, SmackException, InterruptedException { synchronized (this.metaData) { List<String> oldVals = metaData.get(key); if (oldVals == null || !oldVals.get(0).equals(val)) { oldVals.set(0, val); setStatus(presenceMode, maxChats); } } }
java
public void setMetaData(String key, String val) throws XMPPException, SmackException, InterruptedException { synchronized (this.metaData) { List<String> oldVals = metaData.get(key); if (oldVals == null || !oldVals.get(0).equals(val)) { oldVals.set(0, val); setStatus(presenceMode, maxChats); } } }
[ "public", "void", "setMetaData", "(", "String", "key", ",", "String", "val", ")", "throws", "XMPPException", ",", "SmackException", ",", "InterruptedException", "{", "synchronized", "(", "this", ".", "metaData", ")", "{", "List", "<", "String", ">", "oldVals", "=", "metaData", ".", "get", "(", "key", ")", ";", "if", "(", "oldVals", "==", "null", "||", "!", "oldVals", ".", "get", "(", "0", ")", ".", "equals", "(", "val", ")", ")", "{", "oldVals", ".", "set", "(", "0", ",", "val", ")", ";", "setStatus", "(", "presenceMode", ",", "maxChats", ")", ";", "}", "}", "}" ]
Allows the addition of a new key-value pair to the agent's meta data, if the value is new data, the revised meta data will be rebroadcast in an agent's presence broadcast. @param key the meta data key @param val the non-null meta data value @throws XMPPException if an exception occurs. @throws SmackException @throws InterruptedException
[ "Allows", "the", "addition", "of", "a", "new", "key", "-", "value", "pair", "to", "the", "agent", "s", "meta", "data", "if", "the", "value", "is", "new", "data", "the", "revised", "meta", "data", "will", "be", "rebroadcast", "in", "an", "agent", "s", "presence", "broadcast", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L275-L285
27,076
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.removeMetaData
public void removeMetaData(String key) throws XMPPException, SmackException, InterruptedException { synchronized (this.metaData) { List<String> oldVal = metaData.remove(key); if (oldVal != null) { setStatus(presenceMode, maxChats); } } }
java
public void removeMetaData(String key) throws XMPPException, SmackException, InterruptedException { synchronized (this.metaData) { List<String> oldVal = metaData.remove(key); if (oldVal != null) { setStatus(presenceMode, maxChats); } } }
[ "public", "void", "removeMetaData", "(", "String", "key", ")", "throws", "XMPPException", ",", "SmackException", ",", "InterruptedException", "{", "synchronized", "(", "this", ".", "metaData", ")", "{", "List", "<", "String", ">", "oldVal", "=", "metaData", ".", "remove", "(", "key", ")", ";", "if", "(", "oldVal", "!=", "null", ")", "{", "setStatus", "(", "presenceMode", ",", "maxChats", ")", ";", "}", "}", "}" ]
Allows the removal of data from the agent's meta data, if the key represents existing data, the revised meta data will be rebroadcast in an agent's presence broadcast. @param key the meta data key. @throws XMPPException if an exception occurs. @throws SmackException @throws InterruptedException
[ "Allows", "the", "removal", "of", "data", "from", "the", "agent", "s", "meta", "data", "if", "the", "key", "represents", "existing", "data", "the", "revised", "meta", "data", "will", "be", "rebroadcast", "in", "an", "agent", "s", "presence", "broadcast", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L296-L304
27,077
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.setOnline
public void setOnline(boolean online) throws XMPPException, SmackException, InterruptedException { // If the online status hasn't changed, do nothing. if (this.online == online) { return; } Presence presence; // If the user is going online... if (online) { presence = new Presence(Presence.Type.available); presence.setTo(workgroupJID); presence.addExtension(new StandardExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE)); StanzaCollector collector = this.connection.createStanzaCollectorAndSend(new AndFilter( new StanzaTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); presence = collector.nextResultOrThrow(); // We can safely update this iv since we didn't get any error this.online = online; } // Otherwise the user is going offline... else { // Update this iv now since we don't care at this point of any error this.online = online; presence = new Presence(Presence.Type.unavailable); presence.setTo(workgroupJID); presence.addExtension(new StandardExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE)); connection.sendStanza(presence); } }
java
public void setOnline(boolean online) throws XMPPException, SmackException, InterruptedException { // If the online status hasn't changed, do nothing. if (this.online == online) { return; } Presence presence; // If the user is going online... if (online) { presence = new Presence(Presence.Type.available); presence.setTo(workgroupJID); presence.addExtension(new StandardExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE)); StanzaCollector collector = this.connection.createStanzaCollectorAndSend(new AndFilter( new StanzaTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); presence = collector.nextResultOrThrow(); // We can safely update this iv since we didn't get any error this.online = online; } // Otherwise the user is going offline... else { // Update this iv now since we don't care at this point of any error this.online = online; presence = new Presence(Presence.Type.unavailable); presence.setTo(workgroupJID); presence.addExtension(new StandardExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE)); connection.sendStanza(presence); } }
[ "public", "void", "setOnline", "(", "boolean", "online", ")", "throws", "XMPPException", ",", "SmackException", ",", "InterruptedException", "{", "// If the online status hasn't changed, do nothing.", "if", "(", "this", ".", "online", "==", "online", ")", "{", "return", ";", "}", "Presence", "presence", ";", "// If the user is going online...", "if", "(", "online", ")", "{", "presence", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "available", ")", ";", "presence", ".", "setTo", "(", "workgroupJID", ")", ";", "presence", ".", "addExtension", "(", "new", "StandardExtensionElement", "(", "AgentStatus", ".", "ELEMENT_NAME", ",", "AgentStatus", ".", "NAMESPACE", ")", ")", ";", "StanzaCollector", "collector", "=", "this", ".", "connection", ".", "createStanzaCollectorAndSend", "(", "new", "AndFilter", "(", "new", "StanzaTypeFilter", "(", "Presence", ".", "class", ")", ",", "FromMatchesFilter", ".", "create", "(", "workgroupJID", ")", ")", ",", "presence", ")", ";", "presence", "=", "collector", ".", "nextResultOrThrow", "(", ")", ";", "// We can safely update this iv since we didn't get any error", "this", ".", "online", "=", "online", ";", "}", "// Otherwise the user is going offline...", "else", "{", "// Update this iv now since we don't care at this point of any error", "this", ".", "online", "=", "online", ";", "presence", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "unavailable", ")", ";", "presence", ".", "setTo", "(", "workgroupJID", ")", ";", "presence", ".", "addExtension", "(", "new", "StandardExtensionElement", "(", "AgentStatus", ".", "ELEMENT_NAME", ",", "AgentStatus", ".", "NAMESPACE", ")", ")", ";", "connection", ".", "sendStanza", "(", "presence", ")", ";", "}", "}" ]
Sets whether the agent is online with the workgroup. If the user tries to go online with the workgroup but is not allowed to be an agent, an XMPPError with error code 401 will be thrown. @param online true to set the agent as online with the workgroup. @throws XMPPException if an error occurs setting the online status. @throws SmackException assertEquals(SmackException.Type.NO_RESPONSE_FROM_SERVER, e.getType()); return; @throws InterruptedException
[ "Sets", "whether", "the", "agent", "is", "online", "with", "the", "workgroup", ".", "If", "the", "user", "tries", "to", "go", "online", "with", "the", "workgroup", "but", "is", "not", "allowed", "to", "be", "an", "agent", "an", "XMPPError", "with", "error", "code", "401", "will", "be", "thrown", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L328-L362
27,078
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.dequeueUser
public void dequeueUser(EntityJid userID) throws XMPPException, NotConnectedException, InterruptedException { // todo: this method simply won't work right now. DepartQueuePacket departPacket = new DepartQueuePacket(workgroupJID, userID); // PENDING this.connection.sendStanza(departPacket); }
java
public void dequeueUser(EntityJid userID) throws XMPPException, NotConnectedException, InterruptedException { // todo: this method simply won't work right now. DepartQueuePacket departPacket = new DepartQueuePacket(workgroupJID, userID); // PENDING this.connection.sendStanza(departPacket); }
[ "public", "void", "dequeueUser", "(", "EntityJid", "userID", ")", "throws", "XMPPException", ",", "NotConnectedException", ",", "InterruptedException", "{", "// todo: this method simply won't work right now.", "DepartQueuePacket", "departPacket", "=", "new", "DepartQueuePacket", "(", "workgroupJID", ",", "userID", ")", ";", "// PENDING", "this", ".", "connection", ".", "sendStanza", "(", "departPacket", ")", ";", "}" ]
Removes a user from the workgroup queue. This is an administrative action that the The agent is not guaranteed of having privileges to perform this action; an exception denying the request may be thrown. @param userID the ID of the user to remove. @throws XMPPException if an exception occurs. @throws NotConnectedException @throws InterruptedException
[ "Removes", "a", "user", "from", "the", "workgroup", "queue", ".", "This", "is", "an", "administrative", "action", "that", "the" ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L507-L513
27,079
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getOccupantsInfo
public OccupantsInfo getOccupantsInfo(String roomID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { OccupantsInfo request = new OccupantsInfo(roomID); request.setType(IQ.Type.get); request.setTo(workgroupJID); OccupantsInfo response = (OccupantsInfo) connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response; }
java
public OccupantsInfo getOccupantsInfo(String roomID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { OccupantsInfo request = new OccupantsInfo(roomID); request.setType(IQ.Type.get); request.setTo(workgroupJID); OccupantsInfo response = (OccupantsInfo) connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response; }
[ "public", "OccupantsInfo", "getOccupantsInfo", "(", "String", "roomID", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "OccupantsInfo", "request", "=", "new", "OccupantsInfo", "(", "roomID", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "request", ".", "setTo", "(", "workgroupJID", ")", ";", "OccupantsInfo", "response", "=", "(", "OccupantsInfo", ")", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "response", ";", "}" ]
Asks the workgroup for information about the occupants of the specified room. The returned information will include the real JID of the occupants, the nickname of the user in the room as well as the date when the user joined the room. @param roomID the room to get information about its occupants. @return information about the occupants of the specified room. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Asks", "the", "workgroup", "for", "information", "about", "the", "occupants", "of", "the", "specified", "room", ".", "The", "returned", "information", "will", "include", "the", "real", "JID", "of", "the", "occupants", "the", "nickname", "of", "the", "user", "in", "the", "room", "as", "well", "as", "the", "date", "when", "the", "user", "joined", "the", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L584-L591
27,080
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getQueue
public WorkgroupQueue getQueue(String queueName) { Resourcepart queueNameResourcepart; try { queueNameResourcepart = Resourcepart.from(queueName); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } return getQueue(queueNameResourcepart); }
java
public WorkgroupQueue getQueue(String queueName) { Resourcepart queueNameResourcepart; try { queueNameResourcepart = Resourcepart.from(queueName); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } return getQueue(queueNameResourcepart); }
[ "public", "WorkgroupQueue", "getQueue", "(", "String", "queueName", ")", "{", "Resourcepart", "queueNameResourcepart", ";", "try", "{", "queueNameResourcepart", "=", "Resourcepart", ".", "from", "(", "queueName", ")", ";", "}", "catch", "(", "XmppStringprepException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "return", "getQueue", "(", "queueNameResourcepart", ")", ";", "}" ]
Get queue. @param queueName the name of the queue @return an instance of WorkgroupQueue for the argument queue name, or null if none exists
[ "Get", "queue", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L616-L625
27,081
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.addOfferListener
public void addOfferListener(OfferListener offerListener) { synchronized (offerListeners) { if (!offerListeners.contains(offerListener)) { offerListeners.add(offerListener); } } }
java
public void addOfferListener(OfferListener offerListener) { synchronized (offerListeners) { if (!offerListeners.contains(offerListener)) { offerListeners.add(offerListener); } } }
[ "public", "void", "addOfferListener", "(", "OfferListener", "offerListener", ")", "{", "synchronized", "(", "offerListeners", ")", "{", "if", "(", "!", "offerListeners", ".", "contains", "(", "offerListener", ")", ")", "{", "offerListeners", ".", "add", "(", "offerListener", ")", ";", "}", "}", "}" ]
Adds an offer listener. @param offerListener the offer listener.
[ "Adds", "an", "offer", "listener", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L660-L666
27,082
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.addInvitationListener
public void addInvitationListener(WorkgroupInvitationListener invitationListener) { synchronized (invitationListeners) { if (!invitationListeners.contains(invitationListener)) { invitationListeners.add(invitationListener); } } }
java
public void addInvitationListener(WorkgroupInvitationListener invitationListener) { synchronized (invitationListeners) { if (!invitationListeners.contains(invitationListener)) { invitationListeners.add(invitationListener); } } }
[ "public", "void", "addInvitationListener", "(", "WorkgroupInvitationListener", "invitationListener", ")", "{", "synchronized", "(", "invitationListeners", ")", "{", "if", "(", "!", "invitationListeners", ".", "contains", "(", "invitationListener", ")", ")", "{", "invitationListeners", ".", "add", "(", "invitationListener", ")", ";", "}", "}", "}" ]
Adds an invitation listener. @param invitationListener the invitation listener.
[ "Adds", "an", "invitation", "listener", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L684-L690
27,083
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.setNote
public void setNote(String sessionID, String note) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ChatNotes notes = new ChatNotes(); notes.setType(IQ.Type.set); notes.setTo(workgroupJID); notes.setSessionID(sessionID); notes.setNotes(note); connection.createStanzaCollectorAndSend(notes).nextResultOrThrow(); }
java
public void setNote(String sessionID, String note) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ChatNotes notes = new ChatNotes(); notes.setType(IQ.Type.set); notes.setTo(workgroupJID); notes.setSessionID(sessionID); notes.setNotes(note); connection.createStanzaCollectorAndSend(notes).nextResultOrThrow(); }
[ "public", "void", "setNote", "(", "String", "sessionID", ",", "String", "note", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "ChatNotes", "notes", "=", "new", "ChatNotes", "(", ")", ";", "notes", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "notes", ".", "setTo", "(", "workgroupJID", ")", ";", "notes", ".", "setSessionID", "(", "sessionID", ")", ";", "notes", ".", "setNotes", "(", "note", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "notes", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Creates a ChatNote that will be mapped to the given chat session. @param sessionID the session id of a Chat Session. @param note the chat note to add. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Creates", "a", "ChatNote", "that", "will", "be", "mapped", "to", "the", "given", "chat", "session", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L856-L863
27,084
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getNote
public ChatNotes getNote(String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ChatNotes request = new ChatNotes(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setSessionID(sessionID); ChatNotes response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response; }
java
public ChatNotes getNote(String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ChatNotes request = new ChatNotes(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setSessionID(sessionID); ChatNotes response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response; }
[ "public", "ChatNotes", "getNote", "(", "String", "sessionID", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "ChatNotes", "request", "=", "new", "ChatNotes", "(", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "request", ".", "setTo", "(", "workgroupJID", ")", ";", "request", ".", "setSessionID", "(", "sessionID", ")", ";", "ChatNotes", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "response", ";", "}" ]
Retrieves the ChatNote associated with a given chat session. @param sessionID the sessionID of the chat session. @return the <code>ChatNote</code> associated with a given chat session. @throws XMPPErrorException if an error occurs while retrieving the ChatNote. @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Retrieves", "the", "ChatNote", "associated", "with", "a", "given", "chat", "session", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L875-L883
27,085
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getAgentHistory
public AgentChatHistory getAgentHistory(EntityBareJid jid, int maxSessions, Date startDate) throws XMPPException, NotConnectedException, InterruptedException { AgentChatHistory request; if (startDate != null) { request = new AgentChatHistory(jid, maxSessions, startDate); } else { request = new AgentChatHistory(jid, maxSessions); } request.setType(IQ.Type.get); request.setTo(workgroupJID); AgentChatHistory response = connection.createStanzaCollectorAndSend( request).nextResult(); return response; }
java
public AgentChatHistory getAgentHistory(EntityBareJid jid, int maxSessions, Date startDate) throws XMPPException, NotConnectedException, InterruptedException { AgentChatHistory request; if (startDate != null) { request = new AgentChatHistory(jid, maxSessions, startDate); } else { request = new AgentChatHistory(jid, maxSessions); } request.setType(IQ.Type.get); request.setTo(workgroupJID); AgentChatHistory response = connection.createStanzaCollectorAndSend( request).nextResult(); return response; }
[ "public", "AgentChatHistory", "getAgentHistory", "(", "EntityBareJid", "jid", ",", "int", "maxSessions", ",", "Date", "startDate", ")", "throws", "XMPPException", ",", "NotConnectedException", ",", "InterruptedException", "{", "AgentChatHistory", "request", ";", "if", "(", "startDate", "!=", "null", ")", "{", "request", "=", "new", "AgentChatHistory", "(", "jid", ",", "maxSessions", ",", "startDate", ")", ";", "}", "else", "{", "request", "=", "new", "AgentChatHistory", "(", "jid", ",", "maxSessions", ")", ";", "}", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "request", ".", "setTo", "(", "workgroupJID", ")", ";", "AgentChatHistory", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResult", "(", ")", ";", "return", "response", ";", "}" ]
Retrieves the AgentChatHistory associated with a particular agent jid. @param jid the jid of the agent. @param maxSessions the max number of sessions to retrieve. @param startDate point in time from which on history should get retrieved. @return the chat history associated with a given jid. @throws XMPPException if an error occurs while retrieving the AgentChatHistory. @throws NotConnectedException @throws InterruptedException
[ "Retrieves", "the", "AgentChatHistory", "associated", "with", "a", "particular", "agent", "jid", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L896-L912
27,086
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getSearchSettings
public SearchSettings getSearchSettings() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { SearchSettings request = new SearchSettings(); request.setType(IQ.Type.get); request.setTo(workgroupJID); SearchSettings response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response; }
java
public SearchSettings getSearchSettings() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { SearchSettings request = new SearchSettings(); request.setType(IQ.Type.get); request.setTo(workgroupJID); SearchSettings response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response; }
[ "public", "SearchSettings", "getSearchSettings", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "SearchSettings", "request", "=", "new", "SearchSettings", "(", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "request", ".", "setTo", "(", "workgroupJID", ")", ";", "SearchSettings", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "response", ";", "}" ]
Asks the workgroup for it's Search Settings. @return SearchSettings the search settings for this workgroup. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Asks", "the", "workgroup", "for", "it", "s", "Search", "Settings", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L923-L930
27,087
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getMacros
public MacroGroup getMacros(boolean global) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Macros request = new Macros(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setPersonal(!global); Macros response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response.getRootGroup(); }
java
public MacroGroup getMacros(boolean global) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Macros request = new Macros(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setPersonal(!global); Macros response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); return response.getRootGroup(); }
[ "public", "MacroGroup", "getMacros", "(", "boolean", "global", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "Macros", "request", "=", "new", "Macros", "(", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "request", ".", "setTo", "(", "workgroupJID", ")", ";", "request", ".", "setPersonal", "(", "!", "global", ")", ";", "Macros", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "response", ".", "getRootGroup", "(", ")", ";", "}" ]
Asks the workgroup for it's Global Macros. @param global true to retrieve global macros, otherwise false for personal macros. @return MacroGroup the root macro group. @throws XMPPErrorException if an error occurs while getting information from the server. @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Asks", "the", "workgroup", "for", "it", "s", "Global", "Macros", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L942-L950
27,088
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.saveMacros
public void saveMacros(MacroGroup group) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Macros request = new Macros(); request.setType(IQ.Type.set); request.setTo(workgroupJID); request.setPersonal(true); request.setPersonalMacroGroup(group); connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); }
java
public void saveMacros(MacroGroup group) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Macros request = new Macros(); request.setType(IQ.Type.set); request.setTo(workgroupJID); request.setPersonal(true); request.setPersonalMacroGroup(group); connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); }
[ "public", "void", "saveMacros", "(", "MacroGroup", "group", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "Macros", "request", "=", "new", "Macros", "(", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "request", ".", "setTo", "(", "workgroupJID", ")", ";", "request", ".", "setPersonal", "(", "true", ")", ";", "request", ".", "setPersonalMacroGroup", "(", "group", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Persists the Personal Macro for an agent. @param group the macro group to save. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Persists", "the", "Personal", "Macro", "for", "an", "agent", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L961-L969
27,089
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getChatMetadata
public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException, NotConnectedException, InterruptedException { ChatMetadata request = new ChatMetadata(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setSessionID(sessionID); ChatMetadata response = connection.createStanzaCollectorAndSend(request).nextResult(); return response.getMetadata(); }
java
public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException, NotConnectedException, InterruptedException { ChatMetadata request = new ChatMetadata(); request.setType(IQ.Type.get); request.setTo(workgroupJID); request.setSessionID(sessionID); ChatMetadata response = connection.createStanzaCollectorAndSend(request).nextResult(); return response.getMetadata(); }
[ "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "getChatMetadata", "(", "String", "sessionID", ")", "throws", "XMPPException", ",", "NotConnectedException", ",", "InterruptedException", "{", "ChatMetadata", "request", "=", "new", "ChatMetadata", "(", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "request", ".", "setTo", "(", "workgroupJID", ")", ";", "request", ".", "setSessionID", "(", "sessionID", ")", ";", "ChatMetadata", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResult", "(", ")", ";", "return", "response", ".", "getMetadata", "(", ")", ";", "}" ]
Query for metadata associated with a session id. @param sessionID the sessionID to query for. @return Map a map of all metadata associated with the sessionID. @throws XMPPException if an error occurs while getting information from the server. @throws NotConnectedException @throws InterruptedException
[ "Query", "for", "metadata", "associated", "with", "a", "session", "id", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L980-L989
27,090
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java
AgentSession.getGenericSettings
public GenericSettings getGenericSettings(XMPPConnection con, String query) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { GenericSettings setting = new GenericSettings(); setting.setType(IQ.Type.get); setting.setTo(workgroupJID); GenericSettings response = connection.createStanzaCollectorAndSend( setting).nextResultOrThrow(); return response; }
java
public GenericSettings getGenericSettings(XMPPConnection con, String query) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { GenericSettings setting = new GenericSettings(); setting.setType(IQ.Type.get); setting.setTo(workgroupJID); GenericSettings response = connection.createStanzaCollectorAndSend( setting).nextResultOrThrow(); return response; }
[ "public", "GenericSettings", "getGenericSettings", "(", "XMPPConnection", "con", ",", "String", "query", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "GenericSettings", "setting", "=", "new", "GenericSettings", "(", ")", ";", "setting", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "setting", ".", "setTo", "(", "workgroupJID", ")", ";", "GenericSettings", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "setting", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "response", ";", "}" ]
Returns the generic metadata of the workgroup the agent belongs to. @param con the XMPPConnection to use. @param query an optional query object used to tell the server what metadata to retrieve. This can be null. @return the settings for the workgroup. @throws XMPPErrorException if an error occurs while sending the request to the server. @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "generic", "metadata", "of", "the", "workgroup", "the", "agent", "belongs", "to", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentSession.java#L1078-L1086
27,091
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportCandidate.java
TransportCandidate.isNull
public boolean isNull() { if (ip == null) { return true; } else if (ip.length() == 0) { return true; } else if (port < 0) { return true; } else { return false; } }
java
public boolean isNull() { if (ip == null) { return true; } else if (ip.length() == 0) { return true; } else if (port < 0) { return true; } else { return false; } }
[ "public", "boolean", "isNull", "(", ")", "{", "if", "(", "ip", "==", "null", ")", "{", "return", "true", ";", "}", "else", "if", "(", "ip", ".", "length", "(", ")", "==", "0", ")", "{", "return", "true", ";", "}", "else", "if", "(", "port", "<", "0", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Return true if the candidate is not valid. @return true if the candidate is null.
[ "Return", "true", "if", "the", "candidate", "is", "not", "valid", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/TransportCandidate.java#L232-L242
27,092
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/ICECandidate.java
ICECandidate.compareTo
@Override public int compareTo(ICECandidate arg) { if (getPreference() < arg.getPreference()) { return -1; } else if (getPreference() > arg.getPreference()) { return 1; } return 0; }
java
@Override public int compareTo(ICECandidate arg) { if (getPreference() < arg.getPreference()) { return -1; } else if (getPreference() > arg.getPreference()) { return 1; } return 0; }
[ "@", "Override", "public", "int", "compareTo", "(", "ICECandidate", "arg", ")", "{", "if", "(", "getPreference", "(", ")", "<", "arg", ".", "getPreference", "(", ")", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "getPreference", "(", ")", ">", "arg", ".", "getPreference", "(", ")", ")", "{", "return", "1", ";", "}", "return", "0", ";", "}" ]
Compare the to other Transport candidate. @param arg another Transport candidate @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
[ "Compare", "the", "to", "other", "Transport", "candidate", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/ICECandidate.java#L422-L430
27,093
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
PacketParserUtils.parseStanza
public static Stanza parseStanza(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception { ParserUtils.assertAtStartTag(parser); final String name = parser.getName(); switch (name) { case Message.ELEMENT: return parseMessage(parser, outerXmlEnvironment); case IQ.IQ_ELEMENT: return parseIQ(parser, outerXmlEnvironment); case Presence.ELEMENT: return parsePresence(parser, outerXmlEnvironment); default: throw new IllegalArgumentException("Can only parse message, iq or presence, not " + name); } }
java
public static Stanza parseStanza(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception { ParserUtils.assertAtStartTag(parser); final String name = parser.getName(); switch (name) { case Message.ELEMENT: return parseMessage(parser, outerXmlEnvironment); case IQ.IQ_ELEMENT: return parseIQ(parser, outerXmlEnvironment); case Presence.ELEMENT: return parsePresence(parser, outerXmlEnvironment); default: throw new IllegalArgumentException("Can only parse message, iq or presence, not " + name); } }
[ "public", "static", "Stanza", "parseStanza", "(", "XmlPullParser", "parser", ",", "XmlEnvironment", "outerXmlEnvironment", ")", "throws", "Exception", "{", "ParserUtils", ".", "assertAtStartTag", "(", "parser", ")", ";", "final", "String", "name", "=", "parser", ".", "getName", "(", ")", ";", "switch", "(", "name", ")", "{", "case", "Message", ".", "ELEMENT", ":", "return", "parseMessage", "(", "parser", ",", "outerXmlEnvironment", ")", ";", "case", "IQ", ".", "IQ_ELEMENT", ":", "return", "parseIQ", "(", "parser", ",", "outerXmlEnvironment", ")", ";", "case", "Presence", ".", "ELEMENT", ":", "return", "parsePresence", "(", "parser", ",", "outerXmlEnvironment", ")", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Can only parse message, iq or presence, not \"", "+", "name", ")", ";", "}", "}" ]
Tries to parse and return either a Message, IQ or Presence stanza. connection is optional and is used to return feature-not-implemented errors for unknown IQ stanzas. @param parser @param outerXmlEnvironment the outer XML environment (optional). @return a stanza which is either a Message, IQ or Presence. @throws Exception
[ "Tries", "to", "parse", "and", "return", "either", "a", "Message", "IQ", "or", "Presence", "stanza", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java#L154-L167
27,094
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
PacketParserUtils.parseMessage
public static Message parseMessage(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { ParserUtils.assertAtStartTag(parser); assert (parser.getName().equals(Message.ELEMENT)); XmlEnvironment messageXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); final int initialDepth = parser.getDepth(); Message message = new Message(); message.setStanzaId(parser.getAttributeValue("", "id")); message.setTo(ParserUtils.getJidAttribute(parser, "to")); message.setFrom(ParserUtils.getJidAttribute(parser, "from")); String typeString = parser.getAttributeValue("", "type"); if (typeString != null) { message.setType(Message.Type.fromString(typeString)); } String language = ParserUtils.getXmlLang(parser); message.setLanguage(language); // Parse sub-elements. We include extra logic to make sure the values // are only read once. This is because it's possible for the names to appear // in arbitrary sub-elements. String thread = null; outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); switch (elementName) { case "subject": String xmlLangSubject = ParserUtils.getXmlLang(parser); String subject = parseElementText(parser); if (message.getSubject(xmlLangSubject) == null) { message.addSubject(xmlLangSubject, subject); } break; case "thread": if (thread == null) { thread = parser.nextText(); } break; case "error": message.setError(parseError(parser, messageXmlEnvironment)); break; default: PacketParserUtils.addExtensionElement(message, parser, elementName, namespace, messageXmlEnvironment); break; } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } message.setThread(thread); // TODO check for duplicate body elements. This means we need to check for duplicate xml:lang pairs and for // situations where we have a body element with an explicit xml lang set and once where the value is inherited // and both values are equal. return message; }
java
public static Message parseMessage(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { ParserUtils.assertAtStartTag(parser); assert (parser.getName().equals(Message.ELEMENT)); XmlEnvironment messageXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); final int initialDepth = parser.getDepth(); Message message = new Message(); message.setStanzaId(parser.getAttributeValue("", "id")); message.setTo(ParserUtils.getJidAttribute(parser, "to")); message.setFrom(ParserUtils.getJidAttribute(parser, "from")); String typeString = parser.getAttributeValue("", "type"); if (typeString != null) { message.setType(Message.Type.fromString(typeString)); } String language = ParserUtils.getXmlLang(parser); message.setLanguage(language); // Parse sub-elements. We include extra logic to make sure the values // are only read once. This is because it's possible for the names to appear // in arbitrary sub-elements. String thread = null; outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); switch (elementName) { case "subject": String xmlLangSubject = ParserUtils.getXmlLang(parser); String subject = parseElementText(parser); if (message.getSubject(xmlLangSubject) == null) { message.addSubject(xmlLangSubject, subject); } break; case "thread": if (thread == null) { thread = parser.nextText(); } break; case "error": message.setError(parseError(parser, messageXmlEnvironment)); break; default: PacketParserUtils.addExtensionElement(message, parser, elementName, namespace, messageXmlEnvironment); break; } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } message.setThread(thread); // TODO check for duplicate body elements. This means we need to check for duplicate xml:lang pairs and for // situations where we have a body element with an explicit xml lang set and once where the value is inherited // and both values are equal. return message; }
[ "public", "static", "Message", "parseMessage", "(", "XmlPullParser", "parser", ",", "XmlEnvironment", "outerXmlEnvironment", ")", "throws", "XmlPullParserException", ",", "IOException", ",", "SmackParsingException", "{", "ParserUtils", ".", "assertAtStartTag", "(", "parser", ")", ";", "assert", "(", "parser", ".", "getName", "(", ")", ".", "equals", "(", "Message", ".", "ELEMENT", ")", ")", ";", "XmlEnvironment", "messageXmlEnvironment", "=", "XmlEnvironment", ".", "from", "(", "parser", ",", "outerXmlEnvironment", ")", ";", "final", "int", "initialDepth", "=", "parser", ".", "getDepth", "(", ")", ";", "Message", "message", "=", "new", "Message", "(", ")", ";", "message", ".", "setStanzaId", "(", "parser", ".", "getAttributeValue", "(", "\"\"", ",", "\"id\"", ")", ")", ";", "message", ".", "setTo", "(", "ParserUtils", ".", "getJidAttribute", "(", "parser", ",", "\"to\"", ")", ")", ";", "message", ".", "setFrom", "(", "ParserUtils", ".", "getJidAttribute", "(", "parser", ",", "\"from\"", ")", ")", ";", "String", "typeString", "=", "parser", ".", "getAttributeValue", "(", "\"\"", ",", "\"type\"", ")", ";", "if", "(", "typeString", "!=", "null", ")", "{", "message", ".", "setType", "(", "Message", ".", "Type", ".", "fromString", "(", "typeString", ")", ")", ";", "}", "String", "language", "=", "ParserUtils", ".", "getXmlLang", "(", "parser", ")", ";", "message", ".", "setLanguage", "(", "language", ")", ";", "// Parse sub-elements. We include extra logic to make sure the values", "// are only read once. This is because it's possible for the names to appear", "// in arbitrary sub-elements.", "String", "thread", "=", "null", ";", "outerloop", ":", "while", "(", "true", ")", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "switch", "(", "eventType", ")", "{", "case", "XmlPullParser", ".", "START_TAG", ":", "String", "elementName", "=", "parser", ".", "getName", "(", ")", ";", "String", "namespace", "=", "parser", ".", "getNamespace", "(", ")", ";", "switch", "(", "elementName", ")", "{", "case", "\"subject\"", ":", "String", "xmlLangSubject", "=", "ParserUtils", ".", "getXmlLang", "(", "parser", ")", ";", "String", "subject", "=", "parseElementText", "(", "parser", ")", ";", "if", "(", "message", ".", "getSubject", "(", "xmlLangSubject", ")", "==", "null", ")", "{", "message", ".", "addSubject", "(", "xmlLangSubject", ",", "subject", ")", ";", "}", "break", ";", "case", "\"thread\"", ":", "if", "(", "thread", "==", "null", ")", "{", "thread", "=", "parser", ".", "nextText", "(", ")", ";", "}", "break", ";", "case", "\"error\"", ":", "message", ".", "setError", "(", "parseError", "(", "parser", ",", "messageXmlEnvironment", ")", ")", ";", "break", ";", "default", ":", "PacketParserUtils", ".", "addExtensionElement", "(", "message", ",", "parser", ",", "elementName", ",", "namespace", ",", "messageXmlEnvironment", ")", ";", "break", ";", "}", "break", ";", "case", "XmlPullParser", ".", "END_TAG", ":", "if", "(", "parser", ".", "getDepth", "(", ")", "==", "initialDepth", ")", "{", "break", "outerloop", ";", "}", "break", ";", "}", "}", "message", ".", "setThread", "(", "thread", ")", ";", "// TODO check for duplicate body elements. This means we need to check for duplicate xml:lang pairs and for", "// situations where we have a body element with an explicit xml lang set and once where the value is inherited", "// and both values are equal.", "return", "message", ";", "}" ]
Parses a message packet. @param parser the XML parser, positioned at the start of a message packet. @param outerXmlEnvironment the outer XML environment (optional). @return a Message packet. @throws XmlPullParserException @throws IOException @throws SmackParsingException
[ "Parses", "a", "message", "packet", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java#L230-L294
27,095
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
PacketParserUtils.parsePresence
public static Presence parsePresence(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); XmlEnvironment presenceXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); Presence.Type type = Presence.Type.available; String typeString = parser.getAttributeValue("", "type"); if (typeString != null && !typeString.equals("")) { type = Presence.Type.fromString(typeString); } Presence presence = new Presence(type); presence.setTo(ParserUtils.getJidAttribute(parser, "to")); presence.setFrom(ParserUtils.getJidAttribute(parser, "from")); presence.setStanzaId(parser.getAttributeValue("", "id")); String language = ParserUtils.getXmlLang(parser); if (language != null && !"".equals(language.trim())) { // CHECKSTYLE:OFF presence.setLanguage(language); // CHECKSTYLE:ON } // Parse sub-elements outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); switch (elementName) { case "status": presence.setStatus(parser.nextText()); break; case "priority": int priority = Integer.parseInt(parser.nextText()); presence.setPriority(priority); break; case "show": String modeText = parser.nextText(); if (StringUtils.isNotEmpty(modeText)) { presence.setMode(Presence.Mode.fromString(modeText)); } else { // Some implementations send presence stanzas with a // '<show />' element, which is a invalid XMPP presence // stanza according to RFC 6121 4.7.2.1 LOGGER.warning("Empty or null mode text in presence show element form " + presence.getFrom() + " with id '" + presence.getStanzaId() + "' which is invalid according to RFC6121 4.7.2.1"); } break; case "error": presence.setError(parseError(parser, presenceXmlEnvironment)); break; default: // Otherwise, it must be a packet extension. // Be extra robust: Skip PacketExtensions that cause Exceptions, instead of // failing completely here. See SMACK-390 for more information. try { PacketParserUtils.addExtensionElement(presence, parser, elementName, namespace, presenceXmlEnvironment); } catch (Exception e) { LOGGER.warning("Failed to parse extension element in Presence stanza: \"" + e + "\" from: '" + presence.getFrom() + " id: '" + presence.getStanzaId() + "'"); } break; } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } return presence; }
java
public static Presence parsePresence(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); XmlEnvironment presenceXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); Presence.Type type = Presence.Type.available; String typeString = parser.getAttributeValue("", "type"); if (typeString != null && !typeString.equals("")) { type = Presence.Type.fromString(typeString); } Presence presence = new Presence(type); presence.setTo(ParserUtils.getJidAttribute(parser, "to")); presence.setFrom(ParserUtils.getJidAttribute(parser, "from")); presence.setStanzaId(parser.getAttributeValue("", "id")); String language = ParserUtils.getXmlLang(parser); if (language != null && !"".equals(language.trim())) { // CHECKSTYLE:OFF presence.setLanguage(language); // CHECKSTYLE:ON } // Parse sub-elements outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); switch (elementName) { case "status": presence.setStatus(parser.nextText()); break; case "priority": int priority = Integer.parseInt(parser.nextText()); presence.setPriority(priority); break; case "show": String modeText = parser.nextText(); if (StringUtils.isNotEmpty(modeText)) { presence.setMode(Presence.Mode.fromString(modeText)); } else { // Some implementations send presence stanzas with a // '<show />' element, which is a invalid XMPP presence // stanza according to RFC 6121 4.7.2.1 LOGGER.warning("Empty or null mode text in presence show element form " + presence.getFrom() + " with id '" + presence.getStanzaId() + "' which is invalid according to RFC6121 4.7.2.1"); } break; case "error": presence.setError(parseError(parser, presenceXmlEnvironment)); break; default: // Otherwise, it must be a packet extension. // Be extra robust: Skip PacketExtensions that cause Exceptions, instead of // failing completely here. See SMACK-390 for more information. try { PacketParserUtils.addExtensionElement(presence, parser, elementName, namespace, presenceXmlEnvironment); } catch (Exception e) { LOGGER.warning("Failed to parse extension element in Presence stanza: \"" + e + "\" from: '" + presence.getFrom() + " id: '" + presence.getStanzaId() + "'"); } break; } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } return presence; }
[ "public", "static", "Presence", "parsePresence", "(", "XmlPullParser", "parser", ",", "XmlEnvironment", "outerXmlEnvironment", ")", "throws", "XmlPullParserException", ",", "IOException", ",", "SmackParsingException", "{", "ParserUtils", ".", "assertAtStartTag", "(", "parser", ")", ";", "final", "int", "initialDepth", "=", "parser", ".", "getDepth", "(", ")", ";", "XmlEnvironment", "presenceXmlEnvironment", "=", "XmlEnvironment", ".", "from", "(", "parser", ",", "outerXmlEnvironment", ")", ";", "Presence", ".", "Type", "type", "=", "Presence", ".", "Type", ".", "available", ";", "String", "typeString", "=", "parser", ".", "getAttributeValue", "(", "\"\"", ",", "\"type\"", ")", ";", "if", "(", "typeString", "!=", "null", "&&", "!", "typeString", ".", "equals", "(", "\"\"", ")", ")", "{", "type", "=", "Presence", ".", "Type", ".", "fromString", "(", "typeString", ")", ";", "}", "Presence", "presence", "=", "new", "Presence", "(", "type", ")", ";", "presence", ".", "setTo", "(", "ParserUtils", ".", "getJidAttribute", "(", "parser", ",", "\"to\"", ")", ")", ";", "presence", ".", "setFrom", "(", "ParserUtils", ".", "getJidAttribute", "(", "parser", ",", "\"from\"", ")", ")", ";", "presence", ".", "setStanzaId", "(", "parser", ".", "getAttributeValue", "(", "\"\"", ",", "\"id\"", ")", ")", ";", "String", "language", "=", "ParserUtils", ".", "getXmlLang", "(", "parser", ")", ";", "if", "(", "language", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "language", ".", "trim", "(", ")", ")", ")", "{", "// CHECKSTYLE:OFF", "presence", ".", "setLanguage", "(", "language", ")", ";", "// CHECKSTYLE:ON", "}", "// Parse sub-elements", "outerloop", ":", "while", "(", "true", ")", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "switch", "(", "eventType", ")", "{", "case", "XmlPullParser", ".", "START_TAG", ":", "String", "elementName", "=", "parser", ".", "getName", "(", ")", ";", "String", "namespace", "=", "parser", ".", "getNamespace", "(", ")", ";", "switch", "(", "elementName", ")", "{", "case", "\"status\"", ":", "presence", ".", "setStatus", "(", "parser", ".", "nextText", "(", ")", ")", ";", "break", ";", "case", "\"priority\"", ":", "int", "priority", "=", "Integer", ".", "parseInt", "(", "parser", ".", "nextText", "(", ")", ")", ";", "presence", ".", "setPriority", "(", "priority", ")", ";", "break", ";", "case", "\"show\"", ":", "String", "modeText", "=", "parser", ".", "nextText", "(", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "modeText", ")", ")", "{", "presence", ".", "setMode", "(", "Presence", ".", "Mode", ".", "fromString", "(", "modeText", ")", ")", ";", "}", "else", "{", "// Some implementations send presence stanzas with a", "// '<show />' element, which is a invalid XMPP presence", "// stanza according to RFC 6121 4.7.2.1", "LOGGER", ".", "warning", "(", "\"Empty or null mode text in presence show element form \"", "+", "presence", ".", "getFrom", "(", ")", "+", "\" with id '\"", "+", "presence", ".", "getStanzaId", "(", ")", "+", "\"' which is invalid according to RFC6121 4.7.2.1\"", ")", ";", "}", "break", ";", "case", "\"error\"", ":", "presence", ".", "setError", "(", "parseError", "(", "parser", ",", "presenceXmlEnvironment", ")", ")", ";", "break", ";", "default", ":", "// Otherwise, it must be a packet extension.", "// Be extra robust: Skip PacketExtensions that cause Exceptions, instead of", "// failing completely here. See SMACK-390 for more information.", "try", "{", "PacketParserUtils", ".", "addExtensionElement", "(", "presence", ",", "parser", ",", "elementName", ",", "namespace", ",", "presenceXmlEnvironment", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "warning", "(", "\"Failed to parse extension element in Presence stanza: \\\"\"", "+", "e", "+", "\"\\\" from: '\"", "+", "presence", ".", "getFrom", "(", ")", "+", "\" id: '\"", "+", "presence", ".", "getStanzaId", "(", ")", "+", "\"'\"", ")", ";", "}", "break", ";", "}", "break", ";", "case", "XmlPullParser", ".", "END_TAG", ":", "if", "(", "parser", ".", "getDepth", "(", ")", "==", "initialDepth", ")", "{", "break", "outerloop", ";", "}", "break", ";", "}", "}", "return", "presence", ";", "}" ]
Parses a presence packet. @param parser the XML parser, positioned at the start of a presence packet. @param outerXmlEnvironment the outer XML environment (optional). @return a Presence packet. @throws IOException @throws XmlPullParserException @throws SmackParsingException
[ "Parses", "a", "presence", "packet", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java#L522-L598
27,096
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
PacketParserUtils.parseIQ
public static IQ parseIQ(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); XmlEnvironment iqXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); IQ iqPacket = null; StanzaError.Builder error = null; final String id = parser.getAttributeValue("", "id"); final Jid to = ParserUtils.getJidAttribute(parser, "to"); final Jid from = ParserUtils.getJidAttribute(parser, "from"); final IQ.Type type = IQ.Type.fromString(parser.getAttributeValue("", "type")); outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); switch (elementName) { case "error": error = PacketParserUtils.parseError(parser, iqXmlEnvironment); break; // Otherwise, see if there is a registered provider for // this element name and namespace. default: IQProvider<IQ> provider = ProviderManager.getIQProvider(elementName, namespace); if (provider != null) { iqPacket = provider.parse(parser, outerXmlEnvironment); } // Note that if we reach this code, it is guranteed that the result IQ contained a child element // (RFC 6120 § 8.2.3 6) because otherwhise we would have reached the END_TAG first. else { // No Provider found for the IQ stanza, parse it to an UnparsedIQ instance // so that the content of the IQ can be examined later on iqPacket = new UnparsedIQ(elementName, namespace, parseElement(parser)); } break; } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } // Decide what to do when an IQ packet was not understood if (iqPacket == null) { switch (type) { case error: // If an IQ packet wasn't created above, create an empty error IQ packet. iqPacket = new ErrorIQ(error); break; case result: iqPacket = new EmptyResultIQ(); break; default: break; } } // Set basic values on the iq packet. iqPacket.setStanzaId(id); iqPacket.setTo(to); iqPacket.setFrom(from); iqPacket.setType(type); iqPacket.setError(error); return iqPacket; }
java
public static IQ parseIQ(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws Exception { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); XmlEnvironment iqXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment); IQ iqPacket = null; StanzaError.Builder error = null; final String id = parser.getAttributeValue("", "id"); final Jid to = ParserUtils.getJidAttribute(parser, "to"); final Jid from = ParserUtils.getJidAttribute(parser, "from"); final IQ.Type type = IQ.Type.fromString(parser.getAttributeValue("", "type")); outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String elementName = parser.getName(); String namespace = parser.getNamespace(); switch (elementName) { case "error": error = PacketParserUtils.parseError(parser, iqXmlEnvironment); break; // Otherwise, see if there is a registered provider for // this element name and namespace. default: IQProvider<IQ> provider = ProviderManager.getIQProvider(elementName, namespace); if (provider != null) { iqPacket = provider.parse(parser, outerXmlEnvironment); } // Note that if we reach this code, it is guranteed that the result IQ contained a child element // (RFC 6120 § 8.2.3 6) because otherwhise we would have reached the END_TAG first. else { // No Provider found for the IQ stanza, parse it to an UnparsedIQ instance // so that the content of the IQ can be examined later on iqPacket = new UnparsedIQ(elementName, namespace, parseElement(parser)); } break; } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } // Decide what to do when an IQ packet was not understood if (iqPacket == null) { switch (type) { case error: // If an IQ packet wasn't created above, create an empty error IQ packet. iqPacket = new ErrorIQ(error); break; case result: iqPacket = new EmptyResultIQ(); break; default: break; } } // Set basic values on the iq packet. iqPacket.setStanzaId(id); iqPacket.setTo(to); iqPacket.setFrom(from); iqPacket.setType(type); iqPacket.setError(error); return iqPacket; }
[ "public", "static", "IQ", "parseIQ", "(", "XmlPullParser", "parser", ",", "XmlEnvironment", "outerXmlEnvironment", ")", "throws", "Exception", "{", "ParserUtils", ".", "assertAtStartTag", "(", "parser", ")", ";", "final", "int", "initialDepth", "=", "parser", ".", "getDepth", "(", ")", ";", "XmlEnvironment", "iqXmlEnvironment", "=", "XmlEnvironment", ".", "from", "(", "parser", ",", "outerXmlEnvironment", ")", ";", "IQ", "iqPacket", "=", "null", ";", "StanzaError", ".", "Builder", "error", "=", "null", ";", "final", "String", "id", "=", "parser", ".", "getAttributeValue", "(", "\"\"", ",", "\"id\"", ")", ";", "final", "Jid", "to", "=", "ParserUtils", ".", "getJidAttribute", "(", "parser", ",", "\"to\"", ")", ";", "final", "Jid", "from", "=", "ParserUtils", ".", "getJidAttribute", "(", "parser", ",", "\"from\"", ")", ";", "final", "IQ", ".", "Type", "type", "=", "IQ", ".", "Type", ".", "fromString", "(", "parser", ".", "getAttributeValue", "(", "\"\"", ",", "\"type\"", ")", ")", ";", "outerloop", ":", "while", "(", "true", ")", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "switch", "(", "eventType", ")", "{", "case", "XmlPullParser", ".", "START_TAG", ":", "String", "elementName", "=", "parser", ".", "getName", "(", ")", ";", "String", "namespace", "=", "parser", ".", "getNamespace", "(", ")", ";", "switch", "(", "elementName", ")", "{", "case", "\"error\"", ":", "error", "=", "PacketParserUtils", ".", "parseError", "(", "parser", ",", "iqXmlEnvironment", ")", ";", "break", ";", "// Otherwise, see if there is a registered provider for", "// this element name and namespace.", "default", ":", "IQProvider", "<", "IQ", ">", "provider", "=", "ProviderManager", ".", "getIQProvider", "(", "elementName", ",", "namespace", ")", ";", "if", "(", "provider", "!=", "null", ")", "{", "iqPacket", "=", "provider", ".", "parse", "(", "parser", ",", "outerXmlEnvironment", ")", ";", "}", "// Note that if we reach this code, it is guranteed that the result IQ contained a child element", "// (RFC 6120 § 8.2.3 6) because otherwhise we would have reached the END_TAG first.", "else", "{", "// No Provider found for the IQ stanza, parse it to an UnparsedIQ instance", "// so that the content of the IQ can be examined later on", "iqPacket", "=", "new", "UnparsedIQ", "(", "elementName", ",", "namespace", ",", "parseElement", "(", "parser", ")", ")", ";", "}", "break", ";", "}", "break", ";", "case", "XmlPullParser", ".", "END_TAG", ":", "if", "(", "parser", ".", "getDepth", "(", ")", "==", "initialDepth", ")", "{", "break", "outerloop", ";", "}", "break", ";", "}", "}", "// Decide what to do when an IQ packet was not understood", "if", "(", "iqPacket", "==", "null", ")", "{", "switch", "(", "type", ")", "{", "case", "error", ":", "// If an IQ packet wasn't created above, create an empty error IQ packet.", "iqPacket", "=", "new", "ErrorIQ", "(", "error", ")", ";", "break", ";", "case", "result", ":", "iqPacket", "=", "new", "EmptyResultIQ", "(", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "// Set basic values on the iq packet.", "iqPacket", ".", "setStanzaId", "(", "id", ")", ";", "iqPacket", ".", "setTo", "(", "to", ")", ";", "iqPacket", ".", "setFrom", "(", "from", ")", ";", "iqPacket", ".", "setType", "(", "type", ")", ";", "iqPacket", ".", "setError", "(", "error", ")", ";", "return", "iqPacket", ";", "}" ]
Parses an IQ packet. @param parser the XML parser, positioned at the start of an IQ packet. @param outerXmlEnvironment the outer XML environment (optional). @return an IQ object. @throws Exception
[ "Parses", "an", "IQ", "packet", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java#L612-L682
27,097
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
PacketParserUtils.parseMechanisms
public static Collection<String> parseMechanisms(XmlPullParser parser) throws XmlPullParserException, IOException { List<String> mechanisms = new ArrayList<String>(); boolean done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { String elementName = parser.getName(); if (elementName.equals("mechanism")) { mechanisms.add(parser.nextText()); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("mechanisms")) { done = true; } } } return mechanisms; }
java
public static Collection<String> parseMechanisms(XmlPullParser parser) throws XmlPullParserException, IOException { List<String> mechanisms = new ArrayList<String>(); boolean done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { String elementName = parser.getName(); if (elementName.equals("mechanism")) { mechanisms.add(parser.nextText()); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("mechanisms")) { done = true; } } } return mechanisms; }
[ "public", "static", "Collection", "<", "String", ">", "parseMechanisms", "(", "XmlPullParser", "parser", ")", "throws", "XmlPullParserException", ",", "IOException", "{", "List", "<", "String", ">", "mechanisms", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "boolean", "done", "=", "false", ";", "while", "(", "!", "done", ")", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "if", "(", "eventType", "==", "XmlPullParser", ".", "START_TAG", ")", "{", "String", "elementName", "=", "parser", ".", "getName", "(", ")", ";", "if", "(", "elementName", ".", "equals", "(", "\"mechanism\"", ")", ")", "{", "mechanisms", ".", "add", "(", "parser", ".", "nextText", "(", ")", ")", ";", "}", "}", "else", "if", "(", "eventType", "==", "XmlPullParser", ".", "END_TAG", ")", "{", "if", "(", "parser", ".", "getName", "(", ")", ".", "equals", "(", "\"mechanisms\"", ")", ")", "{", "done", "=", "true", ";", "}", "}", "}", "return", "mechanisms", ";", "}" ]
Parse the available SASL mechanisms reported from the server. @param parser the XML parser, positioned at the start of the mechanisms stanza. @return a collection of Stings with the mechanisms included in the mechanisms stanza. @throws IOException @throws XmlPullParserException
[ "Parse", "the", "available", "SASL", "mechanisms", "reported", "from", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java#L692-L712
27,098
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
PacketParserUtils.parseCompressionFeature
public static Compress.Feature parseCompressionFeature(XmlPullParser parser) throws IOException, XmlPullParserException { assert (parser.getEventType() == XmlPullParser.START_TAG); String name; final int initialDepth = parser.getDepth(); List<String> methods = new LinkedList<>(); outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: name = parser.getName(); switch (name) { case "method": methods.add(parser.nextText()); break; } break; case XmlPullParser.END_TAG: name = parser.getName(); switch (name) { case Compress.Feature.ELEMENT: if (parser.getDepth() == initialDepth) { break outerloop; } } } } assert (parser.getEventType() == XmlPullParser.END_TAG); assert (parser.getDepth() == initialDepth); return new Compress.Feature(methods); }
java
public static Compress.Feature parseCompressionFeature(XmlPullParser parser) throws IOException, XmlPullParserException { assert (parser.getEventType() == XmlPullParser.START_TAG); String name; final int initialDepth = parser.getDepth(); List<String> methods = new LinkedList<>(); outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: name = parser.getName(); switch (name) { case "method": methods.add(parser.nextText()); break; } break; case XmlPullParser.END_TAG: name = parser.getName(); switch (name) { case Compress.Feature.ELEMENT: if (parser.getDepth() == initialDepth) { break outerloop; } } } } assert (parser.getEventType() == XmlPullParser.END_TAG); assert (parser.getDepth() == initialDepth); return new Compress.Feature(methods); }
[ "public", "static", "Compress", ".", "Feature", "parseCompressionFeature", "(", "XmlPullParser", "parser", ")", "throws", "IOException", ",", "XmlPullParserException", "{", "assert", "(", "parser", ".", "getEventType", "(", ")", "==", "XmlPullParser", ".", "START_TAG", ")", ";", "String", "name", ";", "final", "int", "initialDepth", "=", "parser", ".", "getDepth", "(", ")", ";", "List", "<", "String", ">", "methods", "=", "new", "LinkedList", "<>", "(", ")", ";", "outerloop", ":", "while", "(", "true", ")", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "switch", "(", "eventType", ")", "{", "case", "XmlPullParser", ".", "START_TAG", ":", "name", "=", "parser", ".", "getName", "(", ")", ";", "switch", "(", "name", ")", "{", "case", "\"method\"", ":", "methods", ".", "add", "(", "parser", ".", "nextText", "(", ")", ")", ";", "break", ";", "}", "break", ";", "case", "XmlPullParser", ".", "END_TAG", ":", "name", "=", "parser", ".", "getName", "(", ")", ";", "switch", "(", "name", ")", "{", "case", "Compress", ".", "Feature", ".", "ELEMENT", ":", "if", "(", "parser", ".", "getDepth", "(", ")", "==", "initialDepth", ")", "{", "break", "outerloop", ";", "}", "}", "}", "}", "assert", "(", "parser", ".", "getEventType", "(", ")", "==", "XmlPullParser", ".", "END_TAG", ")", ";", "assert", "(", "parser", ".", "getDepth", "(", ")", "==", "initialDepth", ")", ";", "return", "new", "Compress", ".", "Feature", "(", "methods", ")", ";", "}" ]
Parse the Compression Feature reported from the server. @param parser the XML parser, positioned at the start of the compression stanza. @return The CompressionFeature stream element @throws IOException @throws XmlPullParserException if an exception occurs while parsing the stanza.
[ "Parse", "the", "Compression", "Feature", "reported", "from", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java#L722-L752
27,099
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
PacketParserUtils.parseSASLFailure
public static SASLFailure parseSASLFailure(XmlPullParser parser) throws XmlPullParserException, IOException { final int initialDepth = parser.getDepth(); String condition = null; Map<String, String> descriptiveTexts = null; outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String name = parser.getName(); if (name.equals("text")) { descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts); } else { assert (condition == null); condition = parser.getName(); } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } return new SASLFailure(condition, descriptiveTexts); }
java
public static SASLFailure parseSASLFailure(XmlPullParser parser) throws XmlPullParserException, IOException { final int initialDepth = parser.getDepth(); String condition = null; Map<String, String> descriptiveTexts = null; outerloop: while (true) { int eventType = parser.next(); switch (eventType) { case XmlPullParser.START_TAG: String name = parser.getName(); if (name.equals("text")) { descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts); } else { assert (condition == null); condition = parser.getName(); } break; case XmlPullParser.END_TAG: if (parser.getDepth() == initialDepth) { break outerloop; } break; } } return new SASLFailure(condition, descriptiveTexts); }
[ "public", "static", "SASLFailure", "parseSASLFailure", "(", "XmlPullParser", "parser", ")", "throws", "XmlPullParserException", ",", "IOException", "{", "final", "int", "initialDepth", "=", "parser", ".", "getDepth", "(", ")", ";", "String", "condition", "=", "null", ";", "Map", "<", "String", ",", "String", ">", "descriptiveTexts", "=", "null", ";", "outerloop", ":", "while", "(", "true", ")", "{", "int", "eventType", "=", "parser", ".", "next", "(", ")", ";", "switch", "(", "eventType", ")", "{", "case", "XmlPullParser", ".", "START_TAG", ":", "String", "name", "=", "parser", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "\"text\"", ")", ")", "{", "descriptiveTexts", "=", "parseDescriptiveTexts", "(", "parser", ",", "descriptiveTexts", ")", ";", "}", "else", "{", "assert", "(", "condition", "==", "null", ")", ";", "condition", "=", "parser", ".", "getName", "(", ")", ";", "}", "break", ";", "case", "XmlPullParser", ".", "END_TAG", ":", "if", "(", "parser", ".", "getDepth", "(", ")", "==", "initialDepth", ")", "{", "break", "outerloop", ";", "}", "break", ";", "}", "}", "return", "new", "SASLFailure", "(", "condition", ",", "descriptiveTexts", ")", ";", "}" ]
Parses SASL authentication error packets. @param parser the XML parser. @return a SASL Failure packet. @throws IOException @throws XmlPullParserException
[ "Parses", "SASL", "authentication", "error", "packets", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java#L780-L805