List of usage examples for java.lang Byte valueOf
public static Byte valueOf(String s) throws NumberFormatException
From source file:org.lable.oss.dynamicconfig.core.commonsconfiguration.ConcurrentConfigurationTest.java
@Test public void testMethodWrappers() { CombinedConfiguration mockConfiguration = mock(CombinedConfiguration.class); Configuration concurrentConfiguration = new ConcurrentConfiguration(mockConfiguration, null); concurrentConfiguration.subset("subset"); concurrentConfiguration.isEmpty();//from w w w . j a v a 2 s. com concurrentConfiguration.containsKey("key"); concurrentConfiguration.getProperty("getprop"); concurrentConfiguration.getKeys("getkeys"); concurrentConfiguration.getKeys(); concurrentConfiguration.getProperties("getprops"); concurrentConfiguration.getBoolean("getboolean1"); concurrentConfiguration.getBoolean("getboolean2", true); concurrentConfiguration.getBoolean("getboolean3", Boolean.FALSE); concurrentConfiguration.getByte("getbyte1"); concurrentConfiguration.getByte("getbyte2", (byte) 0); concurrentConfiguration.getByte("getbyte3", Byte.valueOf((byte) 0)); concurrentConfiguration.getDouble("getdouble1"); concurrentConfiguration.getDouble("getdouble2", 0.2); concurrentConfiguration.getDouble("getdouble3", Double.valueOf(0.2)); concurrentConfiguration.getFloat("getfloat1"); concurrentConfiguration.getFloat("getfloat2", 0f); concurrentConfiguration.getFloat("getfloat3", Float.valueOf(0f)); concurrentConfiguration.getInt("getint1"); concurrentConfiguration.getInt("getint2", 0); concurrentConfiguration.getInteger("getint3", 0); concurrentConfiguration.getLong("getlong1"); concurrentConfiguration.getLong("getlong2", 0L); concurrentConfiguration.getLong("getlong3", Long.valueOf(0L)); concurrentConfiguration.getShort("getshort1"); concurrentConfiguration.getShort("getshort2", (short) 0); concurrentConfiguration.getShort("getshort3", Short.valueOf((short) 0)); concurrentConfiguration.getBigDecimal("getbigd1"); concurrentConfiguration.getBigDecimal("getbigd2", BigDecimal.valueOf(0.4)); concurrentConfiguration.getBigInteger("getbigi1"); concurrentConfiguration.getBigInteger("getbigi2", BigInteger.valueOf(2L)); concurrentConfiguration.getString("getstring1"); concurrentConfiguration.getString("getstring2", "def"); concurrentConfiguration.getStringArray("stringarray"); concurrentConfiguration.getList("getlist1"); concurrentConfiguration.getList("getlist2", Arrays.asList("a", "b")); verify(mockConfiguration, times(1)).subset("subset"); verify(mockConfiguration, times(1)).isEmpty(); verify(mockConfiguration, times(1)).containsKey("key"); verify(mockConfiguration, times(1)).getProperty("getprop"); verify(mockConfiguration, times(1)).getKeys("getkeys"); verify(mockConfiguration, times(1)).getKeys(); verify(mockConfiguration, times(1)).getProperties("getprops"); verify(mockConfiguration, times(1)).getBoolean("getboolean1"); verify(mockConfiguration, times(1)).getBoolean("getboolean2", true); verify(mockConfiguration, times(1)).getBoolean("getboolean3", Boolean.FALSE); verify(mockConfiguration, times(1)).getByte("getbyte1"); verify(mockConfiguration, times(1)).getByte("getbyte2", (byte) 0); verify(mockConfiguration, times(1)).getByte("getbyte3", Byte.valueOf((byte) 0)); verify(mockConfiguration, times(1)).getDouble("getdouble1"); verify(mockConfiguration, times(1)).getDouble("getdouble2", 0.2); verify(mockConfiguration, times(1)).getDouble("getdouble3", Double.valueOf(0.2)); verify(mockConfiguration, times(1)).getFloat("getfloat1"); verify(mockConfiguration, times(1)).getFloat("getfloat2", 0f); verify(mockConfiguration, times(1)).getFloat("getfloat3", Float.valueOf(0f)); verify(mockConfiguration, times(1)).getInt("getint1"); verify(mockConfiguration, times(1)).getInt("getint2", 0); verify(mockConfiguration, times(1)).getInteger("getint3", Integer.valueOf(0)); verify(mockConfiguration, times(1)).getLong("getlong1"); verify(mockConfiguration, times(1)).getLong("getlong2", 0L); verify(mockConfiguration, times(1)).getLong("getlong3", Long.valueOf(0L)); verify(mockConfiguration, times(1)).getShort("getshort1"); verify(mockConfiguration, times(1)).getShort("getshort2", (short) 0); verify(mockConfiguration, times(1)).getShort("getshort3", Short.valueOf((short) 0)); verify(mockConfiguration, times(1)).getBigDecimal("getbigd1"); verify(mockConfiguration, times(1)).getBigDecimal("getbigd2", BigDecimal.valueOf(0.4)); verify(mockConfiguration, times(1)).getBigInteger("getbigi1"); verify(mockConfiguration, times(1)).getBigInteger("getbigi2", BigInteger.valueOf(2L)); verify(mockConfiguration, times(1)).getString("getstring1"); verify(mockConfiguration, times(1)).getString("getstring2", "def"); verify(mockConfiguration, times(1)).getStringArray("stringarray"); verify(mockConfiguration, times(1)).getList("getlist1"); verify(mockConfiguration, times(1)).getList("getlist2", Arrays.asList("a", "b")); }
From source file:IndexService.IndexIFormatOutputWriter.java
public IndexIFormatOutputWriter(String fileName, JobConf job) throws IOException { this.conf = job; ifdf = new IFormatDataFile(job); ihead = new IHead(); String[] fieldStrings = job.getStrings(ConstVar.HD_fieldMap); IFieldMap fieldMap = new IFieldMap(); for (int i = 0; i < fieldStrings.length; i++) { String[] def = fieldStrings[i].split(ConstVar.RecordSplit); byte type = Byte.valueOf(def[0]); int index = Short.valueOf(def[1]); fieldMap.addFieldType(new IRecord.IFType(type, index)); }//from ww w .ja v a2s. c om ihead.setFieldMap(fieldMap); String[] files = job.getStrings(ConstVar.HD_index_filemap); IUserDefinedHeadInfo iudhi = new IUserDefinedHeadInfo(); iudhi.addInfo(123456, job.get("datafiletype")); for (int i = 0; i < files.length; i++) { iudhi.addInfo(i, files[i]); } ihead.setUdi(iudhi); ihead.setPrimaryIndex(0); ifdf.create(fileName, ihead); record = ifdf.getIRecordObj(); }
From source file:org.talend.utils.sql.TalendTypeConvert.java
/** * // w w w. j a v a 2s . c o m * DOC qiongli Comment method "convertToObject". * * @param talendType * @param value * @param datePattern:just for date type then parse with the given pattern(format). * @return */ public static Object convertToObject(String talendType, String value, String datePattern) { Object object = null; // bug 19036 .remove the epmty string, '\r','\n'. value = value.trim(); value = StringUtils.remove(value, "\r"); value = StringUtils.remove(value, "\n"); try { if (talendType.equals(talendTypeName(Boolean.class))) { object = Boolean.valueOf(value).booleanValue(); } else if (talendType.equals(talendTypeName(Byte.class))) { object = Byte.valueOf(value).byteValue(); } else if (talendType.equals(talendTypeName(Date.class))) { // MOD qiongli 2011-10-27 TDQ-3802. if (datePattern == null || StringUtils.EMPTY.equals(datePattern.trim())) { datePattern = "yyyy-MM-dd"; } else { datePattern = StringUtils.replace(datePattern, "\"", StringUtils.EMPTY); } // add the parameter 'Locale.US' because make like 'AM/PM' could be parsed.then format and output as // the given 'datePattern' SimpleDateFormat sdf = new SimpleDateFormat(datePattern, Locale.US); object = sdf.parse(value); } else if (talendType.equals(talendTypeName(Double.class))) { object = Double.parseDouble(value); } else if (talendType.equals(talendTypeName(Float.class))) { object = Float.parseFloat(value); } else if (talendType.equals(talendTypeName(Integer.class))) { object = Integer.parseInt(value); } else if (talendType.equals(talendTypeName(Long.class))) { object = Long.parseLong(value); } else if (talendType.equals(talendTypeName(Short.class))) { object = Short.parseShort(value); } else if (talendType.equals(talendTypeName(String.class)) || talendType.equals(talendTypeName(Character.class))) { object = value; } } catch (ClassCastException ce) { return null; } catch (Exception e) { return null; } return object; }
From source file:org.red5.io.mock.Output.java
/** {@inheritDoc} */ public void writeBoolean(Boolean bol) { list.add(Byte.valueOf(DataTypes.CORE_BOOLEAN)); list.add(bol); }
From source file:controller.ViewPackageController.java
@RequestMapping(method = RequestMethod.GET) public String viewPackage(ModelMap mm) { List<Packages> list = packModel.find(Byte.valueOf("1"), "status", false); mm.put("listPackage", list); mm.put("title", "View package"); return "viewPackage"; }
From source file:com.base.dao.sql.ReflectionUtils.java
public static Object convertValue(Object value, Class toType) { Object result = null;//from w ww . jav a 2 s.com if (value != null) { 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) longValue(value)); if ((toType == Double.class) || (toType == Double.TYPE)) result = new Double(doubleValue(value)); if ((toType == Boolean.class) || (toType == Boolean.TYPE)) result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE; if ((toType == Byte.class) || (toType == Byte.TYPE)) result = Byte.valueOf((byte) longValue(value)); if ((toType == Character.class) || (toType == Character.TYPE)) result = new Character((char) longValue(value)); if ((toType == Short.class) || (toType == Short.TYPE)) result = Short.valueOf((short) longValue(value)); if ((toType == Long.class) || (toType == Long.TYPE)) result = Long.valueOf(longValue(value)); if ((toType == Float.class) || (toType == Float.TYPE)) result = new Float(doubleValue(value)); if (toType == BigInteger.class) result = bigIntValue(value); if (toType == BigDecimal.class) result = bigDecValue(value); if (toType == String.class) result = stringValue(value); if (toType == Date.class) { result = DateUtils.toDate(stringValue(value)); } if (Enum.class.isAssignableFrom(toType)) result = enumValue((Class<Enum>) toType, value); } } else { if (toType.isPrimitive()) { result = primitiveDefaults.get(toType); } } return result; }
From source file:controller.FAQManagerController.java
@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public String editFAQ(@PathVariable(value = "id") int id, ModelMap mm) { Faq f = faqModel.getByID(id);//from w w w . j a v a2s.c o m if (f == null) { f = new Faq(); f.setStatus(Byte.valueOf("1")); } mm.addAttribute("FAQ", f); return "editFAQ"; }
From source file:openlr.binary.ByteArray.java
/** * Instantiates a new byte array from the input stream. * * @param stream the input stream//from www. j a va 2 s . c om * @throws IOException Signals that an I/O exception has occurred. */ public ByteArray(final InputStream stream) throws IOException { List<Byte> byteList = new ArrayList<Byte>(); int b = stream.read(); while (b >= 0) { byteList.add(Byte.valueOf((byte) b)); b = stream.read(); } bytes = new byte[byteList.size()]; for (int i = 0; i < byteList.size(); i++) { bytes[i] = byteList.get(i).byteValue(); } }
From source file:org.red5.io.mock.Output.java
/** {@inheritDoc} */ public void writeDate(Date date) { list.add(Byte.valueOf(DataTypes.CORE_DATE)); list.add(date); }
From source file:com.workday.autoparse.xml.demo.XmlParserTest.java
@Test public void testParse() throws UnknownElementException, ParseException, UnexpectedChildException { XmlStreamParser parser = XmlStreamParserFactory.newXmlStreamParser(); InputStream in = getInputStreamOf("input.xml"); DemoModel model = (DemoModel) parser.parseStream(in); assertTrue(model.myBoxedBoolean);/*from w w w . j av a 2s . c om*/ assertTrue(model.myPrimitiveBoolean); assertEquals(new BigDecimal(0.5), model.myBigDecimal); assertEquals(BigInteger.ONE, model.myBigInteger); assertEquals(2, model.myPrimitiveByte); assertEquals(Byte.valueOf((byte) 4), model.myBoxedByte); assertEquals('a', model.myPrimitiveChar); assertEquals(Character.valueOf('b'), model.myBoxedChar); assertEquals(5.5, model.myPrimitiveDouble, DOUBLE_E); assertEquals(Double.valueOf(6.5), model.myBoxedDouble); assertEquals(7.5f, model.myPrimitiveFloat, FLOAT_E); assertEquals(Float.valueOf(8.5f), model.myBoxedFloat); assertEquals(9, model.myPrimitiveInt); assertEquals(Integer.valueOf(10), model.myBoxedInt); assertEquals(11, model.myPrimitiveLong); assertEquals(Long.valueOf(12), model.myBoxedLong); assertEquals(13, model.myPrimitiveShort); assertEquals(Short.valueOf((short) 15), model.myBoxedShort); assertEquals("Bob", model.myString); assertTrue(model.myChildModel != null); assertEquals("My_String_Value", model.myChildModel.myString); assertEquals(5, model.myChildModel.myInt); assertEquals(3, model.repeatedChildModels.size()); assertEquals("a", model.repeatedChildModels.get(0).value); assertEquals("I am some text.", model.repeatedChildModels.get(0).textContent); assertEquals("b", model.repeatedChildModels.get(1).value); assertNull(model.repeatedChildModels.get(1).textContent); assertEquals("c", model.repeatedChildModels.get(2).value); }