⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iqregister.java

📁 一款即时通讯软件
💻 JAVA
字号:
/*
 *   License
 *
 * The contents of this file are subject to the Jabber Open Source License
 * Version 1.0 (the "License").  You may not copy or use this file, in either
 * source code or executable form, except in compliance with the License.  You
 * may obtain a copy of the License at http://www.jabber.com/license/ or at
 * http://www.opensource.org/.  
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 *   Copyrights
 *
 * Portions created by or assigned to Jabber.com, Inc. are 
 * Copyright (c) 2000 Jabber.com, Inc.  All Rights Reserved.  Contact
 * information for Jabber.com, Inc. is available at http://www.jabber.com/.
 *
 * Portions Copyright (c) 1999-2000 David Waite 
 *
 *   Acknowledgements
 * 
 * Special thanks to the Jabber Open Source Contributors for their
 * suggestions and support of Jabber.
 * 
 *   Changes
 *
 * @author  $Author: chris $
 * @version $Revision: 1.1 $
 *
 * j.komzak
 * Added handling of embedded extensions (like jabber:x:data for forms).
 */

package edu.ou.kmi.buddyspace.xml;

import java.util.*;
import org.jabber.jabberbeans.Extension.Extension;
import org.jabber.jabberbeans.Extension.HashExtension;
import org.jabber.jabberbeans.Extension.QueryExtension;

/**
 * An <code>IQRegister</code> holds the values that would be stored in
 * a jabber:iq:register namespace. This namespace is used to register and
 * deregister accounts with the jabber server and with various transports.
 *
 * NOTE: it is my personal hope that this extension dies a horrible death at
 * a later date, probably at the hand of XML forms.
 *
 * all parameters are subject to interpretation - the names are meant to be 
 * labels to editable text boxes, with instructions being broadcast on how to
 * use the interface.
 *
 * also note that the values do not have default states - <name/> is 
 * represented by name.equals(""), whereas name=null indicates the element 
 * is not present
 *
 * @author  David Waite <a href="mailto:dwaite@jabber.com">
 *                      <i>&lt;dwaite@jabber.com&gt;</i></a>
 * @author  $Author: chris $
 * @version $Revision: 1.1 $
 *
 * @author  Jiri Komzak <a href="mailto:j.komzak@open.ac.uk">
 *                      <i>&lt;j.komzak@open.ac.uk&gt;</i></a>
 * @author  $Author: chris $
 * @version $Revision: 1.1 $
 */
public class IQRegister extends HashExtension
                        implements QueryExtension {
                            
    /** Vector of extension objects contained. */
    private Vector extensions;
    
    /** Creates a new <code>IQRegister</code> instance. */
    public IQRegister(IQRegisterBuilder builder)
        throws InstantiationException
    {
	super(builder);
        extensions = (Vector) builder.extensions().clone();
    }
    
    /**
     * Used to fetch the internal XMLNS, which is used by AppendItem and
     * toString to return the proper XML representation.
     *
     * @return <code>String</code> holding the XML namespace
     */
    protected String getXMLNS()
    {
	return "jabber:iq:register";
    }
    
    
    /**
     * returns an enumeration of <code>extensions</code> contained within this
     * object.
     *
     * @return an <code>Enumeration</code> value
     */
    public Enumeration extensions()
    {
        return extensions.elements();
    }
    
    
    /**
     * <code>appendItem</code> appends the XML representation of the
     * current packet data to the specified <code>StringBuffer</code>.
     *
     * @param retval The <code>StringBuffer</code> to append to
     */
    public void appendItem(StringBuffer retval)
    {
	retval.append("<query xmlns=\"");
	retval.append(getXMLNS());
	retval.append("\">");
        
        Enumeration names=entries.keys();
        if (names!=null)
        {
            while (names.hasMoreElements())
            {
                String name=(String)names.nextElement();
                appendChild(retval,
                              name,
                              (String)entries.get(name));
            }
        }
        
        Enumeration extEnum = extensions.elements();
        while (extEnum.hasMoreElements()) {
            Extension ext = (Extension) extEnum.nextElement();
            ext.appendItem(retval);
        }
        
        retval.append("</query>");
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -