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

📄 simpleelementhandler.java

📁 一个自然语言处理的Java开源工具包。LingPipe目前已有很丰富的功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * LingPipe v. 3.5 * Copyright (C) 2003-2008 Alias-i * * This program is licensed under the Alias-i Royalty Free License * Version 1 WITHOUT ANY WARRANTY, without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the Alias-i * Royalty Free License Version 1 for more details. * * You should have received a copy of the Alias-i Royalty Free License * Version 1 along with this program; if not, visit * http://alias-i.com/lingpipe/licenses/lingpipe-license-1.txt or contact * Alias-i, Inc. at 181 North 11th Street, Suite 401, Brooklyn, NY 11211, * +1 (718) 290-9170. */package com.aliasi.xml;import org.xml.sax.Attributes;import org.xml.sax.SAXException;import org.xml.sax.helpers.AttributesImpl;import org.xml.sax.helpers.DefaultHandler;/** * A <code>SimpleElementHandler</code> is a default handler that * supplies utilities for simple elements and attributes. * * @author  Bob Carpenter * @version 2.3 * @since   LingPipe1.0 */public class SimpleElementHandler extends DefaultHandler {    /**     * Converts the string to a character array in order to     * call {@link #characters(char[],int,int)} to handle the     * characters.     *     * @param s String whose characters are to be handled.     *     * @throws SAXException if the handler throws a SAX exception.     */    public void characters(String s) throws SAXException {        characters(this,s);    }    /**     * Handls the specified character array by delegation to     * {@link #characters(char[],int,int)}.     *     * @param cs Character array to be handled.     *     * @throws SAXException if the handler throws a SAX exception.     */    public void characters(char[] cs) throws SAXException {        characters(this,cs);    }    /**     * Starts an element with a <code>null</code> namespace     * and no attributes.     *     * @param name Name of element to start.     *     * @throws SAXException if the contained hanlder throws a SAX     * exception.     *     * @see #startSimpleElement(String,Attributes)     */    public void startSimpleElement(String name) throws SAXException {        startSimpleElement(this,name);    }    /**     * Starts an element with a <code>null</code> namespace and a     * single attribute and value.     *     * @param name Name of element to start.     * @param att Name of single attribute.     * @param value The attribute's value.     *     * @throws SAXException if the contained hanlder throws a SAX     * exception.     *     * @see #startSimpleElement(String,Attributes)     */    public void startSimpleElement(String name, String att, String value)        throws SAXException {        startSimpleElement(this,name,att,value);    }    /**     * Starts an element with a <code>null</code> namespace and a     * pair of attributes and values.     *     * @param name Name of element to start.     * @param att1 Name of the first attribute.     * @param val1 Value of the first attribute.     * @param att2 Name of the second attribute.     * @param val2 Value of the second attribute.     *     * @throws SAXException if the contained hanlder throws a SAX     * exception.     */    public void startSimpleElement(String name, String att1, String val1,                                   String att2, String val2)        throws SAXException {        Attributes atts = createAttributes(att1,val1,att2,val2);        startSimpleElement(name,atts);    }    /**     * Starts an element with a <code>null</code> namespace and the     * specified local name, which is also provided as the qualified     * name.     *     * @param localName Local name of element to start.     * @param atts Attributes for this element.     *     * @throws SAXException if the contained hanlder throws a SAX     * exception.     */    public void startSimpleElement(String localName, Attributes atts)        throws SAXException {        startSimpleElement(this,localName,atts);    }    /**     * End an element with a <code>null</code> namespace, using     * the local name for both local and qualified names.     *     * @param localName Local name of element to end.     * @throws SAXException if the contained hanlder throws a SAX     * exception.     */    public void endSimpleElement(String localName) throws SAXException {        endSimpleElement(this,localName);    }    /**     * Starts and then ends a simple element of the specified     * local name.     *     * @param localName Name of element.     * @throws SAXException If the contained handler throws a SAX     * exception.     */    public void startEndSimpleElement(String localName)         throws SAXException {        startSimpleElement(localName);        endSimpleElement(localName);    }    /**     * Starts and then ends a simple element of the specified     * local name with the specified attributes.     *     * @param localName Name of element.     * @param atts Attributes for the element.     * @throws SAXException If the contained handler throws a SAX     * exception.     */    public void startEndSimpleElement(String localName, Attributes atts)         throws SAXException {            startSimpleElement(localName,atts);        endSimpleElement(localName);    }        /**     * Add a local name and value to an attributes implementation     * as type <code>"CDATA"</code>.  Sets both local and qualified     * name on attribute.     *     * @param atts Attributes to which the specified attribute and     * value are added.     * @param localName Local name of attribute to add.     * @param value Value of attribute to add.     */    public static void addSimpleAttribute(AttributesImpl atts,                                          String localName,                                          String value) {        atts.addAttribute(null,localName,                          localName,CDATA_ATTS_TYPE,value);    }    /**     * An implementation of <code>Attributes</code> with no     * attributes.     */    public static final Attributes EMPTY_ATTS = new AttributesImpl();    /**     * Create an attributes list with the specified attribute     * and value.     *     * @param attribute Name of attribute.     * @param value Value of  attribute.     * @return Resulting attribute-value list.     */    public static final Attributes createAttributes(String attribute,                                                    String value) {        AttributesImpl atts = new AttributesImpl();        addSimpleAttribute(atts,attribute,value);        return atts;    }    /**     * Create an attributes list with the specified pair of     * attributes.     *     * @param attribute1 Name of first attribute.     * @param value1 Value of first attribute.     * @param attribute2 Name of second attribute.     * @param value2 Value of second attribute.     * @return Resulting attribute-value list.     */    public static final Attributes createAttributes(String attribute1,                                                    String value1,                                                    String attribute2,                                                    String value2) {        AttributesImpl atts = new AttributesImpl();        addSimpleAttribute(atts,attribute1,value1);        addSimpleAttribute(atts,attribute2,value2);        return atts;    }    /**     * Create an attributes list with the specified tripe of     * attributes and values.     *     * @param attribute1 Name of first attribute.     * @param value1 Value of first attribute.     * @param attribute2 Name of second attribute.     * @param value2 Value of second attribute.     * @param attribute3 Name of third attribute.

⌨️ 快捷键说明

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