List of usage examples for java.lang Double Double
@Deprecated(since = "9") public Double(String s) throws NumberFormatException
From source file:com.likethecolor.alchemy.api.entity.TitleAlchemyEntityTest.java
@Test public void testEquals() { final String title = "Authorities: Pilot accused of faking death found in Florida - CNN.com"; final TitleAlchemyEntity entity = new TitleAlchemyEntity(); assertFalse(entity.equals(null));/*from w w w . j a v a 2s.c o m*/ assertFalse(entity.equals(new Double(1312D))); assertTrue(entity.equals(entity)); assertEquals(entity, entity); assertSame(entity, entity); final TitleAlchemyEntity other = new TitleAlchemyEntity(); assertTrue(entity.equals(other)); assertEquals(entity, other); assertNotSame(entity, other); // title entity.setTitle(title); other.setTitle(null); assertFalse(entity.equals(other)); assertNotSame(entity, other); entity.setTitle(null); other.setTitle(title); assertFalse(entity.equals(other)); assertNotSame(entity, other); entity.setTitle(title); other.setTitle(title); assertTrue(entity.equals(other)); assertEquals(entity, other); assertNotSame(entity, other); }
From source file:org.jfree.data.general.WaferMapDataset.java
/** * Creates a new dataset.//from w ww . j ava2s . co m * * @param maxChipX the wafer x-dimension. * @param maxChipY the wafer y-dimension. * @param chipSpace the space between chips. */ public WaferMapDataset(int maxChipX, int maxChipY, Number chipSpace) { this.maxValue = new Double(Double.NEGATIVE_INFINITY); this.minValue = new Double(Double.POSITIVE_INFINITY); this.data = new DefaultKeyedValues2D(); this.maxChipX = maxChipX; this.maxChipY = maxChipY; if (chipSpace == null) { this.chipSpace = DEFAULT_CHIP_SPACE; } else { this.chipSpace = chipSpace.doubleValue(); } }
From source file:io.pivotal.gemfire.main.GemFireServerApplication.java
static CacheLoader<Long, Long> cubesCacheLoader() { return new CacheLoader<Long, Long>() { public Long load(final LoaderHelper<Long, Long> helper) throws CacheLoaderException { long number = helper.getKey(); return new Double(Math.pow(number, 3)).longValue(); }//from ww w.j ava 2s . c o m public void close() { } }; }
From source file:com.aw.core.format.NumeroEnTextoFormatter.java
/** *Retorna en letras monto concatenado.//from www. j ava 2s . c om *@param numero: Variable int que ser procesada. *@param fin: Indica si existen o no, procesos pendientes. *@return String: Monto concatenado en letras. */ public static String base(int numero, boolean fin) { String cadena = ""; int decena; int centena; if (numero < 1000) { if (numero > 99) { centena = (new Double(numero / 100)).intValue(); numero = numero - centena * 100; if (centena == 1 && numero == 0) cadena += "CIEN "; else cadena += centenas(centena) + " "; } if (numero > 29) { decena = (new Double(numero / 10)).intValue(); numero = numero - decena * 10; if (numero > 0) cadena += decenas(decena) + " Y " + unidad(numero, false) + " "; else cadena += decenas(decena) + " "; } else { cadena += unidad(numero, fin); } } return cadena.trim(); }
From source file:com.wordpress.growworkinghard.riverNe3.composite.key.Key.java
/** * @brief Getter method for key in <strong>decimal</strong> format * * @return the key in decimal format as <tt>Double</tt> object *//*from w ww . j av a 2s . co m*/ public Double getDouble() { return new Double(hexToDecimal()); }
From source file:com.odap.server.audit.ConfigHandler.java
public ConfigMessage registerNewServer(ConfigMessage config) throws TException { logger.info("Enter registerNewServer()"); ConfigMessage msg = new ConfigMessage(); QueryRunner qRunner = new QueryRunner(); Integer account_id = null;/*from w w w . j av a 2 s . co m*/ Integer server_id = null; //Authenticate the user and get the account_id; String query = "SELECT * FROM joomla.cloud_users WHERE username = ? AND password = ?"; { String parameters[] = { config.getUsername().replaceAll("[^A-Za-z0-9 ]", ""), DigestUtils.md5Hex(config.getPassword().replaceAll("[^A-Za-z0-9 ]", "")) }; try { List<Map<String, Object>> mapList = (List<Map<String, Object>>) qRunner .query(AuditServer.connectionPool.getConnection(), query, new MapListHandler(), parameters); if (mapList.size() < 1) { logger.warn("Username " + config.getUsername() + " not authenticated"); return msg; } account_id = (Integer) mapList.get(0).get("account_id"); } catch (SQLException e) { logger.error("Issue finding user account", e); return msg; } } String session_id = nextSessionId(); { try { { query = "INSERT INTO servers (account_id,server_name,server_software,server_port,server_authentication_token,server_timezone,strip_predicates) VALUES (?,?,?,?,?,?,?)"; Object parameters[] = { account_id.toString(), config.getServer_name().replaceAll("[^A-Za-z0-9 ]", ""), config.getServer_software(), new Short(config.getPort()), session_id, new Double(config.getTimezone_offset()), config.strip_predicates }; qRunner.update(AuditServer.connectionPool.getConnection(), query, parameters); } { String parameters[] = { account_id.toString(), config.getServer_name(), session_id }; query = "SELECT * FROM servers WHERE account_id = ? AND server_name = ? and server_authentication_token = ?"; List<Map<String, Object>> mapList = (List<Map<String, Object>>) qRunner.query( AuditServer.connectionPool.getConnection(), query, new MapListHandler(), parameters); if (mapList.size() < 1) { logger.error("Unable to find server after after registering it"); return msg; } server_id = (Integer) mapList.get(0).get("id"); } } catch (SQLException e) { logger.error("Issue registering server", e); } } msg.token = session_id; msg.server_id = server_id.shortValue(); msg.server = "dbauditcloud.com"; logger.info("Exiting registerNewServer()"); return msg; }
From source file:com.church.tools.ChartTools.java
/** * Generate pie chart./*from w w w . j a v a 2 s . co m*/ * * @param title the title * @param values the values * @param captions the captions * @param width the width * @param height the height * @param color the color * * @return the buffered image */ public static BufferedImage GeneratePieChart(String title, double[] values, String[] captions, int width, int height, Color color) { BufferedImage bufferedImage = null; DefaultPieDataset pieDataset = new DefaultPieDataset(); Hashtable<String, String> ht = new Hashtable<String, String>(); for (int i = 0; i < values.length; i++) ht.put(captions[i], Double.toString(values[i])); Enumeration<String> enu = ht.keys(); int i = 0; while (enu.hasMoreElements()) { String str = (String) enu.nextElement(); pieDataset.setValue(str, new Double(Double.parseDouble((String) ht.get(str)))); i++; } JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, false, false, false); chart.setBackgroundPaint(color); bufferedImage = chart.createBufferedImage(width, height); return bufferedImage; }
From source file:org.jfree.data.DefaultKeyedValueTest.java
/** * Some checks for the clone() method.//from w w w. java 2 s.com */ @Test public void testCloning() throws CloneNotSupportedException { DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); DefaultKeyedValue v2 = (DefaultKeyedValue) v1.clone(); assertTrue(v1 != v2); assertTrue(v1.getClass() == v2.getClass()); assertTrue(v1.equals(v2)); // confirm that the clone is independent of the original v2.setValue(new Double(12.3)); assertFalse(v1.equals(v2)); }
From source file:com.judoscript.jamaica.MyUtils.java
public static Object number2object(double val, String typeHint) { if (typeHint != null) { if (typeHint.equals("double")) return new Double(val); if (typeHint.equals("float")) return new Float((float) val); if (typeHint.equals("int")) return new Integer((int) val); if (typeHint.equals("long")) return new Long((long) val); if (typeHint.equals("short")) return new Short((short) val); if (typeHint.equals("char")) return new Character((char) val); if (typeHint.equals("byte")) return new Byte((byte) val); }/* www. java 2 s. c o m*/ return new Double(val); }
From source file:com.likethecolor.alchemy.api.entity.AuthorAlchemyEntityTest.java
@Test public void testEquals() { final String author = "Jon Doe"; final AuthorAlchemyEntity entity = new AuthorAlchemyEntity(author); assertFalse(entity.equals(null));/*from ww w . ja v a 2s . c o m*/ assertFalse(entity.equals(new Double(1312D))); assertTrue(entity.equals(entity)); assertEquals(entity, entity); assertSame(entity, entity); final AuthorAlchemyEntity other = new AuthorAlchemyEntity(author); assertTrue(entity.equals(other)); assertEquals(entity, other); assertNotSame(entity, other); // author entity.setAuthor(null); other.setAuthor(author + "foo"); assertFalse(entity.equals(other)); assertNotSame(entity, other); entity.setAuthor(author); assertFalse(entity.equals(other)); assertNotSame(entity, other); other.setAuthor(author); assertTrue(entity.equals(other)); assertEquals(entity, other); assertNotSame(entity, other); }