7 Working with Suspense Java Hooks in NPL

This chapter lists and describes the Java hooks available for the Oracle Communications Offline Mediation Controller suspense handling.

About Suspense Java Hooks

Java hooks are an advanced feature of NPL (Node Programming Language) that make it possible to call a Java method from an NPL program. For more information on using Java hooks with NPL, see the discussion on Java hooks in Offline Mediation Controller Cartridge Development Kit NPL Reference Guide.

Table 7-1 lists the suspense Java hooks methods.

Table 7-1 Suspense Java Hooks Method Summary

Modifier and Type Method and Description

void

append(DCFieldContainer in, DCFieldContainer out)

Copies to the output record all suspense fields that exist in the input record.

void

assemble(DCFieldContainer inContainer, DCFieldContainer outContainer, LongField errorCode, StringField pipelineName, StringField pipelineCategory)

Clones the input record to the output record, adding the suspense fields.

void

assemble(DCFieldContainer inContainer, DCFieldContainer outContainer, LongField errorCode, StringField pipelineName, StringField pipelineCategory, StringField sourceFileName, StringField serviceCode)

Clones the input record to the output record, adding the suspense fields.

void

assemble(DCFieldContainer out, StringField sourceFileName, StringField pipelineName, LongField errorCode)

Adds to the output record the suspense fields and their values.

void

assemble(DCFieldContainer out, StringField sourceFileName, StringField pipelineName, LongField errorCode, StringField errorDir, StringField errorFileName)

Adds to the output record the suspense fields and their values.

void

assemble(DCFieldContainer out, StringField sourceFileName, StringField pipelineName, LongField errorCode, StringField errorDir, StringField errorFileName, StringField sender, StringField batchId, StringField sequenceNumber, StringField tapInfo, StringField pipelineCategory)

Adds to the output record the suspense fields and their values.

StringField

bytesAsString(BytesField inputBytes)

Converts the given BytesField to StringField. The StringField return value contains a string of hex byte values.

StringField

exists(DCFieldContainer container)

If 1 or more key suspense fields exist in the given record, returns true (1).

IntField

float2int(FloatField fd) throws NDKException

Converts the given FloatField to an IntField. Note that data may be truncated.

LongField

float2long(FloatField fd) throws NDKException

Converts the given FloatField to a LongtField. Note that data may be truncated.

StringField

get3GPPTimeStamp(BytesField threeGPPDateField)

Converts the BytesField of a byte array containing date in yyMMddhhmmss format to StringField of timestamp in seconds.

StringField

get3GPPTimeStamp(BytesField threeGPPDateField, StringField dateFormat)

Converts the BytesField of a byte array containing date in yyMMddhhmmss format to StringField of timestamp in the given date format.

BytesField

get3GPPTimeStamp(LongField timestampInSecs)

Converts the given LongField containing the timestamp in seconds into BytesField of a byte array containing date in yyMMddhhmmss format.

StringField

getDurationInSeconds(StringField startDate, StringField endDate)

Returns the StringField containing the absolute long value of duration in seconds between the two given dates both in "yyyy-MM-dd HH:mm:ss" format.

StringField

getDurationInSeconds(StringField startDate, StringField endDate, StringField dateFormat)

Returns the StringField containing the absolute long value of duration in seconds between the two given the date format.

StringField

getValue(ListField list, StringField mapName, StringField fieldName)

Returns the value for the first fieldName found directly tied to the given ListField or in the first map found in the ListField.

StringField

getValue(ListField list, StringField mapName, StringField fieldName, StringField defaultValue)

Returns the value for the first fieldName found directly tied to the given ListField, in the first map found in the ListField, or the given default value.

StringField

getValue(MapField mapField, StringField fieldName)

Returns the value for the given field tied to the MapField.

StringField

getValue(MapField mapField, StringField fieldName, StringField defaultValue)

Returns the value for the given field tied to the MapField or the given default value.

LongField

getValueSum(ListField listField, StringField mapName, StringField fieldname)

Returns the sum in long of the values found for all the named field under the named map in the ListField.

The sum is returned as a long, 0 is the default.

FloatField

int2float(IntField intd) throws NDKException

Converts the given IntField to a FloatField.

IntField

isRecycled(DCFieldContainer container)

