TextPosn.java 3.06 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.text;

import com.adobe.xfa.text.TextAttr;
import com.adobe.xfa.text.TextPosnBase;
import com.adobe.xfa.text.TextStream;

public class TextPosn
extends TextPosnBase {
    TextPosn mpoNext;

    public TextPosn() {
    }

    public TextPosn(TextPosn oSource) {
        super(oSource);
        this.streamAttach();
    }

    public TextPosn(TextPosnBase oSource) {
        super(oSource);
        this.streamAttach();
    }

    public TextPosn(TextStream poNewStream) {
        super(poNewStream);
        this.streamAttach();
    }

    public TextPosn(TextStream poNewStream, int nNewIndex, int eNewPosn) {
        super(poNewStream, nNewIndex, eNewPosn);
        this.streamAttach();
    }

    public TextPosn(TextStream poNewStream, int nNewIndex) {
        super(poNewStream, nNewIndex);
        this.streamAttach();
    }

    @Override
    public boolean equals(Object object) {
        return super.equals(object);
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    public void copyFrom(TextPosn oSource) {
        this.copyFrom((TextPosnBase)oSource);
    }

    @Override
    public void copyFrom(TextPosnBase oSource) {
        boolean bReattach = this.conditionalDetach(oSource.stream());
        super.copyFrom(oSource);
        this.conditionalAttach(bReattach);
    }

    @Override
    public void associate(TextStream poNewStream, int eNewPosn) {
        boolean bReattach = this.conditionalDetach(poNewStream);
        super.associate(poNewStream, eNewPosn);
        this.conditionalAttach(bReattach);
    }

    @Override
    public void associate(TextStream poNewStream, int nNewIndex, int eNewPosn) {
        boolean bReattach = this.conditionalDetach(poNewStream);
        super.associate(poNewStream, nNewIndex, eNewPosn);
        this.conditionalAttach(bReattach);
    }

    @Override
    public void associate(TextStream poNewStream) {
        boolean bReattach = this.conditionalDetach(poNewStream);
        super.associate(poNewStream);
        this.conditionalAttach(bReattach);
    }

    @Override
    public void para() {
        this.insertPara();
    }

    @Override
    public void text(String sText) {
        this.insert(sText);
    }

    @Override
    public void attr(TextAttr oAttr) {
        this.attribute(oAttr);
    }

    private boolean conditionalDetach(TextStream poNewStream) {
        if (this.stream() == poNewStream) {
            return false;
        }
        if (this.stream() != null) {
            this.streamDetach(this.stream());
        }
        return poNewStream != null;
    }

    private void conditionalAttach(boolean bReattach) {
        if (bReattach) {
            this.streamAttach(this.stream());
        }
    }

    private void streamAttach() {
        if (this.stream() != null) {
            this.streamAttach(this.stream());
        }
    }

    private void streamAttach(TextStream poNewStream) {
        poNewStream.posnAttach(this);
    }

    private void streamDetach(TextStream poOldStream) {
        poOldStream.posnDetach(this);
    }
}