1 /* 2 * Copyright (c) 2003-2008 by Cosylab d. d. 3 * 4 * This file is part of CosyBeans-Common. 5 * 6 * CosyBeans-Common is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * CosyBeans-Common 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. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with CosyBeans-Common. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package com.cosylab.gui.components.numberfield; 21 22 /** 23 * Document, which delegates parsing to <code>NumberDescriptor</code>. 24 * @author ikriznar 25 */ 26 public class NumberDescriptorDocument extends AbstractNumberDocument { 27 28 private static final long serialVersionUID = 1L; 29 private NumberDescriptor descriptor; 30 /** 31 * Creates new instance. 32 */ 33 public NumberDescriptorDocument() { 34 super(); 35 } 36 37 /* (non-Javadoc) 38 * @see com.cosylab.gui.components.numberfield.AbstractNumberDocument#parseString(java.lang.String) 39 */ 40 protected Number parseNumber(String s) { 41 return getDescriptor().parseNumber(s); 42 } 43 44 /** 45 * Returns the NumberDescriptor delegate. 46 * 47 * @return 48 */ 49 public NumberDescriptor getDescriptor() { 50 if (descriptor==null) { 51 descriptor= new DefaultNumberDescriptor(); 52 } 53 return descriptor; 54 } 55 56 /** 57 * Sets the NumberDescriptor delegate. 58 * 59 * @param descriptor 60 */ 61 public void setDescriptor(NumberDescriptor descriptor) { 62 this.descriptor = descriptor; 63 } 64 }