List of usage examples for java.lang Byte Byte
@Deprecated(since = "9") public Byte(String s) throws NumberFormatException
From source file:com.turborep.turbotracker.banking.controller.BankingController.java
@RequestMapping(value = "/createDebitsTransaction", method = RequestMethod.POST) public @ResponseBody Boolean createDebitsTransaction( @RequestParam(value = "moTransactionId", required = false) Integer theMoTransactionID, @RequestParam(value = "tempRec", required = false) Byte theTempRec, @RequestParam(value = "transDate", required = false) String theTransDate, @RequestParam(value = "rxMasterId", required = false) Integer theRxMasterId, @RequestParam(value = "amount", required = false) BigDecimal theAmount, @RequestParam(value = "reference", required = false) String theReference, @RequestParam(value = "description", required = false) String theDescription, @RequestParam(value = "transactionDate", required = false) Date theTransactionDate, @RequestParam(value = "moAccountId", required = false) Integer themoAccountId, ////www .ja v a2 s. co m HttpServletResponse theResponse) throws IOException, BankingException { Motransaction aMotransaction = new Motransaction(); aMotransaction.setMoTransactionId(theMoTransactionID); aMotransaction.setTempRec(theTempRec); aMotransaction.setTransDate(theTransDate); aMotransaction.setVoid_(new Byte((byte) 0)); aMotransaction.setReconciled(new Byte((byte) 0)); aMotransaction.setDirectDeposit(new Byte((byte) 0)); aMotransaction.setPrinted(new Byte((byte) 0)); if (theRxMasterId != null) { aMotransaction.setRxMasterId(theRxMasterId); } //transactionDate aMotransaction.setMoAccountId(themoAccountId); aMotransaction.setTransactionDate(theTransactionDate); aMotransaction.setDescription(theDescription); aMotransaction.setAmount(theAmount); aMotransaction.setReference(theReference); aMotransaction.setMoTransactionTypeId((short) 2); bankingAccountsService.createMoTransactionReconcile(aMotransaction); return true; }
From source file:com.netspective.commons.xdm.XmlDataModelSchema.java
/** * Create a proper implementation of AttributeSetter for the given * attribute type.//from w w w .ja v a 2 s . c o m */ private AttributeSetter createAttributeSetter(final Method m, final String attrName, final Class arg) { if (java.lang.String[].class.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Object[] { TextUtils.getInstance().split(value, ",", true) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.String.class.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new String[] { value }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.Character.class.equals(arg) || java.lang.Character.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Character[] { new Character(value.charAt(0)) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.Byte.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Byte[] { new Byte(value) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.Short.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Short[] { new Short(value) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.Integer.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Integer[] { new Integer(value) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.Long.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Long[] { new Long(value) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.Float.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Float[] { new Float(value) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.lang.Double.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Double[] { new Double(value) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } // boolean gets an extra treatment, because we have a nice method else if (java.lang.Boolean.class.equals(arg) || java.lang.Boolean.TYPE.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, new Boolean[] { new Boolean(TextUtils.getInstance().toBoolean(value)) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } // Class doesn't have a String constructor but a decent factory method else if (java.lang.Class.class.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { try { m.invoke(parent, new Class[] { Class.forName(value) }); } catch (ClassNotFoundException ce) { if (pc != null) { DataModelException dme = new DataModelException(pc, ce); pc.addError(dme); if (pc.isThrowErrorException()) throw dme; } else log.error(ce); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (java.io.File.class.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { // resolve relative paths through DataModel m.invoke(parent, new File[] { pc != null ? pc.resolveFile(value) : new File(value) }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (RedirectValueSource.class.isAssignableFrom(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { TextUtils textUtils = TextUtils.getInstance(); ValueSource vs = ValueSources.getInstance().getValueSourceOrStatic(value); if (vs == null) { // better to throw an error here since if there are objects which are based on null/non-null // value of the value source, it is easier to debug pc.addError("Unable to find ValueSource '" + value + "' to wrap in RedirectValueSource at " + pc.getLocator().getSystemId() + " line " + pc.getLocator().getLineNumber() + ". Valid value sources are: " + textUtils.join(ValueSources.getInstance().getAllValueSourceIdentifiers(), ", ")); } try { RedirectValueSource redirectValueSource = (RedirectValueSource) arg.newInstance(); redirectValueSource.setValueSource(vs); m.invoke(parent, new RedirectValueSource[] { redirectValueSource }); } catch (InstantiationException e) { pc.addError("Unable to create RedirectValueSource for '" + value + "' at " + pc.getLocator().getSystemId() + " line " + pc.getLocator().getLineNumber() + ". Valid value sources are: " + textUtils.join(ValueSources.getInstance().getAllValueSourceIdentifiers(), ", ")); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (ValueSource.class.equals(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException { TextUtils textUtils = TextUtils.getInstance(); ValueSource vs = ValueSources.getInstance().getValueSourceOrStatic(value); if (vs == null) { // better to throw an error here since if there are objects which are based on null/non-null // value of the value source, it is easier to debug if (pc != null) pc.addError("Unable to create ValueSource for '" + value + "' at " + pc.getLocator().getSystemId() + " line " + pc.getLocator().getLineNumber() + ". Valid value sources are: " + textUtils .join(ValueSources.getInstance().getAllValueSourceIdentifiers(), ", ")); else log.error("Unable to create ValueSource for '" + value + ". Valid value sources are: " + textUtils.join(ValueSources.getInstance().getAllValueSourceIdentifiers(), ", ")); } m.invoke(parent, new ValueSource[] { vs }); } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (Command.class.isAssignableFrom(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { try { m.invoke(parent, new Command[] { Commands.getInstance().getCommand(value) }); } catch (CommandNotFoundException e) { if (pc != null) { pc.addError("Unable to create Command for '" + value + "' at " + pc.getLocator().getSystemId() + " line " + pc.getLocator().getLineNumber() + "."); if (pc.isThrowErrorException()) throw new DataModelException(pc, e); } else log.error("Unable to create Command for '" + value + "'", e); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (XdmEnumeratedAttribute.class.isAssignableFrom(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { try { XdmEnumeratedAttribute ea = (XdmEnumeratedAttribute) arg.newInstance(); ea.setValue(pc, parent, attrName, value); m.invoke(parent, new XdmEnumeratedAttribute[] { ea }); } catch (InstantiationException ie) { pc.addError(ie); if (pc.isThrowErrorException()) throw new DataModelException(pc, ie); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (XdmBitmaskedFlagsAttribute.class.isAssignableFrom(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { try { XdmBitmaskedFlagsAttribute bfa; NestedCreator creator = (NestedCreator) nestedCreators.get(attrName); if (creator != null) bfa = (XdmBitmaskedFlagsAttribute) creator.create(parent); else bfa = (XdmBitmaskedFlagsAttribute) arg.newInstance(); bfa.setValue(pc, parent, attrName, value); m.invoke(parent, new XdmBitmaskedFlagsAttribute[] { bfa }); } catch (InstantiationException ie) { pc.addError(ie); if (pc.isThrowErrorException()) throw new DataModelException(pc, ie); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (Locale.class.isAssignableFrom(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { String[] items = TextUtils.getInstance().split(value, ",", true); switch (items.length) { case 1: m.invoke(parent, new Locale[] { new Locale(items[0], "") }); break; case 2: m.invoke(parent, new Locale[] { new Locale(items[1], items[2]) }); break; case 3: m.invoke(parent, new Locale[] { new Locale(items[1], items[2], items[3]) }); break; case 4: if (pc != null) throw new DataModelException(pc, "Too many items in Locale constructor."); else log.error("Too many items in Locale constructor: " + value); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (ResourceBundle.class.isAssignableFrom(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { String[] items = TextUtils.getInstance().split(value, ",", true); switch (items.length) { case 1: m.invoke(parent, new ResourceBundle[] { ResourceBundle.getBundle(items[0]) }); break; case 2: m.invoke(parent, new ResourceBundle[] { ResourceBundle.getBundle(items[0], new Locale(items[1], Locale.US.getCountry())) }); break; case 3: m.invoke(parent, new ResourceBundle[] { ResourceBundle.getBundle(items[0], new Locale(items[1], items[2])) }); break; case 4: m.invoke(parent, new ResourceBundle[] { ResourceBundle.getBundle(items[0], new Locale(items[1], items[2], items[3])) }); default: if (pc != null) throw new DataModelException(pc, "Too many items in ResourceBundle constructor."); else log.error("Too many items in Locale constructor: " + value); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else if (Properties.class.isAssignableFrom(arg)) { return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { // when specifying properties the following are valid // <xxx properties="abc.properties"> <!-- load this property file, throw exception if not found --> // <xxx properties="abc.properties:optional"> <!-- load this property file, no exception if not found --> // <xxx properties="/a/b/abc.properties,/x/y/def.properties"> <!-- load the first property file found, throw exception if none found --> // <xxx properties="/a/b/abc.properties,/x/y/def.properties:optional"> <!-- load the first property file found, no exception if none found --> final TextUtils textUtils = TextUtils.getInstance(); final String[] options = textUtils.split(value, ":", true); final String[] fileNames = textUtils.split(value, ",", true); final Properties properties; switch (options.length) { case 1: properties = PropertiesLoader.loadProperties(fileNames, true, false); m.invoke(parent, new Properties[] { properties }); break; case 2: properties = PropertiesLoader.loadProperties(fileNames, options[1].equals("optional") ? false : true, false); if (properties != null) m.invoke(parent, new Properties[] { properties }); break; default: if (pc != null) throw new DataModelException(pc, "Don't know how to get properties from PropertiesLoader: " + value); else log.error("Don't know how to get properties from PropertiesLoader:" + value); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } else { // worst case. look for a public String constructor and use it try { final Constructor c = arg.getConstructor(new Class[] { java.lang.String.class }); return new AttributeSetter() { public void set(XdmParseContext pc, Object parent, String value) throws InvocationTargetException, IllegalAccessException, DataModelException { try { Object attribute = c.newInstance(new String[] { value }); m.invoke(parent, new Object[] { attribute }); } catch (InstantiationException ie) { if (pc != null) { pc.addError(ie); if (pc.isThrowErrorException()) throw new DataModelException(pc, ie); } else log.error(ie); } } public boolean isInherited() { return !m.getDeclaringClass().equals(bean); } public Class getDeclaringClass() { return m.getDeclaringClass(); } }; } catch (NoSuchMethodException nme) { } } return null; }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link ResetTypeEnum}. */// w ww . j a v a 2s.c o m public static Map getResetTypeMap() { if (resetTypeMap == null) { Map map = new HashMap(14); map.put(RESET_TYPE_NONE, new Byte(JRVariable.RESET_TYPE_NONE)); map.put(RESET_TYPE_REPORT, new Byte(JRVariable.RESET_TYPE_REPORT)); map.put(RESET_TYPE_PAGE, new Byte(JRVariable.RESET_TYPE_PAGE)); map.put(RESET_TYPE_COLUMN, new Byte(JRVariable.RESET_TYPE_COLUMN)); map.put(RESET_TYPE_GROUP, new Byte(JRVariable.RESET_TYPE_GROUP)); map.put(new Byte(JRVariable.RESET_TYPE_NONE), RESET_TYPE_NONE); map.put(new Byte(JRVariable.RESET_TYPE_REPORT), RESET_TYPE_REPORT); map.put(new Byte(JRVariable.RESET_TYPE_PAGE), RESET_TYPE_PAGE); map.put(new Byte(JRVariable.RESET_TYPE_COLUMN), RESET_TYPE_COLUMN); map.put(new Byte(JRVariable.RESET_TYPE_GROUP), RESET_TYPE_GROUP); resetTypeMap = Collections.unmodifiableMap(map); } return resetTypeMap; }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java
public static Byte getNullableByte(ResultSet reader, int colidx) { try {/*from w w w .j a v a 2s .c o m*/ byte val = reader.getByte(colidx); if (reader.wasNull()) { return (null); } else { return (new Byte(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAccMSSqlSchema.class, "getNullableByte", e); } }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link CalculationEnum}. *///from w w w. j a v a 2s . com public static Map getCalculationMap() { if (calculationMap == null) { Map map = new HashMap(30); map.put(CALCULATION_NOTHING, new Byte(JRVariable.CALCULATION_NOTHING)); map.put(CALCULATION_COUNT, new Byte(JRVariable.CALCULATION_COUNT)); map.put(CALCULATION_SUM, new Byte(JRVariable.CALCULATION_SUM)); map.put(CALCULATION_AVERAGE, new Byte(JRVariable.CALCULATION_AVERAGE)); map.put(CALCULATION_LOWEST, new Byte(JRVariable.CALCULATION_LOWEST)); map.put(CALCULATION_HIGHEST, new Byte(JRVariable.CALCULATION_HIGHEST)); map.put(CALCULATION_STANDARD_DEVIATION, new Byte(JRVariable.CALCULATION_STANDARD_DEVIATION)); map.put(CALCULATION_VARIANCE, new Byte(JRVariable.CALCULATION_VARIANCE)); map.put(CALCULATION_SYSTEM, new Byte(JRVariable.CALCULATION_SYSTEM)); map.put(CALCULATION_FIRST, new Byte(JRVariable.CALCULATION_FIRST)); map.put(CALCULATION_DISTINCT_COUNT, new Byte(JRVariable.CALCULATION_DISTINCT_COUNT)); map.put(new Byte(JRVariable.CALCULATION_NOTHING), CALCULATION_NOTHING); map.put(new Byte(JRVariable.CALCULATION_COUNT), CALCULATION_COUNT); map.put(new Byte(JRVariable.CALCULATION_SUM), CALCULATION_SUM); map.put(new Byte(JRVariable.CALCULATION_AVERAGE), CALCULATION_AVERAGE); map.put(new Byte(JRVariable.CALCULATION_LOWEST), CALCULATION_LOWEST); map.put(new Byte(JRVariable.CALCULATION_HIGHEST), CALCULATION_HIGHEST); map.put(new Byte(JRVariable.CALCULATION_STANDARD_DEVIATION), CALCULATION_STANDARD_DEVIATION); map.put(new Byte(JRVariable.CALCULATION_VARIANCE), CALCULATION_VARIANCE); map.put(new Byte(JRVariable.CALCULATION_SYSTEM), CALCULATION_SYSTEM); map.put(new Byte(JRVariable.CALCULATION_FIRST), CALCULATION_FIRST); map.put(new Byte(JRVariable.CALCULATION_DISTINCT_COUNT), CALCULATION_DISTINCT_COUNT); calculationMap = Collections.unmodifiableMap(map); } return calculationMap; }
From source file:org.apache.carbondata.sdk.file.CarbonReaderTest.java
@Test public void testVectorReader() { String path = "./testWriteFiles"; try {//w w w . j a va 2 s . c om FileUtils.deleteDirectory(new File(path)); Field[] fields = new Field[12]; fields[0] = new Field("stringField", DataTypes.STRING); fields[1] = new Field("shortField", DataTypes.SHORT); fields[2] = new Field("intField", DataTypes.INT); fields[3] = new Field("longField", DataTypes.LONG); fields[4] = new Field("doubleField", DataTypes.DOUBLE); fields[5] = new Field("boolField", DataTypes.BOOLEAN); fields[6] = new Field("dateField", DataTypes.DATE); fields[7] = new Field("timeField", DataTypes.TIMESTAMP); fields[8] = new Field("decimalField", DataTypes.createDecimalType(8, 2)); fields[9] = new Field("varcharField", DataTypes.VARCHAR); fields[10] = new Field("byteField", DataTypes.BYTE); fields[11] = new Field("floatField", DataTypes.FLOAT); Map<String, String> map = new HashMap<>(); map.put("complex_delimiter_level_1", "#"); CarbonWriter writer = CarbonWriter.builder().outputPath(path).withLoadOptions(map) .withCsvInput(new Schema(fields)).writtenBy("CarbonReaderTest").build(); for (int i = 0; i < 10; i++) { String[] row2 = new String[] { "robot" + (i % 10), String.valueOf(i % 10000), String.valueOf(i), String.valueOf(Long.MAX_VALUE - i), String.valueOf((double) i / 2), String.valueOf(true), "2019-03-02", "2019-02-12 03:03:34", "12.345", "varchar", String.valueOf(i), "1.23" }; writer.write(row2); } writer.close(); // Read data CarbonReader reader = CarbonReader.builder(path, "_temp").build(); int i = 0; while (reader.hasNext()) { Object[] data = (Object[]) reader.readNextRow(); assert (RowUtil.getString(data, 0).equals("robot" + i)); assertEquals(RowUtil.getShort(data, 4), i); assertEquals(RowUtil.getInt(data, 5), i); assert (RowUtil.getLong(data, 6) == Long.MAX_VALUE - i); assertEquals(RowUtil.getDouble(data, 7), ((double) i) / 2); assert (RowUtil.getBoolean(data, 8)); assertEquals(RowUtil.getInt(data, 1), 17957); assert (RowUtil.getDecimal(data, 9).equals("12.35")); assert (RowUtil.getString(data, 3).equals("varchar")); assertEquals(RowUtil.getByte(data, 10), new Byte(String.valueOf(i))); assertEquals(RowUtil.getFloat(data, 11), new Float("1.23")); i++; } assert (i == 10); reader.close(); } catch (Throwable e) { e.printStackTrace(); Assert.fail(e.getMessage()); } finally { try { FileUtils.deleteDirectory(new File(path)); } catch (IOException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } } }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link PrintOrderEnum}. *//*from w w w .jav a 2 s . c o m*/ public static Map getPrintOrderMap() { if (printOrderMap == null) { Map map = new HashMap(6); map.put(PRINT_ORDER_VERTICAL, new Byte(JRReport.PRINT_ORDER_VERTICAL)); map.put(PRINT_ORDER_HORIZONTAL, new Byte(JRReport.PRINT_ORDER_HORIZONTAL)); map.put(new Byte(JRReport.PRINT_ORDER_VERTICAL), PRINT_ORDER_VERTICAL); map.put(new Byte(JRReport.PRINT_ORDER_HORIZONTAL), PRINT_ORDER_HORIZONTAL); printOrderMap = Collections.unmodifiableMap(map); } return printOrderMap; }
From source file:com.fluidops.iwb.api.ReadDataManagerImpl.java
/** * RDF string to Java Object/*from www. j a v a 2s .co m*/ */ @SuppressWarnings({ "unchecked" }) @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "REC_CATCH_EXCEPTION", justification = "Exception caught for robustness.") private <T> T convert(Value s, Class<T> t, Map<Value, Object> resourceStack) { if (s == null) return null; // avoid endless recursion if (resourceStack != null) { Object alreadySeen = resourceStack.get(s); if (alreadySeen != null) { if (alreadySeen.getClass().isAssignableFrom(t)) return (T) alreadySeen; else // TODO: theoretically, a subject could be accessed as Type // T1 and later // as Type T2. So really, the stack should be Map<String, // Map<Class, Object>> // but this seems like a bit of overkill, so we just return // null if the type // seen for this resource before in the stack does not match return null; } } try { if (t == short.class || t == Short.class) return (T) new Short(s.stringValue()); if (t == byte.class || t == Byte.class) return (T) new Byte(s.stringValue()); if (t == boolean.class || t == Boolean.class) return (T) Boolean.valueOf(s.stringValue()); if (t == long.class || t == Long.class) return (T) new Long(s.stringValue()); if (t == float.class || t == Float.class) return (T) new Float(s.stringValue()); if (t == double.class || t == Double.class) return (T) new Double(s.stringValue()); if (t == int.class || t == Integer.class) return (T) new Integer(s.stringValue()); if (t == String.class) return (T) s.stringValue(); if (t == Date.class) return (T) literal2HumanDate(s.stringValue()); if (t == Calendar.class) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(literal2HumanDate(s.stringValue())); return (T) cal; } if (t == URL.class) return (T) new URL(s.stringValue()); if (t == java.net.URI.class) return (T) new java.net.URI(s.stringValue()); if (t == org.openrdf.model.URI.class) return (T) s; /* * todo // interface - use dynamic proxy if ( t.isInterface() || * Proxy.class.isAssignableFrom( t ) ) return (T)Proxy.newInstance( * s, this, t ); */ T instance = t.newInstance(); // create object only if it is necessary if (resourceStack == null) resourceStack = new HashMap<Value, Object>(); resourceStack.put(s, instance); for (Field f : t.getFields()) { if (Modifier.isStatic(f.getModifiers())) continue; if (Modifier.isFinal(f.getModifiers())) continue; if (List.class.isAssignableFrom(f.getType())) { @SuppressWarnings("rawtypes") Class listTypeValue = String.class; if (f.getGenericType() instanceof ParameterizedType) listTypeValue = (Class<?>) ((ParameterizedType) f.getGenericType()) .getActualTypeArguments()[0]; if (f.getAnnotation(RDFMapping.class) == null ? false : f.getAnnotation(RDFMapping.class).inverse()) { List<String> x = getInverseProps(s, RDFMappingUtil.uri(f), listTypeValue, false); f.set(instance, x); } else { List<T> x = new ArrayList<T>(); for (Value v : getProps((Resource) s, RDFMappingUtil.uri(f))) x.add((T) convert(v, listTypeValue, resourceStack)); f.set(instance, x); } } else { if (f.getName().equals("__resource")) f.set(instance, s); else if (f.getAnnotation(RDFMapping.class) == null ? false : f.getAnnotation(RDFMapping.class).inverse()) { Object x = getInversePropInternal(s, RDFMappingUtil.uri(f), f.getType(), resourceStack); f.set(instance, x); } else if (s instanceof Resource) { // for Resources, traverse deeper, for Literals, there // is no substructure Object x = getPropInternal(getProp((Resource) s, RDFMappingUtil.uri(f)), f.getType(), resourceStack); f.set(instance, x); } } } return instance; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link OrientationEnum}. *//*from w w w .j av a 2 s . c o m*/ public static Map getOrientationMap() { if (orientationMap == null) { Map map = new HashMap(6); map.put(ORIENTATION_PORTRAIT, new Byte(JRReport.ORIENTATION_PORTRAIT)); map.put(ORIENTATION_LANDSCAPE, new Byte(JRReport.ORIENTATION_LANDSCAPE)); map.put(new Byte(JRReport.ORIENTATION_PORTRAIT), ORIENTATION_PORTRAIT); map.put(new Byte(JRReport.ORIENTATION_LANDSCAPE), ORIENTATION_LANDSCAPE); orientationMap = Collections.unmodifiableMap(map); } return orientationMap; }
From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java
/** * @deprecated Replaced by {@link WhenNoDataTypeEnum}. *//*w ww . j a v a 2 s .c om*/ public static Map getWhenNoDataTypeMap() { if (whenNoDataTypeMap == null) { Map map = new HashMap(11); map.put(WHEN_NO_DATA_TYPE_NO_PAGES, new Byte(JRReport.WHEN_NO_DATA_TYPE_NO_PAGES)); map.put(WHEN_NO_DATA_TYPE_BLANK_PAGE, new Byte(JRReport.WHEN_NO_DATA_TYPE_BLANK_PAGE)); map.put(WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL, new Byte(JRReport.WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL)); map.put(WHEN_NO_DATA_TYPE_NO_DATA_SECTION, new Byte(JRReport.WHEN_NO_DATA_TYPE_NO_DATA_SECTION)); map.put(new Byte(JRReport.WHEN_NO_DATA_TYPE_NO_PAGES), WHEN_NO_DATA_TYPE_NO_PAGES); map.put(new Byte(JRReport.WHEN_NO_DATA_TYPE_BLANK_PAGE), WHEN_NO_DATA_TYPE_BLANK_PAGE); map.put(new Byte(JRReport.WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL), WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL); map.put(new Byte(JRReport.WHEN_NO_DATA_TYPE_NO_DATA_SECTION), WHEN_NO_DATA_TYPE_NO_DATA_SECTION); whenNoDataTypeMap = Collections.unmodifiableMap(map); } return whenNoDataTypeMap; }