⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shortatom.java

📁 类似于Windows上的Excel
💻 JAVA
字号:
/*
 * MC2 -- j2me spreadsheet
 *
 * Copyright (c) 2004-2006 Michael Zemljanukha (mixaz@mail.ru)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

package com.wapindustrial.calc;
public class ShortAtom extends LispObject  {
    
    public static final ShortAtom ZERO = new ShortAtom( 0 );
    public static final ShortAtom ONE = new ShortAtom( 1 );
    public static final ShortAtom ONE_MINUS = new ShortAtom( -1 );
    
    public short value;
    
    public ShortAtom( int value ) {
        this.value = (short)value;
    }
    
    static ShortAtom createShortAtom( int value ) {
        if( value == 0 )
            return ZERO;
        if( value == 1 )
            return ONE;
        if( value == -1 )
            return ONE_MINUS;
        return new ShortAtom( value );
    }
    
    public void toBuffer( StringBuffer sb ) {
        sb.append( Integer.toString( value ) );
    }
    
//#ifdef JAVA_COMPILER
    public void toJavaBuffer( StringBuffer sb, int ident, FunctorList parent ) {
        addIdent( sb, ident );
        if( value == 0 )
            sb.append( "ShortAtom.ZERO" );
        else if( value == 1 )
            sb.append( "ShortAtom.ONE" );
        else if( value == -1 )
            sb.append( "ShortAtom.ONE_MINUS" );
        else {
            sb.append( "new ShortAtom(" );
            sb.append( value );
            sb.append( ") " );
        }
    }
//#endif    
    
    public int typeNumber() {
        return TYPE_SHORT;
    }

    public LispObject convertToType( int type ) throws EvaluateException {
        LispObject rez = this;
        switch( type ) {
            case TYPE_BOOLEAN:
                rez = value == 0 ? BooleanAtom.FALSE : BooleanAtom.TRUE;
                break;
            case TYPE_SHORT:
                break;
            case TYPE_LONG:
                rez = new LongAtom( (long) value );
                break;
            case TYPE_FLOAT:
                rez = FloatAtom.convertFromLong( (long) value );
                break;
	    case TYPE_DATE:
		rez = new DateAtom( 0, 0, value, 0, 0); // days=value
		break;
            default:    // to STRING
                return super.convertToType( type );
        }
        return rez;
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -