TextValue.java 1.39 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.content;

import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Int;
import com.adobe.xfa.Node;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.XFA;
import com.adobe.xfa.content.Content;
import com.adobe.xfa.content.TextScript;
import org.xml.sax.Attributes;

public final class TextValue
extends Content {
    public TextValue(Element parent, Node prevSibling) {
        super(parent, prevSibling, null, "text", "text", null, XFA.TEXTTAG, "text");
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        return super.equals(object) && this.getValue().equals(((TextValue)object).getValue());
    }

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

    @Override
    public ScriptTable getScriptTable() {
        return TextScript.getScriptTable();
    }

    public String getValue() {
        Int maxChars;
        int max;
        String string = this.getStrValue();
        if (string != null && 0 < (max = (maxChars = (Int)this.getAttribute(XFA.MAXCHARSTAG)).toInt()) && max < string.length()) {
            string = string.substring(0, max);
        }
        return string;
    }

    public void setValue(String sText) {
        super.setStrValue(sText, true, false);
    }
}