List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:com.enonic.esl.containers.ExtendedMap.java
public Object putChar(Object key, char value) { return put(key, new Character(value)); }
From source file:com.digitalpebble.stormcrawler.filtering.basic.BasicURLNormalizer.java
/** * Remove % encoding from path segment in URL for characters which should be * unescaped according to <a//from ww w . j av a2 s . co m * href="https://tools.ietf.org/html/rfc3986#section-2.2">RFC3986</a>. */ private String unescapePath(String path) { StringBuilder sb = new StringBuilder(); Matcher matcher = unescapeRulePattern.matcher(path); int end = -1; int letter; // Traverse over all encoded groups while (matcher.find()) { // Append everything up to this group sb.append(path.substring(end + 1, matcher.start())); // Get the integer representation of this hexadecimal encoded // character letter = Integer.valueOf(matcher.group().substring(1), 16); if (letter < 128 && unescapedCharacters[letter]) { // character should be unescaped in URLs sb.append(new Character((char) letter)); } else { // Append the encoded character as uppercase sb.append(matcher.group().toUpperCase(Locale.ROOT)); } end = matcher.start() + 2; } letter = path.length(); // Append the rest if there's anything if (end <= letter - 1) { sb.append(path.substring(end + 1, letter)); } // Ok! return sb.toString(); }
From source file:javadz.beanutils.ConvertUtilsBean.java
/** * Sets the default value for Character conversions. * @param newDefaultCharacter The default Character value * @deprecated Register replacement converters for Character.TYPE and * Character.class instead/* w w w . j av a 2 s . c om*/ */ public void setDefaultCharacter(char newDefaultCharacter) { defaultCharacter = new Character(newDefaultCharacter); register(new CharacterConverter(defaultCharacter), Character.TYPE); register(new CharacterConverter(defaultCharacter), Character.class); }
From source file:de.hub.cs.dbis.aeolus.queries.utils.TimestampMergerTest.java
@SuppressWarnings("unchecked") private void testExecuteMerge(int numberOfProducers, int numberOfTasks, double duplicatesFraction, boolean tsIndexOrName, int minNumberOfAttributes, int maxNumberOfAttributes) { int createdTasks = this.mockInputs(numberOfProducers, numberOfTasks, tsIndexOrName, minNumberOfAttributes, maxNumberOfAttributes);//from w w w . j av a 2 s .c o m final int numberOfTuples = createdTasks * 10 + this.r.nextInt(createdTasks * (1 + this.r.nextInt(10))); TimestampOrderChecker checkerBolt; TimestampMerger merger; if (tsIndexOrName) { checkerBolt = new TimestampOrderChecker(forwarder, 0, duplicatesFraction != 0); merger = new TimestampMerger(checkerBolt, 0); } else { checkerBolt = new TimestampOrderChecker(forwarder, "ts", duplicatesFraction != 0); merger = new TimestampMerger(checkerBolt, "ts"); } TestOutputCollector collector = new TestOutputCollector(); merger.prepare(null, this.topologyContextMock, new OutputCollector(collector)); this.input = new LinkedList[createdTasks]; for (int i = 0; i < createdTasks; ++i) { this.input[i] = new LinkedList<Tuple>(); } this.result.clear(); int numberDistinctValues = 1; int counter = 0; while (true) { int taskId = this.r.nextInt(createdTasks); Fields schema = this.contextMock.getComponentOutputFields(this.contextMock.getComponentId(taskId), null); int numberOfAttributes = schema.size(); List<Object> value = new ArrayList<Object>(numberOfAttributes); for (int i = 0; i < numberOfAttributes; ++i) { value.add(new Character((char) (32 + this.r.nextInt(95)))); } Long ts = new Long(numberDistinctValues - 1); value.set(schema.fieldIndex("ts"), ts); this.result.add(value); this.input[taskId].add(new TupleImpl(this.contextMock, value, taskId, null)); if (++counter == numberOfTuples) { break; } if (1 - this.r.nextDouble() > duplicatesFraction) { ++numberDistinctValues; } } int[] max = new int[createdTasks]; int[][] bucketSums = new int[createdTasks][numberDistinctValues]; for (int i = 0; i < numberOfTuples; ++i) { int taskId = this.r.nextInt(createdTasks); while (this.input[taskId].size() == 0) { taskId = (taskId + 1) % createdTasks; } Tuple t = this.input[taskId].removeFirst(); max[taskId] = t.getLongByField("ts").intValue(); ++bucketSums[taskId][max[taskId]]; merger.execute(t); } int stillBuffered = numberOfTuples; int smallestMax = Collections.min(Arrays.asList(ArrayUtils.toObject(max))).intValue(); for (int i = 0; i < createdTasks; ++i) { for (int j = 0; j <= smallestMax; ++j) { stillBuffered -= bucketSums[i][j]; } } Assert.assertEquals(this.result.subList(0, this.result.size() - stillBuffered), collector.output.get(Utils.DEFAULT_STREAM_ID)); Assert.assertTrue(collector.acked.size() == numberOfTuples - stillBuffered); Assert.assertTrue(collector.failed.size() == 0); }
From source file:de.hub.cs.dbis.aeolus.utils.TimestampMergerTest.java
@SuppressWarnings("unchecked") private void testExecuteMerge(int numberOfProducers, int numberOfTasks, double duplicatesFraction, boolean tsIndexOrName, int minNumberOfAttributes, int maxNumberOfAttributes) { int createdTasks = this.mockInputs(numberOfProducers, numberOfTasks, tsIndexOrName, minNumberOfAttributes, maxNumberOfAttributes);/*from w w w .ja v a 2 s.c o m*/ final int numberOfTuples = createdTasks * 10 + this.r.nextInt(createdTasks * (1 + this.r.nextInt(10))); TimestampOrderChecker checkerBolt; TimestampMerger merger; if (tsIndexOrName) { checkerBolt = new TimestampOrderChecker(forwarder, 0, duplicatesFraction != 0); merger = new TimestampMerger(checkerBolt, 0); } else { checkerBolt = new TimestampOrderChecker(forwarder, "ts", duplicatesFraction != 0); merger = new TimestampMerger(checkerBolt, "ts"); } TestOutputCollector collector = new TestOutputCollector(); merger.prepare(null, this.topologyContextMock, new OutputCollector(collector)); this.input = new LinkedList[createdTasks]; for (int i = 0; i < createdTasks; ++i) { this.input[i] = new LinkedList<Tuple>(); } this.result.clear(); int numberDistinctValues = 1; int counter = 0; while (true) { int taskId = this.r.nextInt(createdTasks); Fields schema = this.contextMock.getComponentOutputFields(this.contextMock.getComponentId(taskId), null); int numberOfAttributes = schema.size(); List<Object> value = new ArrayList<Object>(numberOfAttributes); for (int i = 0; i < numberOfAttributes; ++i) { value.add(new Character((char) (32 + this.r.nextInt(95)))); } Long ts = new Long(numberDistinctValues - 1); value.set(schema.fieldIndex("ts"), ts); this.result.add(value); this.input[taskId].add(new TupleImpl(this.contextMock, value, taskId, null)); if (++counter == numberOfTuples) { break; } if (1 - this.r.nextDouble() > duplicatesFraction) { ++numberDistinctValues; } } int[] max = new int[createdTasks]; for (int i = 0; i < max.length; ++i) { max[i] = -1; } int[][] bucketSums = new int[createdTasks][numberDistinctValues]; for (int i = 0; i < numberOfTuples; ++i) { int taskId = this.r.nextInt(createdTasks); while (this.input[taskId].size() == 0) { taskId = (taskId + 1) % createdTasks; } Tuple t = this.input[taskId].removeFirst(); max[taskId] = t.getLongByField("ts").intValue(); ++bucketSums[taskId][max[taskId]]; merger.execute(t); } int stillBuffered = numberOfTuples; int smallestMax = Collections.min(Arrays.asList(ArrayUtils.toObject(max))).intValue(); for (int i = 0; i < createdTasks; ++i) { for (int j = 0; j <= smallestMax; ++j) { stillBuffered -= bucketSums[i][j]; } } List<List<Object>> expectedResult = this.result.subList(0, this.result.size() - stillBuffered); if (expectedResult.size() > 0) { Assert.assertEquals(expectedResult, collector.output.get(Utils.DEFAULT_STREAM_ID)); } else { Assert.assertNull(collector.output.get(Utils.DEFAULT_STREAM_ID)); } Assert.assertTrue(collector.acked.size() == numberOfTuples - stillBuffered); Assert.assertTrue(collector.failed.size() == 0); }
From source file:com.exadel.flamingo.flex.messaging.amf.io.AMF0Serializer.java
protected Object[] convertPrimitiveArrayToObjectArray(Object array) { Class<?> componentType = array.getClass().getComponentType(); Object[] result = null;//from w w w . ja v a 2s . c o m if (componentType == null) { throw new NullPointerException("componentType is null"); } else if (componentType == Character.TYPE) { char[] carray = (char[]) array; result = new Object[carray.length]; for (int i = 0; i < carray.length; i++) { result[i] = new Character(carray[i]); } } else if (componentType == Byte.TYPE) { byte[] barray = (byte[]) array; result = new Object[barray.length]; for (int i = 0; i < barray.length; i++) { result[i] = new Byte(barray[i]); } } else if (componentType == Short.TYPE) { short[] sarray = (short[]) array; result = new Object[sarray.length]; for (int i = 0; i < sarray.length; i++) { result[i] = new Short(sarray[i]); } } else if (componentType == Integer.TYPE) { int[] iarray = (int[]) array; result = new Object[iarray.length]; for (int i = 0; i < iarray.length; i++) { result[i] = Integer.valueOf(iarray[i]); } } else if (componentType == Long.TYPE) { long[] larray = (long[]) array; result = new Object[larray.length]; for (int i = 0; i < larray.length; i++) { result[i] = new Long(larray[i]); } } else if (componentType == Double.TYPE) { double[] darray = (double[]) array; result = new Object[darray.length]; for (int i = 0; i < darray.length; i++) { result[i] = new Double(darray[i]); } } else if (componentType == Float.TYPE) { float[] farray = (float[]) array; result = new Object[farray.length]; for (int i = 0; i < farray.length; i++) { result[i] = new Float(farray[i]); } } else if (componentType == Boolean.TYPE) { boolean[] barray = (boolean[]) array; result = new Object[barray.length]; for (int i = 0; i < barray.length; i++) { result[i] = new Boolean(barray[i]); } } else { throw new IllegalArgumentException("unexpected component type: " + componentType.getClass().getName()); } return result; }
From source file:org.apache.jk.common.MsgAjp.java
public static String hexLine(byte buf[], int start, int len) { StringBuffer sb = new StringBuffer(); for (int i = start; i < start + 16; i++) { if (i < len + 4) sb.append(hex(buf[i]) + " "); else// w ww. j a v a2 s . co m sb.append(" "); } sb.append(" | "); for (int i = start; i < start + 16 && i < len + 4; i++) { if (!Character.isISOControl((char) buf[i])) sb.append(new Character((char) buf[i])); else sb.append("."); } return sb.toString(); }
From source file:es.caib.zkib.jxpath.util.BasicTypeConverter.java
/** * Convert null to a primitive type./*from w w w.j a va 2 s . co m*/ * @param toType destination class * @return a wrapper */ protected Object convertNullToPrimitive(Class toType) { if (toType == boolean.class) { return Boolean.FALSE; } if (toType == char.class) { return new Character('\0'); } if (toType == byte.class) { return new Byte((byte) 0); } if (toType == short.class) { return new Short((short) 0); } if (toType == int.class) { return new Integer(0); } if (toType == long.class) { return new Long(0L); } if (toType == float.class) { return new Float(0.0f); } if (toType == double.class) { return new Double(0.0); } return null; }
From source file:org.docx4j.fonts.fop.fonts.SingleByteFont.java
/** * Returns an array with the widths for an additional encoding. * @param index the index of the additional encoding * @return the width array/*from w w w . j av a 2s.c om*/ */ public int[] getAdditionalWidths(int index) { SimpleSingleByteEncoding enc = getAdditionalEncoding(index); int[] arr = new int[enc.getLastChar() - enc.getFirstChar() + 1]; for (int i = 0, c = arr.length; i < c; i++) { NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i); UnencodedCharacter uc = (UnencodedCharacter) this.unencodedCharacters .get(new Character(nc.getSingleUnicodeValue())); arr[i] = uc.getWidth(); } return arr; }
From source file:gov.nih.nci.system.web.struts.action.UpdateAction.java
public Object convertValue(Class klass, Object value) throws Exception { String fieldType = klass.getName(); Object convertedValue = null; try {//from w ww . j a v a 2s . c om if (fieldType.equals("java.lang.Long")) { convertedValue = new Long((String) value); } else if (fieldType.equals("java.lang.Integer")) { convertedValue = new Integer((String) value); } else if (fieldType.equals("java.lang.String")) { convertedValue = value; } else if (fieldType.equals("java.lang.Float")) { convertedValue = new Float((String) value); } else if (fieldType.equals("java.lang.Double")) { convertedValue = new Double((String) value); } else if (fieldType.equals("java.lang.Boolean")) { convertedValue = new Boolean((String) value); } else if (fieldType.equals("java.util.Date")) { SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy"); convertedValue = format.parse((String) value); } else if (fieldType.equals("java.net.URI")) { convertedValue = new URI((String) value); } else if (fieldType.equals("java.lang.Character")) { convertedValue = new Character(((String) value).charAt(0)); } else if (klass.isEnum()) { Class enumKlass = Class.forName(fieldType); convertedValue = Enum.valueOf(enumKlass, (String) value); } else { throw new Exception("type mismatch - " + fieldType); } } catch (NumberFormatException e) { e.printStackTrace(); throw new Exception(e.getMessage()); } catch (Exception ex) { log.error("ERROR : " + ex.getMessage()); throw ex; } return convertedValue; }