If the DETAIL:ASS_SUSPENSE_EXT:SUSPENSE_ID field is found in the given record and its value is greater than 0, returns true (1).

FloatField

long2float(DCFieldContainer container)

Converts the given LongField to a FloatField.

ListField

makeField(StringField listName, StringField mapName, StringField fieldName, DCField field)

Creates the named ListField and the new field to a new MapField created for it.

MapField

makeField(StringField mapName, StringField fieldName, DCField field)

Creates the named MapField and adds the new field to it.

intField

move(StringField sourceDir, StringField sourcePrefix, StringField sourceSuffix, StringField targetDir, StringField targetPrefix, StringField targetSuffix) throws Exception.

Moves file(s) matching specified patterns from source directory to the target directory.

intField

move(StringField sourceFileWithFullPath, StringField targetFileWithFullPath) throws Exception.

Moves source file with full path to the target file with full path.

ListField

setValue(ListField list, StringField mapName, StringField fieldName, DCField field) throws NDKException

Adds or updates a field directly tied to the given ListField or to a map of the given ListField.

The ListField must exist, use Boolean fieldExists(OutputRec rec, String fieldID) to check for existence.

MapField

setValue(MapField mapField, StringField fieldName, DCField field) throws NDKException

Adds or updates the field in the MapField.

The MapField must exist, use Boolean fieldExists(OutputRec rec, String fieldID) to check for existence.

BytesField

stringAsBytes(StringField inputString)

Converts the given StringField containing a string of hex byte values to a BytesField, which is returned.


Suspense Java Hook Method Details

The section describes the suspense Java hook methods.

append

public void append(DCFieldContainer in, DCFieldContainer out)

Usage

Copies all existing suspense fields from the input field to the output record. Fields that already exist in the output record are not overwritten.

Copying all the existing suspense fields, proceeds only if the exists(in) method returns a true value, which indicates that one or more key suspense fields exist.

Parameters

in - the input record.

out - the output record.

assemble

public void assemble(DCFieldContainer inContainer,
  DCFieldContainer outContainer,
  LongField errorCode,
  StringField pipelineName,
  StringField pipelineCategory)
throws Exception
  

Usage

Clones input record to output record and adds to the output record the following fields:

* DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE

* DETAIL:ASS_SUSPENSE_EXT:PIPELINE_NAME

* DETAIL:ASS_SUSPENSE_EXT:PIPELINE_CATEGORY

This method is equivalent to writing the following statements in NPL:

out=clone(in);

out.DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE=<error code>;

out.DETAIL:ASS_SUSPENSE_EXT:PIPELINE_NAME=<pipeline name>;

out.DETAIL:ASS_SUSPENSE_EXT:PIPELINE_CATEGORY=<pipeline category>;

Note:

Fields existing in the outContainer are replaced or removed as a result of the clone operation.

Both input record and output record must be in NAR format, otherwise an exception is thrown, the statement that contains the function call is skipped, and execution will continue with the next statement in the NPL program.

A warning is written to the node's log file if the node's configured debug level is set at the logging warnings level.

Parameters

inContainer - the input record, which must be in NAR format.

outContainer - the output record, which must be in the NAR format.

errorCode - the error code to be added to the output record.

pipelineName - the cartridge name/ID that detects the error and suspends the input record.

pipelineCategory - the group name in which the cartridge that initiates the suspense belongs.

Throws

Exception - if the input record or the output record is not in NAR format.

assemble

public void assemble(DCFieldContainer inContainer,
  DCFieldContainer outContainer,
  LongField errorCode,
  StringField pipelineName,
  StringField pipelineCategory,
  StringField sourceFileName,
  StringField serviceCode)
throws Exception

Usage

Clones input a record to an output record, and adds to the output record the following fields:

* DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE

* DETAIL:ASS_SUSPENSE_EXT:PIPELINE_NAME

* DETAIL:ASS_SUSPENSE_EXT:PIPELINE_CATEGORY

* DETAIL:ASS_SUSPENSE_EXT:SOURCE_FILENAME

* DETAIL:ASS_SUSPENSE_EXT:SERVICE_CODE

This method is equivalent to writing the following statements in NPL:

out=clone(in);

out.DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE=<error code>;

