Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove redundant APIs and replace usages of Encoding module #18309

Merged
merged 16 commits into from
Aug 30, 2019

Conversation

ldclakmal
Copy link
Member

Purpose

This PR removes the redundant APIs of ballerina/encoding module, with the newly introduced APIs of langlib/array and langlib/string.

Newly introduced APIs in langlib/array module

public function toBase64(byte[] arr) returns string = external;
public function fromBase64(string str) returns byte[]|error = external;
public function toBase16(byte[] arr) returns string = external;
public function fromBase16(string str) returns byte[]|error = external;

Newly introduced APIs in langlib/string module

public function fromBytes(byte[] bytes) returns string|error = external;
public function toBytes(string str) returns byte[] = external;

Matching APIs in the ballerina/encoding module

public function encodeBase64(byte[] input) returns string = external;
public function decodeBase64(string input) returns byte[]|Error = external;
public function encodeHex(byte[] input) returns string = external;
public function decodeHex(string input) returns byte[]|Error = external;

public function byteArrayToString(byte[] content, string encoding = "utf-8") returns string = external;

Additionally, the following URI encoding/decoding APIs which are in the ballerina/http module is moved to the ballerina/encoding module as follows:

Existing APIs in the ballerina/http module:

public function encode(string url, string charset) returns string|ClientError = external;
public function decode(string url, string charset) returns string|ClientError = external;

Proposed new APIs for the ballerina/encoding module:

public function encodeUriComponent(string uriComponent, string charset) returns string|Error = external;
public function decodeUriComponent(string uriComponent, string charset) returns string|Error = external;

Related discussion: https://groups.google.com/d/msg/ballerina-dev/sbASEwIl44k/0YlP3IcXFwAJ

Fixes ballerina-platform/ballerina-spec#314

Check List

  • Read the Contributing Guide
  • Required Balo version update
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@codecov-io
Copy link

codecov-io commented Aug 29, 2019

Codecov Report

Merging #18309 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #18309   +/-   ##
=======================================
  Coverage   14.86%   14.86%           
=======================================
  Files          48       48           
  Lines        1265     1265           
  Branches      201      201           
=======================================
  Hits          188      188           
  Misses       1063     1063           
  Partials       14       14

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18b2804...912ef4e. Read the comment docs.

@ldclakmal ldclakmal marked this pull request as ready for review August 29, 2019 12:16
…ina-lang into improve-encoding

# Conflicts:
#	tests/jballerina-integration-test/src/test/resources/auth/src/authservices/oauth2-mock-server.bal
@ldclakmal ldclakmal added this to the Ballerina 1.0.0-beta milestone Aug 29, 2019
@ldclakmal ldclakmal changed the title Remove redundant APIs and replace usages Remove redundant APIs and replace usages of Encoding module Aug 29, 2019
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

Copy link
Member Author

@ldclakmal ldclakmal Aug 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…ina-lang into improve-encoding

# Conflicts:
#	language-server/modules/langserver-core/src/test/resources/completion/function/delimiterBasedCompletionForCompleteSource1.json
#	language-server/modules/langserver-core/src/test/resources/completion/function/matchStatementSuggestions4.json
#	language-server/modules/langserver-core/src/test/resources/completion/function/workerDeclarationContext4.json
#	language-server/modules/langserver-core/src/test/resources/completion/packageimport/packageImport1.json
#	language-server/modules/langserver-core/src/test/resources/completion/toplevel/globalVarDefPackageContent.json
#	language-server/modules/langserver-core/src/test/resources/completion/toplevel/topLevelPackageContentAccess.json
@wggihan wggihan merged commit 7134732 into ballerina-platform:master Aug 30, 2019
@keizer619 keizer619 modified the milestones: Ballerina 1.0.0-beta, Ballerina 1.0.0 Oct 11, 2019
@ldclakmal ldclakmal deleted the improve-encoding branch March 27, 2020 07:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Team/StandardLibs All Ballerina standard libraries Type/Improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redundant APIs for Encoding/Decoding
5 participants