List of usage examples for java.lang Character valueOf
@HotSpotIntrinsicCandidate public static Character valueOf(char c)
From source file:com.nebhale.gpxconverter.GoogleMapsEncoder.java
private String encodeNumber(Long number) { StringBuilder encodeString = new StringBuilder(); long nextValue; long finalValue; while (number >= 0x20) { nextValue = (0x20 | (number & 0x1f)) + 63; encodeString.append(Character.valueOf((char) nextValue)); number >>= 5;/*from w ww .j av a 2 s . c o m*/ } finalValue = number + 63; encodeString.append(Character.valueOf((char) finalValue)); return encodeString.toString(); }
From source file:com.edgenius.wiki.gwt.server.SearchControllerImpl.java
public SearchResultModel search(QueryModel query, int selectPageNumber, int returnCount) { SearchResultModel model = new SearchResultModel(); try {//from w ww .j a v a 2s . com List<String> adv = new ArrayList<String>(); if (query.keywordType != 0) { adv.add(Character.valueOf(SearchService.ADV_KEYWORD_TYPE).toString() + query.keywordType); } if (!StringUtils.isBlank(query.from)) { adv.add(Character.valueOf(SearchService.ADV_DATE_SCOPE).toString() + StringUtils.trimToEmpty(query.from) + ":" + StringUtils.trimToEmpty(query.to)); } if (!StringUtils.isBlank(query.space)) { adv.add(Character.valueOf(SearchService.ADV_SPACE).toString() + StringUtils.trimToEmpty(query.space)); } if (query.type != 0) { adv.add(Character.valueOf(SearchService.ADV_SOURCE_TYPES).toString() + query.type); } if (query.sortBy != 0) { adv.add(Character.valueOf(SearchService.ADV_GROUP_BY).toString() + query.sortBy); } String[] advQ = null; if (adv.size() > 0) advQ = adv.toArray(new String[adv.size()]); SearchResult searchResult = searchService.search(query.keyword, selectPageNumber, returnCount, WikiUtil.getUser(), advQ); SearchUtil.copyResultToModel(searchResult, model); return model; } catch (SearchException e) { model.errorCode = ErrorCode.SEARCH_ERROR; return model; } }
From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?String ?://from w w w . j ava 2 s.c o m * * <pre> * short, int, long, float : 0 * char, byte: 0 * String: null * Map, List: null * Integer, Long, Float : null * Date: null * array: null * </pre> * * @param strValue * @param clazz * @return */ @SuppressWarnings("unchecked") public static <T> T parseStringValue(String strValue, Class<T> clazz, boolean autoDefault) { if (DEF_NULL.equals(strValue)) { if (!clazz.isPrimitive()) { return null; } if (autoDefault) { return (T) getInternalDefaultValue(clazz); } else { return null; } } if (DEF_EMPTY.equals(strValue)) { if (clazz.isArray()) { return (T) Array.newInstance(clazz.getComponentType(), 0); } if (Map.class.isAssignableFrom(clazz)) { return (T) Collections.EMPTY_MAP; } if (List.class.isAssignableFrom(clazz)) { return (T) new ArrayList<Object>(); } if (Set.class.isAssignableFrom(clazz)) { return (T) new HashSet<Object>(); } if (String.class.equals(clazz)) { return (T) StringUtils.EMPTY; } if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) { return (T) Character.valueOf(' '); } if (autoDefault) { return (T) getInternalDefaultValue(clazz); } else { return null; } } if (StringUtils.isBlank(strValue)) {// ? if (autoDefault) { return (T) getInternalDefaultValue(clazz); } else { return null; } } else { if (String.class.equals(clazz)) { return (T) strValue; } if (Short.TYPE.equals(clazz) || Short.class.equals(clazz)) { return (T) Short.valueOf(strValue); } if (Integer.TYPE.equals(clazz) || Integer.class.equals(clazz)) { return (T) Integer.valueOf(strValue); } if (Long.TYPE.equals(clazz) || Long.class.equals(clazz)) { return (T) Long.valueOf(strValue); } if (Boolean.TYPE.equals(clazz) || Boolean.class.equals(clazz)) { return (T) Boolean.valueOf(strValue); } if (Float.TYPE.equals(clazz) || Float.class.equals(clazz)) { return (T) Float.valueOf(strValue); } if (Double.TYPE.equals(clazz) || Double.class.equals(clazz)) { return (T) Double.valueOf(strValue); } if (Byte.TYPE.equals(clazz) || Byte.class.equals(clazz)) { return (T) Byte.valueOf(strValue); } if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) { return (T) Character.valueOf(strValue.charAt(0)); } if (clazz.isArray()) { final Class<?> componentType = clazz.getComponentType(); // String[] if (String.class.equals(componentType)) { return (T) StringUtils.split(strValue, ','); } // ?char[] if (Character.TYPE.equals(componentType)) { return (T) strValue.toCharArray(); } if (Character.class.equals(componentType)) { final char[] tmp = strValue.toCharArray(); final Character[] result = new Character[tmp.length]; for (int i = 0; i < result.length; i++) { result[i] = tmp[i]; } return (T) result; } if (Byte.TYPE.equals(componentType) || Byte.class.equals(componentType)) { return (T) (strValue == null ? null : strValue.getBytes()); } } } return null; }
From source file:com.edgenius.wiki.render.filter.ListFilter.java
public ListFilter() { super();// www.ja v a 2 s .co m openList.put(Character.valueOf('-'), "<ul class=\"minus\">"); openList.put(Character.valueOf('*'), "<ul class=\"star\">"); openList.put(Character.valueOf('#'), "<ol>"); openList.put(Character.valueOf('i'), "<ol class=\"roman\">"); openList.put(Character.valueOf('I'), "<ol class=\"ROMAN\">"); openList.put(Character.valueOf('a'), "<ol class=\"alpha\">"); openList.put(Character.valueOf('A'), "<ol class=\"ALPHA\">"); openList.put(Character.valueOf('g'), "<ol class=\"greek\">"); openList.put(Character.valueOf('h'), "<ol class=\"hiragana\">"); openList.put(Character.valueOf('H'), "<ol class=\"HIRAGANA\">"); openList.put(Character.valueOf('k'), "<ol class=\"katakana\">"); openList.put(Character.valueOf('K'), "<ol class=\"KATAKANA\">"); openList.put(Character.valueOf('j'), "<ol class=\"HEBREW\">"); closeList.put(Character.valueOf('-'), UL_CLOSE); closeList.put(Character.valueOf('*'), UL_CLOSE); closeList.put(Character.valueOf('#'), OL_CLOSE); closeList.put(Character.valueOf('i'), OL_CLOSE); closeList.put(Character.valueOf('I'), OL_CLOSE); closeList.put(Character.valueOf('a'), OL_CLOSE); closeList.put(Character.valueOf('A'), OL_CLOSE); closeList.put(Character.valueOf('g'), OL_CLOSE); closeList.put(Character.valueOf('G'), OL_CLOSE); closeList.put(Character.valueOf('h'), OL_CLOSE); closeList.put(Character.valueOf('H'), OL_CLOSE); closeList.put(Character.valueOf('k'), OL_CLOSE); closeList.put(Character.valueOf('K'), OL_CLOSE); closeList.put(Character.valueOf('j'), OL_CLOSE); }
From source file:com.junly.common.util.ReflectUtils.java
/** * <p class="detail">//from w ww .ja va2 s.com * * </p> * @author wan.Dong * @date 20161112 * @param obj * @param name ?? * @param value (?)??false * @return */ public static boolean setProperty(Object obj, String name, Object value) { if (obj != null) { Class<?> clazz = obj.getClass(); while (clazz != null) { Field field = null; try { field = clazz.getDeclaredField(name); } catch (Exception e) { clazz = clazz.getSuperclass(); continue; } try { Class<?> type = field.getType(); if (type.isPrimitive() == true && value != null) { if (value instanceof String) { if (type.equals(int.class) == true) { value = Integer.parseInt((String) value); } else if (type.equals(double.class) == true) { value = Double.parseDouble((String) value); } else if (type.equals(boolean.class) == true) { value = Boolean.parseBoolean((String) value); } else if (type.equals(long.class) == true) { value = Long.parseLong((String) value); } else if (type.equals(byte.class) == true) { value = Byte.parseByte((String) value); } else if (type.equals(char.class) == true) { value = Character.valueOf(((String) value).charAt(0)); } else if (type.equals(float.class) == true) { value = Float.parseFloat((String) value); } else if (type.equals(short.class) == true) { value = Short.parseShort((String) value); } } field.setAccessible(true); field.set(obj, value); field.setAccessible(false); } if (value == null || type.equals(value.getClass()) == true) { field.setAccessible(true); field.set(obj, value); field.setAccessible(false); } return true; } catch (Exception e) { return false; } } } return false; }
From source file:com.itemanalysis.psychometrics.statistics.TwoWayTable.java
public void addValue(char rowValue, char colValue) { addValue(Character.valueOf(rowValue), Character.valueOf(colValue)); }
From source file:org.apache.streams.data.util.PropertyUtil.java
public static ObjectNode unflattenObjectNode(ObjectNode flatObject, char seperator) { ObjectNode root = mapper.createObjectNode(); Iterator<Map.Entry<String, JsonNode>> iter = flatObject.fields(); while (iter.hasNext()) { Map.Entry<String, JsonNode> item = iter.next(); String fullKey = item.getKey(); if (!fullKey.contains(Character.valueOf(seperator).toString())) { root.put(item.getKey(), item.getValue()); } else {/* w ww .j a v a2 s . com*/ ObjectNode currentNode = root; List<String> keyParts = Splitter.on(seperator).splitToList(item.getKey()); Iterator<String> keyPartIterator = Iterables .limit(Splitter.on(seperator).split(item.getKey()), keyParts.size() - 1).iterator(); while (keyPartIterator.hasNext()) { String part = keyPartIterator.next(); if (currentNode.has(part) && currentNode.get(part).isObject()) { currentNode = (ObjectNode) currentNode.get(part); } else { ObjectNode newNode = mapper.createObjectNode(); currentNode.put(part, newNode); currentNode = newNode; } } ; currentNode.put(keyParts.get(keyParts.size() - 1), item.getValue()); } } return root; }
From source file:org.thymeleaf.util.EvaluationUtilTest.java
@Test public void convertToBooleanTest() { Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(null)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Boolean.TRUE)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Boolean.FALSE)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(BigDecimal.ZERO)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigDecimal.ONE)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigDecimal.TEN)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(BigInteger.ZERO)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigInteger.ONE)); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(BigInteger.TEN)); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Double.valueOf(0.0d))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Float.valueOf(0.0f))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(0.1d))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(0.1f))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(-0.1d))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(-0.1f))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(Double.MAX_VALUE))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(Float.MAX_VALUE))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Double.valueOf(Double.MIN_VALUE))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Float.valueOf(Float.MIN_VALUE))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(Character.valueOf((char) 0))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('x'))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('0'))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(Character.valueOf('1'))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("true")); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("false")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("yes")); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("no")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("on")); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean("off")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("sky")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean("high above")); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("true"))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("false"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("yes"))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("no"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("on"))); Assert.assertFalse(EvaluationUtil.evaluateAsBoolean(new LiteralValue("off"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("sky"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(new LiteralValue("high above"))); Assert.assertTrue(EvaluationUtil.evaluateAsBoolean(EvaluationUtil.class)); }
From source file:org.apache.fop.fonts.SingleByteFont.java
/** {@inheritDoc} */ public int getWidth(int i, int size) { if (i < 256) { int idx = i - getFirstChar(); if (idx >= 0 && idx < width.length) { return size * width[idx]; }/*from w w w . j ava 2s . c o m*/ } else if (this.additionalEncodings != null) { int encodingIndex = (i / 256) - 1; SimpleSingleByteEncoding encoding = getAdditionalEncoding(encodingIndex); int codePoint = i % 256; NamedCharacter nc = encoding.getCharacterForIndex(codePoint); UnencodedCharacter uc = this.unencodedCharacters.get(Character.valueOf(nc.getSingleUnicodeValue())); return size * uc.getWidth(); } return 0; }
From source file:org.apache.streams.util.PropertyUtil.java
public static ObjectNode unflattenObjectNode(ObjectNode flatObject, char seperator) { ObjectNode root = mapper.createObjectNode(); Iterator<Map.Entry<String, JsonNode>> iter = flatObject.fields(); while (iter.hasNext()) { Map.Entry<String, JsonNode> item = iter.next(); String fullKey = item.getKey(); if (!fullKey.contains(Character.valueOf(seperator).toString())) { root.put(item.getKey(), item.getValue()); } else {//w w w. j av a2 s . co m ObjectNode currentNode = root; List<String> keyParts = new ArrayList<>(Arrays.asList(StringUtils.split(item.getKey(), seperator))); keyParts.remove(keyParts.size() - 1); Iterator<String> keyPartIterator = keyParts.iterator(); while (keyPartIterator.hasNext()) { String part = keyPartIterator.next(); if (currentNode.has(part) && currentNode.get(part).isObject()) { currentNode = (ObjectNode) currentNode.get(part); } else { ObjectNode newNode = mapper.createObjectNode(); currentNode.put(part, newNode); currentNode = newNode; } } ; currentNode.put(keyParts.get(keyParts.size() - 1), item.getValue()); } } return root; }