List of usage examples for java.lang Byte valueOf
public static Byte valueOf(String s) throws NumberFormatException
From source file:org.opendaylight.openflowplugin.outputtest.OutputTestCommandProvider.java
public void _sendPacketOutputMsg(CommandInterpreter ci) { /* Sending package OUT with action */ LOG.debug("SendOutMsgWithAction"); if (sessionInitiated) { String inNodeKey = ci.nextArgument(); String inPort = ci.nextArgument(); String outPort = "0xfffffffd"; ArrayList<Byte> _arrayList = new ArrayList<Byte>(40); ArrayList<Byte> list = _arrayList; String _string = new String("sendOutputMsg_TEST"); byte[] msg = _string.getBytes(); int index = 0; for (final byte b : msg) { {//from w w w . j a v a 2 s . c o m list.add(Byte.valueOf(b)); boolean _lessThan = (index < 7); if (_lessThan) { int _plus = (index + 1); index = _plus; } else { index = 0; } } } boolean _lessThan = (index < 8); boolean _while = _lessThan; while (_while) { { Byte _byte = new Byte("0"); list.add(_byte); int _plus = (index + 1); index = _plus; } boolean _lessThan_1 = (index < 8); _while = _lessThan_1; } NodeRef ref = OutputTestUtil.createNodeRef(inNodeKey); TransmitPacketInputBuilder packet_out = new TransmitPacketInputBuilder(); NodeConnectorRef _createNodeConnRef_1 = OutputTestUtil.createNodeConnRef(inNodeKey, inPort); NodeConnectorRef _nodeConnectorRef_1 = new NodeConnectorRef(_createNodeConnRef_1); NodeConnectorRef nIngressConRef = _nodeConnectorRef_1; NodeConnectorRef _createNodeConnRef_2 = OutputTestUtil.createNodeConnRef(inNodeKey, outPort); NodeConnectorRef _nodeConnectorRef_2 = new NodeConnectorRef(_createNodeConnRef_2); NodeConnectorRef nEngressConRef = _nodeConnectorRef_2; final ArrayList<Byte> _converted_list = list; byte[] _primitive = ArrayUtils .toPrimitive(((Byte[]) Conversions.unwrapArray(_converted_list, Byte.class))); List<Action> actionList = new ArrayList<Action>(); ActionBuilder ab = new ActionBuilder(); OutputActionBuilder output = new OutputActionBuilder(); output.setMaxLength(new Integer(0xffff)); Uri value = new Uri(OutputPortValues.CONTROLLER.toString()); output.setOutputNodeConnector(value); ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build()); ab.setOrder(0); ab.setKey(new ActionKey(0)); actionList.add(ab.build()); packet_out.setCookie(null); packet_out.setAction(actionList); packet_out.setPayload(_primitive); packet_out.setNode(ref); packet_out.setIngress(nIngressConRef); packet_out.setEgress(nEngressConRef); packet_out.setBufferId(new Long(0xffffffffL)); packetProcessingService.transmitPacket(packet_out.build()); } else { ci.println("Session not initiated, try again in a few seconds"); } }
From source file:therian.operator.immutablecheck.DefaultImmutableCheckerTest.java
@Test public void testWrapper() { assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Integer.valueOf(666)))).booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Long.valueOf(666L)))).booleanValue()); assertTrue(//from w w w .j a va2 s . c o m therianContext.eval(ImmutableCheck.of(Positions.readOnly(Byte.valueOf((byte) 0)))).booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Short.valueOf((short) 0)))) .booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Character.valueOf((char) 0)))) .booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Boolean.TRUE))).booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Float.valueOf(0.0f)))).booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Double.valueOf(0.0)))).booleanValue()); }
From source file:Main.java
/** * <p>Converts an array of primitive bytes to objects.</p> * <p>/*from w w w . j av a 2 s . c om*/ * <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * * @param array a <code>byte</code> array * @return a <code>Byte</code> array, <code>null</code> if null array input */ public static Byte[] toObject(byte[] array) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_BYTE_OBJECT_ARRAY; } final Byte[] result = new Byte[array.length]; for (int i = 0; i < array.length; i++) { result[i] = Byte.valueOf(array[i]); } return result; }
From source file:org.apache.click.util.RequestTypeConverter.java
/** * Return the converted value for the given value object and target type. * * @param value the value object to convert * @param toType the target class type to convert the value to * @return a converted value into the specified type *///from w w w .j av a 2 s . co m protected 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 = Integer.valueOf((int) OgnlOps.longValue(value)); } else if ((toType == Double.class) || (toType == Double.TYPE)) { result = new Double(OgnlOps.doubleValue(value)); } else if ((toType == Boolean.class) || (toType == Boolean.TYPE)) { result = Boolean.valueOf(value.toString()); } else if ((toType == Byte.class) || (toType == Byte.TYPE)) { result = Byte.valueOf((byte) OgnlOps.longValue(value)); } else if ((toType == Character.class) || (toType == Character.TYPE)) { result = Character.valueOf((char) OgnlOps.longValue(value)); } else if ((toType == Short.class) || (toType == Short.TYPE)) { result = Short.valueOf((short) OgnlOps.longValue(value)); } else if ((toType == Long.class) || (toType == Long.TYPE)) { result = Long.valueOf(OgnlOps.longValue(value)); } else if ((toType == Float.class) || (toType == Float.TYPE)) { result = new Float(OgnlOps.doubleValue(value)); } else if (toType == BigInteger.class) { result = OgnlOps.bigIntValue(value); } else if (toType == BigDecimal.class) { result = bigDecValue(value); } else if (toType == String.class) { result = OgnlOps.stringValue(value); } else if (toType == java.util.Date.class) { long time = getTimeFromDateString(value.toString()); if (time > Long.MIN_VALUE) { result = new java.util.Date(time); } } else if (toType == java.sql.Date.class) { long time = getTimeFromDateString(value.toString()); if (time > Long.MIN_VALUE) { result = new java.sql.Date(time); } } else if (toType == java.sql.Time.class) { long time = getTimeFromDateString(value.toString()); if (time > Long.MIN_VALUE) { result = new java.sql.Time(time); } } else if (toType == java.sql.Timestamp.class) { long time = getTimeFromDateString(value.toString()); if (time > Long.MIN_VALUE) { result = new java.sql.Timestamp(time); } } } } else { if (toType.isPrimitive()) { result = OgnlRuntime.getPrimitiveDefaultValue(toType); } } return result; }
From source file:org.red5.io.mock.Output.java
/** {@inheritDoc} */ public void writeObject(Map<Object, Object> map, Serializer serializer) { list.add(Byte.valueOf(DataTypes.CORE_OBJECT)); list.add(map);/*from www . j av a 2s. c om*/ }
From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?String ?:/* w ww . j a v a 2s. 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:org.apache.hadoop.hive.serde2.binarysortable.MyTestPrimitiveClass.java
public int randomFill(Random r, int randField, int field, ExtraTypeInfo extraTypeInfo) { myBool = chooseNull(r, randField, field++) ? null : Boolean.valueOf(r.nextInt(1) == 1); myByte = chooseNull(r, randField, field++) ? null : Byte.valueOf((byte) r.nextInt()); myShort = chooseNull(r, randField, field++) ? null : Short.valueOf((short) r.nextInt()); myInt = chooseNull(r, randField, field++) ? null : Integer.valueOf(r.nextInt()); myLong = chooseNull(r, randField, field++) ? null : Long.valueOf(r.nextLong()); myFloat = chooseNull(r, randField, field++) ? null : Float.valueOf(r.nextFloat() * 10 - 5); myDouble = chooseNull(r, randField, field++) ? null : Double.valueOf(r.nextDouble() * 10 - 5); myString = chooseNull(r, randField, field++) ? null : getRandString(r); myHiveChar = chooseNull(r, randField, field++) ? null : getRandHiveChar(r, extraTypeInfo); myHiveVarchar = chooseNull(r, randField, field++) ? null : getRandHiveVarchar(r, extraTypeInfo); myBinary = getRandBinary(r, r.nextInt(1000)); myDecimal = chooseNull(r, randField, field++) ? null : getRandHiveDecimal(r, extraTypeInfo); myDate = chooseNull(r, randField, field++) ? null : getRandDate(r); myTimestamp = chooseNull(r, randField, field++) ? null : RandomTypeUtil.getRandTimestamp(r); myIntervalYearMonth = chooseNull(r, randField, field++) ? null : getRandIntervalYearMonth(r); myIntervalDayTime = chooseNull(r, randField, field++) ? null : getRandIntervalDayTime(r); return field; }
From source file:Main.java
/** * <p>Converts an array of primitive bytes to objects.</p> * * <p>This method returns {@code null} for a {@code null} input array.</p> * * @param array a {@code byte} array//from w ww.ja v a 2 s.c om * @return a {@code Byte} array, {@code null} if null array input */ public static Byte[] toObject(final byte[] array) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_BYTE_OBJECT_ARRAY; } final Byte[] result = new Byte[array.length]; for (int i = 0; i < array.length; i++) { result[i] = Byte.valueOf(array[i]); } return result; }
From source file:org.apache.hadoop.hive.serde2.binarysortable.MyTestClass.java
public int randomFill(Random r, ExtraTypeInfo extraTypeInfo) { int randField = r.nextInt(MyTestClass.fieldCount); int field = 0; myBool = (randField == field++) ? null : (r.nextInt(1) == 1); myByte = (randField == field++) ? null : Byte.valueOf((byte) r.nextInt()); myShort = (randField == field++) ? null : Short.valueOf((short) r.nextInt()); myInt = (randField == field++) ? null : Integer.valueOf(r.nextInt()); myLong = (randField == field++) ? null : Long.valueOf(r.nextLong()); myFloat = (randField == field++) ? null : Float.valueOf(r.nextFloat() * 10 - 5); myDouble = (randField == field++) ? null : Double.valueOf(r.nextDouble() * 10 - 5); myString = (randField == field++) ? null : MyTestPrimitiveClass.getRandString(r); myHiveChar = (randField == field++) ? null : MyTestPrimitiveClass.getRandHiveChar(r, extraTypeInfo); myHiveVarchar = (randField == field++) ? null : MyTestPrimitiveClass.getRandHiveVarchar(r, extraTypeInfo); myBinary = MyTestPrimitiveClass.getRandBinary(r, r.nextInt(1000)); myDecimal = (randField == field++) ? null : MyTestPrimitiveClass.getRandHiveDecimal(r, extraTypeInfo); myDate = (randField == field++) ? null : MyTestPrimitiveClass.getRandDate(r); myTimestamp = (randField == field++) ? null : RandomTypeUtil.getRandTimestamp(r); myIntervalYearMonth = (randField == field++) ? null : MyTestPrimitiveClass.getRandIntervalYearMonth(r); myIntervalDayTime = (randField == field++) ? null : MyTestPrimitiveClass.getRandIntervalDayTime(r); myStruct = (randField == field++) ? null : new MyTestInnerStruct(r.nextInt(5) - 2, r.nextInt(5) - 2); myList = (randField == field++) ? null : getRandIntegerArray(r); return field; }
From source file:it.unimi.dsi.util.Properties.java
public void addProperty(final String key, final byte b) { super.addProperty(key, Byte.valueOf(b)); }