//================================================================================================== // D a t a _ s t r u c t u r e Java // E x t e n s i o n // S h o r t P r o p e r t y // By Bruno Bachelet //================================================================================================== // Copyright (c) 1999-2016 // Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net // // This file is part of the B++ Library. This library is free software; you can redistribute it // and/or modify it under the terms of the GNU Library General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your option) any later // version. // // This library 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 Library General Public License for more details (http://www.gnu.org).
/*DESCRIPTION*/ /* This module provides a class to model a short integer additional property for extendable objects. */
// Package //--------------------------------------------------------------------------------------- package bpp.data_structure.extension;
// Importation //-----------------------------------------------------------------------------------
// S h o r t P r o p e r t y Class //-------------------------------------------------------------- /*CLASS ShortProperty */ /* Represents a short integer additional property for extendable objects. It wraps a value of the primitive type <CODE>short</CODE> in an object. */ public class ShortProperty implements Property { //---------------------------------------------------------------------------------------Attributes protected short atValue; //--------------------------------------------------------------------------------------Constructor /*METHOD ShortProperty */ /* Builds a property with default value. */ public ShortProperty() { atValue=0; } //--------------------------------------------------------------------------------------Constructor /*METHOD ShortProperty */ /* Builds a property from a <CODE>short</CODE> value. */ public ShortProperty(short agValue) { atValue=agValue; } //--------------------------------------------------------------------------------------Constructor /*METHOD ShortProperty */ /* Builds a property from a <CODE>long</CODE> value. */ public ShortProperty(long agValue) { atValue=(short)agValue; } //----------------------------------------------------------------------------------------Duplicate /*METHOD ShortProperty */ /* Duplicates the property. */ public Property duplicate() { return (new ShortProperty(atValue)); } //-----------------------------------------------------------------------------------------ToString /*METHOD ShortProperty */ /* Returns a string that fully describes the state of the property. */ public String toString() { return (new String(""+atValue)); } //---------------------------------------------------------------------------------------FromString /*METHOD ShortProperty */ /* Changes the state of the property according to the description provided by a given string. */ public void fromString(String agString) { atValue=Short.parseShort(agString.trim()); } }
// End //------------------------------------------------------------------------------------------- |
|