idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
152,400
private void addResponseHeaderParameters ( InternalRequest request , ResponseHeaderOverrides responseHeaders ) { if ( responseHeaders != null ) { if ( responseHeaders . getCacheControl ( ) != null ) { request . addParameter ( ResponseHeaderOverrides . RESPONSE_HEADER_CACHE_CONTROL , responseHeaders . getCacheControl ( ) ) ; } if ( responseHeaders . getContentDisposition ( ) != null ) { request . addParameter ( ResponseHeaderOverrides . RESPONSE_HEADER_CONTENT_DISPOSITION , responseHeaders . getContentDisposition ( ) ) ; } if ( responseHeaders . getContentEncoding ( ) != null ) { request . addParameter ( ResponseHeaderOverrides . RESPONSE_HEADER_CONTENT_ENCODING , responseHeaders . getContentEncoding ( ) ) ; } if ( responseHeaders . getContentLanguage ( ) != null ) { request . addParameter ( ResponseHeaderOverrides . RESPONSE_HEADER_CONTENT_LANGUAGE , responseHeaders . getContentLanguage ( ) ) ; } if ( responseHeaders . getContentType ( ) != null ) { request . addParameter ( ResponseHeaderOverrides . RESPONSE_HEADER_CONTENT_TYPE , responseHeaders . getContentType ( ) ) ; } if ( responseHeaders . getExpires ( ) != null ) { request . addParameter ( ResponseHeaderOverrides . RESPONSE_HEADER_EXPIRES , responseHeaders . getExpires ( ) ) ; } } }
Adds response headers parameters to the request given if non - null .
345
13
152,401
public AppendObjectResponse appendObject ( String bucketName , String key , File file ) { return this . appendObject ( new AppendObjectRequest ( bucketName , key , file ) ) ; }
Uploads the specified appendable file to Bos under the specified bucket and key name .
41
17
152,402
public AppendObjectResponse appendObject ( String bucketName , String key , String value , ObjectMetadata metadata ) { try { return this . appendObject ( bucketName , key , value . getBytes ( DEFAULT_ENCODING ) , metadata ) ; } catch ( UnsupportedEncodingException e ) { throw new BceClientException ( "Fail to get bytes." , e ) ; } }
Uploads the specified string and object metadata to Bos under the specified bucket and key name .
83
18
152,403
public AppendObjectResponse appendObject ( String bucketName , String key , byte [ ] value , ObjectMetadata metadata ) { checkNotNull ( metadata , "metadata should not be null." ) ; if ( metadata . getContentLength ( ) == - 1 ) { metadata . setContentLength ( value . length ) ; } return this . appendObject ( new AppendObjectRequest ( bucketName , key , RestartableInputStream . wrap ( value ) , metadata ) ) ; }
Uploads the appendable bytes and object metadata to Bos under the specified bucket and key name .
100
19
152,404
public AppendObjectResponse appendObject ( String bucketName , String key , InputStream input ) { return this . appendObject ( new AppendObjectRequest ( bucketName , key , input ) ) ; }
Uploads the appendable input stream to Bos under the specified bucket and key name .
42
17
152,405
public GetDedicatedHostResponse getDedicatedHost ( GetDedicatedHostRequest request ) { checkNotNull ( request , "request should not be null." ) ; checkNotNull ( request . getDedicatedHostId ( ) , "request dedicatedHostId should not be null." ) ; InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . GET , request . getDedicatedHostId ( ) ) ; return this . invokeHttpClient ( internalRequest , GetDedicatedHostResponse . class ) ; }
Get the detail information of specified dcc .
116
9
152,406
public ListDedicatedHostsResponse listDedicatedHosts ( ListDedicatedHostsRequest request ) { InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . GET , null ) ; if ( ! Strings . isNullOrEmpty ( request . getMarker ( ) ) ) { internalRequest . addParameter ( "marker" , request . getMarker ( ) ) ; } if ( request . getMaxKeys ( ) >= 0 ) { internalRequest . addParameter ( "maxKeys" , String . valueOf ( request . getMaxKeys ( ) ) ) ; } if ( ! Strings . isNullOrEmpty ( request . getZoneName ( ) ) ) { internalRequest . addParameter ( "zoneName" , request . getZoneName ( ) ) ; } return invokeHttpClient ( internalRequest , ListDedicatedHostsResponse . class ) ; }
get a list of hosts owned by the authenticated user and specified conditions
191
13
152,407
public void setPartETags ( List < PartETag > partETags ) { checkNotNull ( partETags , "partETags should not be null." ) ; for ( int i = 0 ; i < partETags . size ( ) ; ++ i ) { PartETag partETag = partETags . get ( i ) ; checkNotNull ( partETag , "partETags[%s] should not be null." , i ) ; int partNumber = partETag . getPartNumber ( ) ; checkArgument ( partNumber > 0 , "partNumber should be positive. partETags[%s].partNumber:%s" , i , partNumber ) ; checkNotNull ( partETag . getETag ( ) , "partETags[%s].eTag should not be null." , i ) ; } Collections . sort ( partETags , new Comparator < PartETag > ( ) { @ Override public int compare ( PartETag tag1 , PartETag tag2 ) { return tag1 . getPartNumber ( ) - tag2 . getPartNumber ( ) ; } } ) ; int lastPartNumber = 0 ; for ( int i = 0 ; i < partETags . size ( ) ; ++ i ) { int partNumber = partETags . get ( i ) . getPartNumber ( ) ; checkArgument ( partNumber != lastPartNumber , "Duplicated partNumber %s." , partNumber ) ; lastPartNumber = partNumber ; } this . partETags = partETags ; }
Sets the list of part numbers and ETags that identify the individual parts of the multipart upload to complete .
336
23
152,408
public CreatePresetResponse createPreset ( CreatePresetRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getName ( ) , "The parameter name should NOT be null or empty string." ) ; if ( request . getAudio ( ) != null ) { checkNotNull ( request . getAudio ( ) . getBitRateInBps ( ) , "The parameter bitRateInBps in audio should NOT be null." ) ; checkIsTrue ( request . getAudio ( ) . getBitRateInBps ( ) > 0 , "The audio's parameter bitRateInBps should be greater than zero." ) ; } if ( request . getVideo ( ) != null ) { checkNotNull ( request . getVideo ( ) . getBitRateInBps ( ) , "The parameter bitRateInBps in video should NOT be null." ) ; checkIsTrue ( request . getVideo ( ) . getBitRateInBps ( ) > 0 , "The video's parameter bitRateInBps should be greater than zero." ) ; checkNotNull ( request . getVideo ( ) . getMaxFrameRate ( ) , "The parameter maxFrameRate in video should NOT be null." ) ; checkIsTrue ( request . getVideo ( ) . getMaxFrameRate ( ) > 0 , "The video's parameter maxFrameRate should be greater than zero." ) ; checkNotNull ( request . getVideo ( ) . getMaxWidthInPixel ( ) , "The parameter maxWidthInPixel in video should NOT be null." ) ; checkIsTrue ( request . getVideo ( ) . getMaxWidthInPixel ( ) > 0 , "The video's parameter maxWidthInPixel should be greater than zero." ) ; checkNotNull ( request . getVideo ( ) . getMaxHeightInPixel ( ) , "The parameter maxHeightInPixel in video should NOT be null." ) ; checkIsTrue ( request . getVideo ( ) . getMaxHeightInPixel ( ) > 0 , "The video's parameter maxHeightInPixel should be greater than zero." ) ; } // not support yet request . setThumbnail ( null ) ; request . setWatermarks ( null ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . POST , request , LIVE_PRESET ) ; return invokeHttpClient ( internalRequest , CreatePresetResponse . class ) ; }
Create a live preset which contains parameters needed in the live stream service .
515
14
152,409
public CreatePresetResponse createPreset ( String name , String description , Audio audio , Video video , Hls hls , Rtmp rtmp , LiveThumbnail thumbnail , Watermarks watermarks ) { CreatePresetRequest request = new CreatePresetRequest ( ) ; request . setForwardOnly ( false ) ; request . setName ( name ) ; request . setDescription ( description ) ; request . setAudio ( audio ) ; request . setVideo ( video ) ; request . setHls ( hls ) ; request . setRtmp ( rtmp ) ; request . setThumbnail ( thumbnail ) ; request . setWatermarks ( watermarks ) ; return createPreset ( request ) ; }
Create a live preset which contains parameters needed in the live stream service and not in forward only mode so that the input stream will be transcoded according to audio and video parameters .
143
35
152,410
public CreatePresetResponse createForwardOnlyPreset ( String name , String description , Hls hls , Rtmp rtmp , LiveThumbnail thumbnail , Watermarks watermarks ) { CreatePresetRequest request = new CreatePresetRequest ( ) ; request . setForwardOnly ( true ) ; request . setName ( name ) ; request . setDescription ( description ) ; request . setHls ( hls ) ; request . setRtmp ( rtmp ) ; request . setThumbnail ( thumbnail ) ; request . setWatermarks ( watermarks ) ; return createPreset ( request ) ; }
Create a live preset which contains parameters needed in the live stream service and in forward only mode in which the input stream s resolution ratio and code rate will be kept unchanged .
123
34
152,411
public ListPresetsResponse listPresets ( ) { ListPresetsRequest request = new ListPresetsRequest ( ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , LIVE_PRESET ) ; return invokeHttpClient ( internalRequest , ListPresetsResponse . class ) ; }
List all your live presets .
65
6
152,412
public ListSessionsResponse listSessions ( String status ) { ListSessionsRequest request = new ListSessionsRequest ( ) . withStatus ( status ) ; return listSessions ( request ) ; }
List all your live sessions with given status .
42
9
152,413
public ListSessionsResponse listSessions ( ListSessionsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , LIVE_SESSION ) ; if ( request . getStatus ( ) != null ) { checkStringNotEmpty ( request . getStatus ( ) , "The parameter status should NOT be empty string." ) ; internalRequest . addParameter ( STATUS , request . getStatus ( ) ) ; } return invokeHttpClient ( internalRequest , ListSessionsResponse . class ) ; }
List all your live sessions .
127
6
152,414
public ListAppResponse listApp ( ListAppRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , LIVE_APP ) ; return invokeHttpClient ( internalRequest , ListAppResponse . class ) ; }
list all your apps
68
4
152,415
public ListAppStreamsResponse listAppStreams ( String app ) { ListAppStreamsRequest request = new ListAppStreamsRequest ( ) ; request . setApp ( app ) ; return listAppStreams ( request ) ; }
list your streams by app name
49
6
152,416
public StartRecordingResponse startRecording ( String sessionId , String recording ) { checkStringNotEmpty ( sessionId , "The parameter sessionId should NOT be null or empty string." ) ; checkStringNotEmpty ( recording , "The parameter recording should NOT be null or empty string." ) ; StartRecordingRequest request = new StartRecordingRequest ( ) . withSessionId ( sessionId ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . PUT , request , LIVE_SESSION , sessionId ) ; internalRequest . addParameter ( RECORDING , recording ) ; return invokeHttpClient ( internalRequest , StartRecordingResponse . class ) ; }
Start live session recording .
140
5
152,417
public StopRecordingResponse stopRecording ( String sessionId ) { checkStringNotEmpty ( sessionId , "The parameter sessionId should NOT be null or empty string." ) ; StopRecordingRequest request = new StopRecordingRequest ( ) . withSessionId ( sessionId ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . PUT , request , LIVE_SESSION , sessionId ) ; internalRequest . addParameter ( RECORDING , null ) ; return invokeHttpClient ( internalRequest , StopRecordingResponse . class ) ; }
Stop live session recording .
116
5
152,418
public GetSessionSourceInfoResponse getSessionSourceInfo ( String sessionId ) { checkStringNotEmpty ( sessionId , "The parameter sessionId should NOT be null or empty string." ) ; GetSessionSourceInfoRequest request = new GetSessionSourceInfoRequest ( ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , LIVE_SESSION , sessionId ) ; internalRequest . addParameter ( SOURCE_INFO , null ) ; return invokeHttpClient ( internalRequest , GetSessionSourceInfoResponse . class ) ; }
Get your live session source info by live session id .
113
11
152,419
public GetRecordingResponse getRecording ( String recording ) { checkStringNotEmpty ( recording , "The parameter recording should NOT be null or empty string." ) ; GetRecordingRequest request = new GetRecordingRequest ( ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , RECORDING , recording ) ; return invokeHttpClient ( internalRequest , GetRecordingResponse . class ) ; }
Get your live recording preset by live recording preset name .
89
11
152,420
public ListRecordingsResponse listRecordings ( ) { GetRecordingRequest request = new GetRecordingRequest ( ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , RECORDING ) ; return invokeHttpClient ( internalRequest , ListRecordingsResponse . class ) ; }
List all your live recording presets .
64
7
152,421
public ListNotificationsResponse listNotifications ( ) { ListNotificationsRequest request = new ListNotificationsRequest ( ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , LIVE_NOTIFICATION ) ; return invokeHttpClient ( internalRequest , ListNotificationsResponse . class ) ; }
List all your live notifications .
66
6
152,422
public CreateNotificationResponse createNotification ( CreateNotificationRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getName ( ) , "The parameter name should NOT be null or empty string." ) ; checkStringNotEmpty ( request . getEndpoint ( ) , "The parameter endpoint should NOT be null or empty string." ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . POST , request , LIVE_NOTIFICATION ) ; return invokeHttpClient ( internalRequest , CreateNotificationResponse . class ) ; }
Create a live notification in the live stream service .
127
10
152,423
public ListSecurityPoliciesResponse listSecurityPolicies ( ) { ListSecurityPoliciesRequest request = new ListSecurityPoliciesRequest ( ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , LIVE_SECURITY_POLICY ) ; return invokeHttpClient ( internalRequest , ListSecurityPoliciesResponse . class ) ; }
List all your live security policys .
80
8
152,424
public ListDomainAppResponse listDomainApp ( ListDomainAppRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getPlayDomain ( ) , "playDomain should NOT be empty." ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , LIVE_DOMAIN , request . getPlayDomain ( ) , LIVE_APP ) ; return invokeHttpClient ( internalRequest , ListDomainAppResponse . class ) ; }
List a domain s app in the live stream service .
108
11
152,425
public void updateStreamPresets ( UpdateStreamPresetsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getDomain ( ) , "Domain should NOT be empty." ) ; checkStringNotEmpty ( request . getApp ( ) , "App should NOT be empty" ) ; checkStringNotEmpty ( request . getStream ( ) , "Stream should NOT be empty." ) ; // presets can be null for letting stream to use domain's presets, // so no need to check if presets is null InternalRequest internalRequest = createRequest ( HttpMethodName . POST , request , LIVE_DOMAIN , request . getDomain ( ) , LIVE_APP , request . getApp ( ) , LIVE_STREAM , request . getStream ( ) ) ; internalRequest . addParameter ( "presets" , null ) ; invokeHttpClient ( internalRequest , AbstractBceResponse . class ) ; }
Update stream s presets in the live stream service
202
9
152,426
public void updateStreamPresets ( String domain , String app , String stream , Map < String , String > presets ) { UpdateStreamPresetsRequest request = new UpdateStreamPresetsRequest ( ) . withDomain ( domain ) . withApp ( app ) . withStream ( stream ) . withPresets ( presets ) ; updateStreamPresets ( request ) ; }
Update stream s presets
75
4
152,427
public void updateStreamRecording ( UpdateStreamRecordingRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getDomain ( ) , "Domain should NOT be empty." ) ; checkStringNotEmpty ( request . getApp ( ) , "App should NOT be empty" ) ; checkStringNotEmpty ( request . getStream ( ) , "Stream should NOT be empty." ) ; // recording can be null for letting stream to use domain's recording, // so no need to check if recording is null InternalRequest internalRequest = createRequest ( HttpMethodName . PUT , request , LIVE_DOMAIN , request . getDomain ( ) , LIVE_APP , request . getApp ( ) , LIVE_STREAM , request . getStream ( ) ) ; internalRequest . addParameter ( "recording" , request . getRecording ( ) ) ; invokeHttpClient ( internalRequest , AbstractBceResponse . class ) ; }
Update stream recording in the live stream service
209
8
152,428
public void updateStreamRecording ( String domain , String app , String stream , String recording ) { UpdateStreamRecordingRequest request = new UpdateStreamRecordingRequest ( ) . withDomain ( domain ) . withApp ( app ) . withStream ( stream ) . withRecording ( recording ) ; updateStreamRecording ( request ) ; }
Update stream recording in live stream service
70
7
152,429
public void updateStreamPullUrl ( UpdateStreamPullUrlRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getDomain ( ) , "Domain should NOT be empty." ) ; checkStringNotEmpty ( request . getApp ( ) , "App should NOT be empty" ) ; checkStringNotEmpty ( request . getStream ( ) , "Stream should NOT be empty." ) ; checkStringNotEmpty ( request . getPullUrl ( ) , "PullUrl should NOT be empty." ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . PUT , request , LIVE_DOMAIN , request . getDomain ( ) , LIVE_APP , request . getApp ( ) , LIVE_STREAM , request . getStream ( ) ) ; internalRequest . addParameter ( "pullUrl" , request . getPullUrl ( ) ) ; invokeHttpClient ( internalRequest , AbstractBceResponse . class ) ; }
Update stream pullUrl in live stream service
208
8
152,430
public void updateStreamPullUrl ( String domain , String app , String stream , String pullUrl ) { UpdateStreamPullUrlRequest request = new UpdateStreamPullUrlRequest ( ) . withDomain ( domain ) . withApp ( app ) . withStream ( stream ) . withPullUrl ( pullUrl ) ; updateStreamPullUrl ( request ) ; }
Update stream s destination push url
72
6
152,431
public void updateStreamDestinationPushUrl ( UpdateStreamDestinationPushUrlRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getDomain ( ) , "Domain should NOT be empty." ) ; checkStringNotEmpty ( request . getApp ( ) , "App should NOT be empty" ) ; checkStringNotEmpty ( request . getStream ( ) , "Stream should NOT be empty." ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . PUT , request , LIVE_DOMAIN , request . getDomain ( ) , LIVE_APP , request . getApp ( ) , LIVE_STREAM , request . getStream ( ) ) ; internalRequest . addParameter ( "destinationPushUrl" , request . getDestinationPushUrl ( ) ) ; invokeHttpClient ( internalRequest , AbstractBceResponse . class ) ; }
Update stream destination push url in live stream service
193
9
152,432
public GetDomainStatisticsResponse getDomainStatistics ( GetDomainStatisticsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getDomain ( ) , "Domain should NOT be empty." ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , STATISTICS , LIVE_DOMAIN , request . getDomain ( ) ) ; if ( request . getStartDate ( ) != null ) { internalRequest . addParameter ( "startDate" , request . getStartDate ( ) ) ; } if ( request . getEndDate ( ) != null ) { internalRequest . addParameter ( "endDate" , request . getEndDate ( ) ) ; } if ( request . getAggregate ( ) != null ) { internalRequest . addParameter ( "aggregate" , request . getAggregate ( ) . toString ( ) ) ; } return invokeHttpClient ( internalRequest , GetDomainStatisticsResponse . class ) ; }
get domain s statistics in the live stream service .
212
10
152,433
public GetDomainStatisticsResponse getDomainStatistics ( String domain ) { GetDomainStatisticsRequest request = new GetDomainStatisticsRequest ( ) ; request . setDomain ( domain ) ; return getDomainStatistics ( request ) ; }
Get domain s statistics in the live stream service .
44
10
152,434
public GetAllDomainsPlayCountResponse getAllDomainsPlayCount ( GetAllDomainsStatisticsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getTimeInterval ( ) , "timeInterval should NOT be null" ) ; checkStringNotEmpty ( request . getStartTime ( ) , "startTime should NOT be null" ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , STATISTICS , LIVE_DOMAIN , "playcount" ) ; internalRequest . addParameter ( "timeInterval" , request . getTimeInterval ( ) ) ; internalRequest . addParameter ( "startTime" , request . getStartTime ( ) ) ; if ( request . getEndTime ( ) != null ) { internalRequest . addParameter ( "endTime" , request . getEndTime ( ) ) ; } return invokeHttpClient ( internalRequest , GetAllDomainsPlayCountResponse . class ) ; }
get all domains total play count statistics in the live stream service .
217
13
152,435
public GetOneDomainPlayCountResponse getOneDomainPlayCount ( GetOneDomainStatisticsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkNotNull ( request . getDomain ( ) , "The domain parameter can not be null" ) ; checkStringNotEmpty ( request . getTimeInterval ( ) , "timeInterval should NOT be null" ) ; checkStringNotEmpty ( request . getStartTime ( ) , "startTime should NOT be null" ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , STATISTICS , LIVE_DOMAIN , request . getDomain ( ) , "playcount" ) ; internalRequest . addParameter ( "timeInterval" , request . getTimeInterval ( ) ) ; internalRequest . addParameter ( "startTime" , request . getStartTime ( ) ) ; if ( request . getEndTime ( ) != null ) { internalRequest . addParameter ( "endTime" , request . getEndTime ( ) ) ; } return invokeHttpClient ( internalRequest , GetOneDomainPlayCountResponse . class ) ; }
get one domain s play count statistics in the live stream service .
242
13
152,436
public ListDomainStatisticsResponse listDomainStatistics ( ListDomainStatisticsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getStartTime ( ) , "startTime should NOT be empty" ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , STATISTICS , LIVE_DOMAIN , "list" ) ; internalRequest . addParameter ( "startTime" , request . getStartTime ( ) ) ; if ( request . getEndTime ( ) != null ) { internalRequest . addParameter ( "endTime" , request . getEndTime ( ) ) ; } if ( request . getKeyword ( ) != null ) { internalRequest . addParameter ( "keyword" , request . getKeyword ( ) ) ; } if ( request . getKeywordType ( ) != null ) { internalRequest . addParameter ( "keywordType" , request . getKeywordType ( ) ) ; } if ( request . getOrderBy ( ) != null ) { internalRequest . addParameter ( "orderBy" , request . getOrderBy ( ) ) ; } return invokeHttpClient ( internalRequest , ListDomainStatisticsResponse . class ) ; }
list domain s statistics in the live stream service .
263
10
152,437
public ListStreamStatisticsResponse listStreamStatistics ( ListStreamStatisticsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getDomain ( ) , "Domain should NOT be null" ) ; checkStringNotEmpty ( request . getApp ( ) , "App should NOT be null" ) ; checkStringNotEmpty ( request . getStartTime ( ) , "StartTime should NOT be null" ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , STATISTICS , LIVE_DOMAIN , request . getDomain ( ) , LIVE_STREAM ) ; internalRequest . addParameter ( "app" , request . getApp ( ) ) ; internalRequest . addParameter ( "startTime" , request . getStartTime ( ) ) ; if ( request . getEndTime ( ) != null ) { internalRequest . addParameter ( "endTime" , request . getEndTime ( ) ) ; } if ( request . getKeyword ( ) != null ) { internalRequest . addParameter ( "keyword" , request . getKeyword ( ) ) ; } if ( request . getKeywordType ( ) != null ) { internalRequest . addParameter ( "keywordType" , request . getKeywordType ( ) ) ; } if ( request . getOrderBy ( ) != null ) { internalRequest . addParameter ( "orderBy" , request . getOrderBy ( ) ) ; } if ( request . getPageNo ( ) != null ) { internalRequest . addParameter ( "pageNo" , request . getPageNo ( ) . toString ( ) ) ; } if ( request . getPageSize ( ) != null ) { internalRequest . addParameter ( "pageSize" , request . getPageSize ( ) . toString ( ) ) ; } return invokeHttpClient ( internalRequest , ListStreamStatisticsResponse . class ) ; }
list domain s all streams statistics in the live stream service .
409
12
152,438
public GetStreamStatisticsResponse getStreamStatistics ( GetStreamStatisticsRequest request ) { checkNotNull ( request , "The parameter request should NOT be null." ) ; checkStringNotEmpty ( request . getDomain ( ) , "Domain should NOT be null" ) ; checkStringNotEmpty ( request . getApp ( ) , "App should NOT be null" ) ; checkStringNotEmpty ( request . getStream ( ) , "Stream should NOT be null" ) ; InternalRequest internalRequest = createRequest ( HttpMethodName . GET , request , STATISTICS , LIVE_DOMAIN , request . getDomain ( ) , LIVE_APP , request . getApp ( ) , LIVE_STREAM , request . getStream ( ) ) ; if ( request . getStartDate ( ) != null ) { internalRequest . addParameter ( "startDate" , request . getStartDate ( ) ) ; } if ( request . getEndDate ( ) != null ) { internalRequest . addParameter ( "endDate" , request . getEndDate ( ) ) ; } if ( request . getAggregate ( ) != null ) { internalRequest . addParameter ( "aggregate" , request . getAggregate ( ) . toString ( ) ) ; } return invokeHttpClient ( internalRequest , GetStreamStatisticsResponse . class ) ; }
get a domain s all streams statistics in the live stream service .
277
13
152,439
public CreateVpcResponse createVpc ( String name , String cidr ) { CreateVpcRequest request = new CreateVpcRequest ( ) ; request . withName ( name ) . withCidr ( cidr ) ; return createVpc ( request ) ; }
Create a vpc with the specified options .
59
9
152,440
public ListVpcsResponse listVpcs ( ListVpcsRequest request ) { checkNotNull ( request , "request should not be null." ) ; InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . GET , VPC_PREFIX ) ; if ( request . getMarker ( ) != null ) { internalRequest . addParameter ( "marker" , request . getMarker ( ) ) ; } if ( request . getMaxKeys ( ) > 0 ) { internalRequest . addParameter ( "maxKeys" , String . valueOf ( request . getMaxKeys ( ) ) ) ; } if ( request . getIsDefault ( ) != null ) { internalRequest . addParameter ( "isDefault" , request . getIsDefault ( ) . toString ( ) ) ; } return invokeHttpClient ( internalRequest , ListVpcsResponse . class ) ; }
Return a list of vpcs owned by the authenticated user .
192
13
152,441
public GetVpcResponse getVpc ( GetVpcRequest getVpcRequest ) { checkNotNull ( getVpcRequest , "request should not be null." ) ; checkNotNull ( getVpcRequest . getVpcId ( ) , "request vpcId should not be null." ) ; InternalRequest internalRequest = this . createRequest ( getVpcRequest , HttpMethodName . GET , VPC_PREFIX , getVpcRequest . getVpcId ( ) ) ; return this . invokeHttpClient ( internalRequest , GetVpcResponse . class ) ; }
Get the detail information of specified vpc .
126
9
152,442
public void modifyInstanceAttributes ( String name , String vpcId ) { ModifyVpcAttributesRequest request = new ModifyVpcAttributesRequest ( ) ; modifyInstanceAttributes ( request . withName ( name ) . withVpcId ( vpcId ) ) ; }
Modifying the special attribute to new value of the vpc owned by the user .
57
17
152,443
public GetClusterResponse getCluster ( GetClusterRequest request ) { checkNotNull ( request , "request should not be null." ) ; checkStringNotEmpty ( request . getClusterId ( ) , "The parameter clusterId should not be null or empty string." ) ; InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . GET , CLUSTER , request . getClusterId ( ) ) ; return this . invokeHttpClient ( internalRequest , GetClusterResponse . class ) ; }
Describe the detail information of the target cluster .
112
10
152,444
public void modifyInstanceGroups ( ModifyInstanceGroupsRequest request ) { checkNotNull ( request , "request should not be null." ) ; checkStringNotEmpty ( request . getClusterId ( ) , "The clusterId should not be null or empty string." ) ; checkNotNull ( request . getInstanceGroups ( ) , "The instanceGroups should not be null." ) ; StringWriter writer = new StringWriter ( ) ; try { JsonGenerator jsonGenerator = JsonUtils . jsonGeneratorOf ( writer ) ; jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeArrayFieldStart ( "instanceGroups" ) ; for ( ModifyInstanceGroupConfig instanceGroup : request . getInstanceGroups ( ) ) { checkStringNotEmpty ( instanceGroup . getId ( ) , "The instanceGroupId should not be null or empty string." ) ; jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeStringField ( "id" , instanceGroup . getId ( ) ) ; jsonGenerator . writeNumberField ( "instanceCount" , instanceGroup . getInstanceCount ( ) ) ; jsonGenerator . writeEndObject ( ) ; } jsonGenerator . writeEndArray ( ) ; jsonGenerator . writeEndObject ( ) ; jsonGenerator . close ( ) ; } catch ( IOException e ) { throw new BceClientException ( "Fail to generate json" , e ) ; } byte [ ] json = null ; try { json = writer . toString ( ) . getBytes ( DEFAULT_ENCODING ) ; } catch ( UnsupportedEncodingException e ) { throw new BceClientException ( "Fail to get UTF-8 bytes" , e ) ; } InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . PUT , CLUSTER , request . getClusterId ( ) , INSTANCE_GROUP ) ; internalRequest . addHeader ( Headers . CONTENT_LENGTH , String . valueOf ( json . length ) ) ; internalRequest . addHeader ( Headers . CONTENT_TYPE , "application/json" ) ; internalRequest . setContent ( RestartableInputStream . wrap ( json ) ) ; if ( request . getClientToken ( ) != null ) { internalRequest . addParameter ( "clientToken" , request . getClientToken ( ) ) ; } this . invokeHttpClient ( internalRequest , AbstractBceResponse . class ) ; }
Modify the instance groups of the target cluster .
527
10
152,445
public void terminateCluster ( TerminateClusterRequest request ) { checkNotNull ( request , "request should not be null." ) ; checkStringNotEmpty ( request . getClusterId ( ) , "The parameter clusterId should not be null or empty string." ) ; InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . DELETE , CLUSTER , request . getClusterId ( ) ) ; this . invokeHttpClient ( internalRequest , AbstractBceResponse . class ) ; }
Terminate a BMR cluster and release all the virtual machine instances .
111
14
152,446
public ListInstanceGroupsResponse listInstanceGroups ( ListInstanceGroupsRequest request ) { checkNotNull ( request , "request should not be null." ) ; checkStringNotEmpty ( request . getClusterId ( ) , "The parameter clusterId should not be null or empty string." ) ; InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . GET , CLUSTER , request . getClusterId ( ) , INSTANCE_GROUP ) ; return this . invokeHttpClient ( internalRequest , ListInstanceGroupsResponse . class ) ; }
List the instance groups of the target BMR cluster .
121
11
152,447
public ListInstancesResponse listInstances ( ListInstancesRequest request ) { checkNotNull ( request , "request should not be null." ) ; checkStringNotEmpty ( request . getClusterId ( ) , "The parameter clusterId should not be null or empty string." ) ; checkStringNotEmpty ( request . getInstanceGroupId ( ) , "The parameter instanceGroupId should not be null or empty string." ) ; InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . GET , CLUSTER , request . getClusterId ( ) , INSTANCE_GROUP , request . getInstanceGroupId ( ) , INSTANCE ) ; return this . invokeHttpClient ( internalRequest , ListInstancesResponse . class ) ; }
List the instances belonging to the target instance group in the BMR cluster .
159
15
152,448
public ListInstancesResponse listInstances ( String clusterId , String instanceGroupId ) { return listInstances ( new ListInstancesRequest ( ) . withClusterId ( clusterId ) . withInstanceGroupId ( instanceGroupId ) ) ; }
List the instances belonging to the target instance in the BMR cluster .
53
14
152,449
public AddStepsResponse addSteps ( AddStepsRequest request ) { checkNotNull ( request , "request should not be null." ) ; checkNotNull ( request . getSteps ( ) , "The parameter steps should not be null." ) ; checkStringNotEmpty ( request . getClusterId ( ) , "The parameter clusterId should not be null or empty string." ) ; StringWriter writer = new StringWriter ( ) ; List < StepConfig > steps = request . getSteps ( ) ; try { JsonGenerator jsonGenerator = JsonUtils . jsonGeneratorOf ( writer ) ; jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeArrayFieldStart ( "steps" ) ; for ( StepConfig step : steps ) { jsonGenerator . writeStartObject ( ) ; if ( step . getName ( ) != null ) { jsonGenerator . writeStringField ( "name" , step . getName ( ) ) ; } jsonGenerator . writeStringField ( "type" , step . getType ( ) ) ; jsonGenerator . writeStringField ( "actionOnFailure" , step . getActionOnFailure ( ) ) ; jsonGenerator . writeObjectFieldStart ( "properties" ) ; for ( String propertyKey : step . getProperties ( ) . keySet ( ) ) { jsonGenerator . writeObjectField ( propertyKey , step . getProperties ( ) . get ( propertyKey ) ) ; } jsonGenerator . writeEndObject ( ) ; jsonGenerator . writeArrayFieldStart ( "additionalFiles" ) ; for ( AdditionalFile additionalFile : step . getAdditionalFiles ( ) ) { jsonGenerator . writeStartObject ( ) ; jsonGenerator . writeStringField ( "remote" , additionalFile . getRemote ( ) ) ; jsonGenerator . writeStringField ( "local" , additionalFile . getLocal ( ) ) ; jsonGenerator . writeEndObject ( ) ; } jsonGenerator . writeEndArray ( ) ; jsonGenerator . writeEndObject ( ) ; } jsonGenerator . writeEndArray ( ) ; jsonGenerator . writeEndObject ( ) ; jsonGenerator . close ( ) ; } catch ( IOException e ) { throw new BceClientException ( "Fail to generate json" , e ) ; } byte [ ] json = null ; try { json = writer . toString ( ) . getBytes ( DEFAULT_ENCODING ) ; } catch ( UnsupportedEncodingException e ) { throw new BceClientException ( "Fail to get UTF-8 bytes" , e ) ; } InternalRequest internalRequest = this . createRequest ( request , HttpMethodName . POST , CLUSTER , request . getClusterId ( ) , STEP ) ; internalRequest . addHeader ( Headers . CONTENT_LENGTH , String . valueOf ( json . length ) ) ; internalRequest . addHeader ( Headers . CONTENT_TYPE , "application/json" ) ; internalRequest . setContent ( RestartableInputStream . wrap ( json ) ) ; if ( request . getClientToken ( ) != null ) { internalRequest . addParameter ( "clientToken" , request . getClientToken ( ) ) ; } return this . invokeHttpClient ( internalRequest , AddStepsResponse . class ) ; }
Add steps to a BMR cluster .
706
8
152,450
public GetDocumentImagesResponse getDocumentImages ( String documentId ) { checkNotNull ( documentId , "documentId should not be null." ) ; GetDocumentImagesRequest request = new GetDocumentImagesRequest ( ) ; request . setDocumentId ( documentId ) ; InternalRequest internalRequest = this . createRequest ( HttpMethodName . GET , request , DOC , request . getDocumentId ( ) ) ; internalRequest . addParameter ( "getImages" , null ) ; GetDocumentImagesResponse response ; try { response = this . invokeHttpClient ( internalRequest , GetDocumentImagesResponse . class ) ; } finally { try { internalRequest . getContent ( ) . close ( ) ; } catch ( Exception e ) { // ignore exception } } return response ; }
get a Document Image list if Converted to image . Make Sure the Document convert type is image otherwise will throw BceServiceException
159
25
152,451
public ListDocumentsResponse listDocuments ( ) { ListDocumentsRequest request = new ListDocumentsRequest ( ) ; InternalRequest internalRequest = this . createRequest ( HttpMethodName . GET , request , DOC ) ; ListDocumentsResponse response ; try { response = this . invokeHttpClient ( internalRequest , ListDocumentsResponse . class ) ; } finally { try { internalRequest . getContent ( ) . close ( ) ; } catch ( Exception e ) { // ignore exception } } return response ; }
list all Document .
101
4
152,452
public GetDocumentDownloadResponse getDocumentDownload ( String documentId ) { checkNotNull ( documentId , "documentId should not be null." ) ; GetDocumentDownloadRequest request = new GetDocumentDownloadRequest ( ) ; request . setDocumentId ( documentId ) ; InternalRequest internalRequest = this . createRequest ( HttpMethodName . GET , request , DOC , request . getDocumentId ( ) ) ; internalRequest . addParameter ( "download" , null ) ; GetDocumentDownloadResponse response ; try { response = this . invokeHttpClient ( internalRequest , GetDocumentDownloadResponse . class ) ; } finally { try { internalRequest . getContent ( ) . close ( ) ; } catch ( Exception e ) { // ignore exception } } return response ; }
get a Document Download link .
158
6
152,453
public void setMode ( String mode ) { checkNotNull ( mode , "mode should not be null" ) ; if ( MODE_ASYNC . equals ( mode ) || MODE_SYNC . equals ( mode ) ) { this . mode = mode ; } else { throw new IllegalArgumentException ( "illegal mode: " + mode ) ; } }
Sets the mode of this fetching job .
76
10
152,454
public AddStepsRequest withStep ( StepConfig step ) { if ( this . steps == null ) { this . steps = new ArrayList < StepConfig > ( ) ; } this . steps . add ( step ) ; return this ; }
Configure the step to be added .
50
8
152,455
public static String generateHostHeader ( URI uri ) { String host = uri . getHost ( ) ; if ( isUsingNonDefaultPort ( uri ) ) { host += ":" + uri . getPort ( ) ; } return host ; }
Returns a host header according to the specified URI . The host header is generated with the same logic used by apache http client that is append the port to hostname only if it is not the default port .
54
42
152,456
public Key withAttribute ( String attributeName , AttributeValue value ) { if ( this . attributes == null ) { this . attributes = new HashMap < String , AttributeValue > ( ) ; } attributes . put ( attributeName , value ) ; return this ; }
The method set attribute name and attribute value with input parameters for a key . Returns a reference to this object so that method calls can be chained together .
56
30
152,457
private void initEngine ( ) { engine = ( NashornScriptEngine ) new ScriptEngineManager ( ) . getEngineByName ( "nashorn" ) ; try { engine . eval ( "(function(global){global.global = global})(this);" ) ; engine . eval ( NashornVueTemplateCompiler . NASHORN_VUE_TEMPLATE_COMPILER ) ; } catch ( ScriptException e ) { e . printStackTrace ( ) ; } }
Init the Nashorn engine and load the Vue compiler in it .
106
14
152,458
public VueTemplateCompilerResult compile ( String htmlTemplate ) throws VueTemplateCompilerException { ScriptObjectMirror templateCompilerResult ; try { templateCompilerResult = ( ScriptObjectMirror ) engine . invokeFunction ( "compile" , htmlTemplate ) ; } catch ( ScriptException | NoSuchMethodException e ) { e . printStackTrace ( ) ; throw new VueTemplateCompilerException ( "An error occurred while compiling the template: " + htmlTemplate + " -> " + e . getMessage ( ) ) ; } String renderFunction = ( String ) templateCompilerResult . get ( "render" ) ; String [ ] staticRenderFunctions = ( ( ScriptObjectMirror ) templateCompilerResult . get ( "staticRenderFns" ) ) . to ( String [ ] . class ) ; return new VueTemplateCompilerResult ( renderFunction , staticRenderFunctions ) ; }
Compile the given HTML template to JS functions using vue - template - compiler .
193
17
152,459
public static boolean isMethodVisibleInTemplate ( ExecutableElement method ) { return isMethodVisibleInJS ( method ) && ! hasAnnotation ( method , Computed . class ) && ! hasAnnotation ( method , Watch . class ) && ! hasAnnotation ( method , PropValidator . class ) && ! hasAnnotation ( method , PropDefault . class ) && ! method . getModifiers ( ) . contains ( Modifier . STATIC ) && ! method . getModifiers ( ) . contains ( Modifier . PRIVATE ) ; }
Check if a given method is usable in the template
117
10
152,460
public static int getSuperComponentCount ( TypeElement component ) { return getSuperComponentType ( component ) . map ( superComponent -> getSuperComponentCount ( superComponent ) + 1 ) . orElse ( 0 ) ; }
Return the number of super component in the chain of parents
46
11
152,461
public static boolean hasTemplate ( ProcessingEnvironment processingEnvironment , TypeElement component ) { Component annotation = component . getAnnotation ( Component . class ) ; if ( annotation == null || ! annotation . hasTemplate ( ) ) { return false ; } if ( component . getModifiers ( ) . contains ( Modifier . ABSTRACT ) ) { return false ; } return ! hasInterface ( processingEnvironment , component . asType ( ) , HasRender . class ) ; }
Check if the given Component has a Template . It doesn t have a template if the class is abstract if it implements render function or if it has the flag hasTemplate to false on the component annotation .
96
40
152,462
private void compileTemplateString ( ComponentExposedTypeGenerator exposedTypeGenerator , TemplateParserResult templateParserResult ) { VueTemplateCompilerResult compilerResult ; try { VueTemplateCompiler vueTemplateCompiler = new VueTemplateCompiler ( ) ; compilerResult = vueTemplateCompiler . compile ( templateParserResult . getProcessedTemplate ( ) ) ; } catch ( VueTemplateCompilerException e ) { e . printStackTrace ( ) ; throw new RuntimeException ( ) ; } generateGetRenderFunction ( exposedTypeGenerator , compilerResult , templateParserResult ) ; generateGetStaticRenderFunctions ( exposedTypeGenerator , compilerResult ) ; }
Compile the HTML template and transform it to a JS render function .
143
14
152,463
private void generateGetRenderFunction ( ComponentExposedTypeGenerator exposedTypeGenerator , VueTemplateCompilerResult result , TemplateParserResult templateParserResult ) { MethodSpec . Builder getRenderFunctionBuilder = MethodSpec . methodBuilder ( "getRenderFunction" ) . addModifiers ( Modifier . PRIVATE ) . returns ( Function . class ) . addStatement ( "String renderFunctionString = $S" , result . getRenderFunction ( ) ) ; for ( VariableInfo vModelField : templateParserResult . getvModelDataFields ( ) ) { String placeHolderVModelValue = vModelFieldToPlaceHolderField ( vModelField . getName ( ) ) ; String fieldName = vModelField . getName ( ) ; if ( vModelField instanceof ComputedVariableInfo ) fieldName = ( ( ComputedVariableInfo ) vModelField ) . getFieldName ( ) ; getRenderFunctionBuilder . addStatement ( "renderFunctionString = $T.replaceVariableInRenderFunction(renderFunctionString, $S, this, () -> this.$L = $L)" , VueGWTTools . class , placeHolderVModelValue , fieldName , getFieldMarkingValueForType ( vModelField . getType ( ) ) ) ; } getRenderFunctionBuilder . addStatement ( "return new $T(renderFunctionString)" , Function . class ) ; exposedTypeGenerator . getClassBuilder ( ) . addMethod ( getRenderFunctionBuilder . build ( ) ) ; }
Generate the method that returns the body of the render function .
320
13
152,464
private void generateGetStaticRenderFunctions ( ComponentExposedTypeGenerator exposedTypeGenerator , VueTemplateCompilerResult result ) { CodeBlock . Builder staticFunctions = CodeBlock . builder ( ) ; boolean isFirst = true ; for ( String staticRenderFunction : result . getStaticRenderFunctions ( ) ) { if ( ! isFirst ) { staticFunctions . add ( ", " ) ; } else { isFirst = false ; } staticFunctions . add ( "new $T($S)" , Function . class , staticRenderFunction ) ; } MethodSpec . Builder getStaticRenderFunctionsBuilder = MethodSpec . methodBuilder ( "getStaticRenderFunctions" ) . addModifiers ( Modifier . PRIVATE ) . returns ( Function [ ] . class ) . addStatement ( "return new $T[] { $L }" , Function . class , staticFunctions . build ( ) ) ; exposedTypeGenerator . getClassBuilder ( ) . addMethod ( getStaticRenderFunctionsBuilder . build ( ) ) ; }
Generate the method that returns the body of the static render functions .
220
14
152,465
private void processTemplateExpressions ( ComponentExposedTypeGenerator exposedTypeGenerator , TemplateParserResult templateParserResult ) { for ( TemplateExpression expression : templateParserResult . getExpressions ( ) ) { generateTemplateExpressionMethod ( exposedTypeGenerator , expression , templateParserResult . getTemplateName ( ) ) ; } // Declare methods in the component String templateMethods = templateParserResult . getExpressions ( ) . stream ( ) . map ( expression -> "p." + expression . getId ( ) ) . collect ( Collectors . joining ( ", " ) ) ; exposedTypeGenerator . getOptionsBuilder ( ) . addStatement ( "options.registerTemplateMethods($L)" , templateMethods ) ; }
Process the expressions found in the HTML template
151
8
152,466
private void generateTemplateExpressionMethod ( ComponentExposedTypeGenerator exposedTypeGenerator , TemplateExpression expression , String templateName ) { MethodSpec . Builder templateExpressionMethodBuilder = MethodSpec . methodBuilder ( expression . getId ( ) ) . addModifiers ( Modifier . PUBLIC ) . addAnnotation ( JsMethod . class ) . addAnnotation ( getUnusableByJSAnnotation ( ) ) . returns ( expression . getType ( ) ) ; String expressionPosition = templateName ; if ( expression . getLineInHtml ( ) != null ) { expressionPosition += ", line " + expression . getLineInHtml ( ) ; } templateExpressionMethodBuilder . addComment ( expressionPosition ) ; expression . getParameters ( ) . forEach ( parameter -> templateExpressionMethodBuilder . addParameter ( parameter . getType ( ) , parameter . getName ( ) ) ) ; if ( expression . isReturnString ( ) ) { templateExpressionMethodBuilder . addStatement ( "return $T.templateExpressionToString($L)" , VueGWTTools . class , expression . getBody ( ) ) ; } else if ( expression . isReturnVoid ( ) ) { templateExpressionMethodBuilder . addStatement ( "$L" , expression . getBody ( ) ) ; } else if ( expression . isReturnAny ( ) ) { templateExpressionMethodBuilder . addStatement ( "return $T.asAny($L)" , Js . class , expression . getBody ( ) ) ; } else if ( expression . isShouldCast ( ) ) { templateExpressionMethodBuilder . addStatement ( "return ($T) ($L)" , expression . getType ( ) , expression . getBody ( ) ) ; } else { templateExpressionMethodBuilder . addStatement ( "return $L" , expression . getBody ( ) ) ; } exposedTypeGenerator . getClassBuilder ( ) . addMethod ( templateExpressionMethodBuilder . build ( ) ) ; exposedTypeGenerator . addMethodToProto ( expression . getId ( ) ) ; }
Generate the Java method for an expression in the Template
438
11
152,467
public static String componentToTagName ( Element componentElement ) throws MissingComponentAnnotationException { Component componentAnnotation = componentElement . getAnnotation ( Component . class ) ; JsComponent jsComponentAnnotation = componentElement . getAnnotation ( JsComponent . class ) ; String annotationNameValue ; if ( componentAnnotation != null ) { annotationNameValue = componentAnnotation . name ( ) ; } else if ( jsComponentAnnotation != null ) { annotationNameValue = jsComponentAnnotation . value ( ) ; } else { throw new MissingComponentAnnotationException ( ) ; } if ( ! "" . equals ( annotationNameValue ) ) { return annotationNameValue ; } // Drop "Component" at the end of the class name String componentClassName = componentElement . getSimpleName ( ) . toString ( ) . replaceAll ( "Component$" , "" ) ; // Convert from CamelCase to kebab-case return CaseFormat . UPPER_CAMEL . to ( CaseFormat . LOWER_HYPHEN , componentClassName ) . toLowerCase ( ) ; }
Return the default name to register a component based on it s class name . The name of the tag is the name of the component converted to kebab - case . If the component class ends with Component this part is ignored .
231
46
152,468
public static String directiveToTagName ( String directiveClassName ) { // Drop "Component" at the end of the class name directiveClassName = directiveClassName . replaceAll ( "Directive$" , "" ) ; // Convert from CamelCase to kebab-case return CaseFormat . UPPER_CAMEL . to ( CaseFormat . LOWER_HYPHEN , directiveClassName ) . toLowerCase ( ) ; }
Return the default name to register a directive based on it s class name The name of the tag is the name of the component converted to kebab - case If the component class ends with Directive this part is ignored
93
43
152,469
private void initLoopVariable ( String type , String name , TemplateParserContext context ) { this . loopVariableInfo = context . addLocalVariable ( context . getFullyQualifiedNameForClassName ( type . trim ( ) ) , name . trim ( ) ) ; }
Init the loop variable and add it to the parser context
57
11
152,470
private void initIndexVariable ( String name , TemplateParserContext context ) { this . indexVariableInfo = context . addLocalVariable ( "int" , name . trim ( ) ) ; }
Init the index variable and add it to the parser context
39
11
152,471
private void initKeyVariable ( String name , TemplateParserContext context ) { this . keyVariableInfo = context . addLocalVariable ( "String" , name . trim ( ) ) ; }
Init the key variable and add it to the parser context
39
11
152,472
public String toTemplateString ( ) { String [ ] parametersName = this . parameters . stream ( ) . map ( VariableInfo :: getName ) . toArray ( String [ ] :: new ) ; return this . getId ( ) + "(" + String . join ( ", " , parametersName ) + ")" ; }
Return this expression as a string that can be placed in the template as a replacement of the Java expression .
67
21
152,473
public TemplateParserResult parseHtmlTemplate ( String htmlTemplate , TemplateParserContext context , Elements elements , Messager messager , URI htmlTemplateUri ) { this . context = context ; this . elements = elements ; this . messager = messager ; this . logger = new TemplateParserLogger ( context , messager ) ; this . htmlTemplateUri = htmlTemplateUri ; initJerichoConfig ( this . logger ) ; Source source = new Source ( htmlTemplate ) ; outputDocument = new OutputDocument ( source ) ; result = new TemplateParserResult ( context ) ; processImports ( source ) ; result . setScopedCss ( processScopedCss ( source ) ) ; source . getChildElements ( ) . forEach ( this :: processElement ) ; result . setProcessedTemplate ( outputDocument . toString ( ) ) ; return result ; }
Parse a given HTML template and return the a result object containing the expressions and a transformed HTML .
184
20
152,474
private void processImports ( Source doc ) { doc . getAllElements ( ) . stream ( ) . filter ( element -> "vue-gwt:import" . equalsIgnoreCase ( element . getName ( ) ) ) . peek ( importElement -> { String classAttributeValue = importElement . getAttributeValue ( "class" ) ; if ( classAttributeValue != null ) { context . addImport ( classAttributeValue ) ; } String staticAttributeValue = importElement . getAttributeValue ( "static" ) ; if ( staticAttributeValue != null ) { context . addStaticImport ( staticAttributeValue ) ; } } ) . forEach ( outputDocument :: remove ) ; }
Add java imports in the template to the context .
145
10
152,475
private void processElement ( Element element ) { context . setCurrentSegment ( element ) ; currentProp = null ; currentAttribute = null ; // Process attributes boolean shouldPopContext = processElementAttributes ( element ) ; // Process text segments StreamSupport . stream ( ( ( Iterable < Segment > ) element :: getNodeIterator ) . spliterator ( ) , false ) . filter ( segment -> ! ( segment instanceof Tag ) && ! ( segment instanceof CharacterReference ) ) . filter ( segment -> { for ( Element child : element . getChildElements ( ) ) { if ( child . encloses ( segment ) ) { return false ; } } return true ; } ) . forEach ( this :: processTextNode ) ; // Recurse downwards element . getChildElements ( ) . forEach ( this :: processElement ) ; // After downward recursion, pop the context layer if necessary if ( shouldPopContext ) { context . popContextLayer ( ) ; } }
Recursive method that will process the whole template DOM tree .
202
12
152,476
private TypeMirror getTypeFromDOMElement ( Element element ) { return DOMElementsUtil . getTypeForElementTag ( element . getStartTag ( ) . getName ( ) ) . map ( Class :: getCanonicalName ) . map ( elements :: getTypeElement ) . map ( TypeElement :: asType ) . orElse ( null ) ; }
Find the corresponding TypeMirror from Elemental2 for a given DOM Element
78
14
152,477
private void registerMandatoryAttributes ( Attributes attributes ) { // see https://sourceforge.net/p/jerichohtml/discussion/350024/thread/501a7d05/ Map < String , String > attrs = context . getMandatoryAttributes ( ) ; if ( ! attrs . isEmpty ( ) ) { for ( Entry < String , String > i : attrs . entrySet ( ) ) { String v = i . getValue ( ) ; if ( v == null ) { outputDocument . insert ( attributes . getBegin ( ) , " " + i . getKey ( ) + " " ) ; } else { outputDocument . insert ( attributes . getBegin ( ) , " " + i . getKey ( ) + "\"" + v + "\" " ) ; } } } }
Register mandatory attributes for Scoped CSS
174
7
152,478
private TypeName getExpressionReturnTypeForAttribute ( Attribute attribute , Map < String , Class < ? > > propertiesTypes ) { String attributeName = attribute . getKey ( ) . toLowerCase ( ) ; if ( attributeName . indexOf ( "@" ) == 0 || attributeName . indexOf ( "v-on:" ) == 0 ) { return TypeName . VOID ; } if ( "v-if" . equals ( attributeName ) || "v-show" . equals ( attributeName ) ) { return TypeName . BOOLEAN ; } if ( isBoundedAttribute ( attributeName ) ) { String unboundedAttributeName = boundedAttributeToAttributeName ( attributeName ) ; if ( unboundedAttributeName . equals ( "class" ) || unboundedAttributeName . equals ( "style" ) ) { return TypeName . get ( Any . class ) ; } if ( propertiesTypes . containsKey ( unboundedAttributeName ) ) { return TypeName . get ( propertiesTypes . get ( unboundedAttributeName ) ) ; } } if ( currentProp != null ) { return currentProp . getType ( ) ; } return TypeName . get ( Any . class ) ; }
Guess the type of the expression based on where it is used . The guessed type can be overridden by adding a Cast to the desired type at the beginning of the expression .
252
36
152,479
private String processVForValue ( String vForValue ) { VForDefinition vForDef = new VForDefinition ( vForValue , context , logger ) ; // Set return of the "in" expression currentExpressionReturnType = vForDef . getInExpressionType ( ) ; String inExpression = this . processExpression ( vForDef . getInExpression ( ) ) ; // And return the newly built definition return vForDef . getVariableDefinition ( ) + " in " + inExpression ; }
Process a v - for value . It will register the loop variables as a local variable in the context stack .
111
22
152,480
private String processSlotScopeValue ( String value ) { SlotScopeDefinition slotScopeDefinition = new SlotScopeDefinition ( value , context , logger ) ; return slotScopeDefinition . getSlotScopeVariableName ( ) ; }
Process a scoped - slot value .
44
8
152,481
private String processExpression ( String expressionString ) { expressionString = expressionString == null ? "" : expressionString . trim ( ) ; if ( expressionString . isEmpty ( ) ) { if ( isAttributeBinding ( currentAttribute ) ) { logger . error ( "Empty expression in template property binding. If you want to pass an empty string then simply don't use binding: my-attribute=\"\"" , currentAttribute . toString ( ) ) ; } else if ( isEventBinding ( currentAttribute ) ) { logger . error ( "Empty expression in template event binding." , currentAttribute . toString ( ) ) ; } else { return "" ; } } if ( expressionString . startsWith ( "{" ) ) { logger . error ( "Object literal syntax are not supported yet in Vue GWT, please use map(e(\"key1\", myValue), e(\"key2\", myValue2 > 5)...) instead. The object returned by map() is a regular Javascript Object (JsObject) with the given key/values." , expressionString ) ; } if ( expressionString . startsWith ( "[" ) ) { logger . error ( "Array literal syntax are not supported yet in Vue GWT, please use array(myValue, myValue2 > 5...) instead. The object returned by array() is a regular Javascript Array (JsArray) with the given values." , expressionString ) ; } if ( shouldSkipExpressionProcessing ( expressionString ) ) { return expressionString ; } return processJavaExpression ( expressionString ) . toTemplateString ( ) ; }
Process a given template expression
333
5
152,482
private boolean shouldSkipExpressionProcessing ( String expressionString ) { // We don't skip if it's a component prop as we want Java validation // We don't optimize String expression, as we want GWT to convert Java values // to String for us (Enums, wrapped primitives...) return currentProp == null && ! String . class . getCanonicalName ( ) . equals ( currentExpressionReturnType . toString ( ) ) && isSimpleVueJsExpression ( expressionString ) ; }
In some cases we want to skip expression processing for optimization . This is when we are sure the expression is valid and there is no need to create a Java method for it .
106
35
152,483
private TemplateExpression processJavaExpression ( String expressionString ) { Expression expression ; try { expression = JavaParser . parseExpression ( expressionString ) ; } catch ( ParseProblemException parseException ) { logger . error ( "Couldn't parse Expression, make sure it is valid Java." , expressionString ) ; throw parseException ; } resolveTypesUsingImports ( expression ) ; resolveStaticMethodsUsingImports ( expression ) ; checkMethodNames ( expression ) ; // Find the parameters used by the expression List < VariableInfo > expressionParameters = new LinkedList <> ( ) ; findExpressionParameters ( expression , expressionParameters ) ; // If there is a cast first, we use this as the type of our expression if ( currentProp == null ) { expression = getTypeFromCast ( expression ) ; } // Update the expression as it might have been changed expressionString = expression . toString ( ) ; // Add the resulting expression to our result return result . addExpression ( expressionString , currentExpressionReturnType , currentProp == null , expressionParameters ) ; }
Process the given string as a Java expression .
223
9
152,484
private void resolveTypesUsingImports ( Expression expression ) { if ( expression instanceof NodeWithType ) { NodeWithType < ? , ? > nodeWithType = ( ( NodeWithType < ? , ? > ) expression ) ; nodeWithType . setType ( getQualifiedName ( nodeWithType . getType ( ) ) ) ; } // Recurse downward in the expression expression . getChildNodes ( ) . stream ( ) . filter ( Expression . class :: isInstance ) . map ( Expression . class :: cast ) . forEach ( this :: resolveTypesUsingImports ) ; }
Resolve all the types in the expression . This will replace the Class with the full qualified name using the template imports .
124
24
152,485
private void resolveStaticMethodsUsingImports ( Expression expression ) { if ( expression instanceof MethodCallExpr ) { MethodCallExpr methodCall = ( ( MethodCallExpr ) expression ) ; String methodName = methodCall . getName ( ) . getIdentifier ( ) ; if ( ! methodCall . getScope ( ) . isPresent ( ) && context . hasStaticMethod ( methodName ) ) { methodCall . setName ( context . getFullyQualifiedNameForMethodName ( methodName ) ) ; } } // Recurse downward in the expression expression . getChildNodes ( ) . stream ( ) . filter ( Expression . class :: isInstance ) . map ( Expression . class :: cast ) . forEach ( this :: resolveStaticMethodsUsingImports ) ; }
Resolve static method calls using static imports
164
8
152,486
private void checkMethodNames ( Expression expression ) { if ( expression instanceof MethodCallExpr ) { MethodCallExpr methodCall = ( ( MethodCallExpr ) expression ) ; if ( ! methodCall . getScope ( ) . isPresent ( ) ) { String methodName = methodCall . getName ( ) . getIdentifier ( ) ; if ( ! context . hasMethod ( methodName ) && ! context . hasStaticMethod ( methodName ) ) { logger . error ( "Couldn't find the method \"" + methodName + "\". " + "Make sure it is not private." ) ; } } } for ( com . github . javaparser . ast . Node node : expression . getChildNodes ( ) ) { if ( ! ( node instanceof Expression ) ) { continue ; } Expression childExpr = ( Expression ) node ; checkMethodNames ( childExpr ) ; } }
Check the expression for component method calls . This will check that the methods used in the template exist in the Component . It throws an exception if we use a method that is not declared in our Component . This will not check for the type or number of parameters we leave that to the Java Compiler .
192
60
152,487
private void createStaticGetMethod ( TypeElement component , ClassName vueFactoryClassName , Builder vueFactoryBuilder , List < CodeBlock > staticInitParameters ) { MethodSpec . Builder getBuilder = MethodSpec . methodBuilder ( "get" ) . addModifiers ( Modifier . STATIC , Modifier . PUBLIC ) . returns ( vueFactoryClassName ) ; getBuilder . beginControlFlow ( "if ($L == null)" , INSTANCE_PROP ) ; getBuilder . addStatement ( "$L = new $T()" , INSTANCE_PROP , vueFactoryClassName ) ; if ( hasTemplate ( processingEnv , component ) ) { getBuilder . addStatement ( "$L.injectComponentCss($T.getScopedCss())" , INSTANCE_PROP , componentExposedTypeName ( component ) ) ; } getBuilder . addCode ( "$L.init(" , INSTANCE_PROP ) ; boolean isFirst = true ; for ( CodeBlock staticInitParameter : staticInitParameters ) { if ( ! isFirst ) { getBuilder . addCode ( ", " ) ; } getBuilder . addCode ( staticInitParameter ) ; isFirst = false ; } getBuilder . addCode ( ");" ) ; getBuilder . endControlFlow ( ) ; getBuilder . addStatement ( "return $L" , INSTANCE_PROP ) ; vueFactoryBuilder . addMethod ( getBuilder . build ( ) ) ; }
Create a static get method that can be used to retrieve an instance of our Factory . Factory retrieved using this method do NOT support injection .
312
27
152,488
public TemplateExpression addExpression ( String expression , TypeName expressionType , boolean shouldCast , List < VariableInfo > parameters ) { String id = "exp$" + this . expressions . size ( ) ; TemplateExpression templateExpression = new TemplateExpression ( id , expression . trim ( ) , expressionType , shouldCast , parameters , context . getCurrentLine ( ) . orElse ( null ) ) ; this . expressions . add ( templateExpression ) ; return templateExpression ; }
Add an expression to the result . All the Java methods from the template will be added here so we can add them to our Vue . js component .
104
31
152,489
public void addRef ( String name , TypeMirror elementType , boolean isArray ) { refs . add ( new RefInfo ( name , elementType , isArray ) ) ; }
Register a ref found in the template
39
7
152,490
public static String escapeStringForJsRegexp ( String input ) { JsString string = uncheckedCast ( input ) ; return string . replace ( ESCAPE_JS_STRING_REGEXP , "\\$&" ) ; }
Escape a String to be used in a JsRegexp as a String literal
50
18
152,491
private void registerLocalDirectives ( Component annotation , MethodSpec . Builder initBuilder ) { try { Class < ? > [ ] componentsClass = annotation . directives ( ) ; if ( componentsClass . length > 0 ) { addGetDirectivesStatement ( initBuilder ) ; } Stream . of ( componentsClass ) . forEach ( clazz -> initBuilder . addStatement ( "directives.set($S, new $T())" , directiveToTagName ( clazz . getName ( ) ) , directiveOptionsName ( clazz ) ) ) ; } catch ( MirroredTypesException mte ) { List < DeclaredType > classTypeMirrors = ( List < DeclaredType > ) mte . getTypeMirrors ( ) ; if ( ! classTypeMirrors . isEmpty ( ) ) { addGetDirectivesStatement ( initBuilder ) ; } classTypeMirrors . forEach ( classTypeMirror -> { TypeElement classTypeElement = ( TypeElement ) classTypeMirror . asElement ( ) ; initBuilder . addStatement ( "directives.set($S, new $T())" , directiveToTagName ( classTypeElement . getSimpleName ( ) . toString ( ) ) , directiveOptionsName ( classTypeElement ) ) ; } ) ; } }
Register directives passed to the annotation .
269
7
152,492
@ JsOverlay public final void initRenderFunctions ( Function renderFunctionString , Function [ ] staticRenderFnsStrings ) { this . setRender ( renderFunctionString ) ; this . setStaticRenderFns ( cast ( staticRenderFnsStrings ) ) ; }
Initialise the render functions from our template .
59
9
152,493
@ JsOverlay public final void initData ( boolean useFactory , Set < String > fieldNames ) { JsPropertyMap < Object > dataFields = JsPropertyMap . of ( ) ; dataFieldsToProxy = new HashSet <> ( ) ; for ( String fieldName : fieldNames ) { dataFields . set ( fieldName , null ) ; // If field name starts with $ or _ Vue.js won't proxify it so we must do it if ( fieldName . startsWith ( "$" ) || fieldName . startsWith ( "_" ) ) { dataFieldsToProxy . add ( fieldName ) ; } } if ( useFactory ) { String dataFieldsJSON = JSON . stringify ( dataFields ) ; this . setData ( ( DataFactory ) ( ) -> JSON . parse ( dataFieldsJSON ) ) ; } else { this . setData ( ( DataFactory ) ( ) -> dataFields ) ; } }
Initialise the data structure then set it to either a Factory or directly on the Component .
206
18
152,494
@ JsOverlay public final void addJavaComputed ( Function javaMethod , String computedPropertyName , ComputedKind kind ) { ComputedOptions computedDefinition = getComputedOptions ( computedPropertyName ) ; if ( computedDefinition == null ) { computedDefinition = new ComputedOptions ( ) ; addComputedOptions ( computedPropertyName , computedDefinition ) ; } if ( kind == ComputedKind . GETTER ) { computedDefinition . get = javaMethod ; } else if ( kind == ComputedKind . SETTER ) { computedDefinition . set = javaMethod ; } }
Add a computed property to this ComponentOptions . If the computed has both a getter and a setter this will be called twice once for each .
120
30
152,495
@ JsOverlay public final void addJavaWatch ( Function javaMethod , String watchedPropertyName , boolean isDeep , boolean isImmediate ) { if ( ! isDeep && ! isImmediate ) { addWatch ( watchedPropertyName , javaMethod ) ; return ; } JsPropertyMap < Object > watchDefinition = JsPropertyMap . of ( ) ; watchDefinition . set ( "handler" , javaMethod ) ; watchDefinition . set ( "deep" , isDeep ) ; watchDefinition . set ( "immediate" , isImmediate ) ; addWatch ( watchedPropertyName , watchDefinition ) ; }
Add a watch property to this Component Definition
129
8
152,496
@ JsOverlay public final void addJavaProp ( String propName , String fieldName , boolean required , String exposedTypeName ) { if ( propsToProxy == null ) { propsToProxy = new HashSet <> ( ) ; } PropOptions propDefinition = new PropOptions ( ) ; propDefinition . required = required ; if ( exposedTypeName != null ) { propDefinition . type = ( ( JsPropertyMap < Object > ) DomGlobal . window ) . get ( exposedTypeName ) ; } propsToProxy . add ( new PropProxyDefinition ( propName , fieldName ) ) ; addProp ( propName , propDefinition ) ; }
Add a prop to our ComponentOptions . This will allow to receive data from the outside of our Component .
137
21
152,497
private void findLocalComponentsForComponent ( LocalComponents localComponents , TypeElement componentTypeElement ) { Component componentAnnotation = componentTypeElement . getAnnotation ( Component . class ) ; if ( componentAnnotation == null ) { return ; } processLocalComponentClass ( localComponents , componentTypeElement ) ; getComponentLocalComponents ( elements , componentTypeElement ) . stream ( ) . map ( DeclaredType . class :: cast ) . map ( DeclaredType :: asElement ) . map ( TypeElement . class :: cast ) . forEach ( childTypeElement -> processLocalComponentClass ( localComponents , childTypeElement ) ) ; getSuperComponentType ( componentTypeElement ) . ifPresent ( superComponentType -> findLocalComponentsForComponent ( localComponents , superComponentType ) ) ; }
Register all locally declared components .
172
6
152,498
public void customizeVueObserverPrototype ( VueObserver vueObserver ) { vueObserveArrayFunction = vueObserver . getObserveArray ( ) ; vueWalkFunction = vueObserver . getWalk ( ) ; vueObserver . setWalk ( toObserve -> { if ( observeJavaObject ( toObserve ) ) { return ; } vueWalkFunction . call ( this , toObserve ) ; } ) ; }
Customize the VueObserver instance . We get in between to be warned whenever an object is observed and observe it using our Java observers if necessary .
100
31
152,499
public static boolean hasInjectAnnotation ( Element element ) { for ( AnnotationMirror annotationMirror : element . getAnnotationMirrors ( ) ) { String annotationQualifiedName = annotationMirror . getAnnotationType ( ) . toString ( ) ; if ( annotationQualifiedName . equals ( Inject . class . getCanonicalName ( ) ) ) { return true ; } if ( annotationQualifiedName . equals ( "com.google.inject.Inject" ) ) { return true ; } } return false ; }
Check if the given element has an Inject annotation . Either the one from Google Gin or the javax one . We don t want to depend on Gin so we check the google one based on qualifiedName
116
42