Shuyi Chen | d7955ce | 2013-05-22 14:51:55 -0700 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2009 Jonas Ã…dahl. |
| 3 | * Copyright 2011-2013 Florian Schmaus |
| 4 | * |
| 5 | * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | package org.jivesoftware.smackx.entitycaps.packet; |
| 19 | |
| 20 | import org.jivesoftware.smack.packet.PacketExtension; |
| 21 | import org.jivesoftware.smackx.entitycaps.EntityCapsManager; |
| 22 | |
| 23 | public class CapsExtension implements PacketExtension { |
| 24 | |
| 25 | private String node, ver, hash; |
| 26 | |
| 27 | public CapsExtension() { |
| 28 | } |
| 29 | |
| 30 | public CapsExtension(String node, String version, String hash) { |
| 31 | this.node = node; |
| 32 | this.ver = version; |
| 33 | this.hash = hash; |
| 34 | } |
| 35 | |
| 36 | public String getElementName() { |
| 37 | return EntityCapsManager.ELEMENT; |
| 38 | } |
| 39 | |
| 40 | public String getNamespace() { |
| 41 | return EntityCapsManager.NAMESPACE; |
| 42 | } |
| 43 | |
| 44 | public String getNode() { |
| 45 | return node; |
| 46 | } |
| 47 | |
| 48 | public void setNode(String node) { |
| 49 | this.node = node; |
| 50 | } |
| 51 | |
| 52 | public String getVer() { |
| 53 | return ver; |
| 54 | } |
| 55 | |
| 56 | public void setVer(String ver) { |
| 57 | this.ver = ver; |
| 58 | } |
| 59 | |
| 60 | public String getHash() { |
| 61 | return hash; |
| 62 | } |
| 63 | |
| 64 | public void setHash(String hash) { |
| 65 | this.hash = hash; |
| 66 | } |
| 67 | |
| 68 | /* |
| 69 | * <c xmlns='http://jabber.org/protocol/caps' |
| 70 | * hash='sha-1' |
| 71 | * node='http://code.google.com/p/exodus' |
| 72 | * ver='QgayPKawpkPSDYmwT/WM94uAlu0='/> |
| 73 | * |
| 74 | */ |
| 75 | public String toXML() { |
| 76 | String xml = "<" + EntityCapsManager.ELEMENT + " xmlns=\"" + EntityCapsManager.NAMESPACE + "\" " + |
| 77 | "hash=\"" + hash + "\" " + |
| 78 | "node=\"" + node + "\" " + |
| 79 | "ver=\"" + ver + "\"/>"; |
| 80 | |
| 81 | return xml; |
| 82 | } |
| 83 | } |