com.dxfeed.api
Class DXFeedTimeSeriesSubscription<E extends TimeSeriesEvent>

java.lang.Object
  extended by com.dxfeed.api.DXFeedSubscription<E>
      extended by com.dxfeed.api.DXFeedTimeSeriesSubscription<E>
Type Parameters:
E - the type of events.
All Implemented Interfaces:
ObservableSubscription<E>, Serializable

public class DXFeedTimeSeriesSubscription<E extends TimeSeriesEvent>
extends DXFeedSubscription<E>

Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols and event types. This class decorates symbols that are passed to xxxSymbols methods in DXFeedSubscription by wrapping them into TimeSeriesSubscriptionSymbol instances with the current value of fromTime property. While getSymbols method returns original (undecorated) symbols, any installed ObservableSubscriptionChangeListener will see decorated ones.

Only events that implement TimeSeriesEvent interface can be subscribed to with DXFeedTimeSeriesSubscription.

From time

The value of fromTime property defines the time-span of events that are subscribed to. Only events that satisfy event.getEventTime() >= thisSubscription.getFromTime() are looked for.

The value fromTime is initially set to Long.MAX_VALUE with a special meaning that no events will be received until fromTime is changed with setFromTime method.

Threads and locks

This class is thread-safe and can be used concurrently from multiple threads without external synchronization.

See Also:
Serialized Form

Constructor Summary
DXFeedTimeSeriesSubscription(Class<? extends E>... eventTypes)
          Creates detached time-series subscription for the given list of event types.
DXFeedTimeSeriesSubscription(Class<? extends E> eventType)
          Creates detached time-series subscription for a single event type.
 
Method Summary
protected  Object decorateSymbol(Object symbol)
          Decorates the specified symbol after it was received from the DXFeedSubscription client code before it goes to installed ObservableSubscriptionChangeListener instances.
 long getFromTime()
          Returns the earliest timestamp from which time-series of events shall be received.
 void setFromTime(long fromTime)
          Sets the earliest timestamp from which time-series of events shall be received.
protected  Object undecorateSymbol(Object symbol)
          Undoes the decoration of the specified symbol doing the reverse operation to decorateSymbol(Object).
 
Methods inherited from class com.dxfeed.api.DXFeedSubscription
addChangeListener, addEventListener, addSymbols, addSymbols, clear, close, containsEventType, getEventTypes, getSymbols, isClosed, removeChangeListener, removeEventListener, removeSymbols, removeSymbols, setSymbols, setSymbols
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DXFeedTimeSeriesSubscription

public DXFeedTimeSeriesSubscription(Class<? extends E> eventType)
Creates detached time-series subscription for a single event type.

Parameters:
eventType - the event type.
Throws:
NullPointerException - if event type is null.

DXFeedTimeSeriesSubscription

public DXFeedTimeSeriesSubscription(Class<? extends E>... eventTypes)
Creates detached time-series subscription for the given list of event types.

Parameters:
eventTypes - the list of event types.
Throws:
IllegalArgumentException - if the list of event types is empty.
NullPointerException - if any event type is null.
Method Detail

getFromTime

public long getFromTime()
Returns the earliest timestamp from which time-series of events shall be received. The timestamp is in milliseconds from midnight, January 1, 1970 UTC.

Returns:
the earliest timestamp from which time-series of events shall be received.
See Also:
System.currentTimeMillis()

setFromTime

public void setFromTime(long fromTime)
Sets the earliest timestamp from which time-series of events shall be received. The timestamp is in milliseconds from midnight, January 1, 1970 UTC.

Parameters:
fromTime - the timestamp.
See Also:
System.currentTimeMillis()

decorateSymbol

protected Object decorateSymbol(Object symbol)
Decorates the specified symbol after it was received from the DXFeedSubscription client code before it goes to installed ObservableSubscriptionChangeListener instances. This implementation wraps symbol into TimeSeriesSubscriptionSymbol with a current fromTime value.

Overrides:
decorateSymbol in class DXFeedSubscription<E extends TimeSeriesEvent>
Parameters:
symbol - the symbol to decorate.
Returns:
decorated symbol.
Throws:
NullPointerException - if symbol is null.

undecorateSymbol

protected Object undecorateSymbol(Object symbol)
Undoes the decoration of the specified symbol doing the reverse operation to decorateSymbol(Object). This implementation throws ClassCastException is symbol is not an instance of TimeSeriesSubscriptionSymbol or returns its eventSymbol otherwise.

Overrides:
undecorateSymbol in class DXFeedSubscription<E extends TimeSeriesEvent>
Parameters:
symbol - the symbol to undecorate.
Returns:
undecorated symbol.
Throws:
NullPointerException - if symbol is null.
ClassCastException - if symbol is not instance of TimeSeriesSubscriptionSymbol.


Copyright © 2013 Devexperts. All Rights Reserved.