286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2001-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.impl.xs.opti;
286N/A
286N/Aimport org.w3c.dom.DOMException;
286N/Aimport org.w3c.dom.Node;
286N/A
286N/A/**
286N/A * @xerces.internal
286N/A *
286N/A * @author Neil Graham, IBM
286N/A */
286N/A
286N/Apublic class TextImpl extends DefaultText {
286N/A
286N/A // Data
286N/A String fData = null;
286N/A SchemaDOM fSchemaDOM = null;
286N/A int fRow;
286N/A int fCol;
286N/A
286N/A public TextImpl(StringBuffer str, SchemaDOM sDOM, int row, int col) {
286N/A fData = str.toString();
286N/A fSchemaDOM = sDOM;
286N/A fRow = row;
286N/A fCol = col;
286N/A rawname = prefix = localpart = uri = null;
286N/A nodeType = Node.TEXT_NODE;
286N/A }
286N/A
286N/A //
286N/A // org.w3c.dom.Node methods
286N/A //
286N/A
286N/A public Node getParentNode() {
286N/A return fSchemaDOM.relations[fRow][0];
286N/A }
286N/A
286N/A public Node getPreviousSibling() {
286N/A if (fCol == 1) {
286N/A return null;
286N/A }
286N/A return fSchemaDOM.relations[fRow][fCol-1];
286N/A }
286N/A
286N/A
286N/A public Node getNextSibling() {
286N/A if (fCol == fSchemaDOM.relations[fRow].length-1) {
286N/A return null;
286N/A }
286N/A return fSchemaDOM.relations[fRow][fCol+1];
286N/A }
286N/A
286N/A // CharacterData methods
286N/A
286N/A /**
286N/A * The character data of the node that implements this interface. The DOM
286N/A * implementation may not put arbitrary limits on the amount of data
286N/A * that may be stored in a <code>CharacterData</code> node. However,
286N/A * implementation limits may mean that the entirety of a node's data may
286N/A * not fit into a single <code>DOMString</code>. In such cases, the user
286N/A * may call <code>substringData</code> to retrieve the data in
286N/A * appropriately sized pieces.
286N/A * @exception DOMException
286N/A * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
286N/A * @exception DOMException
286N/A * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
286N/A * fit in a <code>DOMString</code> variable on the implementation
286N/A * platform.
286N/A */
286N/A public String getData()
286N/A throws DOMException {
286N/A return fData;
286N/A }
286N/A
286N/A /**
286N/A * The number of 16-bit units that are available through <code>data</code>
286N/A * and the <code>substringData</code> method below. This may have the
286N/A * value zero, i.e., <code>CharacterData</code> nodes may be empty.
286N/A */
286N/A public int getLength() {
286N/A if(fData == null) return 0;
286N/A return fData.length();
286N/A }
286N/A
286N/A /**
286N/A * Extracts a range of data from the node.
286N/A * @param offset Start offset of substring to extract.
286N/A * @param count The number of 16-bit units to extract.
286N/A * @return The specified substring. If the sum of <code>offset</code> and
286N/A * <code>count</code> exceeds the <code>length</code>, then all 16-bit
286N/A * units to the end of the data are returned.
286N/A * @exception DOMException
286N/A * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
286N/A * negative or greater than the number of 16-bit units in
286N/A * <code>data</code>, or if the specified <code>count</code> is
286N/A * negative.
286N/A * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
286N/A * not fit into a <code>DOMString</code>.
286N/A */
286N/A public String substringData(int offset,
286N/A int count)
286N/A throws DOMException {
286N/A if(fData == null) return null;
286N/A if(count < 0 || offset < 0 || offset > fData.length())
286N/A throw new DOMException(DOMException.INDEX_SIZE_ERR, "parameter error");
286N/A if(offset+count >= fData.length())
286N/A return fData.substring(offset);
286N/A return fData.substring(offset, offset+count);
286N/A }
286N/A
286N/A}