use java class with '$' symbol in the class name

9 ビュー (過去 30 日間)
Victor
Victor 2021 年 1 月 21 日
コメント済み: Sai Veeramachaneni 2021 年 1 月 29 日
I am trying to use the Google's Sheets Java API (https://developers.google.com/sheets/api/quickstart/java) directly in Matlab. One of the classes has a '$' symbol in its name. In Java it is accessed using dot notation as in:
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline")
.build();
However when I am trying to import this class in Matlab with the dot notation
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow.Builder.*
flow = GoogleAuthorizationCodeFlowBuilder.Builder(HTTP_TRANSPORT, jsonFactory, clientId, clientSecrets.toString, SCOPES);
I am gtting the error 'Unable to resolve the name GoogleAuthorizationCodeFlowBuilder.Builder.' methodsview('GoogleAuthorizationCodeFlow.Builder') results in
Error using methodsview (line 101)
No class GoogleAuthorizationCodeFlowBuilder.Builder can be located or no methods for class.
Looking into the jar I noticed the class name is actually GoogleAuthorizationCodeFlowBuilder$Builder. With '$' in the name, the methodsview works:
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.*
However can't use it because matlab complains about the '$' symbol in the code:
Is there a way to work around this? I am not very experienced using Java in Matlab, so maybe I am just overlooking something?
Thanks in advance!

回答 (1 件)

Sai Veeramachaneni
Sai Veeramachaneni 2021 年 1 月 25 日
Hi,
It seems that Builder is a nested class inside GoogleAuthorizationCodeFlow.($ denotes presence of inner class)
Try
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow.*;
flow = GoogleAuthorizationCodeFlowBuilder.Builder(HTTP_TRANSPORT, jsonFactory, clientId, clientSecrets.toString, SCOPES);
  2 件のコメント
Victor
Victor 2021 年 1 月 27 日
Hi,
thanks. Unfortunately it does not work either:
Methodsview does not recognise it with the dot notation either. However it does recognise the GoogleAuthorizationCodeFlowBuilder$Builder as previously:
Since import does seem to accept the $ in the class name, is there any way to assign an alias like in
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.* 'as' FlowBuilder
Sai Veeramachaneni
Sai Veeramachaneni 2021 年 1 月 29 日
I suggest you to contact support https://www.mathworks.com/support/contact_us.html

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall Java from MATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by