CharacterDataImpl.java 2.34 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.dom;

import com.adobe.xfa.Node;
import com.adobe.xfa.dom.ParentNode;
import com.adobe.xfa.dom.XFANodeHolder;
import com.adobe.xfa.ut.StringUtils;
import org.w3c.dom.CharacterData;
import org.w3c.dom.DOMException;

abstract class CharacterDataImpl
extends XFANodeHolder
implements CharacterData {
    private final String mData;

    CharacterDataImpl(ParentNode parent, Node newNode, String data) {
        super(parent, newNode);
        this.mData = data;
    }

    @Override
    public void appendData(String arg) throws DOMException {
        throw new DOMException(7, "");
    }

    @Override
    public void deleteData(int offset, int count) throws DOMException {
        throw new DOMException(7, "");
    }

    @Override
    public String getData() throws DOMException {
        return this.mData;
    }

    @Override
    public int getLength() {
        return this.mData.length();
    }

    @Override
    public void insertData(int offset, String arg) throws DOMException {
        throw new DOMException(7, "");
    }

    @Override
    public boolean isEqualNode(org.w3c.dom.Node other) {
        if (!(other instanceof CharacterDataImpl)) {
            return false;
        }
        CharacterDataImpl otherCD = (CharacterDataImpl)other;
        return StringUtils.equalsWithNull(this.mData, otherCD.mData);
    }

    @Override
    public void replaceData(int offset, int count, String arg) throws DOMException {
        throw new DOMException(7, "");
    }

    @Override
    public void setData(String arg) throws DOMException {
        throw new DOMException(7, "");
    }

    @Override
    public String substringData(int offset, int count) throws DOMException {
        int currentLength = this.mData.length();
        if (offset < 0 || offset >= currentLength || count < 0) {
            throw new DOMException(1, "");
        }
        int afterIndex = offset + count;
        if (afterIndex > currentLength) {
            afterIndex = currentLength;
        }
        return this.mData.substring(offset, afterIndex);
    }

    @Override
    public String getNodeValue() throws DOMException {
        return this.mData;
    }

    @Override
    public String getTextContent() throws DOMException {
        return this.mData;
    }

    final String getCharacterData() {
        return this.mData;
    }
}