List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:org.vertx.java.http.eventbusbridge.integration.MessagePublishTest.java
@Test public void testPublishingCharacterJson() 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);//from ww w .j a va2 s . c o m registerListenersAndCheckForResponses(messagePublishHandler, expectations, NUMBER_OF_PUBLISH_HANDLERS, completedCount); String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_JSON, expectations); HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_JSON); }
From source file:cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl.java
/** * Create a HardwareAddress object from its XML representation. * * @param pElement DOM element containing the XML representation of a HardwareAddress object, as created by the * toConfigXML() method. * @throws RuntimeException if unable to instantiate the Hardware address * @see cern.c2mon.shared.common.datatag.address.HardwareAddress#toConfigXML() */// www . j a v a2 s .c om public final synchronized HardwareAddress fromConfigXML(Element pElement) { Class hwAddressClass = null; HardwareAddressImpl hwAddress = null; try { hwAddressClass = Class.forName(pElement.getAttribute("class")); hwAddress = (HardwareAddressImpl) hwAddressClass.newInstance(); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); throw new RuntimeException("Exception caught when instantiating a hardware address from XML", cnfe); } catch (IllegalAccessException iae) { iae.printStackTrace(); throw new RuntimeException("Exception caught when instantiating a hardware address from XML", iae); } catch (InstantiationException ie) { ie.printStackTrace(); throw new RuntimeException("Exception caught when instantiating a hardware address from XML", ie); } NodeList fields = pElement.getChildNodes(); Node fieldNode = null; int fieldsCount = fields.getLength(); String fieldName; String fieldValueString; String fieldTypeName = ""; for (int i = 0; i < fieldsCount; i++) { fieldNode = fields.item(i); if (fieldNode.getNodeType() == Node.ELEMENT_NODE) { fieldName = fieldNode.getNodeName(); if (fieldNode.getFirstChild() != null) { fieldValueString = fieldNode.getFirstChild().getNodeValue(); } else { fieldValueString = ""; } try { Field field = hwAddressClass.getDeclaredField(decodeFieldName(fieldName)); fieldTypeName = field.getType().getName(); if (fieldTypeName.equals("short")) { field.setShort(hwAddress, Short.parseShort(fieldValueString)); } else if (fieldTypeName.equals("java.lang.Short")) { field.set(hwAddress, new Integer(Integer.parseInt(fieldValueString))); } else if (fieldTypeName.equals("int")) { field.setInt(hwAddress, Integer.parseInt(fieldValueString)); } else if (fieldTypeName.equals("java.lang.Integer")) { field.set(hwAddress, new Integer(Integer.parseInt(fieldValueString))); } else if (fieldTypeName.equals("float")) { field.setFloat(hwAddress, Float.parseFloat(fieldValueString)); } else if (fieldTypeName.equals("java.lang.Float")) { field.set(hwAddress, new Float(Float.parseFloat(fieldValueString))); } else if (fieldTypeName.equals("double")) { field.setDouble(hwAddress, Double.parseDouble(fieldValueString)); } else if (fieldTypeName.equals("java.lang.Double")) { field.set(hwAddress, new Double(Double.parseDouble(fieldValueString))); } else if (fieldTypeName.equals("long")) { field.setLong(hwAddress, Long.parseLong(fieldValueString)); } else if (fieldTypeName.equals("java.lang.Long")) { field.set(hwAddress, new Long(Long.parseLong(fieldValueString))); } else if (fieldTypeName.equals("byte")) { field.setByte(hwAddress, Byte.parseByte(fieldValueString)); } else if (fieldTypeName.equals("java.lang.Byte")) { field.set(hwAddress, new Byte(Byte.parseByte(fieldValueString))); } else if (fieldTypeName.equals("char")) { field.setChar(hwAddress, fieldValueString.charAt(0)); } else if (fieldTypeName.equals("java.lang.Character")) { field.set(hwAddress, new Character(fieldValueString.charAt(0))); } else if (fieldTypeName.equals("boolean")) { field.setBoolean(hwAddress, Boolean.getBoolean(fieldValueString)); } else if (fieldTypeName.equals("java.lang.Boolean")) { field.set(hwAddress, new Boolean(Boolean.getBoolean(fieldValueString))); } else if (fieldTypeName.equals("java.util.HashMap")) { field.set(hwAddress, SimpleXMLParser.domNodeToMap(fieldNode)); } else if (field.getType().isEnum()) { Object[] enumConstants = field.getType().getEnumConstants(); for (Object enumConstant : enumConstants) { if (enumConstant.toString().equals(fieldValueString)) { field.set(hwAddress, enumConstant); } } } else { field.set(hwAddress, fieldValueString); } } catch (NoSuchFieldException nsfe) { String errorMsg = "fromConfigXML(...) - Error occured while parsing XML <HardwareAddress> tag. " + "The following variable does not exist in " + hwAddressClass.toString() + ": \"" + decodeFieldName(fieldName) + "\""; log.error(errorMsg); throw new IllegalArgumentException(errorMsg); } catch (IllegalAccessException iae) { iae.printStackTrace(); throw new RuntimeException(iae); } catch (NumberFormatException npe) { String errorMsg = "fromConfigXML(...) - Error occured while parsing XML <HardwareAddress> tag. Field \"" + fieldName + "\" shall not be empty since we expect a \"" + fieldTypeName + "\" value. Please correct the XML configuration for " + hwAddressClass.toString(); log.error(errorMsg); throw new IllegalArgumentException(errorMsg); } } } return hwAddress; }
From source file:com.edmunds.autotest.AutoTestGetterSetter.java
private static Map<Class<?>, Object> createValueMap() { Map<Class<?>, Object> valueMap = new HashMap<Class<?>, Object>(); valueMap.put(byte.class, new Byte((byte) 40)); valueMap.put(short.class, new Short((short) 41)); valueMap.put(int.class, new Integer(42)); valueMap.put(long.class, new Long(43)); valueMap.put(float.class, new Float(44)); valueMap.put(double.class, new Double(45)); valueMap.put(boolean.class, Boolean.TRUE); valueMap.put(char.class, new Character((char) 46)); valueMap.put(Byte.class, new Byte((byte) 40)); valueMap.put(Short.class, new Short((short) 41)); valueMap.put(Integer.class, new Integer(42)); valueMap.put(Long.class, new Long(43)); valueMap.put(Float.class, new Float(44)); valueMap.put(Double.class, new Double(45)); valueMap.put(Boolean.class, Boolean.TRUE); valueMap.put(Character.class, new Character((char) 46)); return valueMap; }
From source file:com.konakart.actions.gateways.PayjunctionAction.java
public String execute() { HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); String errorDesc = null;/* ww w.j a v a2 s .c o m*/ String gatewayResult = null; String transactionId = null; if (log.isDebugEnabled()) { log.debug("PayJunctionAction: code = " + code); } // Create these outside of try / catch since they are needed in the case of a general // exception IpnHistoryIf ipnHistory = new IpnHistory(); ipnHistory.setModuleCode(code); KKAppEng kkAppEng = null; try { int custId; kkAppEng = this.getKKAppEng(request, response); boolean payJunctionDebugMode = log.isDebugEnabled(); // Check to see whether the user is logged in custId = this.loggedIn(request, response, kkAppEng, "Checkout"); if (custId < 0) { if (log.isDebugEnabled()) { log.debug("PayJunctionAction: NotLoggedIn"); } return KKLOGIN; } // Ensure we are using the correct protocol. Redirect if not. String redirForward = checkSSL(kkAppEng, request, custId, /* forceSSL */false); if (redirForward != null) { if (log.isDebugEnabled()) { log.debug("PayJunctionAction: Redirect SSL"); } setupResponseForSSLRedirect(response, redirForward); return null; } // Get the order OrderIf order = kkAppEng.getOrderMgr().getCheckoutOrder(); validateOrder(order, code); if (log.isDebugEnabled()) { log.debug("PayJunctionAction: Order " + order.getId() + " validated"); } // Set the order id for the ipnHistory object ipnHistory.setOrderId(order.getId()); // Get the parameter list for the payment that have been set up earlier PaymentDetailsIf pd = order.getPaymentDetails(); // Now make a second parameter list containing parameters we don't save List<NameValueIf> parmList = new ArrayList<NameValueIf>(); parmList.add(new NameValue("dc_name", encode(pd.getCcOwner()))); parmList.add(new NameValue("dc_number", encode(pd.getCcNumber()))); parmList.add(new NameValue("dc_expiration_month", encode(pd.getCcExpiryMonth()))); parmList.add(new NameValue("dc_expiration_year", encode(pd.getCcExpiryYear()))); if (pd.isShowCVV()) { parmList.add(new NameValue("dc_verification_number", encode(pd.getCcCVV()))); } parmList.add(new NameValue("dc_address", encode(pd.getCcStreetAddress()))); parmList.add(new NameValue("dc_zipcode", encode(pd.getCcPostcode()))); parmList.add(new NameValue("dc_notes", encode("KonaKart OrderId = " + order.getId()))); if (log.isDebugEnabled()) { log.debug("PayJunctionAction: Post the payment details to the gateway"); } // Do the post String gatewayResp = postData(pd, parmList); gatewayResp = URLDecoder.decode(gatewayResp, "UTF-8"); if (log.isDebugEnabled()) { log.debug("Unformatted GatewayResp = \n" + gatewayResp); } if (payJunctionDebugMode) { // Write the response to a file which is handy for diagnosing problems try { String outputFilename = getLogFileDirectory(kkAppEng) + "payjunction_resp_" + order.getId() + ".txt"; File myOutFile = new File(outputFilename); if (log.isDebugEnabled()) { log.debug("Write gateway response to " + myOutFile.getAbsolutePath()); } BufferedWriter bw = new BufferedWriter(new FileWriter(myOutFile)); bw.write(gatewayResp); bw.close(); } catch (Exception e) { // dump the exception and continue e.printStackTrace(); } } StringBuffer sb = new StringBuffer(); HashMap<String, String> response_hash = new HashMap<String, String>(); StringTokenizer st1 = new StringTokenizer(gatewayResp.toString(), new Character((char) 0x1C).toString()); // process results so they are in an easy-to-access format while (st1.hasMoreTokens()) { String key = null, value = null; StringTokenizer st2 = new StringTokenizer(st1.nextToken(), "="); key = st2.nextToken(); if (st2.hasMoreElements()) { value = st2.nextToken(); } response_hash.put(key, value); if (log.isDebugEnabled()) { log.debug("Add to hash: " + key + " = " + value); } sb.append(key + " = " + value + "\n"); } gatewayResult = response_hash.get("dc_response_code"); transactionId = response_hash.get("dc_transaction_id"); errorDesc = response_hash.get("dc_response_message"); // Put the response in the ipnHistory record ipnHistory.setGatewayFullResponse(sb.toString()); ipnHistory.setGatewayTransactionId(transactionId); ipnHistory.setGatewayResult(gatewayResult); if (log.isDebugEnabled()) { log.debug("Response data:"); log.debug(sb.toString()); } // See if we need to send an email, by looking at the configuration String sendEmailsConfig = kkAppEng.getConfig(ConfigConstants.SEND_EMAILS); boolean sendEmail = false; if (sendEmailsConfig != null && sendEmailsConfig.equalsIgnoreCase("true")) { sendEmail = true; } OrderUpdateIf updateOrder = new OrderUpdate(); updateOrder.setUpdatedById(kkAppEng.getActiveCustId()); // Determine whether the request was successful or not.If successful, we update the // inventory as well as changing the state of the order if (gatewayResult != null && (gatewayResult.equals("00") || gatewayResult.equals("85"))) { String comment = ORDER_HISTORY_COMMENT_OK + transactionId; kkAppEng.getEng().updateOrder(kkAppEng.getSessionId(), order.getId(), com.konakart.bl.OrderMgr.PAYMENT_RECEIVED_STATUS, /* customerNotified */ sendEmail, comment, updateOrder); // Update the inventory kkAppEng.getOrderMgr().updateInventory(order.getId()); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RESULT_APPROVED_DESC + " (" + errorDesc + ")"); ipnHistory.setKonakartResultId(RESULT_APPROVED); ipnHistory.setOrderId(order.getId()); ipnHistory.setCustomerId(kkAppEng.getCustomerMgr().getCurrentCustomer().getId()); kkAppEng.getEng().saveIpnHistory(kkAppEng.getSessionId(), ipnHistory); // If we received no exceptions, delete the basket kkAppEng.getBasketMgr().emptyBasket(); if (sendEmail) { sendOrderConfirmationMail(kkAppEng, order.getId(), /* success */true); } return "Approved"; } else if (gatewayResult != null) { String comment = ORDER_HISTORY_COMMENT_KO + errorDesc; kkAppEng.getEng().updateOrder(kkAppEng.getSessionId(), order.getId(), com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, /* customerNotified */ sendEmail, comment, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription( RESULT_DECLINED_DESC + " (" + gatewayResult + ") " + errorDesc); ipnHistory.setKonakartResultId(RESULT_DECLINED); ipnHistory.setCustomerId(kkAppEng.getCustomerMgr().getCurrentCustomer().getId()); kkAppEng.getEng().saveIpnHistory(kkAppEng.getSessionId(), ipnHistory); if (sendEmail) { sendOrderConfirmationMail(kkAppEng, order.getId(), /* success */false); } String msg = kkAppEng.getMsg("checkout.cc.gateway.error", new String[] { errorDesc }); addActionError(msg); // Redirect the user back to the credit card screen return "TryAgain"; } else { /* * We only get to here if there was an unknown response from the gateway */ String comment = RESULT_UNKNOWN_GATEWAY_ERROR_DESC; kkAppEng.getEng().updateOrder(kkAppEng.getSessionId(), order.getId(), com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, /* customerNotified */ sendEmail, comment, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RESULT_UNKNOWN_GATEWAY_ERROR_DESC); ipnHistory.setKonakartResultId(RESULT_UNKNOWN_GATEWAY_ERROR); ipnHistory.setCustomerId(kkAppEng.getCustomerMgr().getCurrentCustomer().getId()); kkAppEng.getEng().saveIpnHistory(kkAppEng.getSessionId(), ipnHistory); if (sendEmail) { sendOrderConfirmationMail(kkAppEng, order.getId(), /* success */false); } String msg = kkAppEng.getMsg("checkout.cc.gateway.error", new String[] { "?" }); addActionError(msg); // Redirect the user back to the credit card screen return "TryAgain"; } } catch (Exception e) { try { if (kkAppEng != null) { ipnHistory.setKonakartResultDescription(RESULT_UNKNOWN_EXCEPTION_DESC + e.getMessage()); ipnHistory.setKonakartResultId(RESULT_UNKNOWN_EXCEPTION); ipnHistory.setCustomerId(kkAppEng.getCustomerMgr().getCurrentCustomer().getId()); ipnHistory.setGatewayResult(e.toString()); kkAppEng.getEng().saveIpnHistory(kkAppEng.getSessionId(), ipnHistory); } if (log.isWarnEnabled()) { log.warn("Exception communicating with PayJunction"); e.printStackTrace(); } } catch (KKException e1) { return super.handleException(request, e1); } return super.handleException(request, e); } }
From source file:net.sf.morph.util.TestUtils.java
/** * Return a "not-same" instance./*from w ww .j a v a2s.co m*/ * @param type * @param o * @return */ public static Object getDifferentInstance(Class type, Object o) { if (type == null) { throw new IllegalArgumentException("Non-null type must be specified"); } if (type.isPrimitive()) { type = ClassUtils.getPrimitiveWrapper(type); } if (o != null && !type.isInstance(o)) { throw new IllegalArgumentException("Negative example object should be of type " + type); } if (type == Number.class) { type = Integer.class; } if (Number.class.isAssignableFrom(type)) { byte b = (byte) (o == null ? 0 : ((Number) o).byteValue() + 1); try { return type.getConstructor(ONE_STRING).newInstance(new Object[] { Byte.toString(b) }); } catch (Exception e) { throw e instanceof RuntimeException ? (RuntimeException) e : new NestableRuntimeException(e); } } if (type == Character.class) { char c = (char) (o == null ? 0 : ((Character) o).charValue() + 1); return new Character(c); } if (type == Boolean.class) { return o != null && ((Boolean) o).booleanValue() ? Boolean.FALSE : Boolean.TRUE; } if (type.isArray()) { return Array.newInstance(type.getComponentType(), 0); } if (type == Class.class) { return o == Object.class ? Class.class : Object.class; } return ClassUtils.newInstance(convertCommonInterfaces(type)); }
From source file:org.hyperic.hq.ui.taglib.OptionMessageListTag.java
protected Iterator getIterator(Object collection) throws JspException { try {// w w w.java2s. c o m return super.getIterator(collection); } catch (ClassCastException e) { List list; if (collection.getClass().isArray()) { if (collection instanceof short[]) { short[] arr = (short[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Short(arr[i])); } } else if (collection instanceof int[]) { int[] arr = (int[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Integer(arr[i])); } } else if (collection instanceof long[]) { long[] arr = (long[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Long(arr[i])); } } else if (collection instanceof float[]) { float[] arr = (float[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Float(arr[i])); } } else if (collection instanceof double[]) { double[] arr = (double[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Double(arr[i])); } } else if (collection instanceof byte[]) { byte[] arr = (byte[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Byte(arr[i])); } } else if (collection instanceof char[]) { char[] arr = (char[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Character(arr[i])); } } else if (collection instanceof boolean[]) { boolean[] arr = (boolean[]) collection; list = new ArrayList(arr.length); for (int i = 0; i < arr.length; ++i) { list.add(new Boolean(arr[i])); } } else { list = new ArrayList(); } } else { list = new ArrayList(); } return list.iterator(); } }
From source file:net.lightbody.bmp.proxy.jetty.util.TypeUtil.java
/** Convert String value to instance. * @param type The class of the instance, which may be a primitive TYPE field. * @param value The value as a string.// ww w .ja va 2s . co m * @return The value as an Object. */ public static Object valueOf(Class type, String value) { try { if (type.equals(java.lang.String.class)) return value; Method m = (Method) class2Value.get(type); if (m != null) return m.invoke(null, new Object[] { value }); if (type.equals(java.lang.Character.TYPE) || type.equals(java.lang.Character.class)) return new Character(value.charAt(0)); Constructor c = type.getConstructor(stringArg); return c.newInstance(new Object[] { value }); } catch (NoSuchMethodException e) { LogSupport.ignore(log, e); } catch (IllegalAccessException e) { LogSupport.ignore(log, e); } catch (InstantiationException e) { LogSupport.ignore(log, e); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof Error) throw (Error) (e.getTargetException()); LogSupport.ignore(log, e); } return null; }
From source file:org.docx4j.fonts.fop.fonts.SingleByteFont.java
/** * Adds an unencoded character (one that is not supported by the primary encoding). * @param ch the named character//from w w w. j a v a 2s .c o m * @param width the width of the character */ public void addUnencodedCharacter(NamedCharacter ch, int width) { if (this.unencodedCharacters == null) { this.unencodedCharacters = new java.util.HashMap(); } if (ch.hasSingleUnicodeValue()) { UnencodedCharacter uc = new UnencodedCharacter(ch, width); this.unencodedCharacters.put(new Character(ch.getSingleUnicodeValue()), uc); } else { //Cannot deal with unicode sequences, so ignore this character } }
From source file:org.janusgraph.graphdb.serializer.SerializerTest.java
License:asdf
@Test public void primitiveSerialization() { DataOutput out = serialize.getDataOutput(128); out.writeObjectNotNull(Boolean.FALSE); out.writeObjectNotNull(Boolean.TRUE); out.writeObjectNotNull(Byte.MIN_VALUE); out.writeObjectNotNull(Byte.MAX_VALUE); out.writeObjectNotNull((byte) 0); out.writeObjectNotNull(Short.MIN_VALUE); out.writeObjectNotNull(Short.MAX_VALUE); out.writeObjectNotNull((short) 0); out.writeObjectNotNull(Character.MIN_VALUE); out.writeObjectNotNull(Character.MAX_VALUE); out.writeObjectNotNull('a'); out.writeObjectNotNull(Integer.MIN_VALUE); out.writeObjectNotNull(Integer.MAX_VALUE); out.writeObjectNotNull(0);//w w w .j a v a 2 s . c om out.writeObjectNotNull(Long.MIN_VALUE); out.writeObjectNotNull(Long.MAX_VALUE); out.writeObjectNotNull(0L); out.writeObjectNotNull((float) 0.0); out.writeObjectNotNull(0.0); ReadBuffer b = out.getStaticBuffer().asReadBuffer(); assertEquals(Boolean.FALSE, serialize.readObjectNotNull(b, Boolean.class)); assertEquals(Boolean.TRUE, serialize.readObjectNotNull(b, Boolean.class)); assertEquals(Byte.MIN_VALUE, serialize.readObjectNotNull(b, Byte.class).longValue()); assertEquals(Byte.MAX_VALUE, serialize.readObjectNotNull(b, Byte.class).longValue()); assertEquals(0, serialize.readObjectNotNull(b, Byte.class).longValue()); assertEquals(Short.MIN_VALUE, serialize.readObjectNotNull(b, Short.class).longValue()); assertEquals(Short.MAX_VALUE, serialize.readObjectNotNull(b, Short.class).longValue()); assertEquals(0, serialize.readObjectNotNull(b, Short.class).longValue()); assertEquals(Character.MIN_VALUE, serialize.readObjectNotNull(b, Character.class).charValue()); assertEquals(Character.MAX_VALUE, serialize.readObjectNotNull(b, Character.class).charValue()); assertEquals(new Character('a'), serialize.readObjectNotNull(b, Character.class)); assertEquals(Integer.MIN_VALUE, serialize.readObjectNotNull(b, Integer.class).longValue()); assertEquals(Integer.MAX_VALUE, serialize.readObjectNotNull(b, Integer.class).longValue()); assertEquals(0, serialize.readObjectNotNull(b, Integer.class).longValue()); assertEquals(Long.MIN_VALUE, serialize.readObjectNotNull(b, Long.class).longValue()); assertEquals(Long.MAX_VALUE, serialize.readObjectNotNull(b, Long.class).longValue()); assertEquals(0, serialize.readObjectNotNull(b, Long.class).longValue()); assertEquals(0.0, serialize.readObjectNotNull(b, Float.class), 1e-20); assertEquals(0.0, serialize.readObjectNotNull(b, Double.class), 1e-20); }
From source file:org.gbif.portal.dao.geospatial.impl.hibernate.CountryDAOImpl.java
/** * @see org.gbif.portal.dao.geospatial.CountryDAO#getCountryAlphabet(java.util.Locale) *///from ww w .java 2 s. co m @SuppressWarnings("unchecked") public List<Character> getCountryAlphabet(final Locale locale) { HibernateTemplate template = getHibernateTemplate(); List<String> results = (List<String>) template.execute(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.createSQLQuery( "select distinct(SUBSTRING(name,1,1)) from country_name where locale=? and name!=' %' order by name"); query.setParameter(0, getLocaleForQuery(locale)); return query.list(); } }); ArrayList<Character> chars = new ArrayList<Character>(); for (String result : results) { if (StringUtils.isNotEmpty(result)) chars.add(new Character(result.charAt(0))); } return chars; }