Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/xpn/xwiki/objects/NumberProperty.java


1   /**
2    * ===================================================================
3    *
4    * Copyright (c) 2003 Ludovic Dubost, All rights reserved.
5    *
6    * This program is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU General Public License
8    * as published by the Free Software Foundation; either version 2
9    * of the License, or (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details, published at
15   * http://www.gnu.org/copyleft/gpl.html or in gpl.txt in the
16   * root folder of this distribution.
17   *
18   * Created by
19   * User: Ludovic Dubost
20   * Date: 9 déc. 2003
21   * Time: 14:04:34
22   */
23  package com.xpn.xwiki.objects;
24  
25  
26  public abstract class NumberProperty extends BaseProperty {
27      private Number value;
28  
29      public NumberProperty() {
30      }
31  
32      public Object getValue() {
33          return value;
34      }
35  
36      public void setValue(Object value) {
37          this.value = (Number)value;
38      }
39  
40      public String toText() {
41          Number nb = (Number)getValue();
42          return (nb==null) ? "" : nb.toString();
43      }
44  
45      public boolean equals(Object obj) {
46          if (!super.equals(obj))
47           return false;
48  
49         if ((getValue()==null)
50              && (((NumberProperty)obj).getValue()==null))
51           return true;
52  
53         return getValue().equals(((NumberProperty)obj).getValue());
54      }
55  
56      public Object clone() {
57          NumberProperty property = (NumberProperty) super.clone();
58          property.setValue(getValue());
59          return property;
60      }
61  
62  }