List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:com.jaspersoft.studio.utils.jasper.JasperReportsConfiguration.java
public Character getPropertyCharacter(String key) { String p = getProperty(key);/*from w w w .j a v a 2 s. com*/ if (p != null && !p.isEmpty()) return new Character(p.charAt(0)); return null; }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
public BiospecimenLocationVO getInvCellLocation(InvCell invCell) throws ArkSystemException { BiospecimenLocationVO biospecimenLocationVo = new BiospecimenLocationVO(); StringBuilder hqlString = new StringBuilder(); hqlString.append(/*www . j av a 2s. co m*/ "SELECT site.name AS siteName, freezer.name as freezerName, rack.name AS rackName, box.name AS boxName, cell.colno AS column, cell.rowno AS row, box.colnotype.name AS colNoType, box.rownotype.name AS rowNoType \n"); hqlString.append("FROM InvCell AS cell \n"); hqlString.append("LEFT JOIN cell.invBox AS box \n"); hqlString.append("LEFT JOIN box.invRack AS rack \n"); hqlString.append("LEFT JOIN rack.invFreezer AS freezer \n"); hqlString.append("LEFT JOIN freezer.invSite AS site \n"); hqlString.append("WHERE cell.id = :id"); Query q = getSession().createQuery(hqlString.toString()); q.setParameter("id", invCell.getId()); Object[] result = (Object[]) q.uniqueResult(); if (result != null) { biospecimenLocationVo.setSiteName(result[0].toString()); biospecimenLocationVo.setFreezerName(result[1].toString()); biospecimenLocationVo.setRackName(result[2].toString()); biospecimenLocationVo.setBoxName(result[3].toString()); Long colno = new Long((Long) result[4]); Long rowno = new Long((Long) result[5]); biospecimenLocationVo.setColumn(colno); biospecimenLocationVo.setRow(rowno); String colNoType = result[6].toString(); String rowNoType = result[7].toString(); String colLabel = new String(); if (colNoType.equalsIgnoreCase("ALPHABET")) { char character = (char) (colno + 64); colLabel = new Character(character).toString(); } else { colLabel = new Integer(colno.intValue()).toString(); } biospecimenLocationVo.setColLabel(colLabel); String rowLabel = new String(); if (rowNoType.equalsIgnoreCase("ALPHABET")) { char character = (char) (rowno + 64); rowLabel = new Character(character).toString(); } else { rowLabel = new Integer(rowno.intValue()).toString(); } biospecimenLocationVo.setRowLabel(rowLabel); } return biospecimenLocationVo; }
From source file:org.vertx.java.http.eventbusbridge.integration.MessagePublishTest.java
@Test public void testPublishingCharacterXml() throws IOException { final EventBusMessageType messageType = EventBusMessageType.Character; final Character sentCharacter = new Character('T'); Map<String, String> expectations = createExpectations(generateUniqueAddress(), Base64.encodeAsString(sentCharacter.toString()), messageType); final AtomicInteger completedCount = new AtomicInteger(0); Handler<Message> messagePublishHandler = new MessagePublishHandler(sentCharacter, expectations, completedCount);/* w w w . j a va 2s.com*/ registerListenersAndCheckForResponses(messagePublishHandler, expectations, NUMBER_OF_PUBLISH_HANDLERS, completedCount); String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_XML, expectations); HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_XML); }
From source file:net.sf.json.TestJSONObject.java
public void testFromBean_use_wrappers() { JSONObject json = JSONObject.fromObject(Boolean.TRUE); assertTrue(json.isEmpty());//from w w w. j av a 2 s. co m json = JSONObject.fromObject(new Byte(Byte.MIN_VALUE)); assertTrue(json.isEmpty()); json = JSONObject.fromObject(new Short(Short.MIN_VALUE)); assertTrue(json.isEmpty()); json = JSONObject.fromObject(new Integer(Integer.MIN_VALUE)); assertTrue(json.isEmpty()); json = JSONObject.fromObject(new Long(Long.MIN_VALUE)); assertTrue(json.isEmpty()); json = JSONObject.fromObject(new Float(Float.MIN_VALUE)); assertTrue(json.isEmpty()); json = JSONObject.fromObject(new Double(Double.MIN_VALUE)); assertTrue(json.isEmpty()); json = JSONObject.fromObject(new Character('A')); assertTrue(json.isEmpty()); }
From source file:org.floggy.synchronization.jme.core.impl.JSONSerializationManagerTest.java
/** * DOCUMENT ME!// w w w . j a va 2s . c o m * * @throws Exception DOCUMENT ME! */ public void testSendHashtableNotNull() throws Exception { JSONStringer stringer = new JSONStringer(); String name = "firstName"; Hashtable value = new Hashtable(); Calendar c1 = Calendar.getInstance(); c1.setTimeZone(TimeZone.getTimeZone("America/Sao_Paulo")); c1.setTime(new Date(1234567890)); Calendar c2 = Calendar.getInstance(); c2.setTimeZone(TimeZone.getTimeZone("America/Sao_Paulo")); c2.setTime(new Date(1234567890)); value.put(Boolean.TRUE, Boolean.TRUE); value.put(new Byte((byte) 90), new Byte((byte) 90)); value.put(new Character('2'), new Character('2')); value.put(new Double(23d), new Double(23d)); value.put(new Float(45f), new Float(45f)); value.put(new Integer(87), new Integer(87)); value.put(new Long(89), new Long(89)); value.put(new Short((short) 78), new Short((short) 78)); value.put("key", "value"); value.put(new Date(1234567890), new Date(9876543221L)); value.put(c1, c2); value.put(TimeZone.getTimeZone("America/Sao_Paulo"), TimeZone.getTimeZone("America/Sao_Paulo")); stringer.object(); JSONSerializationManager.sendHashtable(name, value, stringer); stringer.endObject(); String expected = "{\"firstName\":[{\"key\":{\"className\":\"java.lang.Byte\",\"value\":90},\"value\":{\"className\":\"java.lang.Byte\",\"value\":90}},{\"key\":{\"className\":\"java.lang.Long\",\"value\":89},\"value\":{\"className\":\"java.lang.Long\",\"value\":89}},{\"key\":{\"className\":\"java.lang.Float\",\"value\":45},\"value\":{\"className\":\"java.lang.Float\",\"value\":45}},{\"key\":{\"className\":\"java.util.Date\",\"value\":{\"time\":1234567890}},\"value\":{\"className\":\"java.util.Date\",\"value\":{\"time\":9876543221}}},{\"key\":{\"className\":\"java.lang.Integer\",\"value\":87},\"value\":{\"className\":\"java.lang.Integer\",\"value\":87}},{\"key\":{\"className\":\"java.lang.Double\",\"value\":23},\"value\":{\"className\":\"java.lang.Double\",\"value\":23}},{\"key\":{\"className\":\"java.lang.Boolean\",\"value\":true},\"value\":{\"className\":\"java.lang.Boolean\",\"value\":true}},{\"key\":{\"className\":\"java.util.TimeZone\",\"value\":{\"ID\":\"America/Sao_Paulo\"}},\"value\":{\"className\":\"java.util.TimeZone\",\"value\":{\"ID\":\"America/Sao_Paulo\"}}},{\"key\":{\"className\":\"java.lang.Short\",\"value\":78},\"value\":{\"className\":\"java.lang.Short\",\"value\":78}},{\"key\":{\"className\":\"java.util.Calendar\",\"value\":{\"timeZone\":{\"ID\":\"America/Sao_Paulo\"},\"time\":1234567890}},\"value\":{\"className\":\"java.util.Calendar\",\"value\":{\"timeZone\":{\"ID\":\"America/Sao_Paulo\"},\"time\":1234567890}}},{\"key\":{\"className\":\"java.lang.Character\",\"value\":\"2\"},\"value\":{\"className\":\"java.lang.Character\",\"value\":\"2\"}},{\"key\":{\"className\":\"java.lang.String\",\"value\":\"key\"},\"value\":{\"className\":\"java.lang.String\",\"value\":\"value\"}}]}"; assertEquals(expected, stringer.toString()); }
From source file:org.openadaptor.auxil.convertor.delimited.AbstractDelimitedStringConvertor.java
/** * Splits a string using a literal char delimiter. Preserves blocks of characters * between quoteChars./*from www .j a va 2 s. co m*/ * * This method originally had an algorithm parallel and almost identical to * AbstractDelimitedStringConvertor#extractQuotedValuesLiteralString(String, String, char) * but operating on chars rather than Strings/StringBuffers. This seemed * unnecessary and was replaced by a simple char->String conversion and forward * to the method taking a String. Code is cleaner & easier to test * at a certain performance cost (approx. 50% longer to execute). */ protected String[] extractQuotedValuesLiteralString(String delimitedString, char d, char quoteChar) { return extractQuotedValuesLiteralString(delimitedString, new Character(d).toString(), quoteChar); }
From source file:org.opoo.oqs.core.AbstractQuery.java
public Query setCharacter(int position, char val) { setParameter(position, new Character(val), Type.CHARACTER); return this; }
From source file:eionet.util.Util.java
/** * Finds all urls in a given string and replaces them with HTML anchors with target being a new window. * * @param in/*w w w . ja va2s. co m*/ * - the text to scan in plain text. * @param newWindow * - whether to launch links in a new window. * @param cutLink * - can shorten the link text in the output HTML. * @return The modified text as HTML */ public static String processForLink(String in, boolean newWindow, int cutLink) { if (in == null || in.trim().length() == 0) { return in; } HashSet urlSchemes = new HashSet(); urlSchemes.add("http://"); urlSchemes.add("https://"); urlSchemes.add("ftp://"); urlSchemes.add("mailto://"); urlSchemes.add("ldap://"); urlSchemes.add("file://"); int beginIndex = -1; Iterator iter = urlSchemes.iterator(); while (iter.hasNext() && beginIndex < 0) { beginIndex = in.indexOf((String) iter.next()); } if (beginIndex < 0) { return in; } int endIndex = -1; String s = null; for (endIndex = in.length(); endIndex > beginIndex; endIndex--) { s = in.substring(beginIndex, endIndex); if (isURI(s)) { break; } } if (s == null) { return in; } HashSet endChars = new HashSet(); endChars.add(new Character('!')); endChars.add(new Character('\'')); endChars.add(new Character('(')); endChars.add(new Character(')')); endChars.add(new Character('.')); endChars.add(new Character(':')); endChars.add(new Character(';')); for (endIndex = endIndex - 1; endIndex > beginIndex; endIndex--) { char c = in.charAt(endIndex); if (!endChars.contains(new Character(c))) { break; } } StringBuffer buf = new StringBuffer(in.substring(0, beginIndex)); String link = in.substring(beginIndex, endIndex + 1); StringBuffer _buf = new StringBuffer("<a "); _buf.append("href=\""); _buf.append(link); _buf.append("\">"); if (cutLink < link.length()) { _buf.append(link.substring(0, cutLink)).append("..."); } else { _buf.append(link); } _buf.append("</a>"); buf.append(_buf.toString()); buf.append(in.substring(endIndex + 1)); return buf.toString(); }
From source file:org.apache.felix.webconsole.internal.compendium.ConfigManager.java
/** * @throws NumberFormatException/* w ww . ja v a 2s.c om*/ * If the value cannot be converted to a number and type * indicates a numeric type */ private Object getType(int type, String value) { switch (type) { case AttributeDefinition.BYTE: return Byte.valueOf(value); case AttributeDefinition.CHARACTER: char c = (value.length() > 0) ? value.charAt(0) : 0; return new Character(c); case AttributeDefinition.BOOLEAN: return Boolean.valueOf(value); case AttributeDefinition.LONG: return Long.valueOf(value); case AttributeDefinition.INTEGER: return Integer.valueOf(value); case AttributeDefinition.SHORT: return Short.valueOf(value); case AttributeDefinition.DOUBLE: return Double.valueOf(value); case AttributeDefinition.FLOAT: return Float.valueOf(value); default: // includes AttributeDefinition.STRING return value; } }
From source file:ips1ap101.lib.base.util.StrUtils.java
public static Object getObjeto(String string, Class<?> clazz) { if (string == null || clazz == null) { return null; }/* w w w .ja v a 2s . co m*/ try { String value = StringUtils.trimToNull(string); if (value == null) { return null; } else if (Character.class.isAssignableFrom(clazz)) { return new Character(value.charAt(0)); } else if (String.class.isAssignableFrom(clazz)) { // ALFANUMERICO return string; } else if (Boolean.class.isAssignableFrom(clazz)) { return BitUtils.valueOf(value); } else if (Byte.class.isAssignableFrom(clazz)) { return new Byte(new BigDecimal(value).byteValue()); } else if (Short.class.isAssignableFrom(clazz)) { return new Short(new BigDecimal(value).shortValue()); } else if (Integer.class.isAssignableFrom(clazz)) { // ENTERO return new Integer(new BigDecimal(value).intValue()); } else if (Long.class.isAssignableFrom(clazz)) { return new Long(new BigDecimal(value).longValue()); } else if (Float.class.isAssignableFrom(clazz)) { return new Float(new BigDecimal(value).floatValue()); } else if (Double.class.isAssignableFrom(clazz)) { return new Double(new BigDecimal(value).doubleValue()); } else if (BigInteger.class.isAssignableFrom(clazz)) { // ENTERO_GRANDE return new Long(new BigDecimal(value).longValue()); } else if (BigDecimal.class.isAssignableFrom(clazz)) { // NUMERICO return new BigDecimal(value); } else if (java.util.Date.class.isAssignableFrom(clazz)) { // FECHA_HORA java.util.Date dateTime = TimeUtils.parse(value); if (Timestamp.class.isAssignableFrom(clazz)) { return new Timestamp(dateTime.getTime()); } else if (Time.class.isAssignableFrom(clazz)) { return new Time(dateTime.getTime()); } else if (Date.class.isAssignableFrom(clazz)) { return new Date(dateTime.getTime()); } else { return dateTime; } } // } catch (NumberFormatException e) { // return null; } catch (RuntimeException e) { return null; } return null; }