Skip to content

Commit

Permalink
Update public apis in Ballerina
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed Aug 8, 2024
1 parent dfba0c8 commit a87e7ab
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
30 changes: 30 additions & 0 deletions ballerina/csv_api.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,49 @@

import ballerina/jballerina.java;

# Converts CSV string to subtype of `record{}[]` or `anydata[][]`.
#
# + csvString - Source CSV string value
# + options - Options to be used for filtering in the projection
# + t - Target type
# + return - On success, value belonging to the given target type, else returns an `csv:Error` value.
public isolated function parseString(string csvString, ParseOptions options = {}, typedesc<record{}[]|anydata[][]> t = <>)
returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external;

# Converts byte[] to subtype of `record{}[]` or `anydata[][]`.
#
# + csvBytes - Source CSV byte array
# + options - Options to be used for filtering in the projection
# + t - Target type
# + return - On success, value belonging to the given target type, else returns an `csv:Error` value.
public isolated function parseBytes(byte[] csvBytes, ParseOptions options = {}, typedesc<record{}[]|anydata[][]> t = <>)
returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external;

# Converts CSV byte-block-stream to subtype of `record{}[]` or `anydata[][]`.
#
# + csvByteStream - Source CSV byte-block-stream
# + options - Options to be used for filtering in the projection
# + t - Target type
# + return - On success, value belonging to the given target type, else returns an `csv:Error` value.
public isolated function parseStream(stream<byte[], error?> csvByteStream,
ParseOptions options = {}, typedesc<record{}[]|anydata[][]> t = <>)
returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external;

# Convert value of type record{}[] to subtype of `record{}[]` or `anydata[][]`.
#
# + csvRecords - Source Ballerina record array value
# + options - Options to be used for filtering in the projection
# + t - Target type
# + return - On success, returns value belonging to the given target type, else returns an `csv:Error` value.
public isolated function transform(record{}[] csvRecords,
TransformOptions options = {}, typedesc<record{}[]|anydata[][]> t = <>)
returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external;

# Convert value of type string array of array to subtype of `record{}[]` or `anydata[][]`.
#
# + csvList - Source Ballerina string array of array value
# + options - Options to be used for filtering in the projection
# + t - Target type
# + return - On success, returns value belonging to the given target type, else returns an `csv:Error` value.
public isolated function parseList(string[][] csvList, ParseListOptions options = {}, typedesc<record{}[]|anydata[][]> t = <>)
returns t|Error = @java:Method {'class: "io.ballerina.lib.data.csvdata.csv.Native"} external;
6 changes: 3 additions & 3 deletions ballerina/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public type Options record {
# If `true`, enables validation of constraints during processing.
boolean enableConstraintValidation = true;
# If `true`, the resulted CSV contains the headers as the first row.
# This field is only acceptable if the expected type is subset of `anydata[][]`
# This field is only considered if the expected type is a subset of `anydata[][]`
boolean outputWithHeaders = false;
};

Expand Down Expand Up @@ -63,8 +63,8 @@ public type ParseOptions record {|
# Represents options for treating a list as a record.
public type ParseListOptions record {|
*Options;
# If `0`, all the sources will treat as data rows.
# Otherwise specify the header rows(Starts from 1)
# If `0`, all the source data will treat as data rows.
# Otherwise specify the header rows(Starts from 1) in the source data.
int:Unsigned32 headerRows = 0;
# Specify the header names of the source data.
# This field will overwrite the header values in the header rows.
Expand Down

0 comments on commit a87e7ab

Please sign in to comment.