public SimpleObjectExporter ( final Class<? extends T> objectClass, final ItemFactory factory, final String prefix ) { this.objectClass = objectClass; this.factory = factory; this.prefix = prefix; createFields (); setValue ( null ); }
setItemValue ( pd, item, data, timestamp ); setItemError ( pd, item, e ); setItemError ( pd, item, null ); for ( final DataItemInputChained item : this.itemMap.values () ) setItemError ( null, item, e );
private void setItemError ( final PropertyDescriptor pd, final DataItemInputChained item, final Exception e ) { final Map<String, Variant> attributes = new HashMap<String, Variant> (); if ( pd != null ) { fillAttributes ( pd, attributes ); } if ( e != null ) { attributes.put ( "invocation.error", Variant.TRUE ); attributes.put ( "invocation.error.message", Variant.valueOf ( e.getMessage () ) ); } else { attributes.put ( "null.error", Variant.TRUE ); } item.updateData ( Variant.NULL, attributes, AttributeMode.SET ); }
/** * Set the current value with default timestamp handling * * @param value * the new value to set */ public void setValue ( final T value ) { setValue ( value, false ); }
private void createFields () { try { final BeanInfo bi = Introspector.getBeanInfo ( this.objectClass ); for ( final PropertyDescriptor pd : bi.getPropertyDescriptors () ) { if ( pd.getReadMethod () != null ) { createDataItem ( pd ); } } } catch ( final Exception e ) { logger.warn ( "Failed to create fields", e ); } }
setItemValue ( pd, item, data, timestamp ); setItemError ( pd, item, e ); setItemError ( pd, item, null ); for ( final DataItemInputChained item : this.itemMap.values () ) setItemError ( null, item, e );
private void setItemError ( final PropertyDescriptor pd, final DataItemInputChained item, final Exception e ) { final Map<String, Variant> attributes = new HashMap<String, Variant> (); if ( pd != null ) { fillAttributes ( pd, attributes ); } if ( e != null ) { attributes.put ( "invocation.error", Variant.TRUE ); attributes.put ( "invocation.error.message", Variant.valueOf ( e.getMessage () ) ); } else { attributes.put ( "null.error", Variant.TRUE ); } item.updateData ( Variant.NULL, attributes, AttributeMode.SET ); }
/** * Set the current value with default timestamp handling * * @param value * the new value to set */ public void setValue ( final T value ) { setValue ( value, false ); }
private void createFields () { try { final BeanInfo bi = Introspector.getBeanInfo ( this.objectClass ); for ( final PropertyDescriptor pd : bi.getPropertyDescriptors () ) { if ( pd.getReadMethod () != null ) { createDataItem ( pd ); } } } catch ( final Exception e ) { logger.warn ( "Failed to create fields", e ); } }
public SimpleObjectExporter ( final Class<? extends T> objectClass, final ItemFactory factory, final String prefix ) { this.objectClass = objectClass; this.factory = factory; this.prefix = prefix; createFields (); setValue ( null ); }
private void setItemValue ( final PropertyDescriptor pd, final DataItemInputChained item, final Object data, final Long timestamp ) { final Map<String, Variant> attributes = new HashMap<String, Variant> (); fillAttributes ( pd, attributes ); if ( timestamp != null ) { attributes.put ( "timestamp", Variant.valueOf ( timestamp ) ); } item.updateData ( Variant.valueOf ( data ), attributes, AttributeMode.SET ); }
private void setItemValue ( final PropertyDescriptor pd, final DataItemInputChained item, final Object data, final Long timestamp ) { final Map<String, Variant> attributes = new HashMap<String, Variant> (); fillAttributes ( pd, attributes ); if ( timestamp != null ) { attributes.put ( "timestamp", Variant.valueOf ( timestamp ) ); } item.updateData ( Variant.valueOf ( data ), attributes, AttributeMode.SET ); }