out.DETAIL:ASS_SUSPENSE_EXT:PIPELINE_NAME=<pipeline name>;

out.DETAIL:ASS_SUSPENSE_EXT:PIPELINE_CATEGORY=<pipeline category>;

out.DETAIL:ASS_SUSPENSE_EXT:SOURCE_FILENAME=<source_filename>;

out.DETAIL:ASS_SUSPENSE_EXT:SERVICE_CODE=<service_code>;

Note:

Fields existing in the outContainer are replaced or removed as a result of the clone operation.

Both the input record and output record must be in NAR format, or an exception is thrown, the statement that contains the function call is skipped, and processing will continue with the next statement in the NPL program.

A warning is written to the node's log file if the node's configured debug level is set at the logging warnings level.

Parameters

inContainer - the input record, which must be in NAR format.

outContainer - the output record, which must be in the NAR format.

errorCode - the error code, which is added to the output record.

pipelineName - the cartridge names ID that detects the error and suspends the input record.

pipelineCategory - the group name in which the cartridge that initiates the suspense belongs.

sourceFileName - the input source file name for the suspended CDR.

serviceCode - the service code for the suspended record CDR.

Throws

Exception - if the input record or the output record is not in NAR format.

assemble

public void assemble(DCFieldContainer out,
  StringField sourceFileName,
  StringField pipelineName,
  LongField errorCode)

Usage

Adds to output record the following fields with the given values:

* DETAIL:ASS_SUSPENSE_EXT:SOURCE_FILENAME

* DETAIL:ASS_SUSPENSE_EXT:PIPELINE_NAME

* DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE

Existing values are overwritten if the field already exists in the output record.

Parameters

out - the output record.

sourceFileName - the input source file that is suspended.

pipelineName - the cartridge name/ID that detects the error and suspends the input record.

errorCode - the error code to be added to the output record.

assemble

public void assemble(DCFieldContainer out,
  String sourceFileName,
  String pipelineName,
  long errorCode,
  String errorDir,
  String errorFileName)

Usage

Adds to output record the following fields with the given values:

* DETAIL:ASS_SUSPENSE_EXT:SOURCE_FILENAME

* DETAIL:ASS_SUSPENSE_EXT:PIPELINE_NAME

* DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE

* DETAIL:ASS_SUSPENSE_EXT:ERROR_PATH

* DETAIL:ASS_SUSPENSE_EXT:ERROR_FILENAME

Existing values are overwritten if the field already exists in the output record.

Parameters

out - the output record.

sourceFileName - the input source file that is suspended.

pipelineName - the cartridge name/ID that detects the error and suspends the input record.

errorCode - the error code to be added to the output record.

errorDir - the directory path where the suspended files are located.

errorFileName - the error filename.

assemble

public void assemble(DCFieldContainer out,
  StringField sourceFileName,
  StringField pipelineName,
  LongField errorCode,
  StringField errorDir,
  StringField errorFileName,
  StringField sender,
  StringField batchId,
  StringField sequenceNumber,
  StringField tapInfo,
  StringField pipelineCategory)

Usage

Adds to output record the following fields with the given values:

* DETAIL:ASS_SUSPENSE_EXT:SOURCE_FILENAME

* DETAIL:ASS_SUSPENSE_EXT:PIPELINE_NAME

* DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE

* DETAIL:ASS_SUSPENSE_EXT:ERROR_PATH

* DETAIL:ASS_SUSPENSE_EXT:ERROR_FILENAME

*HEADER:SENDER

*HEADER:BATCH_ID

*HEADER:SEQUENCE_NUMBER

*HEADER:TAP_PROCESSING_INFO

*DETAIL:ASS_SUSPENSE_EXT:PIPELINE_CATEGORY

Existing values are overwritten if the field already exists in the output record.

Parameters

out - the output record.

sourceFileName - the suspended input source file.

pipelineName - the cartridge name/ID that detects the error and suspends the input record.

errorCode - the error code, which is added to the output record.

errorDir - the directory path where the suspended files are located.

errorFileName - the error filename.

sender - the sender of the input source file.

batchId - the batch ID assigned with this suspension.

sequenceNumber - the sequence number associated with the suspended file.

tapInfo - the TAP processing information.

