1 31 package org.pdfbox.cos; 32 33 import java.io.IOException ; 34 35 import java.util.HashMap ; 36 import java.util.Map ; 37 38 44 public abstract class COSNumber extends COSBase 45 { 46 49 public static final COSInteger ZERO = new COSInteger( 0 ); 50 53 public static final COSInteger ONE = new COSInteger( 1 ); 54 private static final Map COMMON_NUMBERS = new HashMap (); 55 56 static 57 { 58 COMMON_NUMBERS.put( "0", ZERO ); 59 COMMON_NUMBERS.put( "1", ONE ); 60 } 61 62 67 public abstract float floatValue(); 68 69 74 public abstract double doubleValue(); 75 76 81 public abstract int intValue(); 82 83 88 public abstract long longValue(); 89 90 99 public static COSNumber get( String number ) throws IOException 100 { 101 COSNumber result = (COSNumber)COMMON_NUMBERS.get( number ); 102 if( result == null ) 103 { 104 if (number.indexOf('.') >= 0) 105 { 106 result = new COSFloat( number ); 107 } 108 else 109 { 110 result = new COSInteger( number ); 111 } 112 } 113 return result; 114 } 115 } | Popular Tags |