List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:org.jboss.dashboard.commons.misc.ReflectionUtils.java
public static <T> T newInstanceForClass(Class<T> type) { Object object = null;/*from www . ja va 2 s. c o m*/ if (type.isArray()) { Class componentClass = type.getComponentType(); if (componentClass.isPrimitive()) { if (componentClass.equals(int.class)) object = new int[0]; else if (componentClass.equals(boolean.class)) object = new boolean[0]; else if (componentClass.equals(long.class)) object = new long[0]; else if (componentClass.equals(char.class)) object = new char[0]; else if (componentClass.equals(double.class)) object = new double[0]; else if (componentClass.equals(float.class)) object = new float[0]; else if (componentClass.equals(byte.class)) object = new byte[0]; else if (componentClass.equals(short.class)) object = new short[0]; } else if (String.class.equals(componentClass)) object = new String[0]; else if (componentClass.equals(Integer.class)) object = new Integer[0]; else if (componentClass.equals(Boolean.class)) object = new Boolean[0]; else if (componentClass.equals(Long.class)) object = new Long[0]; else if (componentClass.equals(Character.class)) object = new Character[0]; else if (componentClass.equals(Double.class)) object = new Double[0]; else if (componentClass.equals(Float.class)) object = new Float[0]; else if (componentClass.equals(Byte.class)) object = new Byte[0]; else if (componentClass.equals(Short.class)) object = new Short[0]; else object = Array.newInstance(componentClass, 0); } else { if (String.class.equals(type)) object = ""; else if (type.equals(int.class)) object = new Integer(0); else if (type.equals(boolean.class)) object = Boolean.FALSE; else if (type.equals(long.class)) object = new Long(0); else if (type.equals(char.class)) object = new Character((char) 0); else if (type.equals(double.class)) object = new Double(0); else if (type.equals(float.class)) object = new Float(0); else if (type.equals(byte.class)) object = new Byte((byte) 0); else if (type.equals(short.class)) object = new Short((short) 0); else if (type.equals(Integer.class)) object = new Integer(0); else if (type.equals(Boolean.class)) object = Boolean.FALSE; else if (type.equals(Long.class)) object = new Long(0); else if (type.equals(Character.class)) object = new Character((char) 0); else if (type.equals(Double.class)) object = new Double(0); else if (type.equals(Float.class)) object = new Float(0); else if (type.equals(Byte.class)) object = new Byte((byte) 0); else if (type.equals(Short.class)) object = new Short((short) 0); else object = null; } return type.cast(object); }
From source file:org.vertx.java.http.eventbusbridge.integration.MessageSendTest.java
@Test public void testSendingCharacterXml() throws IOException { final EventBusMessageType messageType = EventBusMessageType.Character; final Character sentCharacter = new Character('T'); Map<String, String> expectations = createExpectations("someaddress", Base64.encodeAsString(sentCharacter.toString()), messageType); Handler<Message> messageConsumerHandler = new MessageSendHandler(sentCharacter, expectations); vertx.eventBus().registerHandler(expectations.get("address"), messageConsumerHandler); String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_XML, expectations); HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_XML);/* w ww .ja v a2 s. c o m*/ }
From source file:mitm.application.djigzo.tools.Monitor.java
private void handleCommandline(String[] args) throws IOException, ParseException, WSProxyFactoryException, WebServiceCheckedException { CommandLineParser parser = new BasicParser(); Options options = createCommandLineOptions(); HelpFormatter formatter = new HelpFormatter(); CommandLine commandLine;/*from ww w .j ava2s. c o m*/ try { commandLine = parser.parse(options, args); } catch (ParseException e) { formatter.printHelp(COMMAND_NAME, options, true); throw e; } initLogging(commandLine.hasOption(loggingOption.getOpt())); user = userOption.getValue(); password = passwordOption.getValue(); repository = mpaSizeOption.getValue(); if (commandLine.getOptions().length == 0) { formatter.printHelp(COMMAND_NAME, options, true); System.exit(1); return; } if (commandLine.getOptions().length == 0 || commandLine.hasOption(helpOption.getOpt())) { formatter.printHelp(COMMAND_NAME, options, true); return; } if (commandLine.hasOption(passwordPromptOption.getOpt())) { System.err.println("Please enter password: "); password = new jline.ConsoleReader().readLine(new Character('*')); } if (commandLine.hasOption(mpaSizeOption.getOpt())) { retrieveMPAQueueSize(); } if (commandLine.hasOption(crlStoreSizeOption.getOpt())) { retrieveCRLStoreSize(); } if (commandLine.hasOption(runningOption.getOpt())) { checkRunning(); } if (commandLine.hasOption(mtaSizeOption.getOpt())) { retrieveMTAQueueSize(); } if (commandLine.hasOption(certStoreSizeOption.getOpt())) { retrieveCertStoreSize(); } if (commandLine.hasOption(certRequestStoreSizeOption.getOpt())) { retrieveCertRequestStoreSize(); } if (commandLine.hasOption(smsSizeOption.getOpt())) { retrieveSMSSize(); } if (commandLine.hasOption(userSizeOption.getOpt())) { retrieveUsersSize(); } }
From source file:au.org.theark.lims.model.dao.InventoryDao.java
public BiospecimenLocationVO getBiospecimenLocation(Biospecimen biospecimen) { BiospecimenLocationVO biospecimenLocationVo = new BiospecimenLocationVO(); StringBuilder hqlString = new StringBuilder(); hqlString.append(/*from ww w .j a v a 2 s. 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.biospecimen = :biospecimen"); Query q = getSession().createQuery(hqlString.toString()); q.setParameter("biospecimen", biospecimen); Object[] result = (Object[]) q.uniqueResult(); if (result != null) { biospecimenLocationVo.setIsAllocated(true); 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:TypeConversionHelper.java
/** * Convert a byte[] into an instance of our value class. * @param buf byte array to be converted * @return converted Character array as object *//*from w w w.jav a 2 s . c om*/ public static Object getCharObjectArrayFromByteArray(byte[] buf) { char[] d = (char[]) getCharArrayFromByteArray(buf); Character[] a = new Character[d.length]; for (int i = 0; i < a.length; i++) { a[i] = new Character(d[i]); } return a; }
From source file:com.twinsoft.convertigo.engine.util.XMLUtils.java
public static Object readObjectFromXml(Element node) throws Exception { String nodeName = node.getNodeName(); String nodeValue = ((Element) node).getAttribute("value"); if (nodeName.equals("java.lang.Boolean")) { return new Boolean(nodeValue); } else if (nodeName.equals("java.lang.Byte")) { return new Byte(nodeValue); } else if (nodeName.equals("java.lang.Character")) { return new Character(nodeValue.charAt(0)); } else if (nodeName.equals("java.lang.Integer")) { return new Integer(nodeValue); } else if (nodeName.equals("java.lang.Double")) { return new Double(nodeValue); } else if (nodeName.equals("java.lang.Float")) { return new Float(nodeValue); } else if (nodeName.equals("java.lang.Long")) { return new Long(nodeValue); } else if (nodeName.equals("java.lang.Short")) { return new Short(nodeValue); } else if (nodeName.equals("java.lang.String")) { return nodeValue; } else if (nodeName.equals("array")) { String className = node.getAttribute("classname"); String length = node.getAttribute("length"); int len = (new Integer(length)).intValue(); Object array;// ww w . java 2 s . c om if (className.equals("byte")) { array = new byte[len]; } else if (className.equals("boolean")) { array = new boolean[len]; } else if (className.equals("char")) { array = new char[len]; } else if (className.equals("double")) { array = new double[len]; } else if (className.equals("float")) { array = new float[len]; } else if (className.equals("int")) { array = new int[len]; } else if (className.equals("long")) { array = new long[len]; } else if (className.equals("short")) { array = new short[len]; } else { array = Array.newInstance(Class.forName(className), len); } Node xmlNode = null; NodeList nl = node.getChildNodes(); int len_nl = nl.getLength(); int i = 0; for (int j = 0; j < len_nl; j++) { xmlNode = nl.item(j); if (xmlNode.getNodeType() == Node.ELEMENT_NODE) { Object o = XMLUtils.readObjectFromXml((Element) xmlNode); Array.set(array, i, o); i++; } } return array; } // XMLization else if (nodeName.equals("xmlizable")) { String className = node.getAttribute("classname"); Node xmlNode = findChildNode(node, Node.ELEMENT_NODE); Object xmlizable = Class.forName(className).newInstance(); ((XMLizable) xmlizable).readXml(xmlNode); return xmlizable; } // Serialization else if (nodeName.equals("serializable")) { Node cdata = findChildNode(node, Node.CDATA_SECTION_NODE); String objectSerializationData = cdata.getNodeValue(); Engine.logEngine.debug("Object serialization data:\n" + objectSerializationData); byte[] objectBytes = org.apache.commons.codec.binary.Base64.decodeBase64(objectSerializationData); // We read the object to a bytes array ByteArrayInputStream inputStream = new ByteArrayInputStream(objectBytes); ObjectInputStream objectInputStream = new ObjectInputStream(inputStream); Object object = objectInputStream.readObject(); inputStream.close(); return object; } return null; }
From source file:org.novoj.utils.datePattern.DatePatternConverter.java
/** * Returns delimiter between date and time part of the DateFormat pattern. This part is needed to by handed forward * to the jQueryUI DatePicker to combine data with TimePicker addon. * * @param patternDecomposition/* w w w. j av a2 s . com*/ * @return * @throws PatternNotConvertableException */ @SuppressWarnings({ "ImplicitNumericConversion", "OverlyComplexMethod" }) public String getDateAndTimeDelimiter(List<String> patternDecomposition) throws PatternNotConvertableException { boolean anyPatternRecognized = false; Map<String, String> patternSource = null; StringBuffer result = new StringBuffer(); for (String patternPart : patternDecomposition) { char leadLetter = patternPart.charAt(0); if (leadLetter == '\'') { if (anyPatternRecognized) { result.append(patternPart); } } else if (Character.isLetter(leadLetter)) { if (java2jQueryUIdatePatterns.containsKey(patternPart) || java2jQueryUItimePatterns.containsKey(patternPart)) { if (patternSource != null && patternSource.containsKey(patternPart)) { result = new StringBuffer(); } else { if (anyPatternRecognized) { break; } else { anyPatternRecognized = true; patternSource = java2jQueryUIdatePatterns.containsKey(patternPart) ? java2jQueryUIdatePatterns : java2jQueryUItimePatterns; } } } } else { if (anyPatternRecognized) { if (result.length() > 0 || !specialCharacters.contains(new Character(patternPart.charAt(0)))) { result.append(patternPart); } } } } return REGEX_APOSTROPHE.matcher(result.toString()).replaceAll(""); }
From source file:com.jaspersoft.studio.utils.jasper.JasperReportsConfiguration.java
public Character getPropertyCharacterDef(String key, Character def) { Character p = getPropertyCharacter(key); if (p == null) { String v = pstore.getDefaultString(key); if (v != null && !v.isEmpty()) return new Character(v.charAt(0)); }//www.j ava2 s . co m if (p == null) p = def; return p; }
From source file:wicket.util.lang.Objects.java
/** * Returns the value converted numerically to the given class type * //from w w w .j a v a 2 s . co m * This method also detects when arrays are being converted and converts the * components of one array to the type of the other. * * @param value * an object to be converted to the given type * @param toType * class type to be converted to * @return converted value of the type given, or value if the value cannot * be converted to the given type. */ public static Object convertValue(Object value, Class toType) { Object result = null; if (value != null) { /* If array -> array then convert components of array individually */ if (value.getClass().isArray() && toType.isArray()) { Class componentType = toType.getComponentType(); result = Array.newInstance(componentType, Array.getLength(value)); for (int i = 0, icount = Array.getLength(value); i < icount; i++) { Array.set(result, i, convertValue(Array.get(value, i), componentType)); } } else { if ((toType == Integer.class) || (toType == Integer.TYPE)) { result = new Integer((int) longValue(value)); } if ((toType == Double.class) || (toType == Double.TYPE)) { result = new Double(doubleValue(value)); } if ((toType == Boolean.class) || (toType == Boolean.TYPE)) { result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE; } if ((toType == Byte.class) || (toType == Byte.TYPE)) { result = new Byte((byte) longValue(value)); } if ((toType == Character.class) || (toType == Character.TYPE)) { result = new Character((char) longValue(value)); } if ((toType == Short.class) || (toType == Short.TYPE)) { result = new Short((short) longValue(value)); } if ((toType == Long.class) || (toType == Long.TYPE)) { result = new Long(longValue(value)); } if ((toType == Float.class) || (toType == Float.TYPE)) { result = new Float(doubleValue(value)); } if (toType == BigInteger.class) { result = bigIntValue(value); } if (toType == BigDecimal.class) { result = bigDecValue(value); } if (toType == String.class) { result = stringValue(value); } } } else { if (toType.isPrimitive()) { result = primitiveDefaults.get(toType); } } return result; }
From source file:net.openkoncept.vroom.VroomController.java
private Object getParameterValue(Class propType, String id, Object[] paramValues, String format, Map paramMap) { Object value = null;/* w w w . java 2 s . c o m*/ if (paramValues == null) { if (paramMap != null) { value = paramMap.get(id); if (value instanceof List) { List l = (List) value; paramValues = l.toArray(); value = null; } } } SimpleDateFormat sdf = null; try { String typeName = propType.getName(); if (typeName.indexOf("java.lang.String") != -1) { if (!propType.isArray()) { value = paramValues[0]; } else { value = new String[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = paramValues[i]; } } } else if (typeName.indexOf("java.lang.Character") != -1) { if (!propType.isArray()) { value = new Character(((String) paramValues[0]).charAt(0)); } else { value = new Character[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = new Character(((String) paramValues[i]).charAt(0)); } } } else if (typeName.indexOf("java.lang.Short") != -1) { if (!propType.isArray()) { value = Short.valueOf((String) paramValues[0]); } else { value = new Short[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = Short.valueOf((String) paramValues[i]); } } } else if (typeName.indexOf("java.lang.Integer") != -1) { if (!propType.isArray()) { value = Integer.valueOf((String) paramValues[0]); } else { value = new Integer[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = Integer.valueOf((String) paramValues[i]); } } } else if (typeName.indexOf("java.lang.Long") != -1) { if (!propType.isArray()) { value = Long.valueOf((String) paramValues[0]); } else { value = new Long[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = Long.valueOf((String) paramValues[i]); } } } else if (typeName.indexOf("java.lang.Float") != -1) { if (!propType.isArray()) { value = Float.valueOf((String) paramValues[0]); } else { value = new Float[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = Float.valueOf((String) paramValues[i]); } } } else if (typeName.indexOf("java.lang.Double") != -1) { if (!propType.isArray()) { value = Double.valueOf((String) paramValues[0]); } else { value = new Double[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = Double.valueOf((String) paramValues[i]); } } } else if (typeName.indexOf("java.lang.Boolean") != -1) { if (!propType.isArray()) { value = Boolean.valueOf((String) paramValues[0]); } else { value = new Boolean[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = Boolean.valueOf((String) paramValues[i]); } } } else if (typeName.indexOf("java.util.Date") != -1) { if (format != null) { sdf = new SimpleDateFormat(format); } else { sdf = new SimpleDateFormat(); } if (!propType.isArray()) { value = sdf.parse((String) paramValues[0]); } else { value = new Date[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = sdf.parse((String) paramValues[i]); } } } else if (typeName.indexOf("org.apache.commons.fileupload.FileItem") != -1) { if (!propType.isArray()) { value = paramValues[0]; } else { value = new org.apache.commons.fileupload.FileItem[paramValues.length]; for (int i = 0; i < paramValues.length; i++) { ((Object[]) value)[i] = paramValues[i]; } } } } catch (Exception ex) { value = null; } return value; }