📄 discoidentityhandler.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 $
*
* j.komzak
* Changed to DiscoIdentityHandler
*
*/
package edu.ou.kmi.buddyspace.plugins.disco.xml;
import org.jabber.jabberbeans.*;
import org.jabber.jabberbeans.sax.*;
import org.xml.sax.AttributeList;
import org.xml.sax.SAXException;
/**
* Handler class to build DiscoIdentity objects. This creates xml structure.
*/
public class DiscoIdentityHandler
extends SubHandler
{
/** used to capture data between element tags */
private StringBuffer elementChars;
/** builder for DiscoIdentity objects */
private DiscoIdentityBuilder builder;
/**
* Creates a new <code>DiscoIdentityHandler</code> instance.
*/
public DiscoIdentityHandler() {
super();
builder = new DiscoIdentityBuilder();
};
/**
* Gets called when the underlying engine decides to pass an entity and
* all sub-entities off to your subhandler.<p>
*
* Upon seeing the element that this subhandler handles, we call this
* constructor, passing in the attributes.
*
* @param attributes a value of type 'AttributeList'
*/
public void startHandler(String name, AttributeList attributes)
throws SAXException
{
elementChars = new StringBuffer();
builder.reset();
builder.setAttributes(attributes);
};
/**
* This is an exact copy of the start element in the main handler.
*
* @param name string that holds the element name
* @param attributes AttributeList of attributes going with this element
* @exception SAXException thrown on error (unexpected element)
*/
public void handleStartElement(String name, AttributeList attributes)
throws SAXException
{
elementChars=new StringBuffer();
}
/**
* This is an exact copy of the end element in the main handler
*
* @param name string holding the element name
* @exception SAXException thrown on error
*/
public void handleEndElement(String name)
throws SAXException
{ }
/**
* This is an exact copy of the characters function in the main handler
*
* @param ch character string detected
* @param start start position
* @param length length of string
* @exception SAXException thrown on error
*/
public void characters(char[] ch, int start, int length)
throws SAXException
{
elementChars.append(ch, start, length);
}
/**
* Stophandler is the same as end element, except that it is called saying
* that the subhandler is no longer in scope.
*
* @param nil a value of type ''
*/
public Object stopHandler(String name)
throws SAXException
{
try {
return builder.build();
}
catch (InstantiationException e) {
e.fillInStackTrace();
throw new SAXException(e);
}
}
/**
* received data handler from subobjects. Ignored since this
* handler never creates child handlers
*
* @param subHandler child subhandler which is returning
* @param child Object which the child is returning
*/
public void receiveChildData(SubHandler subHandler, Object child) {
//Add the returned object to the child vector
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -