public Variant getValue () { if ( this.value == null ) { return Variant.NULL; } return this.value.getValue (); }
public Variant getPrimaryValue ( final String name ) { final DataItemValue div = getValue ( name ); if ( div == null ) { return Variant.NULL; } else { return div.getValue (); } }
public Variant getPrimaryValue ( final String name ) { final DataItemValue div = getValue ( name ); if ( div == null ) { return Variant.NULL; } else { return div.getValue (); } }
public Builder ( final DataItemValue sourceValue ) { if ( sourceValue == null ) { this.value = Variant.NULL; this.attributes = new HashMap<String, Variant> (); this.subscriptionState = SubscriptionState.DISCONNECTED; } else { this.value = sourceValue.getValue (); this.attributes = new HashMap<String, Variant> ( sourceValue.getAttributes () ); this.subscriptionState = sourceValue.getSubscriptionState (); this.subscriptionError = sourceValue.getSubscriptionError (); } }
public Builder ( final DataItemValue sourceValue ) { if ( sourceValue == null ) { this.value = Variant.NULL; this.attributes = new HashMap<String, Variant> (); this.subscriptionState = SubscriptionState.DISCONNECTED; } else { this.value = sourceValue.getValue (); this.attributes = new HashMap<String, Variant> ( sourceValue.getAttributes () ); this.subscriptionState = sourceValue.getSubscriptionState (); this.subscriptionError = sourceValue.getSubscriptionError (); } }
public boolean isValid () { for ( final Map.Entry<String, DataValue> entry : this.data.entrySet () ) { if ( entry.getValue () == null || entry.getValue ().isIgnoreSummary () ) { continue; } final DataItemValue value = entry.getValue ().getValue (); if ( value == null || !value.isConnected () || value.isError () || value.getValue () == null || value.getValue ().isNull () && entry.getValue ().isNullInvalid () ) { return false; } } for ( final SummaryInformation child : this.childData ) { if ( !child.isValid () ) { return false; } } return true; }
this.lastValue = value == null ? null : value.getValue (); this.value = value;
@Override public void run () { listener.notifySubscriptionChange ( SubscriptionState.CONNECTED, null ); listener.notifyDataChange ( value.getValue (), value.getAttributes (), false ); } } );
@Override public void run () { listener.notifySubscriptionChange ( SubscriptionState.CONNECTED, null ); listener.notifyDataChange ( value.getValue (), value.getAttributes (), true ); }; } );
@Override protected void update () { if ( this.value == null ) { return; } if ( this.value.getSubscriptionError () == null ) { this.stateText.setText ( this.value.getSubscriptionState ().name () ); } else { this.stateText.setText ( String.format ( Messages.OverviewDetailsPart_SubscriptionStateFormat, this.value.getSubscriptionState ().name (), this.value.getSubscriptionError ().getMessage () ) ); } this.warnText.setText ( this.value.isWarning () ? Messages.OverviewDetailsPart_WarningActiveText : Messages.OverviewDetailsPart_WarningInactiveText ); this.alarmText.setText ( this.value.isAlarm () ? Messages.OverviewDetailsPart_AlarmActiveText : Messages.OverviewDetailsPart_AlarmInactiveText ); this.errorText.setText ( this.value.isError () ? Messages.OverviewDetailsPart_ErrorActiveText : Messages.OverviewDetailsPart_ErrorInactiveText ); this.manualText.setText ( this.value.isManual () ? Messages.OverviewDetailsPart_ManualActiveText : Messages.OverviewDetailsPart_ManualInactiveText ); this.blockedText.setText ( this.value.isBlocked () ? Messages.OverviewDetailsPart_BlockedActiveText : Messages.OverviewDetailsPart_BlockedInactiveText ); this.valueText.setText ( this.value.getValue () != null ? this.value.getValue ().toString () : Messages.OverviewDetailsPart_NullText ); final Calendar c = this.value.getTimestamp (); this.timestampText.setText ( c != null ? String.format ( Messages.OverviewDetailsPart_TimeFormat, c ) : Messages.OverviewDetailsPart_NullText ); } }
this.lastValue = value == null ? null : value.getValue (); this.value = value;
@Override protected void update () { if ( this.value == null ) { return; } if ( this.value.getSubscriptionError () == null ) { this.stateText.setText ( this.value.getSubscriptionState ().name () ); } else { this.stateText.setText ( String.format ( Messages.OverviewDetailsPart_SubscriptionStateFormat, this.value.getSubscriptionState ().name (), this.value.getSubscriptionError ().getMessage () ) ); } this.warnText.setText ( this.value.isWarning () ? Messages.OverviewDetailsPart_WarningActiveText : Messages.OverviewDetailsPart_WarningInactiveText ); this.alarmText.setText ( this.value.isAlarm () ? Messages.OverviewDetailsPart_AlarmActiveText : Messages.OverviewDetailsPart_AlarmInactiveText ); this.errorText.setText ( this.value.isError () ? Messages.OverviewDetailsPart_ErrorActiveText : Messages.OverviewDetailsPart_ErrorInactiveText ); this.manualText.setText ( this.value.isManual () ? Messages.OverviewDetailsPart_ManualActiveText : Messages.OverviewDetailsPart_ManualInactiveText ); this.blockedText.setText ( this.value.isBlocked () ? Messages.OverviewDetailsPart_BlockedActiveText : Messages.OverviewDetailsPart_BlockedInactiveText ); this.valueText.setText ( this.value.getValue () != null ? this.value.getValue ().toString () : Messages.OverviewDetailsPart_NullText ); final Calendar c = this.value.getTimestamp (); this.timestampText.setText ( c != null ? String.format ( Messages.OverviewDetailsPart_TimeFormat, c ) : Messages.OverviewDetailsPart_NullText ); } }
private DataItemValue applyAutoTimestamp ( DataItemValue value ) { if ( value != null && value.getTimestamp () == null ) { try { if ( !this.lastValue.equals ( value.getValue () ) ) { this.lastTimestamp = Calendar.getInstance (); } } catch ( final Exception e ) { // nothing logger.info ( "Failed to update timestamp", e ); } final DataItemValue.Builder builder = new DataItemValue.Builder ( value ); builder.setTimestamp ( this.lastTimestamp ); value = builder.build (); } return value; }
private DataItemValue applyAutoTimestamp ( DataItemValue value ) { if ( value != null && value.getTimestamp () == null ) { try { if ( !this.lastValue.equals ( value.getValue () ) ) { this.lastTimestamp = Calendar.getInstance (); } } catch ( final Exception e ) { // nothing logger.info ( "Failed to update timestamp", e ); } final DataItemValue.Builder builder = new DataItemValue.Builder ( value ); builder.setTimestamp ( this.lastTimestamp ); value = builder.build (); } return value; }
public static DataItemValueLight valueOf ( final DataItemValue dataItemValue ) { if ( ( dataItemValue == null ) || dataItemValue.equals ( DataItemValue.DISCONNECTED ) ) { return DISCONNECTED; } return new DataItemValueLight ( dataItemValue.getValue (), dataItemValue.getSubscriptionState (), dataItemValue.getTimestamp () == null ? Long.MIN_VALUE : dataItemValue.getTimestamp ().getTimeInMillis (), dataItemValue.isManual (), dataItemValue.isError () ); }
public static DataItemValueLight valueOf ( final DataItemValue dataItemValue ) { if ( ( dataItemValue == null ) || dataItemValue.equals ( DataItemValue.DISCONNECTED ) ) { return DISCONNECTED; } return new DataItemValueLight ( dataItemValue.getValue (), dataItemValue.getSubscriptionState (), dataItemValue.getTimestamp () == null ? Long.MIN_VALUE : dataItemValue.getTimestamp ().getTimeInMillis (), dataItemValue.isManual (), dataItemValue.isError () ); }
@Override public void run () { if ( state != ConnectionState.BOUND ) { listener.notifySubscriptionChange ( SubscriptionState.DISCONNECTED, null ); } else if ( value != null ) { listener.notifySubscriptionChange ( SubscriptionState.CONNECTED, null ); listener.notifyDataChange ( value.getValue (), value.getAttributes (), true ); } else { listener.notifySubscriptionChange ( SubscriptionState.GRANTED, null ); } } } );