List of usage examples for java.lang Byte valueOf
public static Byte valueOf(String s) throws NumberFormatException
From source file:PrimitiveUtils.java
public static Object read(String value, Class type) { Object ret = value;//from w w w. j a v a 2 s .c o m if (Integer.TYPE.equals(type)) { ret = Integer.valueOf(value); } if (Byte.TYPE.equals(type)) { ret = Byte.valueOf(value); } if (Short.TYPE.equals(type)) { ret = Short.valueOf(value); } if (Long.TYPE.equals(type)) { ret = Long.valueOf(value); } if (Float.TYPE.equals(type)) { ret = Float.valueOf(value); } if (Double.TYPE.equals(type)) { ret = Double.valueOf(value); } if (Boolean.TYPE.equals(type)) { ret = Boolean.valueOf(value); } if (Character.TYPE.equals(type)) { ret = value.charAt(0); } // TODO others. return ret; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T parse(Class<T> type, String stringValue) throws IllegalArgumentException { if (type.equals(String.class)) { return (T) stringValue; }// www.j a v a2s . c o m if (type.equals(Boolean.class) || type.equals(boolean.class)) { return (T) Boolean.valueOf(stringValue); } try { if (type.equals(Integer.class) || type.equals(int.class)) { return (T) Integer.valueOf(stringValue); } if (type.equals(Long.class) || type.equals(long.class)) { return (T) Long.valueOf(stringValue); } if (type.equals(Short.class) || type.equals(short.class)) { return (T) Short.valueOf(stringValue); } if (type.equals(Byte.class) || type.equals(byte.class)) { return (T) Byte.valueOf(stringValue); } if (type.equals(Double.class) || type.equals(double.class)) { return (T) Double.valueOf(stringValue); } if (type.equals(Float.class) || type.equals(float.class)) { return (T) Float.valueOf(stringValue); } if (type.equals(File.class)) { return (T) new File(stringValue); } } catch (final NumberFormatException e) { throw new IllegalArgumentException(e.getMessage(), e); } if (type.isEnum()) { @SuppressWarnings("rawtypes") final Class enumType = type; return (T) Enum.valueOf(enumType, stringValue); } throw new IllegalArgumentException("Can't handle type " + type); }
From source file:Main.java
public static String byteArray2HexString(byte abyte0[], int i) { int j = i;/*from ww w . ja va 2 s .c o m*/ StringBuilder stringbuilder = new StringBuilder(i); if (abyte0.length < i) { Log.w("Util", "data length is shorter then print command length"); j = abyte0.length; } int k = 0; do { if (k >= j) return stringbuilder.toString(); Object aobj[] = new Object[1]; aobj[0] = Byte.valueOf(abyte0[k]); stringbuilder.append(String.format("%02X ", aobj)); k++; } while (true); }
From source file:Main.java
public static byte[] getBitData(byte[] src, int start, int end, boolean isLH) { byte[] result = null; StringBuffer sb = new StringBuffer(); for (byte b : src) { sb.append(getBinaryString(b));//from w w w .ja v a 2 s . co m } String bitString = (isLH ? sb : sb.reverse()).substring(start, end); result = new byte[bitString.length()]; for (int i = 0; i < bitString.length(); i++) { result[i] = Byte.valueOf(String.valueOf(bitString.charAt(i))); } return result; }
From source file:controller.FAQController.java
@RequestMapping(method = RequestMethod.GET) public String FAQViews(ModelMap mm) { List<Faq> list = fModel.find(Byte.valueOf("1"), "status", false); mm.put("listFAQ", list); mm.put("title", "FAQ"); return "FAQViews"; }
From source file:com.attilax.zip.FileUtil.java
/** * ????/*from ww w.ja v a 2s . c om*/ * @param seed ??? * @return */ public static String getRandomFileName(String seed) { byte[] ra = new byte[100]; new Random().nextBytes(ra); StringBuilder build = new StringBuilder(""); for (int i = 0; i < ra.length; i++) { build.append(Byte.valueOf(ra[i]).toString()); } String currentDate = Long.valueOf(new Date().getTime()).toString(); seed = seed + currentDate + build.toString(); // return EncryptUtils.getMD5ofStr(seed).toLowerCase(); return ""; }
From source file:org.talend.components.processing.runtime.filterrow.TypeConverterUtils.java
public static Byte parseToByte(Object value) { if (value == null) { return null; } else if (value instanceof Number) { return ((Number) value).byteValue(); } else if (value instanceof Boolean) { return (byte) (((Boolean) value) ? 1 : 0); } else if (value instanceof String) { return Byte.decode((String) value).byteValue(); } else {// ww w.j a v a 2s . c om return Byte.valueOf(value.toString()); } }
From source file:org.exolab.castor.xml.parsing.primitive.objects.PrimitiveByte.java
@Override public Object getObject(Class<?> type, String value) { if (StringUtils.isEmpty(value)) { return Byte.valueOf((byte) 0); }/*from www . j a v a2s . c om*/ return Byte.valueOf(Byte.parseByte(value)); }
From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?,?,//from w w w . j a va 2s. co m * * @param clazz * @return */ @SuppressWarnings("unchecked") private static <T> T getInternalDefaultValue(Class<T> clazz) { if (!clazz.isPrimitive()) { return null; } if (Short.TYPE.equals(clazz)) { return (T) Short.valueOf((short) 0); } if (Integer.TYPE.equals(clazz)) { return (T) Integer.valueOf(0); } if (Long.TYPE.equals(clazz)) { return (T) Long.valueOf(0); } if (Boolean.TYPE.equals(clazz)) { return (T) Boolean.valueOf(false); } if (Float.TYPE.equals(clazz)) { return (T) Float.valueOf(0); } if (Double.TYPE.equals(clazz)) { return (T) Double.valueOf(0); } if (Byte.TYPE.equals(clazz)) { return (T) Byte.valueOf((byte) 0); } if (Character.TYPE.equals(clazz)) { return (T) Character.valueOf('\0'); } return null; }
From source file:Main.java
/** * Same as {@link #asByte(String, Node)} but allows an xpath to be passed * in explicitly for reuse.// w ww . j a v a 2 s. c om */ public static Byte asByte(String expression, Node node, XPath xpath) throws XPathExpressionException { String byteString = evaluateAsString(expression, node, xpath); return (isEmptyString(byteString)) ? null : Byte.valueOf(byteString); }