discoidentity.java

来自「一款即时通讯软件」· Java 代码 · 共 70 行

JAVA
70
字号
package edu.ou.kmi.buddyspace.plugins.disco.xml;

/*
 * DiscoIdentity.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2003
 *
 *
 * Created on 20 August 2003, 8:45
 */

import java.io.Serializable;
import java.util.*;
import org.jabber.jabberbeans.util.*;
import org.jabber.jabberbeans.*;
import org.jabber.jabberbeans.Extension.*;
import org.xml.sax.AttributeList;
import org.xml.sax.helpers.AttributeListImpl;

/**
 * <code>DiscoIdentity</code> contains &lt;identity&gt tag from disco#info.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public class DiscoIdentity
    extends XMLData
    implements QueryExtension
{
    /** Attributes. */
    private AttributeList attributes;
    
    /**
     * Creates a new <code>DiscoIdentity</code> instance, based on the builder
     * state.
     *
     * @param builder an <code>DiscoIdentityBuilder</code> value
     * @exception InstantiationException if malformed or insufficient data is
     * in the builder.
     */
    public DiscoIdentity(DiscoIdentityBuilder builder)
        throws InstantiationException
    {
        attributes = builder.getAttributes();
    }
    
    
    public String getAttribute(String name) {
        return (attributes == null || name == null)? null : attributes.getValue(name);
    }
    
    
    /**
     * <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("<identity");
        
        for (int i=0; attributes != null && i < attributes.getLength(); i++) {
            appendAttrib(retval, attributes.getName(i), attributes.getValue(i));
        }
        
        retval.append("/>");
    }
}

⌨️ 快捷键说明

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