Package java.math

Examples of java.math.BigInteger


        if (n < 0) {
            throw new IllegalArgumentException(n + "<0");
        } else if (n < 2) {
            return BigInteger.ONE;
        }
        BigInteger x = new BigInteger("" + n);
        BigInteger result = x;
        for (int i = n - 1; i >= 2; i--) {
            x = x.subtract(BigInteger.ONE);
            result = result.multiply(x);
        }
        return result;
    }
View Full Code Here


            else if (Float.class.equals(clazz))
                return new Float(number.floatValue());
            else if (BigDecimal.class.equals(clazz))
                return new BigDecimal(number.doubleValue());
            else if (BigInteger.class.equals(clazz))
                return new BigInteger(number.toString());
           // else
            // TODO log warn
             
        } else if (isDateTime(clazz)) {
          return handleAsDate(clazz,value,customizeInfo,method);
        } else if (clazz.isEnum()) {
            String sValue = (value instanceof Map) ? ((String)((Map)value).get("_name")) : (String) value;
            try{
              return Enum.valueOf(clazz, sValue);
            }catch(Throwable th){
              // try in value fields
              for(Object conzt: clazz.getEnumConstants()){
            try{
              // If xml value annotation use it.
              if(clazz.getDeclaredField(((Enum<?>)conzt).name()).
                  getAnnotation(XmlEnumValue.class).value().equals(sValue)){
                return conzt;
              }
            }catch(Throwable t){};
          }
              // user error?
              return null;
            }
        } else if (value instanceof String) {
            String sValue = (String) value;
            if(sValue.trim().isEmpty() && Number.class.isAssignableFrom(clazz)){
              sValue = "0";
              if(traceEnabled)traceLog.warn("Empty string passed for number. Converting it to zero. Field : " + method.getName());
            }
            if (String.class.equals(clazz))
              return value;
            else if (Boolean.TYPE.equals(clazz))
                return Boolean.parseBoolean(sValue);
            else if (Boolean.class.equals(clazz))
                return Boolean.valueOf(sValue);
            else if (Short.TYPE.equals(clazz)   || Short.class.equals(clazz))
                return Short.decode(sValue);
            else if (Byte.TYPE.equals(clazz)   || Byte.class.equals(clazz))
                return Byte.decode(sValue);
            else if (Integer.TYPE.equals(clazz) || Integer.class.equals(clazz))
                return Integer.decode(sValue);
            else if (Long.TYPE.equals(clazz|| Long.class.equals(clazz))
                return Long.decode(sValue);
            else if (Float.TYPE.equals(clazz))
                return Float.parseFloat(sValue);
            else if (Float.class.equals(clazz))
                return Float.valueOf(sValue);
            else if (Double.TYPE.equals(clazz))
                return Double.parseDouble(sValue);
            else if (Double.class.equals(clazz))
                return Double.valueOf(sValue);
            else if (BigDecimal.class.equals(clazz))
                return new BigDecimal(sValue);
            else if (BigInteger.class.equals(clazz))
                return new BigInteger(sValue);
            else if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) {
                char charValue = 0;
                if (sValue.length() > 0) {
                    charValue = sValue.charAt(0);
                }
View Full Code Here

    private void testParseSpecialValues() throws SQLException {
        for (int i = -10; i < 10; i++) {
            testParseSpecialValue("" + ((long) Integer.MIN_VALUE + i));
            testParseSpecialValue("" + ((long) Integer.MAX_VALUE + i));
            BigInteger bi = BigInteger.valueOf(i);
            testParseSpecialValue(bi.add(BigInteger.valueOf(Long.MIN_VALUE)).toString());
            testParseSpecialValue(bi.add(BigInteger.valueOf(Long.MAX_VALUE)).toString());
        }
    }
View Full Code Here

                tuples[index].add(null);
                tuples[index].add(null);
                tuples[index].add(null);
                tuples[index].add(null);
                tuples[index].add(new Short((short)i));
                tuples[index].add(new BigInteger(i+"")); //$NON-NLS-1$
                tuples[index].add(new BigDecimal(i+".0")); //$NON-NLS-1$
                tuples[index].add(null);
            }
           
            dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
View Full Code Here

                tuples[row].add(new Integer(row))//IntNum
                tuples[row].add(String.valueOf(row)); //StringNum
                for(int col=0; col<10; col++) { //FloatNum, LongNum, DoubleNum, ByteNum, DateValue, TimeValue, TimestampValue, BooleanValue, CharValue, ShortValue
                    tuples[row].add(null);   
                }   
                tuples[row].add(new BigInteger(String.valueOf(row))); //BigIntegerValue
                tuples[row].add(new BigDecimal(row)); //BigDecimalValue
                tuples[row].add(null);    //ObjectValue
            }
            dataMgr.registerTuples(metadata, groupName, tuples);
        }
View Full Code Here

        +"SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"; //$NON-NLS-1$
       
       
        // Create expected results
        List[] expected = new List[] {
            Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$  //$NON-NLS-2$
            Arrays.asList(new Object[] { "1", new BigInteger("1") }), //$NON-NLS-1$  //$NON-NLS-2$
            Arrays.asList(new Object[] { "2", new BigInteger("2") }), //$NON-NLS-1$  //$NON-NLS-2$
            Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$  //$NON-NLS-2$
            Arrays.asList(new Object[] { "1", new BigInteger("1") }), //$NON-NLS-1$  //$NON-NLS-2$
            Arrays.asList(new Object[] { "2", new BigInteger("2") }), //$NON-NLS-1$  //$NON-NLS-2$
        };   
       
        // Construct data manager with data
        FakeDataManager dataManager = new FakeDataManager();
        sampleDataBQT2a(dataManager);
View Full Code Here

       
        String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355 WHERE StringKey = '0'"//$NON-NLS-1$
       
        // Create expected results
        List[] expected = new List[] {
            Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$  //$NON-NLS-2$
        };   
       
        // Construct data manager with data
        FakeDataManager dataManager = new FakeDataManager();
        sampleDataBQT2a(dataManager);
View Full Code Here

       
        String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355a WHERE StringKey = '0'"//$NON-NLS-1$
       
        // Create expected results
        List[] expected = new List[] {
            Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$  //$NON-NLS-2$
        };   
       
        // Construct data manager with data
        FakeDataManager dataManager = new FakeDataManager();
        sampleDataBQT2a(dataManager);
View Full Code Here

       
        String sql = "SELECT BigIntegerValue, StringKey FROM VQT.Defect15355 WHERE StringKey = '0'"//$NON-NLS-1$
       
        // Create expected results
        List[] expected = new List[] {
            Arrays.asList(new Object[] { new BigInteger("0"), "0" }), //$NON-NLS-1$  //$NON-NLS-2$
        };   
       
        // Construct data manager with data
        FakeDataManager dataManager = new FakeDataManager();
        sampleDataBQT2a(dataManager);
View Full Code Here

       
        String sql = "SELECT BigIntegerValue FROM VQT.Defect15355 WHERE StringKey = '0'"//$NON-NLS-1$
       
        // Create expected results
        List[] expected = new List[] {
            Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$ 
        };   
       
        // Construct data manager with data
        FakeDataManager dataManager = new FakeDataManager();
        sampleDataBQT2a(dataManager);
View Full Code Here

TOP

Related Classes of java.math.BigInteger

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.