pipelineCategory - the group name in which the cartridge that initiates the suspense belongs.

bytesAsString

public StringField bytesAsString(BytesField inputBytes)

Usage

Converts the given BytesField to StringField, containing a string of hex byte values, which is returned.

Parameters

inputBytes - the BytesField containing the byte array, which is converted to a string.

Returns

The conversion resulted string in StringField.

exists

public IntField exists(DCFieldContainer container) 

Usage

Returns true (1) if 1 or more key suspense fields exist in the given record.

* DETAIL:ASS_SUSPENSE_EXT:SUSPENSE_ID

* DETAIL:ASS_SUSPENSE_EXT:ERROR_CODE

* DETAIL:ASS_SUSPENSE_EXT:SUSPENSE_STATUS

Parameters

container - the record to check.

Returns

true if one of the above suspense fields is found in the given record.

float2int

public IntField float2int(FloatField fd) throws NDKException

Usage

Converts the given FloatField to an IntField. Note that data may be truncated.

Parameters

fd - The FloatField to be converted from a float to an integer.

Returns

The conversion resulted integer in IntField.

Throws

NDKException.

float2long

public LongField float2long(FloatField fd) throws NDKException

Usage

Converts the given FloatField to a LongField. Note that data may be truncated.

Parameters

fd - the FloatField to be converted from a float to a long.

Returns

The conversion resulted long in LongField.

Throws

NDKException.

get3GPPTimeStamp

public StringField get3GPPTimeStamp(BytesField threeGPPDateField) 

Usage

Converts the BytesField of a byte array containing the date in yyMMddhhmmss format to StringField of timestamp in seconds.

The following example shows the DETAIL:CHARGING_START_TIMESTAMP is set to the timestamp in seconds converted from ServiceDeliveryStartTimeStamp:

out.DETAIL:CHARGING_START_TIMESTAMP=str2long(suspHandler.get3GPPTimeStamp(in.ServiceDeliveryStartTimeStamp));

Parameters

threeGPPDateField - the BytesField containing date in yyMMddhhmmss format.

Returns

StringField containing time in seconds, which can be converted into a long.

get3GPPTimeStamp

public StringField get3GPPTimeStamp(BytesField threeGPPDateField, StringField dateFormat)

Usage

Converts the BytesField of a byte array containing the date in yyMMddhhmmss format to StringField of timestamp in the given date format.

The following example shows how to log an entry by printing ServiceDeliveryStartTimeStamp as a string in yyyy-MM-dd HH:mm:ss date format:

 logInfo("StartDate="+suspHandler.get3GPPTimeStamp(in.ServiceDeliveryStartTimeStamp, "yyyy-MM-dd HH:mm:ss"));

Parameters

threeGPPDateField - the BytesField containing the date in yyMMddhhmmss format.

dateFormat - a date format according to the Java documentation of the time pattern format syntax for the SimpleDateFormat class.

For example, yyyy-MM-dd HH:mm:ss.

Use "" (blank) to get the timestamp in seconds without the date format, which is equivalent to get3GPPTimeStamp(BytesFieldthreeGPPDateField)

Returns

StringField containing date in the given format.

get3GPPTimeStamp

public BytesField get3GPPTimeStamp(LongField timestampInSecs)

Usage

Converts the given LongField containing the timestamp in seconds into BytesField of a byte array containing the date in yyMMddhhmmss format.

The following example shows the BytesField named ServiceDeliveryStartTimeStamp is set to the LongField DETAIL:CHARGING_START_TIMESTAMP, converted to a byte array containing the date in yyMMddhhmmss format:

 out.ServiceDeliveryStartTimeStamp=suspHandler.get3GPPTimeStamp(in.DETAIL:CHARGING_START_TIMESTAMP);

Parameters

timestampInSecs - the given LongField, which is the timestamp in seconds.

Returns

BytesField of a byte array containing date in yyMMddhhmmss format.

getDurationInSeconds

public StringField getDurationInSeconds(StringField startDate, StringField endDate)

Usage

Returns the StringField containing the absolute long value of duration in seconds between the two given dates, both in "yyyy-MM-dd HH:mm:ss" format.

The following example shows how to log an entry for the duration between ServiceDeliveryStartTimeStamp and ServiceDeliveryEndTimeStamp:

