diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 489998f..43b1aac 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerinax" name = "copybook" -version = "0.1.3" +version = "0.2.0" authors = ["Ballerina"] keywords = ["copybook", "serdes", "cobol", "mainframe"] repository = "https://github.com/ballerina-platform/module-ballerinax-copybook" @@ -15,14 +15,14 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.lib" artifactId = "copybook-native" -version = "0.1.3-SNAPSHOT" -path="../native/build/libs/copybook-native-0.1.3-SNAPSHOT.jar" +version = "0.2.0-SNAPSHOT" +path="../native/build/libs/copybook-native-0.2.0-SNAPSHOT.jar" [[platform.java17.dependency]] groupId = "io.ballerina.lib" artifactId = "copybook-commons" -version = "0.1.3" -path = "../commons/build/libs/copybook-commons-0.1.3-SNAPSHOT.jar" +version = "0.2.0" +path = "../commons/build/libs/copybook-commons-0.2.0-SNAPSHOT.jar" [[platform.java17.dependency]] groupId = "org.antlr" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index bcda983..0e2184a 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -113,7 +113,7 @@ dependencies = [ [[package]] org = "ballerinax" name = "copybook" -version = "0.1.3" +version = "0.2.0" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "file"}, diff --git a/ballerina/convertor.bal b/ballerina/convertor.bal index 2f76865..5125d03 100644 --- a/ballerina/convertor.bal +++ b/ballerina/convertor.bal @@ -18,11 +18,11 @@ import ballerina/constraint; import ballerina/file; import ballerina/jballerina.java; -# This class represents a copybook convertor that facilitates the conversion of ASCII data to and from JSON data. -public isolated class Convertor { +# This class represents a copybook converter that facilitates the conversion of ASCII data to and from JSON data. +public isolated class Converter { private final Schema schema; - # Initializes the convertor with a schema. + # Initializes the converter with a schema. # + schemaFilePath - The path of the copybook file # + return - `copybook:Error` on failure, Nil otherwise public isolated function init(string schemaFilePath) returns Error? { @@ -61,9 +61,9 @@ public isolated class Convertor { readonly & map readonlyJson = check input.cloneWithType(); lock { check self.validateTargetRecordName(targetRecordName); - JsonToCopybookConvertor convertor = new (self.schema, targetRecordName); - convertor.visitSchema(self.schema, readonlyJson); - return convertor.getValue(); + JsonToCopybookConverter converter = new (self.schema, targetRecordName); + converter.visitSchema(self.schema, readonlyJson); + return converter.getValue(); } } on fail error err { return createError(err); @@ -96,7 +96,7 @@ public isolated class Convertor { # + return - A record value on success, a `copybook:Error` in case of coercion errors public isolated function fromCopybook(string copybookData, string? targetRecordName = (), typedesc t = <>) returns t|Error = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; private isolated function toRecord(string copybookData, typedesc t, @@ -114,5 +114,5 @@ public isolated class Convertor { } isolated function parseSchemaFile(string schemaFilePath) returns Schema|Error = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; diff --git a/ballerina/data_item.bal b/ballerina/data_item.bal index 6e76a42..2372b10 100644 --- a/ballerina/data_item.bal +++ b/ballerina/data_item.bal @@ -20,27 +20,27 @@ isolated distinct class DataItem { *Node; isolated function getLevel() returns int = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getName() returns string = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getElementCount() returns int = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function isNumeric() returns boolean = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function isSigned() returns boolean = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getReadLength() returns int = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function isDecimal() returns boolean { @@ -48,15 +48,15 @@ isolated distinct class DataItem { } isolated function getFloatingPointLength() returns int = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getPicture() returns string = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getRedefinedItemName() returns string? = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function accept(Visitor visitor, anydata data = ()) { diff --git a/ballerina/group_item.bal b/ballerina/group_item.bal index a175f4a..85cb46c 100644 --- a/ballerina/group_item.bal +++ b/ballerina/group_item.bal @@ -20,23 +20,23 @@ distinct class GroupItem { *Node; isolated function getLevel() returns int = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getName() returns string = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getElementCount() returns int = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getRedefinedItemName() returns string? = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getChildren() returns Node[] = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function accept(Visitor visitor, anydata data = ()) { diff --git a/ballerina/init.bal b/ballerina/init.bal index dc12db6..f8c8683 100644 --- a/ballerina/init.bal +++ b/ballerina/init.bal @@ -21,5 +21,5 @@ isolated function init() { } isolated function setModule() = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.ModuleUtils" + 'class: "io.ballerina.lib.copybook.runtime.converter.ModuleUtils" } external; diff --git a/ballerina/json_to_copybook_convertor.bal b/ballerina/json_to_copybook_convertor.bal index 0b56bff..82c16e6 100644 --- a/ballerina/json_to_copybook_convertor.bal +++ b/ballerina/json_to_copybook_convertor.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -class JsonToCopybookConvertor { +class JsonToCopybookConverter { *Visitor; private final string[] value = []; @@ -220,7 +220,11 @@ class JsonToCopybookConvertor { check self.checkDecimalLength(wholeNumber, fraction, input, dataItem); // Handle trailing zeros in decimal - fraction = fraction.substring(0, dataItem.getFloatingPointLength()); + if fraction.length() < dataItem.getFloatingPointLength() { + fraction = fraction.padEnd(dataItem.getFloatingPointLength(), "0"); + } else if fraction.length() > dataItem.getFloatingPointLength() { + fraction = fraction.substring(0, dataItem.getFloatingPointLength()); + } // Handle supress zero ex: Z(9)9.8; int supressZeroCount = getSupressZeroCount(dataItem.getPicture()); string decimalString = wholeNumber + "." + fraction.padEnd(dataItem.getFloatingPointLength(), "0"); @@ -238,7 +242,7 @@ class JsonToCopybookConvertor { } private isolated function checkDecimalLength(string wholeNumber, string fraction, decimal input, - DataItem dataItem) returns error? { + DataItem dataItem) returns error? { // A deducted of 1 made from readLength for decimal seperator "." int expectedWholeNumberLength = dataItem.getReadLength() - dataItem.getFloatingPointLength() - 1; // If PIC has + or -, then remove the space allocated for the sign diff --git a/ballerina/schema.bal b/ballerina/schema.bal index 9a14dac..fb9b7fb 100644 --- a/ballerina/schema.bal +++ b/ballerina/schema.bal @@ -32,11 +32,11 @@ distinct class Schema { } isolated function getTypeDefinitions() returns Node[] = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getRedefinedItems() returns map = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function accept(Visitor visitor, anydata data = ()) { diff --git a/ballerina/tests/resources/copybook-inputs/copybook-1.txt b/ballerina/tests/resources/copybook-ascii/copybook-1.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-1.txt rename to ballerina/tests/resources/copybook-ascii/copybook-1.txt diff --git a/ballerina/tests/resources/copybook-ascii/copybook-10.txt b/ballerina/tests/resources/copybook-ascii/copybook-10.txt new file mode 100644 index 0000000..ca0e4ff --- /dev/null +++ b/ballerina/tests/resources/copybook-ascii/copybook-10.txt @@ -0,0 +1 @@ +10.00 \ No newline at end of file diff --git a/ballerina/tests/resources/copybook-inputs/copybook-2.txt b/ballerina/tests/resources/copybook-ascii/copybook-2.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-2.txt rename to ballerina/tests/resources/copybook-ascii/copybook-2.txt diff --git a/ballerina/tests/resources/copybook-inputs/copybook-3.txt b/ballerina/tests/resources/copybook-ascii/copybook-3.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-3.txt rename to ballerina/tests/resources/copybook-ascii/copybook-3.txt diff --git a/ballerina/tests/resources/copybook-inputs/copybook-4.txt b/ballerina/tests/resources/copybook-ascii/copybook-4.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-4.txt rename to ballerina/tests/resources/copybook-ascii/copybook-4.txt diff --git a/ballerina/tests/resources/copybook-inputs/copybook-5.txt b/ballerina/tests/resources/copybook-ascii/copybook-5.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-5.txt rename to ballerina/tests/resources/copybook-ascii/copybook-5.txt diff --git a/ballerina/tests/resources/copybook-inputs/copybook-6.txt b/ballerina/tests/resources/copybook-ascii/copybook-6.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-6.txt rename to ballerina/tests/resources/copybook-ascii/copybook-6.txt diff --git a/ballerina/tests/resources/copybook-inputs/copybook-7.txt b/ballerina/tests/resources/copybook-ascii/copybook-7.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-7.txt rename to ballerina/tests/resources/copybook-ascii/copybook-7.txt diff --git a/ballerina/tests/resources/copybook-inputs/copybook-8.txt b/ballerina/tests/resources/copybook-ascii/copybook-8.txt similarity index 100% rename from ballerina/tests/resources/copybook-inputs/copybook-8.txt rename to ballerina/tests/resources/copybook-ascii/copybook-8.txt diff --git a/ballerina/tests/resources/copybook-json/copybook-10.json b/ballerina/tests/resources/copybook-json/copybook-10.json new file mode 100644 index 0000000..ef62445 --- /dev/null +++ b/ballerina/tests/resources/copybook-json/copybook-10.json @@ -0,0 +1,3 @@ +{ + "Decimal": 10 +} diff --git a/ballerina/tests/resources/copybooks/copybook-10.cpy b/ballerina/tests/resources/copybooks/copybook-10.cpy new file mode 100644 index 0000000..8ae1a3e --- /dev/null +++ b/ballerina/tests/resources/copybooks/copybook-10.cpy @@ -0,0 +1 @@ +01 Decimal PIC 9(2).99. diff --git a/ballerina/tests/test.bal b/ballerina/tests/test.bal index 22c061e..be223e9 100644 --- a/ballerina/tests/test.bal +++ b/ballerina/tests/test.bal @@ -25,42 +25,42 @@ isolated function testParseSchemaFile() returns error? { } @test:Config { - dataProvider: testConvertorDataProvider + dataProvider: testConverterDataProvider } -isolated function testConvertor(string copybookFilePath, string inputFilePath) returns error? { - Convertor convertor = check new (copybookFilePath); +isolated function testConverter(string copybookFilePath, string inputFilePath) returns error? { + Converter converter = check new (copybookFilePath); string[] input = check io:fileReadLines(inputFilePath); foreach string line in input { - map jsonData = check (check convertor.toJson(line)).get(DATA).ensureType(); - string output = check convertor.toCopybook(jsonData); + map jsonData = check (check converter.toJson(line)).get(DATA).ensureType(); + string output = check converter.toCopybook(jsonData); test:assertEquals(output, line); } } -isolated function testConvertorDataProvider() returns [string, string][] { +isolated function testConverterDataProvider() returns [string, string][] { [string, string][] filePaths = []; foreach int i in 1 ... 5 { - filePaths.push([getCopybookPath(string `copybook-${i}`), getInputPath(string `copybook-${i}`)]); + filePaths.push([getCopybookPath(string `copybook-${i}`), getAsciiFilePath(string `copybook-${i}`)]); } return filePaths; } @test:Config -isolated function testConvertorWithTargetRecordName() returns error? { - Convertor convertor = check new (getCopybookPath("copybook-6")); - string[] input = check io:fileReadLines(getInputPath("copybook-6")); +isolated function testConverterWithTargetRecordName() returns error? { + Converter converter = check new (getCopybookPath("copybook-6")); + string[] input = check io:fileReadLines(getAsciiFilePath("copybook-6")); foreach string line in input { - map jsonData = check (check convertor.toJson(line, "DATA-DETAIL-REGISTRY")).get(DATA).ensureType(); - string output = check convertor.toCopybook(jsonData, "DATA-DETAIL-REGISTRY"); + map jsonData = check (check converter.toJson(line, "DATA-DETAIL-REGISTRY")).get(DATA).ensureType(); + string output = check converter.toCopybook(jsonData, "DATA-DETAIL-REGISTRY"); test:assertEquals(output, line); } } @test:Config isolated function testToJsonWithInvalidTargetRecordName() returns error? { - Convertor convertor = check new (getCopybookPath("copybook-7")); - string input = check io:fileReadString(getInputPath("copybook-7")); - Copybook7|Error copybook = convertor.fromCopybook(input, "InvalidName"); + Converter converter = check new (getCopybookPath("copybook-7")); + string input = check io:fileReadString(getAsciiFilePath("copybook-7")); + Copybook7|Error copybook = converter.fromCopybook(input, "InvalidName"); if copybook !is Error { test:assertFail("Expected a 'copybook:Error'"); } @@ -69,9 +69,9 @@ isolated function testToJsonWithInvalidTargetRecordName() returns error? { @test:Config isolated function testToJsonRequiresTargetRecordName() returns error? { - Convertor convertor = check new (getCopybookPath("copybook-7")); - string input = check io:fileReadString(getInputPath("copybook-7")); - Copybook7|Error copybook = convertor.fromCopybook(input); + Converter converter = check new (getCopybookPath("copybook-7")); + string input = check io:fileReadString(getAsciiFilePath("copybook-7")); + Copybook7|Error copybook = converter.fromCopybook(input); if copybook !is Error { test:assertFail("Expected a 'copybook:Error'"); } @@ -80,20 +80,20 @@ isolated function testToJsonRequiresTargetRecordName() returns error? { @test:Config isolated function testfromCopybookApi() returns error? { - Convertor convertor = check new (getCopybookPath("copybook-7")); - string[] input = check io:fileReadLines(getInputPath("copybook-7")); + Converter converter = check new (getCopybookPath("copybook-7")); + string[] input = check io:fileReadLines(getAsciiFilePath("copybook-7")); foreach string line in input { - Copybook7 copybook = check convertor.fromCopybook(line, "Record2"); - string output = check convertor.toCopybook(copybook, "Record2"); + Copybook7 copybook = check converter.fromCopybook(line, "Record2"); + string output = check converter.toCopybook(copybook, "Record2"); test:assertEquals(output, line); } } @test:Config isolated function testfromCopybookReturningError() returns error? { - Convertor convertor = check new (getCopybookPath("copybook-8")); - string input = check io:fileReadString(getInputPath("copybook-8")); - Copybook8|Error copybook = convertor.fromCopybook(input); + Converter converter = check new (getCopybookPath("copybook-8")); + string input = check io:fileReadString(getAsciiFilePath("copybook-8")); + Copybook8|Error copybook = converter.fromCopybook(input); if copybook !is Error { test:assertFail("Expected a 'copybook:Error' but found a 'string'"); } @@ -104,18 +104,18 @@ isolated function testfromCopybookReturningError() returns error? { @test:Config isolated function testToCopybookWithoutRedefinedItems() returns error? { - Convertor convertor = check new (getCopybookPath("copybook-1")); + Converter converter = check new (getCopybookPath("copybook-1")); json jsonInput = check io:fileReadJson(getCopybookJsonPath("copybook-1")); - string asciiData = check convertor.toCopybook(check jsonInput.cloneWithType()); - string expectedAscii = check io:fileReadString(getInputPath("copybook-1")); + string asciiData = check converter.toCopybook(check jsonInput.cloneWithType()); + string expectedAscii = check io:fileReadString(getAsciiFilePath("copybook-1")); test:assertEquals(asciiData, expectedAscii); } @test:Config isolated function testToCopybookReturningError() returns error? { - Convertor convertor = check new (getCopybookPath("copybook-9")); + Converter converter = check new (getCopybookPath("copybook-9")); json jsonInput = check io:fileReadJson(getCopybookJsonPath("copybook-9")); - string|Error copybook = convertor.toCopybook(check jsonInput.cloneWithType()); + string|Error copybook = converter.toCopybook(check jsonInput.cloneWithType()); if copybook !is Error { test:assertFail("Expected a 'copybook:Error' but found a 'string'"); } @@ -123,3 +123,12 @@ isolated function testToCopybookReturningError() returns error? { json actualErrorDetail = check copybook.detail().ensureType(); test:assertEquals(actualErrorDetail.toJson(), expectedErrorDetail); } + +@test:Config +isolated function testDecimalWithoutFraction() returns error? { + Converter converter = check new (getCopybookPath("copybook-10")); + json jsonInput = check io:fileReadJson(getCopybookJsonPath("copybook-10")); + string copybook = check converter.toCopybook(check jsonInput.cloneWithType()); + string expectedAscii = check io:fileReadString(getAsciiFilePath("copybook-10")); + test:assertEquals(copybook, expectedAscii); +} diff --git a/ballerina/tests/utils.bal b/ballerina/tests/utils.bal index 0698c51..0f887e8 100644 --- a/ballerina/tests/utils.bal +++ b/ballerina/tests/utils.bal @@ -20,8 +20,8 @@ isolated function getCopybookPath(string fileName) returns string { return string `tests/resources/copybooks/${fileName}.cpy`; } -isolated function getInputPath(string fileName) returns string { - return string `tests/resources/copybook-inputs/${fileName}.txt`; +isolated function getAsciiFilePath(string fileName) returns string { + return string `tests/resources/copybook-ascii/${fileName}.txt`; } isolated function getSchemaPath(string fileName) returns string { diff --git a/ballerina/utils.bal b/ballerina/utils.bal index d26ecf2..df5d06f 100644 --- a/ballerina/utils.bal +++ b/ballerina/utils.bal @@ -121,7 +121,7 @@ isolated function decimalToString(decimal value) returns string { } isolated function externToString(Node node) returns string = @java:Method { - 'class: "io.ballerina.lib.copybook.runtime.convertor.Utils" + 'class: "io.ballerina.lib.copybook.runtime.converter.Utils" } external; isolated function getTypeDefinition(Schema schema, string? targetRecordName) returns Node { diff --git a/changelog.md b/changelog.md index ebc8469..24b329c 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - [[#5783] Fix Incorrect Length Validation in Negative Decimals](https://github.com/ballerina-platform/ballerina-library/issues/5783) +- [[#5848] Fix String Index Out Of Range Error During Decimal to String Conversion](https://github.com/ballerina-platform/ballerina-library/issues/5848) + +### Changed +- [[#5849] Rename Copybook Convertor Object to Converter](https://github.com/ballerina-platform/ballerina-library/issues/5849) ## [0.1.2] - 2023-11-15 diff --git a/examples/EmployeeDetails/service.bal b/examples/EmployeeDetails/service.bal index cf1b836..ecd7fed 100644 --- a/examples/EmployeeDetails/service.bal +++ b/examples/EmployeeDetails/service.bal @@ -23,22 +23,22 @@ type Copybook record { }; service on new http:Listener(9090) { - private final copybook:Convertor convertor; + private final copybook:Converter converter; isolated function init() returns error? { - self.convertor = check new ("resources/copybook.cpy"); + self.converter = check new ("resources/copybook.cpy"); } isolated resource function post convertToJson(@http:Payload string asciiData) returns json|error { - return self.convertor.toJson(asciiData); + return self.converter.toJson(asciiData); } isolated resource function post convertToAscii(@http:Payload map jsonData) returns string|error { - return self.convertor.toCopybook(jsonData); + return self.converter.toCopybook(jsonData); } isolated resource function post getEmployeeSalary(@http:Payload string asciiData) returns decimal|error { - Copybook cb = check self.convertor.fromCopybook(asciiData); + Copybook cb = check self.converter.fromCopybook(asciiData); decimal? salary = cb.EmployeeRecord?.EmployeeSalary; if salary is () { return error("No value found for EmployeeSalary"); diff --git a/gradle.properties b/gradle.properties index 48e2f62..c8a3de0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.caching=true group=io.ballerina.lib -version=0.1.3-SNAPSHOT +version=0.2.0-SNAPSHOT ballerinaLangVersion=2201.8.0 checkstylePluginVersion=10.12.0 diff --git a/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ExecutionCallback.java b/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ExecutionCallback.java index b90608e..b110610 100644 --- a/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ExecutionCallback.java +++ b/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ExecutionCallback.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.lib.copybook.runtime.convertor; +package io.ballerina.lib.copybook.runtime.converter; import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.async.Callback; diff --git a/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ModuleUtils.java b/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ModuleUtils.java index db65dc7..92154c1 100644 --- a/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ModuleUtils.java +++ b/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/ModuleUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.lib.copybook.runtime.convertor; +package io.ballerina.lib.copybook.runtime.converter; import io.ballerina.runtime.api.Environment; import io.ballerina.runtime.api.Module; diff --git a/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/Utils.java b/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/Utils.java index c36ef05..715993d 100644 --- a/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/Utils.java +++ b/native/src/main/java/io/ballerina/lib/copybook/runtime/convertor/Utils.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.lib.copybook.runtime.convertor; +package io.ballerina.lib.copybook.runtime.converter; import io.ballerina.lib.copybook.commons.schema.Copybook; import io.ballerina.lib.copybook.commons.schema.CopybookNode; @@ -44,7 +44,7 @@ import java.util.ArrayList; import java.util.List; -import static io.ballerina.lib.copybook.runtime.convertor.ModuleUtils.getModule; +import static io.ballerina.lib.copybook.runtime.converter.ModuleUtils.getModule; public final class Utils { @@ -203,12 +203,12 @@ public static boolean hasRedefinedItems(BObject bObject, BString name) { return schema.getRedefinedItems().containsKey(name.getValue()); } - public static Object fromCopybook(Environment env, BObject convertor, BString copybookData, Object targetRecordName, + public static Object fromCopybook(Environment env, BObject converter, BString copybookData, Object targetRecordName, BTypedesc typedesc) { Future balFuture = env.markAsync(); ExecutionCallback callback = new ExecutionCallback(balFuture); Object[] paramFeed = {copybookData, true, typedesc, true, targetRecordName, true}; - env.getRuntime().invokeMethodAsyncConcurrently(convertor, TO_RECORD_METHOD_NAME, null, null, callback, null, + env.getRuntime().invokeMethodAsyncConcurrently(converter, TO_RECORD_METHOD_NAME, null, null, callback, null, PredefinedTypes.TYPE_NULL, paramFeed); return null; } diff --git a/native/src/main/java/module-info.java b/native/src/main/java/module-info.java index 30690a1..a772e53 100644 --- a/native/src/main/java/module-info.java +++ b/native/src/main/java/module-info.java @@ -20,5 +20,5 @@ requires io.ballerina.runtime; requires io.ballerina.lib.copybook.commons; - exports io.ballerina.lib.copybook.runtime.convertor; + exports io.ballerina.lib.copybook.runtime.converter; }