001 package com.softnetConsult.utils.mutableWrappers; 002 003 004 /** 005 * This class wraps a single <strong>public</strong> variable of type {@code short} - 006 * it can be used to emulate passing short values by reference. 007 * All methods here are self-explanatory and perform the same function as the corresponding 008 * methods of the classes {@link java.lang.Number} and {@link java.lang.Short}. 009 * 010 * <p style="font-size:smaller;">This product includes software developed by the 011 * <strong>SoftNet-Consult Java Utility Library</strong> project and its contributors.<br /> 012 * (<a href="http://java-tools.sourceforge.net" target="_blank">http://java-tools.sourceforge.net</a>)<br /> 013 * Copyright (c) 2007-2008 SoftNet-Consult.<br /> 014 * Copyright (c) 2007-2008 G. Paperin.<br /> 015 * All rights reserved. 016 * </p> 017 * <p style="font-size:smaller;">File: MutableShort.java<br /> 018 * Library API version: {@value com.softnetConsult.utils.APIProperties#apiVersion}<br /> 019 * Java compliance version: {@value com.softnetConsult.utils.APIProperties#javaComplianceVersion} 020 * </p> 021 * <p style="font-size:smaller;">Redistribution and use in source and binary forms, with or 022 * without modification, are permitted provided that the following terms and conditions are met: 023 * </p> 024 * <p style="font-size:smaller;">1. Redistributions of source code must retain the above 025 * acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright 026 * notice, this list of conditions and the following disclaimer.<br /> 027 * 2. Redistributions in binary form must reproduce the above acknowledgement of the 028 * SoftNet-Consult Java Utility Library project, the above copyright notice, this list of 029 * conditions and the following disclaimer in the documentation and/or other materials 030 * provided with the distribution.<br /> 031 * 3. All advertising materials mentioning features or use of this software or any derived 032 * software must display the following acknowledgement:<br /> 033 * <em>This product includes software developed by the SoftNet-Consult Java Utility Library 034 * project and its contributors.</em> 035 * </p> 036 * <p style="font-size:smaller;">THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY 037 * OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 038 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 039 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 040 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 041 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 042 * </p> 043 * @author Greg Paperin (<a href="http://www.paperin.org" target="_blank">http://www.paperin.org</a>) 044 * @version {@value com.softnetConsult.utils.APIProperties#apiVersion} 045 * 046 */ 047 public class MutableShort extends Number implements MutableWrapper { 048 049 public short value = 0; 050 051 public MutableShort() {} 052 053 public MutableShort(short value) { 054 this.value = value; 055 } 056 057 public MutableShort(String value) { 058 this.value = Short.parseShort(value); 059 } 060 061 public boolean booleanValue() { return (0 == this.value); } 062 @Override public byte byteValue() { return (byte) this.value; } 063 @Override public short shortValue() { return this.value; } 064 @Override public int intValue() { return (int) this.value; } 065 @Override public long longValue() { return (long) this.value; } 066 @Override public float floatValue() { return (float) this.value; } 067 @Override public double doubleValue() { return (double) this.value; } 068 public String stringValue() { return Short.toString(this.value); } 069 @Override public String toString() { return stringValue(); } 070 071 } // public class MutableShort