logInfo("Duration="+suspHandler.getDurationInSeconds( suspHandler.get3GPPTimeStamp(in.ServiceDeliveryStartTimeStamp), suspHandler.get3GPPTimeStamp(in.ServiceDeliveryEndTimeStamp)));

Parameters

startDate - the given start date.

endDate - the given end date.

StringField containing the long value of duration between startDate and endDate, both in "yyyy-MM-dd HH:mm:ss" format.

Returns

StringField containing the long value of duration between startDate and endDate in the given format.

getDurationInSeconds

public StringField getDurationInSeconds(StringField startDate, StringField endDate, StringField dateFormat)

Usage

Returns the StringField containing the absolute long value of duration in seconds between the two given the date format.

The following example shows how to log an entry for the duration between ServiceDeliveryStartTimeStamp and ServiceDeliveryEndTimeStamp:

logInfo("Duration="+suspHandler.getDurationInSeconds( suspHandler.get3GPPTimeStamp(in.ServiceDeliveryEndTimeStamp, "yyyy-MM-dd HH:mm:ss"), suspHandler.get3GPPTimeStamp(in.ServiceDeliveryStartTimeStamp, "yyyy-MM-dd HH:mm:ss"), "yyyy-MM-dd HH:mm:ss"));

Parameters

startDate - the given start date.

endDate - the given end date.

dateFormat - the date format for the two dates.

Returns

StringField containing the long value of duration between startDate and endDate in the given format.

getValue

public StringField getValue(ListField list, StringField mapName, StringField fieldName) 

Usage

Returns the value for the first fieldName found directly tied to the given ListField or in the first map found in the ListField.

The following example shows the DETAIL:A_NUMBER is set to the value of SIP_URI field or TEL_URI fields in any MapField under ListField named List_Of_Calling_Party_Address:

out.DETAIL:A_NUMBER=suspHandler.getValue(in.List_Of_Calling_Party_Address,"*","SIP_URI,TEL_URI");

Parameters

list - the ListField in which fieldName is searched and a value returned.

mapName - the map name directly under the list.

Multiple map names may be entered, delimited by a comma. The first matched map is used to find the matching fieldName.

  • Use "*" for the first map found.

  • Use "" for the field directly tied to the list without a map.

fieldName - the field name where the value is returned.

Multiple field names may be entered, delimited by comma. The first value for the fieldName found is returned.

Returns

The String value associated with the field name.

An empty string ("") is returned if the field is not found.

getValue

public StringField getValue(ListField list, StringField mapName, StringField fieldName, StringField defaultValue) 

Usage

Returns the value for the first fieldName found directly tied to the given ListField, in the first map found in the ListField, or the given default value

The following example shows the DETAIL:VOLUME_SENT is set to the value of Content_Length field in any MapField under ListField named List_Of_Message_Bodies, given the default value of 0:

out.DETAIL:VOLUME_SENT=str2float(suspHandler.getValue(in.List_Of_Message_Bodies, "*", "Content_Length","0"));

Parameters

list - the ListField in which fieldName is searched and a value returned.

mapName - the map name directly under the list.

  • Multiple map names may be entered, delimited by a comma. The first matched map is used to find the matching fieldName.

  • Use "*" for the first map found.

  • Use "" for the field directly tied to the list without a map.

fieldName - the field name in which the value is returned.

Multiple field names may be entered, delimited by comma. The first value for the fieldName found is returned.

defaultValue - the value to return if fieldName is not found.

Returns

The String value associated with the field name or the given default value if fieldName is not found.

getValue

public StringField getValue(MapField mapField, StringField fieldName)

Usage

Returns the value for the given field tied to the MapField.

The following example shows DETAIL:B_NUMBER is set to the value of SIP_URI or TEL_URL fields in the MapField named Called_Party_Address:

out.DETAIL:B_NUMBER=suspHandler.getValue(in.Called_Party_Address,"SIP_URI,TEL_URI");

Parameters

mapField - the MapField in which the value for the given fieldName is to be found.

fieldName - the field name for which the value is to be returned.

Multiple field names may be entered, delimited by comma. The first value for the fieldName found is returned.

Returns

The String value associated with the field name.

An empty string ("") is returned if the field is not found.

