List of usage examples for java.lang Character valueOf
@HotSpotIntrinsicCandidate public static Character valueOf(char c)
From source file:com.vmware.bdd.cli.commands.ClusterCommands.java
private String getInputedPassword(String promptMsg) { try {// w w w.j ava2s. co m ConsoleReader reader = CommandsUtils.getConsoleReader(); reader.setPrompt(promptMsg); String password = null; password = reader.readLine(Character.valueOf('*')); if (isValidPassword(password)) { return password; } else { return null; } } catch (IOException e) { return null; } }
From source file:org.eclipse.kapua.app.console.server.GwtDeviceManagementServiceImpl.java
private Object getObjectValue(GwtConfigParameter gwtConfigParam, String strValue) { Object objValue = null;//w ww .j a va 2 s . c o m if (strValue != null) { GwtConfigParameterType gwtType = gwtConfigParam.getType(); switch (gwtType) { case LONG: objValue = Long.parseLong(strValue); break; case DOUBLE: objValue = Double.parseDouble(strValue); break; case FLOAT: objValue = Float.parseFloat(strValue); break; case INTEGER: objValue = Integer.parseInt(strValue); break; case SHORT: objValue = Short.parseShort(strValue); break; case BYTE: objValue = Byte.parseByte(strValue); break; case BOOLEAN: objValue = Boolean.parseBoolean(strValue); break; case PASSWORD: objValue = new Password(strValue); break; case CHAR: objValue = Character.valueOf(strValue.charAt(0)); break; case STRING: objValue = strValue; break; } } return objValue; }
From source file:org.apache.axis2.corba.receivers.CorbaUtil.java
public static Object parseValue(DataType type, String value) { if (value == null) return null; value = value.trim();//from w ww. ja v a 2 s . c o m Object ret = null; switch (type.getTypeCode().kind().value()) { case TCKind._tk_long: ret = Integer.valueOf(value); break; case TCKind._tk_ulong: ret = Integer.valueOf(value); break; case TCKind._tk_longlong: ret = Long.valueOf(value); break; case TCKind._tk_ulonglong: ret = Long.valueOf(value); break; case TCKind._tk_short: ret = Short.valueOf(value); break; case TCKind._tk_ushort: ret = Short.valueOf(value); break; case TCKind._tk_float: ret = Float.valueOf(value); break; case TCKind._tk_double: ret = Double.valueOf(value); break; case TCKind._tk_char: ret = Character.valueOf(value.charAt(0)); break; case TCKind._tk_wchar: ret = Character.valueOf(value.charAt(0)); break; case TCKind._tk_boolean: ret = Boolean.valueOf(value); break; case TCKind._tk_octet: ret = Byte.valueOf(value); break; case TCKind._tk_string: ret = value; break; case TCKind._tk_wstring: ret = value; break; case TCKind._tk_enum: EnumType enumType = (EnumType) type; EnumValue enumValue = new EnumValue(enumType); int i = enumType.getEnumMembers().indexOf(value); enumValue.setValue(i); ret = enumValue; break; default: log.error("ERROR! Invalid dataType"); break; } return ret; }
From source file:org.apache.openjpa.kernel.StateManagerImpl.java
public Object fetchField(int field, boolean transitions) { FieldMetaData fmd = _meta.getField(field); if (fmd == null) throw new UserException(_loc.get("no-field", String.valueOf(field), getManagedInstance().getClass())) .setFailedObject(getManagedInstance()); // do normal state transitions if (!fmd.isPrimaryKey() && transitions) accessingField(field);//from w w w. j a v a 2 s. co m switch (fmd.getDeclaredTypeCode()) { case JavaTypes.STRING: return fetchStringField(field); case JavaTypes.OBJECT: return fetchObjectField(field); case JavaTypes.BOOLEAN: return (fetchBooleanField(field)) ? Boolean.TRUE : Boolean.FALSE; case JavaTypes.BYTE: return Byte.valueOf(fetchByteField(field)); case JavaTypes.CHAR: return Character.valueOf(fetchCharField(field)); case JavaTypes.DOUBLE: return Double.valueOf(fetchDoubleField(field)); case JavaTypes.FLOAT: return Float.valueOf(fetchFloatField(field)); case JavaTypes.INT: return fetchIntField(field); case JavaTypes.LONG: return fetchLongField(field); case JavaTypes.SHORT: return Short.valueOf(fetchShortField(field)); default: return fetchObjectField(field); } }
From source file:com.glaf.core.util.StringTools.java
public static String splitLine(String sourceString, int length) { if (sourceString == null) { return ""; }//from www .ja v a 2 s.c o m if (sourceString.length() <= length) { return sourceString; } char[] sourceChrs = sourceString.toCharArray(); char[] distinChrs = new char[length]; for (int i = 0; i < length; i++) { if (i >= sourceChrs.length) { return sourceString; } Character chr = Character.valueOf(sourceChrs[i]); if (chr.charValue() <= 202 && chr.charValue() >= 8) { distinChrs[i] = chr.charValue(); } else { distinChrs[i] = chr.charValue(); length--; } } return new String(distinChrs) + ""; }
From source file:org.apache.openjpa.kernel.StateManagerImpl.java
/** * Fetch the specified field from the specified field manager, wrapping it * in an object if it's a primitive. A field should be provided to the * field manager before this call is made. *//*from w w w .j a v a 2s .c o m*/ private static Object fetchField(FieldManager fm, FieldMetaData fmd) { int field = fmd.getIndex(); switch (fmd.getDeclaredTypeCode()) { case JavaTypes.BOOLEAN: return (fm.fetchBooleanField(field)) ? Boolean.TRUE : Boolean.FALSE; case JavaTypes.BYTE: return Byte.valueOf(fm.fetchByteField(field)); case JavaTypes.CHAR: return Character.valueOf(fm.fetchCharField(field)); case JavaTypes.DOUBLE: return Double.valueOf(fm.fetchDoubleField(field)); case JavaTypes.FLOAT: return Float.valueOf(fm.fetchFloatField(field)); case JavaTypes.INT: return fm.fetchIntField(field); case JavaTypes.LONG: return fm.fetchLongField(field); case JavaTypes.SHORT: return Short.valueOf(fm.fetchShortField(field)); case JavaTypes.STRING: return fm.fetchStringField(field); default: return fm.fetchObjectField(field); } }
From source file:fi.ni.IFC_ClassModel.java
/** * Parse_ if c_ line statement./* w w w. j a v a2 s . c o m*/ * * @param line * the line */ private void parse_IFC_LineStatement(String line) { IFC_X3_VO ifcvo = new IFC_X3_VO(); int state = 0; StringBuffer sb = new StringBuffer(); int cl_count = 0; LinkedList<Object> current = ifcvo.getList(); Stack<LinkedList<Object>> list_stack = new Stack<LinkedList<Object>>(); for (int i = 0; i < line.length(); i++) { char ch = line.charAt(i); switch (state) { case 0: if (ch == '=') { ifcvo.setLine_num(toLong(sb.toString())); sb.setLength(0); state++; continue; } else if (Character.isDigit(ch)) sb.append(ch); break; case 1: // ( if (ch == '(') { ifcvo.setName(sb.toString()); sb.setLength(0); state++; continue; } else if (ch == ';') { ifcvo.setName(sb.toString()); sb.setLength(0); state = Integer.MAX_VALUE; } else if (!Character.isWhitespace(ch)) sb.append(ch); break; case 2: // (... line started and doing (... if (ch == '\'') { state++; } if (ch == '(') { list_stack.push(current); LinkedList<Object> tmp = new LinkedList<Object>(); if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); sb.setLength(0); current.add(tmp); // listaan listn lista current = tmp; cl_count++; // sb.append(ch); } else if (ch == ')') { if (cl_count == 0) { if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); sb.setLength(0); state = Integer.MAX_VALUE; // line is done continue; } else { if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); sb.setLength(0); cl_count--; current = list_stack.pop(); } } else if (ch == ',') { if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); current.add(Character.valueOf(ch)); sb.setLength(0); } else { sb.append(ch); } break; case 3: // (... if (ch == '\'') { state--; } else { sb.append(ch); } break; default: // Do nothing } } linemap.put(ifcvo.line_num, ifcvo); }
From source file:io.fabric8.kubernetes.api.KubernetesHelper.java
/** * Validates that the given value is valid according to the kubernetes ID parsing rules, throwing an exception if not. *//*from w w w . j a v a 2 s. co m*/ public static String validateKubernetesId(String currentValue, String description) throws IllegalArgumentException { if (isNullOrBlank(currentValue)) { throw new IllegalArgumentException("No " + description + " is specified!"); } int size = currentValue.length(); for (int i = 0; i < size; i++) { char ch = currentValue.charAt(i); if (Character.isUpperCase(ch)) { throw new IllegalArgumentException("Invalid upper case letter '" + Character.valueOf(ch) + "' at index " + i + " for " + description + " value: " + currentValue); } } return currentValue; }
From source file:org.wso2.carbon.identity.sso.saml.util.SAMLSSOUtil.java
private static String normalizeUrlEncoding(String text) { if (text == null) return null; int len = text.length(); StringBuilder normalized = new StringBuilder(len); for (int i = 0; i < len; i++) { char current = text.charAt(i); if (current == '%' && i < len - 2) { String percentCode = text.substring(i, i + 3).toUpperCase(); try { String str = URLDecoder.decode(percentCode, "ISO-8859-1"); char chr = str.charAt(0); if (UNRESERVED_CHARACTERS.contains(Character.valueOf(chr))) normalized.append(chr); else normalized.append(percentCode); } catch (UnsupportedEncodingException e) { normalized.append(percentCode); if (log.isDebugEnabled()) { log.debug("Unsupported Encoding exception while decoding percent code.", e); }/*from w w w .ja v a2s . com*/ } i += 2; } else { normalized.append(current); } } return normalized.toString(); }
From source file:org.specrunner.plugins.core.objects.AbstractPluginObject.java
/** * Sets a char to a field./* w w w . jav a 2 s .c o m*/ * * @param instance * The object instance. * @param f * The field information. * @param value * The value to be set. * @throws Exception * On setting errors. */ protected void setChar(Object instance, Field f, Object value) throws Exception { PropertyUtils.setProperty(instance, f.getFullName(), Character.valueOf(String.valueOf(value).charAt(0))); }