• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * $Revision$
3  * $Date$
4  *
5  * Copyright 2003-2007 Jive Software.
6  *
7  * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 package org.jivesoftware.smackx.workgroup.packet;
21 
22 import org.jivesoftware.smack.packet.PacketExtension;
23 import org.jivesoftware.smack.provider.PacketExtensionProvider;
24 import org.xmlpull.v1.XmlPullParser;
25 
26 public class UserID implements PacketExtension {
27 
28     /**
29      * Element name of the packet extension.
30      */
31     public static final String ELEMENT_NAME = "user";
32 
33     /**
34      * Namespace of the packet extension.
35      */
36     public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
37 
38     private String userID;
39 
UserID(String userID)40     public UserID(String userID) {
41         this.userID = userID;
42     }
43 
getUserID()44     public String getUserID() {
45         return this.userID;
46     }
47 
getElementName()48     public String getElementName() {
49         return ELEMENT_NAME;
50     }
51 
getNamespace()52     public String getNamespace() {
53         return NAMESPACE;
54     }
55 
toXML()56     public String toXML() {
57         StringBuilder buf = new StringBuilder();
58 
59         buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\" ");
60         buf.append("id=\"").append(this.getUserID());
61         buf.append("\"/>");
62 
63         return buf.toString();
64     }
65 
66     public static class Provider implements PacketExtensionProvider {
67 
parseExtension(XmlPullParser parser)68         public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
69             String userID = parser.getAttributeValue("", "id");
70 
71             // Advance to end of extension.
72             parser.next();
73 
74             return new UserID(userID);
75         }
76     }
77 }
78