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

📄 xdatafieldoption.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  David Waite <a href="mailto:dwaite@jabber.com">
 *                      <i>&lt;dwaite@jabber.com&gt;</i></a>
 *
 * @author  $Author: chris $
 * @version $Revision: 1.1 $
 *
 * j.komzak
 * Changed into XDataFieldOption
 */

package edu.ou.kmi.buddyspace.xml;

/*
 * XDataFieldOption.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2003
 *
 *
 * Created on 5 February 2003, 13:11
 */

import java.util.Vector;
import java.util.Enumeration;
import org.jabber.jabberbeans.*;
import org.jabber.jabberbeans.Extension.*;

/**
 * <code>XDataFieldOption</code> contains &lt;option&gt tag from jabber:x:data fields.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public class XDataFieldOption
    extends XMLData
    implements MessageExtension, QueryExtension
{
    /** Attributes. */
    private String label;
    private String value;
    private String data;
    
    /**
     * Creates a new <code>XDataFieldOption</code> instance, based on the builder
     * state.
     *
     * @param builder an <code>XDataFieldOptionBuilder</code> value
     * @exception InstantiationException if malformed or insufficient data is
     * in the builder.
     */
    public XDataFieldOption(XDataFieldOptionBuilder builder)
        throws InstantiationException
    {
        label = builder.getLabel();
        value = builder.getValue();
        data = builder.getData();
    }
    
    public String getLabel() {
        return label;
    }

    public String getValue() {
        return value;
    }

    public String getData() {
        return data;
    }

    /**
     * <code>appendItem</code> converts this packet to XML. 
     * It then appends it to a StringBuffer.
     *
     * @param retval The <code>StringBuffer</code> to append to
     */
    public void appendItem(StringBuffer retval)
    {
	retval.append("<option"
                        + ((label != null)? " label=\"" + label + "\"" : ""));
                
        boolean emptyTag = true;
        
        if (value != null) {
            emptyTag = false;
            retval.append(">\n<value>");
            escapeString(retval, value);
            retval.append("</value>\n");
        }
            
        if (data != null) {
            if (emptyTag)
                retval.append(">");
            emptyTag = false;
            escapeString(retval, data);
        }
            
        if (!emptyTag)
            retval.append("</option>\n");
        else
            retval.append("/>\n");
    }
}

⌨️ 快捷键说明

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