getValue

public StringField getValue(MapField mapField, StringField fieldName, StringField defaultValue)

Usage

Returns the value for the given field tied to the MapField or the given value.

The following example shows DETAIL:B_NUMBER is set to the value of TEL_URL fields in the MapField named Called_Party_Address, given the default value of 9990000:

out.DETAIL:B_NUMBER=suspHandler.getValue(in.Called_Party_Address,"TEL_URI", "9990000");

Parameters

mapField - the MapField in which the value for the given fieldName is to be found.

fieldName - the field name for which the value is to be returned.

Multiple field names may be entered, delimited by a comma. The first value for the fieldName found is returned.

defaultValue - the value to return if fieldName is not found.

Returns

The String value associated with the field name or the default value if fieldName is not found.

getValueSum

public LongField getValueSum(ListField list, StringField mapName, StringField fieldName)

Usage

Returns the sum in long of the values found for all the named field under the named map in the ListField. The sum is returned as a long, 0 is the default.

The following example shows DETAIL:VOLUME_SENT is set to the sum of the value of all DataVolumeGPRSUplink fields of any MapField in ListField 20209:

out.DETAIL:VOLUME_SENT = suspHandler.long2float(suspHandler.getValueSum(in.20209, "*", "DataVolumeGPRSUplink"));

Parameters

list - the ListField in which fieldName is searched and value returned.

mapName - The name of the map to which the field is tied.

Use "*" for the first map found in the ListField.

Use "" for the field directly tied to the list without a map.

fieldName - the named field. The type of the field for the given fieldName must be of long, int, or short to be summed.

Returns

The sum in long of the values found for all the named field.

int2float

public FloatField int2float(IntField intd) throws NDKException

Usage

Converts the given IntField to a FloatField.

Parameters

intd - The IntField to be converted from an integer to a float.

Returns

The conversion resulted float in FloatField.

Throws

NDKException.

isRecycled

public IntField isRecycled(DCFieldContainer container) 

Usage

Returns true (1) if DETAIL:ASS_SUSPENSE_EXT:SUSPENSE_ID field is found in the given record and its value is greater than 0.

Parameters

container - the record to check.

Returns

True (1) if DETAIL:ASS_SUSPENSE_EXT:SUSPENSE_ID field exists and its value is greater than 0. Else, false.

long2float

public FloatField long2float(LongField longfd) throws NDKException 

Usage

Converts the given LongField to a FloatField.

Parameters

longfd - The LongField to be converted from an long to a float.

Returns

The conversion resulted float in FloatField.

Throws

NDKException.

makeField

public ListField makeField(StringField listName, StringField mapName, StringField fieldName, DCField field)

Usage

Creates the named ListField and the new field to a new MapField created for it.

The following example shows that a ListField named "List_Of_Calling_Party_Address" is to be created with a MapField with no name to which a new field TEL_URI is created with data type and value from TEL_URI:

out.List_Of_Calling_Party_Address=suspHandler.makeField("List_Of_Calling_Party_Address", "*", "TEL_URI", TEL_URI);

Parameters

listName - the name of the ListField to create.

mapName - the map name for the new map. Use "*" or "" for map of no name.

fieldName - the field name of the new field to create and add to the map.

field - the DCField that contains the field type and field value for the named field.

Returns

The ListField created.

makeField

public MapField makeField(StringField mapName, StringField fieldName, DCField field)

Usage

Creates the named MapField and adds the new field to it.

The following example shows that the MapField Called_Party_Address is created and the field TEL_URI is added to it. The data type and value is given in TEL_URL:

out.Called_Party_Address=suspHandler.makeField("Called_Party_Address", "TEL_URI", TEL_URI);

Parameters

mapName - the map name for the new map. Use "*" or "" for map of no name.

fieldName - the field name of the new field to create and add to the map.

field - the DCField that contains the field type and field value for the named field.

Returns

The MapField created.

move

public IntField move(String sourceDir,
  String sourcePrefix,
  String sourceSuffix,
  String targetDir,
  String targetPrefix,
  String targetSuffix)
throws Exception

Usage

Moves files in sourceDir having sourcePrefix and sourceSuffix to targetDir replacing file names with targetPrefix and targetSuffix.

