ibi Patterns .NET API
Loading...
Searching...
No Matches
NetricsServerInterface.NetricsRecFile Class Reference

Define name and format of a server side record source file. More...

Public Member Functions

 NetricsRecFile (String fileName, String encoding, bool doMaxWork, bool leadingKey, int initialKey, bool fieldNamesFirst, bool fieldTypesFirst, int keyIndex, String keyName, int parentKeyIndex, String parentKeyName)
 Define a CSV file record source.
 
 NetricsRecFile (String fileName, String encoding, bool doMaxWork, bool leadingKey, int initialKey, bool fieldNamesFirst, bool fieldTypesFirst, int keyIndex, String keyName)
 Define a CSV file record source.
 
 NetricsRecFile (String fileName, String keyName, String parentKeyName)
 Define a default CSV file record source.
 
 NetricsRecFile (String fileName)
 Define a default CSV file record source.
 
 NetricsRecFile (String fileName, int keyIndex)
 Define a default CSV file record source.
 
 NetricsRecFile (String fileName, int[] fieldLengths, String encoding, bool doMaxWork, bool leadingKey, int initialKey, bool fieldNamesFirst, bool fieldTypesFirst, int keyIndex, String keyName)
 Define a Fixed Width file record source.
 
String getFileName ()
 Return the value of CSV file name setting.
 
void setFileName (String fileName)
 Set the value of CSV file name setting.
 
String getEncoding ()
 Return the value of character encoding setting.
 
void setEncoding (String encoding_name)
 Set the character encoding.
 
bool getDoMaxWork ()
 Return the Do Max Work setting, false if never set.
 
void setDoMaxWork (bool doMaxWork)
 Set the Do Max Work flag to the given value.
 
bool getLeadingKey ()
 Return the leading key setting, false if never set.
 
void setLeadingKey (bool leadingKey)
 Set the leading key flag to the given value.
 
int getInitialKey ()
 Return the initial key setting, -1 if never set.
 
void setInitialKey (int initialKey)
 Set the initial key flag to the given value.
 
int getKeyIndex ()
 Return the value of the key index, -1 if never set.
 
void setKeyIndex (int keyIndex)
 Set the value of the key index.
 
int getParentKeyIndex ()
 Return the value of the parent key index, -1 if never set.
 
void setParentKeyIndex (int parentKeyIndex)
 Set the value of the parent key index.
 
String getKeyName ()
 Return the value of the key name, null if never set.
 
void setKeyName (String keyName)
 Set the value of the key name.
 
String getParentKeyName ()
 Return the value of the parent key name, null if never set.
 
void setParentKeyName (String parentKeyName)
 Set the value of the parent key name.
 
bool getFieldNamesFirst ()
 Return the state of the field names first setting.
 
void setFieldNamesFirst (bool fieldNamesFirst)
 Set the field names first flag.
 
bool getFieldTypesFirst ()
 Return the state of the field types first setting.
 
void setFieldTypesFirst (bool fieldTypesFirst)
 Set the state of the field types first flag.
 

Detailed Description

Define name and format of a server side record source file.

This class is used to define a file of records read by the ibi™ Patterns - Search Server. The file must be located inside the server's loadable-data directory. File types currently supported are:

CSV - Excel format CSV files.

Fixed Width - Files with fixed width fields.

In both cases the files may start with an optional header line defining the field names, and/or an optional header line defining the field types. If both are given the field names must be given first.

Record keys are defined in one of four ways:

No key - no key is given in the file, keys are generated by the server.

Leading key - an unnamed, untyped initial field in each data record provides the record key. This field does not appear in the header records, so data records will have one more field than header records.

Field Index - the index position (starting at 0) of the field containing the key is given. This field appears in all header records as well as data records, but this field is loaded as the record key and does not appear as a record data field.

Field Name - the name of the field containing the key is given. If this method is used then the field names header record must be present. This is like Field Index in behavior.

If you are loading records into a child table a field of the file can be specified as containing the parent key. This can be done either by specifying the field name or the field index.

The optional field types header line can use either the field type integer id (as defined in NetricsTable) or one of the following field type names. The names are not letter case sensitive, so may appear in either upper or lower case.
attributes or attrs
date
datetime or datet
double or float
integer or int
key
parent-key or parent_key or parentkey
searchtext or srchtext
text

All leading and trailing whitespace is ignored.

Simple examples of each file type are given below. All file types except Field Index are show with both header records. They are optional in all file types except Field Name where the Field Names header record is required.

No Key

first,middle,last,order
5,5,5,INT
William,Jefferson,Clinton,42
George,W,Bush,43

Leading Key
first,middle,last,order
srchtext,srchtext,srchtext,integer
key1,William,Jefferson,Clinton,42
key2,George,W,Bush,43

