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

📄 characterdataimpl.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
字号:
/** * org/ozone-db/xml/dom/CharacterData.java * * The contents of this file are subject to the OpenXML Public * License Version 1.0; you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.openxml.org/license.html * * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING * RIGHTS AND LIMITATIONS UNDER THE LICENSE. * * The Initial Developer of this code under the License is Assaf Arkin. * Portions created by Assaf Arkin are Copyright (C) 1998, 1999. * All Rights Reserved. *//** * Changes for Persistent DOM running with ozone are * Copyright 1999 by SMB GmbH. All rights reserved. */package org.ozoneDB.xml.dom;import org.w3c.dom.*;/** * Abstract data class has methods for interacting directly with data contained * in it. Derived classes {@link org.w3c.dom.Text}, {@link org.w3c.dom.Comment} * and {@link org.w3c.dom.CDATASection} provide full implementation of this class. * <P> * The initial data is guaranteed to be a zero length string, not null. Setting * the data to null will always return an empty string. * <P> * Notes: * <OL> * <LI>Node does not support childern * </OL> * * * @version $Revision: 1.11 $ $Date: 2000/10/28 16:55:22 $ * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a> * @see org.w3c.dom.CharacterData * @see NodeImpl */public abstract class CharacterDataImpl extends NodeImpl implements CharacterDataProxy {        final static long serialVersionUID = 1;            public final String getData() {        // Same as calling getNodeValue().        return getNodeValue();    }             public final void setData( String value ) throws DOMException {        setNodeValue( value == null ? "" : value );    }             public final int getLength() {        return getNodeValue().length();    }             public synchronized final String substringData( int start, int count ) throws DOMException {        // Make sure that start and start + count are not outside the range of        // the data.        if (start < 0 || start >= getLength()) {            throw new DOMExceptionImpl( DOMException.INDEX_SIZE_ERR, "'start' out of data size." );        }         if (start + count > getLength()) {            throw new DOMExceptionImpl( DOMException.INDEX_SIZE_ERR, "'start + count' out of data size." );        }         // Cut the data and return.        return getNodeValue().substring( start, count );    }             public synchronized final void appendData( String value ) {        if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         if (value == null) {            value = "";        }         setNodeValue( getNodeValue() + value );    }             public synchronized final void insertData( int offset, String value ) throws DOMException {        if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         if (value == null) {            value = "";        }         // Make sure that offest is not outside the range of the data.        if (offset < 0 || offset > getLength()) {            throw new DOMExceptionImpl( DOMException.INDEX_SIZE_ERR, "'start' out of data size." );        }         // If offset is zero, prepend value to data. If offest is size        // of data, append value to data.        if (offset == 0) {            setNodeValue( value + getNodeValue() );        } else if (offset == getLength()) {            setNodeValue( getNodeValue() + value );        } else {            // Cut data in the middle and combine all three parts.            setNodeValue( getNodeValue().substring( 0, offset ) + value + getNodeValue().substring( offset ) );        }     }             public synchronized final void deleteData( int offset, int count ) throws DOMException {        // Make sure that offest and offset + count are not outside        // the range of the data.        if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         if (offset < 0 || offset >= getLength()) {            throw new DOMExceptionImpl( DOMException.INDEX_SIZE_ERR, "'start' out of data size." );        }         if (offset + count > getLength()) {            throw new DOMExceptionImpl( DOMException.INDEX_SIZE_ERR, "'start + count' out of data size." );        }         if (count == 0) {            return;        }                 // If offest + count reach end of data, it's easier to cut end of data.        // If offest is zero, it's easier to cut beginning of data.        if (offset + count == getLength()) {            setNodeValue( getNodeValue().substring( 0, offset ) );        } else if (offset == 0) {            setNodeValue( getNodeValue().substring( count ) );        } else {            // Cut data in the middle and combine the two parts.            setNodeValue( getNodeValue().substring( 0, offset ) + getNodeValue().substring( offset + count ) );        }     }             public synchronized final void replaceData( int offset, int count, String value ) throws DOMException {        if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         if (value == null) {            value = "";        }         // Cheap implementation performs deletion and insertion. Both methods        // are synchronized, but replace() must also be synchronized to prevent        // mid-call changes.        deleteData( offset, count );        insertData( offset, value );    }             protected final boolean supportsChildern() {        return false;    }             /**     * Constructor for derived classes.     *     * @param owner The owner of this document     * @param name The name of this node type     * @param value Initial value or empty string     */    protected CharacterDataImpl( DocumentImpl owner, String name, String value ) {        super();        init( owner, name, value );    }            public CharacterDataImpl() {        super();    }            public void init( DocumentProxy owner, String name, String value ) {        super.init( owner, name, value, false );    }     }

⌨️ 快捷键说明

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