Ordinary files are moved, but not directories. The number of files moved (and renamed) is returned.

If the target file exists, it is replaced with a delete before the file move.

Note:

This method uses Java File.renameTo(File) so its limitation is inherent.

In the example below, n=move("/home/pin", "my_", "txt", "/tmp", "err_", "bad"), where n=2

ls /home/pin
my_file101.txt my_file102.txt web/
  
(after the move)
  
ls /home/pin
web/
  
ls /tmp
err_file101.bad err_file102.bad

Parameters

sourceDir - the source directory from where files are to be moved.

sourcePrefix - the beginning string to match the source file name for move.

sourceSuffix - the ending string to match the source file name for move.

targetDir - the destination directory to where files are moved.

targetPrefix - the string to add at the beginning of the target file name.

targetSuffix - the string to append at the end of the target file name.

Returns

The number of files moved.

Throws

Exception - if the specified directories are not valid, the source directory is not readable, target directory is not writable, or when the existing target file cannot be replaced.

move

public IntField move(String sourceFileWithFullPath,
   String targetFileWithFullPath)
throws Exception

Usage

Moves the source file with full path to the target file with full path.

If the target file exists, it is deleted before the file is moved. The number of files moved is returned, that is, 1 if successful, else 0.

Note:

This method uses Java File.renameTo(File) so its limitation is inherent.

Parameters

sourceFileWithFullPath - the full path of the source file to be moved (renamed).

targetFileWithFullPath - the full path of the target file.

Returns

1 if move was successful, else returns 0.

Throws

Exception - if either file is invalid, the source file is not found, or when the existing target file cannot be replaced.

setValue

public ListField setValue(ListField list, StringField mapName, StringField fieldName, DCField field) throws NDKException

Usage

Adds or updates a field directly tied to the given ListField or to a map of the given ListField.

The ListField must exist. Use Boolean fieldExists(OutputRec rec, String fieldID) to check for existence.

The following example shows that ListField InterOperatorIdentifiers is updated where OriginatingIOI field in MapField InterOperatorIdentifiers is set to the value of OperatorID, if OriginatingIOI field does not exist, it is added:

out.InterOperatorIdentifiers=suspHandler.setValue(out.InterOperatorIdentifiers,
"InterOperatorIdentifiers", "OriginatingIOI", OperatorID);
  

Example below shows how to update or create ListField:

if (fieldExists(out, "InterOperatorIdentifiers")) {
  out.InterOperatorIdentifiers=suspHandler.setValue(out.InterOperatorIdentifiers,
"InterOperatorIdentifiers", "OriginatingIOI", OperatorID);  } else {
    out.InterOperatorIdentifiers=suspHandler.makeField("InterOperatorIdentifiers",
"InterOperatorIdentifiers", "OriginatingIOI", OperatorID);
}

Parameters

listField - the listField to which the field is directly tied or the map of which the field is a member.

mapName - the name of the map to which the field is tied.

Use "*" for the first map found.

Use "" for the field directly tied to the list without a map.

fieldName - the name of the field to add or update.

field - the DCField that contains the field type and field value for the named field.

Returns

The updated ListField.

Throws

NDKException

setValue

public MapField setValue(MapField mapField, StringField fieldName, DCField field) throws NDKException

Usage

Adds or updates the field in the MapField.

The MapField must exist, use Boolean fieldExists(OutputRec rec, String fieldID) to check for existence.

In the following example, MapField Called_Party_Address is updated, and the TEL_URI field is set to the value of DETAIL:A_NUMBER. If the TEL_URI field does not exist, it is added:

out.Called_Party_Address=suspHandler.setValue(out.Called_Party_Address, "TEL_URI", in.DETAIL:A_NUMBER);

Parameters

mapField - the MapField to which field will be added or updated with the field and value given.

fieldName - the name of the field to add or update.

field - the DCField that contains the field type and field value for the named field.

Returns

The updated MapField.

Throws

NDKException

stringAsBytes

public BytesField stringAsBytes(StringField inputString)

Usage

Converts the given StringField containing a string of hex byte values to a BytesField, which is returned.

Parameters

inputString - the StringField containing a string of hex byte values, which are converted to a byte array.

Returns

The conversion resulted byte array in the BytesField.