Field Index (value 4)

William,Jefferson,Clinton,42,key1
George,W,Bush,43,key2

Field Name(value key)

first,middle,last,order,key
SEARCHTEXT,SEARCHTEXT,SEARCHTEXT,INTEGER,KEY
William,Jefferson,Clinton,42,key1
key1,George,W,Bush,43,key2

Loading Child records. Field Name(value key) Parent Field Name(value parent-key)

key,first,middle,last,parent-key
Key,5,5,5,ParentKey
c1,Chelsea,Victoria,Clinton,key1
c1,Jenna,Bush,Hagar,key2
c2,Barbara,Pierce,Bush,key2

See also
NetricsServerInterface.tblload(NetricsTable,NetricsRecFile), NetricsServerInterface.addRecsFromFile(String,bool,NetricsRecFile)

Constructor & Destructor Documentation

◆ NetricsRecFile() [1/6]

NetricsServerInterface.NetricsRecFile.NetricsRecFile ( String  fileName,
String  encoding,
bool  doMaxWork,
bool  leadingKey,
int  initialKey,
bool  fieldNamesFirst,
bool  fieldTypesFirst,
int  keyIndex,
String  keyName,
int  parentKeyIndex,
String  parentKeyName 
)
inline

Define a CSV file record source.

Parameters
fileNameThe name of the file containing the records.
encodingThis defines the character encoding used in the file. Currently supported encodings are: "UTF-8" or "LATIN1". DEFAULT: "LATIN1"
doMaxWorkIgnore badly formatted records.
leadingKeyThis parameter is true if the file has the Leading Key format.
initialKeyIf the No Key format is used this defines the initial key value for the generated keys. If this is less than 0 the default value of 0 is used. Keys are sequential numbers starting at the initial key.
fieldNamesFirstIf true the field names header line is present in the file.
fieldTypesFirstIf true the field types header line is present in the file.
keyIndexIf this is non-negative it defines the index (0 based) of the key field in the file records.
keyNameIf this is non-null it defines the name of the key field in the file records and the file must contain a field names header record and fieldNamesFirst must be true.
parentKeyIndexIf this is non-negative it defines the index (0 based) of the parent key field in the file records.
parentKeyNameIf this is non-null it defines the name of the parent key field in the file records and the file must contain a field names header record and fieldNamesFirst must be true.
Exceptions
NetricsExceptionIf an invalid or illegal combination of values is given.

◆ NetricsRecFile() [2/6]

NetricsServerInterface.NetricsRecFile.NetricsRecFile ( String  fileName,
String  encoding,
bool  doMaxWork,
bool  leadingKey,
int  initialKey,
bool  fieldNamesFirst,
bool  fieldTypesFirst,
int  keyIndex,
String  keyName 
)
inline

Define a CSV file record source.

This is the same as:

NetricsRecFile(fileName,encoding,doMaxWork,leadingKey,initialKey,fieldNamesFirst,fieldTypesFirst,keyIndex,keyName,-1,null)

Parameters
fileNameThe name of the file containing the records.
encodingThis defines the character encoding used in the file. Currently supported encodings are: "UTF-8" or "LATIN1". DEFAULT: "LATIN1"
doMaxWorkIgnore badly formatted records.
leadingKeyThis parameter is true if the file has the Leading Key format.
initialKeyIf the No Key format is used this defines the initial key value for the generated keys. If this is less than 0 the default value of 0 is used. Keys are sequential numbers starting at the initial key.
fieldNamesFirstIf true the field names header line is present in the file.
fieldTypesFirstIf true the field types header line is present in the file.
keyIndexIf this is non-negative it defines the index (0 based) of the key field in the file records.
keyNameIf this is non-null it defines the name of the key field in the file records and the file must contain a field names header record and fieldNamesFirst must be true.
Exceptions
NetricsExceptionIf an invalid or illegal combination of values is given.

◆ NetricsRecFile() [3/6]

NetricsServerInterface.NetricsRecFile.NetricsRecFile ( String  fileName,
String  keyName,
String  parentKeyName 
)
inline

Define a default CSV file record source.

This is the same as:

NetricsRecFile(fileName,null,false,false,-1,true,false,-1,keyName,-1,parentKeyName)

Parameters
fileNameThe name of the file containing the records.
Parameters
keyNameIf this is non-null it defines the name of the key field in the file records and the file must contain a field names header record and fieldNamesFirst must be true.
parentKeyNameIf this is non-null it defines the name of the parent key field in the file records and the file must contain a field names header record and fieldNamesFirst must be true.

◆ NetricsRecFile() [4/6]

NetricsServerInterface.NetricsRecFile.NetricsRecFile ( String  fileName)
inline

