List of usage examples for java.lang Byte Byte
@Deprecated(since = "9") public Byte(String s) throws NumberFormatException
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link VerticalAlignEnum}. *///from www .j ava 2 s . c o m public static Map getVerticalAlignMap() { if (verticalAlignMap == null) { Map map = new HashMap(8); map.put(VERTICAL_ALIGN_TOP, new Byte(JRAlignment.VERTICAL_ALIGN_TOP)); map.put(VERTICAL_ALIGN_MIDDLE, new Byte(JRAlignment.VERTICAL_ALIGN_MIDDLE)); map.put(VERTICAL_ALIGN_BOTTOM, new Byte(JRAlignment.VERTICAL_ALIGN_BOTTOM)); map.put(new Byte(JRAlignment.VERTICAL_ALIGN_TOP), VERTICAL_ALIGN_TOP); map.put(new Byte(JRAlignment.VERTICAL_ALIGN_MIDDLE), VERTICAL_ALIGN_MIDDLE); map.put(new Byte(JRAlignment.VERTICAL_ALIGN_BOTTOM), VERTICAL_ALIGN_BOTTOM); verticalAlignMap = Collections.unmodifiableMap(map); } return verticalAlignMap; }
From source file:net.sf.json.TestJSONArray.java
public void testToList_Byte() { List expected = new ArrayList(); expected.add(new Integer(1)); expected.add(new Integer(2)); List bytes = new ArrayList(); bytes.add(new Byte((byte) 1)); bytes.add(new Byte((byte) 2)); JSONArray jsonArray = JSONArray.fromObject(bytes); List actual = JSONArray.toList(jsonArray); Assertions.assertEquals(expected, actual); }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link RotationEnum}. *///w w w.j a v a2 s . c o m public static Map getRotationMap() { if (rotationMap == null) { Map map = new HashMap(11); map.put(ROTATION_NONE, new Byte(JRTextElement.ROTATION_NONE)); map.put(ROTATION_LEFT, new Byte(JRTextElement.ROTATION_LEFT)); map.put(ROTATION_RIGHT, new Byte(JRTextElement.ROTATION_RIGHT)); map.put(ROTATION_UPSIDE_DOWN, new Byte(JRTextElement.ROTATION_UPSIDE_DOWN)); map.put(new Byte(JRTextElement.ROTATION_NONE), ROTATION_NONE); map.put(new Byte(JRTextElement.ROTATION_LEFT), ROTATION_LEFT); map.put(new Byte(JRTextElement.ROTATION_RIGHT), ROTATION_RIGHT); map.put(new Byte(JRTextElement.ROTATION_UPSIDE_DOWN), ROTATION_UPSIDE_DOWN); rotationMap = Collections.unmodifiableMap(map); } return rotationMap; }
From source file:alice.tuprolog.lib.OOLibrary.java
/** * //from ww w . j a va 2 s. co m * parsing 'as' operator, which makes it possible to define the specific * class of an argument * */ private boolean parse_as(Object[] values, Class<?>[] types, int i, PTerm castWhat, PTerm castTo) { try { if (!(castWhat instanceof Number)) { String castTo_name = alice.util.Tools.removeApices(((Struct) castTo).getName()); String castWhat_name = alice.util.Tools.removeApices(castWhat.getTerm().toString()); // System.out.println(castWhat_name+" "+castTo_name); if (castTo_name.equals("java.lang.String") && castWhat_name.equals("true")) { values[i] = "true"; types[i] = String.class; return true; } else if (castTo_name.equals("java.lang.String") && castWhat_name.equals("false")) { values[i] = "false"; types[i] = String.class; return true; } else if (castTo_name.endsWith("[]")) { switch (castTo_name) { case "boolean[]": castTo_name = "[Z"; break; case "byte[]": castTo_name = "[B"; break; case "short[]": castTo_name = "[S"; break; case "char[]": castTo_name = "[C"; break; case "int[]": castTo_name = "[I"; break; case "long[]": castTo_name = "[L"; break; case "float[]": castTo_name = "[F"; break; case "double[]": castTo_name = "[D"; break; default: castTo_name = "[L" + castTo_name.substring(0, castTo_name.length() - 2) + ';'; break; } } if (!castWhat_name.equals("null")) { Object obj_to_cast = currentObjects.get(castWhat_name); if (obj_to_cast == null) { if (castTo_name.equals("boolean")) { switch (castWhat_name) { case "true": values[i] = new Boolean(true); break; case "false": values[i] = new Boolean(false); break; default: return false; } types[i] = Boolean.TYPE; } else { // conversion to array return false; } } else { values[i] = obj_to_cast; try { types[i] = Class.forName(castTo_name, true, dynamicLoader); } catch (ClassNotFoundException ex) { getEngine().logger.warn("Java class not found: " + castTo_name); return false; } } } else { values[i] = null; switch (castTo_name) { case "byte": types[i] = Byte.TYPE; break; case "short": types[i] = Short.TYPE; break; case "char": types[i] = Character.TYPE; break; case "int": types[i] = Integer.TYPE; break; case "long": types[i] = java.lang.Long.TYPE; break; case "float": types[i] = java.lang.Float.TYPE; break; case "double": types[i] = java.lang.Double.TYPE; break; case "boolean": types[i] = Boolean.TYPE; break; default: try { types[i] = Class.forName(castTo_name, true, dynamicLoader); } catch (ClassNotFoundException ex) { getEngine().logger.warn("Java class not found: " + castTo_name); return false; } break; } } } else { Number num = (Number) castWhat; String castTo_name = ((Struct) castTo).getName(); switch (castTo_name) { case "byte": values[i] = new Byte((byte) num.intValue()); types[i] = Byte.TYPE; break; case "short": values[i] = new Short((short) num.intValue()); types[i] = Short.TYPE; break; case "int": values[i] = new Integer(num.intValue()); types[i] = Integer.TYPE; break; case "long": values[i] = new java.lang.Long(num.longValue()); types[i] = java.lang.Long.TYPE; break; case "float": values[i] = new java.lang.Float(num.floatValue()); types[i] = java.lang.Float.TYPE; break; case "double": values[i] = new java.lang.Double(num.doubleValue()); types[i] = java.lang.Double.TYPE; break; default: return false; } } } catch (Exception ex) { getEngine().logger.warn("Casting " + castWhat + " to " + castTo + " failed"); return false; } return true; }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link BreakTypeEnum}. *//*from www .j av a 2 s . c o m*/ public static Map getBreakTypeMap() { if (breakTypeMap == null) { Map map = new HashMap(6); map.put(BREAK_TYPE_PAGE, new Byte(JRBreak.TYPE_PAGE)); map.put(BREAK_TYPE_COLUMN, new Byte(JRBreak.TYPE_COLUMN)); map.put(new Byte(JRBreak.TYPE_PAGE), BREAK_TYPE_PAGE); map.put(new Byte(JRBreak.TYPE_COLUMN), BREAK_TYPE_COLUMN); breakTypeMap = Collections.unmodifiableMap(map); } return breakTypeMap; }
From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSybase.CFInternetSybaseSchema.java
public static Byte getNullableByte(ResultSet reader, int colidx) { try {/*from w w w.j a va 2 s.co m*/ byte val = reader.getByte(colidx); if (reader.wasNull()) { return (null); } else { return (new Byte(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFInternetSybaseSchema.class, "getNullableByte", e); } }
From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetPgSql.CFInternetPgSqlSchema.java
public static Byte getNullableByte(ResultSet reader, int colidx) { try {//from w w w . j av a 2s . com byte val = reader.getByte(colidx); if (reader.wasNull()) { return (null); } else { return (new Byte(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFInternetPgSqlSchema.class, "getNullableByte", e); } }
From source file:org.plasma.sdo.helper.DataConverter.java
/** * Converts the given string value to an object appropriate * for the target type. If java.util.Arrays formatting * is detected for the given string value, the formatting is * removed and the arrays converted into a list * of elements appropriate for the target type. * @param targetType the target data type * @param value the value/*from ww w .java 2s. co m*/ * @return the converted value */ public Object fromString(Type targetType, String value) { DataType targetDataType = DataType.valueOf(targetType.getName()); switch (targetDataType) { case String: if (!value.startsWith("[")) { return value; } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<String> list = new ArrayList<String>(); for (String arrayValue : strings) list.add(arrayValue); return list; } case Decimal: if (!value.startsWith("[")) { return new BigDecimal(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<BigDecimal> list = new ArrayList<BigDecimal>(); for (String arrayValue : strings) list.add(new BigDecimal(arrayValue)); return list; } case Bytes: if (!value.startsWith("[")) { return value.getBytes(); // FIXME: charset? } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<byte[]> list = new ArrayList<byte[]>(); for (String arrayValue : strings) list.add(value.getBytes()); // FIXME: charset? return list; } case Byte: if (!value.startsWith("[")) { byte[] byteArray = value.getBytes(); // FIXME: charset? return new Byte(byteArray[0]); //TODO: truncation warning? } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Byte> list = new ArrayList<Byte>(); byte[] byteArray = null; for (String arrayValue : strings) { byteArray = arrayValue.getBytes(); list.add(new Byte(byteArray[0])); } return list; } case Boolean: if (!value.startsWith("[")) { return Boolean.valueOf(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Boolean> list = new ArrayList<Boolean>(); for (String arrayValue : strings) list.add(Boolean.valueOf(arrayValue)); return list; } case Character: if (!value.startsWith("[")) { return Character.valueOf(value.charAt(0)); // TODO: truncation warning? } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Character> list = new ArrayList<Character>(); for (String arrayValue : strings) list.add(Character.valueOf(arrayValue.charAt(0))); return list; } case Double: if (!value.startsWith("[")) { return Double.valueOf(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Double> list = new ArrayList<Double>(); for (String arrayValue : strings) list.add(Double.valueOf(arrayValue)); return list; } case Float: if (!value.startsWith("[")) { return Float.valueOf(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Float> list = new ArrayList<Float>(); for (String arrayValue : strings) list.add(Float.valueOf(arrayValue)); return list; } case Int: if (!value.startsWith("[")) { return Integer.valueOf(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Integer> list = new ArrayList<Integer>(); for (String arrayValue : strings) list.add(Integer.valueOf(arrayValue)); return list; } case Integer: if (!value.startsWith("[")) { return new BigInteger(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<BigInteger> list = new ArrayList<BigInteger>(); for (String arrayValue : strings) list.add(new BigInteger(arrayValue)); return list; } case Long: if (!value.startsWith("[")) { return Long.valueOf(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Long> list = new ArrayList<Long>(); for (String arrayValue : strings) list.add(Long.valueOf(arrayValue)); return list; } case Short: if (!value.startsWith("[")) { return Short.valueOf(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Short> list = new ArrayList<Short>(); for (String arrayValue : strings) list.add(Short.valueOf(arrayValue)); return list; } case Strings: if (!value.startsWith("[")) { String[] values = value.split("\\s"); List<String> list = new ArrayList<String>(values.length); for (int i = 0; i < values.length; i++) list.add(values[i]); return list; } else { // don't replace whitespace internal to individual 'strings' value String tempValue = value.replaceAll("[\\[\\]]", ""); tempValue.trim(); // just trim Arrays formatting String[] strings = tempValue.split(","); List<List<String>> list = new ArrayList<List<String>>(); for (String arrayValue : strings) { String[] values = arrayValue.split("\\s"); List<String> subList = new ArrayList<String>(values.length); for (int i = 0; i < values.length; i++) subList.add(values[i]); list.add(subList); } return list; } case Date: try { if (!value.startsWith("[")) { return getDateFormat().parse(value); } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<Date> list = new ArrayList<Date>(); for (String arrayValue : strings) list.add(getDateFormat().parse(arrayValue)); return list; } } catch (ParseException e) { throw new PlasmaDataObjectException(e); } case DateTime: case Month: case MonthDay: case URI: case Day: case Duration: case Time: case Year: case YearMonth: case YearMonthDay: // TODO: See lexical XML Schema string representation for these types if (!value.startsWith("[")) { return value; } else { String[] strings = value.replaceAll("[\\[\\]\\s]", "").split(","); List<String> list = new ArrayList<String>(); for (String arrayValue : strings) list.add(arrayValue); return list; } default: throw new InvalidDataConversionException(targetDataType, DataType.String, value); } }
From source file:Arrays.java
/** * Converts array of bytes to Vector./*from w ww.ja v a 2 s . c om*/ * * @param patData array of byte data * @return equivalent collection of Byte objects * @since 0.3.0.3 */ public static Vector arrayToVector(final byte[] patData) { Vector oVector = new Vector(patData.length); for (int i = 0; i < patData.length; i++) { oVector.add(new Byte(patData[i])); } return oVector; }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link RunDirectionEnum}. *//*from w w w . j av a 2 s . co m*/ public static Map getRunDirectionMap() { if (runDirectionMap == null) { Map map = new HashMap(6); map.put(RUN_DIRECTION_LTR, new Byte(JRPrintText.RUN_DIRECTION_LTR)); map.put(RUN_DIRECTION_RTL, new Byte(JRPrintText.RUN_DIRECTION_RTL)); map.put(new Byte(JRPrintText.RUN_DIRECTION_LTR), RUN_DIRECTION_LTR); map.put(new Byte(JRPrintText.RUN_DIRECTION_RTL), RUN_DIRECTION_RTL); runDirectionMap = Collections.unmodifiableMap(map); } return runDirectionMap; }