/*
 * SDK Pullenti Lingvo, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software.
 * This class is generated using the converter Unisharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

package com.pullenti.morph;

/**
 * Информация о символах токена
 * 
 * Символьная информация
 */
public class CharsInfo {

    public short value;

    private boolean getValue(int i) {
        return ((((((int)value) >> i)) & 1)) != 0;
    }

    private void setValue(int i, boolean val) {
        if (val) 
            value |= ((short)(1 << i));
        else 
            value &= ((short)(~(1 << i)));
    }

    public boolean isAllUpper() {
        return this.getValue(0);
    }

    public boolean setAllUpper(boolean _value) {
        this.setValue(0, _value);
        return _value;
    }


    public boolean isAllLower() {
        return this.getValue(1);
    }

    public boolean setAllLower(boolean _value) {
        this.setValue(1, _value);
        return _value;
    }


    public boolean isCapitalUpper() {
        return this.getValue(2);
    }

    public boolean setCapitalUpper(boolean _value) {
        this.setValue(2, _value);
        return _value;
    }


    public boolean isLastLower() {
        return this.getValue(3);
    }

    public boolean setLastLower(boolean _value) {
        this.setValue(3, _value);
        return _value;
    }


    public boolean isLetter() {
        return this.getValue(4);
    }

    public boolean setLetter(boolean _value) {
        this.setValue(4, _value);
        return _value;
    }


    public boolean isLatinLetter() {
        return this.getValue(5);
    }

    public boolean setLatinLetter(boolean _value) {
        this.setValue(5, _value);
        return _value;
    }


    public boolean isCyrillicLetter() {
        return this.getValue(6);
    }

    public boolean setCyrillicLetter(boolean _value) {
        this.setValue(6, _value);
        return _value;
    }


    @Override
    public String toString() {
        if (!isLetter()) 
            return "Nonletter";
        StringBuilder tmpStr = new StringBuilder();
        if (isAllUpper()) 
            tmpStr.append("AllUpper");
        else if (isAllLower()) 
            tmpStr.append("AllLower");
        else if (isCapitalUpper()) 
            tmpStr.append("CapitalUpper");
        else if (isLastLower()) 
            tmpStr.append("LastLower");
        else 
            tmpStr.append("Nonstandard");
        if (isLatinLetter()) 
            tmpStr.append(" Latin");
        else if (isCyrillicLetter()) 
            tmpStr.append(" Cyrillic");
        else if (isLetter()) 
            tmpStr.append(" Letter");
        return tmpStr.toString();
    }

    /**
     * Сравнение на совпадение значений всех полей
     * @param obj сравниваемый объект
     * @return 
     */
    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof CharsInfo)) 
            return false;
        return value == ((CharsInfo)obj).value;
    }

    public String convertWord(String word) {
        if (com.pullenti.unisharp.Utils.isNullOrEmpty(word)) 
            return word;
        if (isAllLower()) 
            return word.toLowerCase();
        if (isAllUpper()) 
            return word.toUpperCase();
        if (isCapitalUpper() && word.length() > 0) {
            StringBuilder tmp = new StringBuilder(word);
            for (int i = 0; i < tmp.length(); i++) {
                if (i == 0) 
                    tmp.setCharAt(0, Character.toUpperCase(tmp.charAt(0)));
                else if (tmp.charAt(i - 1) == '-' || tmp.charAt(i - 1) == ' ') 
                    tmp.setCharAt(0, Character.toUpperCase(tmp.charAt(0)));
                else 
                    tmp.setCharAt(i, Character.toLowerCase(tmp.charAt(i)));
            }
            return tmp.toString();
        }
        return word;
    }

    public static CharsInfo _new3217(boolean _arg1) {
        CharsInfo res = new CharsInfo();
        res.setCapitalUpper(_arg1);
        return res;
    }

    public static CharsInfo _new3386(boolean _arg1) {
        CharsInfo res = new CharsInfo();
        res.setCyrillicLetter(_arg1);
        return res;
    }

    public static CharsInfo _new3392(boolean _arg1, boolean _arg2) {
        CharsInfo res = new CharsInfo();
        res.setCyrillicLetter(_arg1);
        res.setCapitalUpper(_arg2);
        return res;
    }

    public static CharsInfo _new3397(boolean _arg1, boolean _arg2, boolean _arg3, boolean _arg4) {
        CharsInfo res = new CharsInfo();
        res.setCapitalUpper(_arg1);
        res.setCyrillicLetter(_arg2);
        res.setLatinLetter(_arg3);
        res.setLetter(_arg4);
        return res;
    }

    public static CharsInfo _new3405(short _arg1) {
        CharsInfo res = new CharsInfo();
        res.value = _arg1;
        return res;
    }

    public static CharsInfo _new3426(boolean _arg1) {
        CharsInfo res = new CharsInfo();
        res.setLatinLetter(_arg1);
        return res;
    }
    public CharsInfo() {
    }
}
