//
// UnsignedInt16.java
//
// The contents of this file are subject to the SNIA Public License Version 1.0
// (the "License"); you may not use this file except in compliance with the
// License. You may obtain a copy of the License at
//
//	http://www.snia.org/resources/openSource.html
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is UnsignedInt16.java
// 
// The Initial Developer of the Original Code is David Simons.
//
// Contributor(s): Peter Rivera
//
// This source uses the Solaris WBEM APIs version 2.2. 
// Synchronization will be maintained with the Solaris WBEM APIS,
// which are being standardized through the Java Community Process.
//
//
// $Id: UnsignedInt16.java,v 1.1 2003/07/17 18:32:55 kumpf Exp $
//
// $Log: UnsignedInt16.java,v $
// Revision 1.1  2003/07/17 18:32:55  kumpf
// HP-BAPU: PEP-64 CIM Client and CIM Listener Java Interface
//
// Revision 1.1.1.1  2001/10/31 18:14:40  karl
// import of SNIA 0_7
//
// Revision 1.2  2001/01/02 19:34:54  davidsi
// - Switched longs to ints.
//
// Revision 1.1  2000/11/18 14:22:13  davidsi
// - Initial version.
//
//
//
package org.snia.wbem.cim;

import java.lang.Number;

/**
    Creates and instantiates an unsigned 16-bit integer object.
 */

public class UnsignedInt16  extends Number {

    public static final int MAX_VALUE=65535;
    public static final int MIN_VALUE=0;

    private int value;

    public UnsignedInt16(int inVal)  {
	value=inVal & (int)0xffff;
    }

    public UnsignedInt16(java.lang.String inStr) throws java.lang.NumberFormatException {
	Integer l=new Integer(inStr);
	int val=l.intValue();
	if (val<MIN_VALUE || val>MAX_VALUE)
	    throw new java.lang.NumberFormatException("Not an unsigned 16 bit integer");
	value=val &  (int)0xffff;
    }
	

    public String toString() {
	return(""+value);
    }

    public int hashCode(){
	return((int)(value  & 0xffff)); 
    }

    public boolean equals(java.lang.Object o){
	if ( !(o instanceof UnsignedInt16) )
	    return(false);
	return( ((UnsignedInt16)o).value == value );
    }

    public int intValue() {
	return((int)(value  & (MAX_VALUE))); 
    }

    public long longValue() {
	return((long)(value  & (MAX_VALUE))); 
    }

    public float floatValue() {
	return ((float)value);
    }

    public double doubleValue() {
	return ((double)value);
    }

    public byte byteValue() {
	return((byte)(value  & 0xff)); 
    }

    public short shortValue() {
	return((short)(value  & 0xffff)); 
    }
}