Define a default CSV file record source.

This is the same as:

NetricsRecFile(fileName,null,false,false,-1,true,false,-1,null)

Parameters
fileNameThe name of the file containing the records.

◆ NetricsRecFile() [5/6]

NetricsServerInterface.NetricsRecFile.NetricsRecFile ( String  fileName,
int  keyIndex 
)
inline

Define a default CSV file record source.

This is the same as:

NetricsRecFile(fileName,null,false,false,-1,true,false,keyIndex,null)

Parameters
fileNameThe name of the file containing the records.
keyIndexIf this is non-negative it defines the index (0 based) of the key field in the file records.

◆ NetricsRecFile() [6/6]

NetricsServerInterface.NetricsRecFile.NetricsRecFile ( String  fileName,
int[]  fieldLengths,
String  encoding,
bool  doMaxWork,
bool  leadingKey,
int  initialKey,
bool  fieldNamesFirst,
bool  fieldTypesFirst,
int  keyIndex,
String  keyName 
)
inline

Define a Fixed Width file record source.

Parameters
fileNameThe name of the file containing the records.
fieldLengthsThis array contains the field widths in characters. The length of the array must be the same as the number of fields in the record, including any key field, even if it is a leading key field.
encodingThis defines the character encoding used in the file. Currently supported encodings are: "UTF-8" or "LATIN1". DEFAULT: "LATIN1"
doMaxWorkIgnore badly formatted records.
leadingKeyThis parameter is true if the file has the Leading Key format.
initialKeyIf the No Key format is used this defines the initial key value for the generated keys. If this is less than 0 the default value of 0 is used. Keys are sequential numbers starting at the initial key.
fieldNamesFirstIf true the field names header line is present in the file.
fieldTypesFirstIf true the field types header line is present in the file.
keyIndexIf this is non-negative it defines the index (0 based) of the key field in the file records.
keyNameIf this is non-null it defines the name of the key field in the file records and the file must contain a field names header record and fieldNamesFirst must be true.
Exceptions
NetricsExceptionIf an invalid or illegal combination of values is given.

Member Function Documentation

◆ getEncoding()

String NetricsServerInterface.NetricsRecFile.getEncoding ( )
inline

Return the value of character encoding setting.

Returns the character encoding. Null if it was not set.

◆ getFileName()

String NetricsServerInterface.NetricsRecFile.getFileName ( )
inline

Return the value of CSV file name setting.

Returns the CSV file name. Null if it was not set.

◆ setEncoding()

void NetricsServerInterface.NetricsRecFile.setEncoding ( String  encoding_name)
inline

Set the character encoding.

Sets the character encoding to the named character set.

◆ setFieldNamesFirst()

void NetricsServerInterface.NetricsRecFile.setFieldNamesFirst ( bool  fieldNamesFirst)
inline

Set the field names first flag.

If true is given the first line of the file is used as the field names.

◆ setFieldTypesFirst()

void NetricsServerInterface.NetricsRecFile.setFieldTypesFirst ( bool  fieldTypesFirst)
inline

Set the state of the field types first flag.

If this is true the first line of the file (after any field names) contains the integer values of the field types.

◆ setKeyIndex()

void NetricsServerInterface.NetricsRecFile.setKeyIndex ( int  keyIndex)
inline

Set the value of the key index.

This sets the index (zero based) of the field that holds the record key value. This field is used as the record key and is NOT loaded as a data field. Use -1 to indicate that no key index is specified.

Exceptions
System.InvalidOperationExceptionthrown if key is already specified by name

◆ setKeyName()

void NetricsServerInterface.NetricsRecFile.setKeyName ( String  keyName)
inline

Set the value of the key name.

This sets the name of the field that holds the record key value. This field is used as the record key and in NOT loaded as a data field. Use null to indicate that no key name is specified.

Exceptions
System.InvalidOperationExceptionthrown if key is already specified by index

◆ setParentKeyIndex()

void NetricsServerInterface.NetricsRecFile.setParentKeyIndex ( int  parentKeyIndex)
inline

Set the value of the parent key index.

This sets the index (zero based) of the field that holds the parent record key value. This field is used as the record key and is NOT loaded as a data field. Use -1 to indicate that no key index is specified.

Exceptions
System.InvalidOperationExceptionthrown if parent key is already specified by name

◆ setParentKeyName()

void NetricsServerInterface.NetricsRecFile.setParentKeyName ( String  parentKeyName)
inline

Set the value of the parent key name.

This sets the name of the field that holds the parent record key value. This field is used as the record key and in NOT loaded as a data field. Use null to indicate that no key name is specified.

Exceptions
System.InvalidOperationExceptionthrown if parent key is already specified by index