com.devexperts.qd.kit
Class DefaultScheme

java.lang.Object
  extended by com.devexperts.qd.kit.DefaultScheme
All Implemented Interfaces:
DataScheme

public class DefaultScheme
extends java.lang.Object
implements DataScheme

The DefaultScheme is a basic implementation of data scheme. It uses record identifier and CompactInt format for record identity serialization. Note, that this implementation works only with records that are derived from DefaultRecord class and fields that are derived from AbstractDataIntField and AbstractDataObjField classes.


Field Summary
protected  SymbolCodec codec
           
protected  DefaultRecord[] records
           
 
Constructor Summary
DefaultScheme(SymbolCodec codec, DataRecord[] records)
           
 
Method Summary
static DataScheme createFromProperties(java.util.Map properties, java.lang.String prefix)
          Deprecated. This method shall be moved to PropertyConfigurator or equivalent.
 AbstractDataIntField findIntFieldByName(java.lang.String name)
          Returns Int-field by its name.
 AbstractDataObjField findObjFieldByName(java.lang.String name)
          Returns Obj-field by its name.
 DefaultRecord findRecordByName(java.lang.String name)
          Returns data record by its name.
 SymbolCodec getCodec()
          Returns symbol codec used in this scheme.
 DefaultRecord getRecord(int index)
          Returns data record by its index within this scheme.
 int getRecordCount()
          Returns number of records in this scheme.
<T> T
getService(java.lang.Class<T> service_class)
          Extension point for additional scheme-specific services.
static void setParentReferences(DataScheme scheme)
          Deprecated. No replacement. Just remove usages of this method. DefaultScheme(SymbolCodec, DataRecord[]) constructor now does it automatically.
static void verifyScheme(DataScheme scheme)
          Deprecated. No replacement. Just remove usages of this method. DefaultScheme(SymbolCodec, DataRecord[]) constructor does it all automatically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codec

protected final SymbolCodec codec

records

protected final DefaultRecord[] records
Constructor Detail

DefaultScheme

public DefaultScheme(SymbolCodec codec,
                     DataRecord[] records)
Method Detail

getCodec

public final SymbolCodec getCodec()
Description copied from interface: DataScheme
Returns symbol codec used in this scheme.

Specified by:
getCodec in interface DataScheme

getRecordCount

public final int getRecordCount()
Description copied from interface: DataScheme
Returns number of records in this scheme.

Specified by:
getRecordCount in interface DataScheme

getRecord

public final DefaultRecord getRecord(int index)
Description copied from interface: DataScheme
Returns data record by its index within this scheme. The record index in the scheme coincides with its identifier and is also used for identification of data record in serialized form.

Specified by:
getRecord in interface DataScheme

findRecordByName

public final DefaultRecord findRecordByName(java.lang.String name)
Description copied from interface: DataScheme
Returns data record by its name. Returns null if no such records exists.

Specified by:
findRecordByName in interface DataScheme

findIntFieldByName

public final AbstractDataIntField findIntFieldByName(java.lang.String name)
Description copied from interface: DataScheme
Returns Int-field by its name. Returns null if no such fields exists.

Specified by:
findIntFieldByName in interface DataScheme

findObjFieldByName

public final AbstractDataObjField findObjFieldByName(java.lang.String name)
Description copied from interface: DataScheme
Returns Obj-field by its name. Returns null if no such fields exists.

Specified by:
findObjFieldByName in interface DataScheme

getService

public <T> T getService(java.lang.Class<T> service_class)
Description copied from interface: DataScheme
Extension point for additional scheme-specific services. The following services are now supported: This method returns null if no scheme-specific override for the corresponding service is found.

Default implementation in DefaultScheme is to use Services.createService(java.lang.Class, java.lang.ClassLoader, java.lang.String) with this scheme's class loader.

Specified by:
getService in interface DataScheme

setParentReferences

public static void setParentReferences(DataScheme scheme)
Deprecated. No replacement. Just remove usages of this method. DefaultScheme(SymbolCodec, DataRecord[]) constructor now does it automatically.

Sets references to corresponding parent entities in the specified scheme. Requires that scheme is instance of DefaultScheme.

Throws:
java.lang.ClassCastException - if scheme is not an instance of DefaultScheme.
java.lang.IllegalStateException - if some parent reference already set to different instance.

verifyScheme

public static void verifyScheme(DataScheme scheme)
Deprecated. No replacement. Just remove usages of this method. DefaultScheme(SymbolCodec, DataRecord[]) constructor does it all automatically.

This method does nothing.


createFromProperties

public static DataScheme createFromProperties(java.util.Map properties,
                                              java.lang.String prefix)
Deprecated. This method shall be moved to PropertyConfigurator or equivalent.

Creates data scheme from specified properties filtered with specified prefix. The sample properties (to be used with prefix "myscheme."):
 myscheme.codec.class=com.devexperts.qd.kit.PentaCodec

 myscheme.10.id=1
 myscheme.10.name=Fundamental
 myscheme.10.0.class=com.devexperts.qd.kit.CompactIntField
 myscheme.10.0.name=Fundamental.High
 myscheme.10.1.class=com.devexperts.qd.kit.CompactIntField
 myscheme.10.1.name=Fundamental.Low

 myscheme.22.id=6
 myscheme.22.name=Quote&A
 myscheme.22.time=true
 myscheme.22.0.class=com.devexperts.qd.kit.CompactIntField
 myscheme.22.0.name=Quote&A.Bid.Price
 myscheme.22.1.class=com.devexperts.qd.kit.CompactIntField
 myscheme.22.1.name=Quote&A.Bid.Size
 
The numbers in the property key define relative index of record (first number) and field within the record (second number). These numbers must be small non-negative numbers, but they need not be consecutive.