idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
29,000
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 .
29,001
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 .
29,002
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 .
29,003
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
29,004
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 > ( ) { 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 .
29,005
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." ) ; } 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 .
29,006
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 .
29,007
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 .
29,008
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 .
29,009
public ListSessionsResponse listSessions ( String status ) { ListSessionsRequest request = new ListSessionsRequest ( ) . withStatus ( status ) ; return listSessions ( request ) ; }
List all your live sessions with given status .
29,010
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 .
29,011
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
29,012
public ListAppStreamsResponse listAppStreams ( String app ) { ListAppStreamsRequest request = new ListAppStreamsRequest ( ) ; request . setApp ( app ) ; return listAppStreams ( request ) ; }
list your streams by app name
29,013
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 .
29,014
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 .
29,015
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 .
29,016
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 .
29,017
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 .
29,018
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 .
29,019
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 .
29,020
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 .
29,021
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 .
29,022
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." ) ; 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
29,023
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
29,024
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." ) ; 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
29,025
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
29,026
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
29,027
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
29,028
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
29,029
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 .
29,030
public GetDomainStatisticsResponse getDomainStatistics ( String domain ) { GetDomainStatisticsRequest request = new GetDomainStatisticsRequest ( ) ; request . setDomain ( domain ) ; return getDomainStatistics ( request ) ; }
Get domain s statistics in the live stream service .
29,031
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 .
29,032
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 .
29,033
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 .
29,034
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 .
29,035
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 .
29,036
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 .
29,037
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 .
29,038
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 .
29,039
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 .
29,040
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 .
29,041
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 .
29,042
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 .
29,043
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 .
29,044
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 .
29,045
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 .
29,046
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 .
29,047
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 ) { } } return response ; }
get a Document Image list if Converted to image . Make Sure the Document convert type is image otherwise will throw BceServiceException
29,048
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 ) { } } return response ; }
list all Document .
29,049
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 ) { } } return response ; }
get a Document Download link .
29,050
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 .
29,051
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 .
29,052
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 .
29,053
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 .
29,054
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 .
29,055
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 .
29,056
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
29,057
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
29,058
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 .
29,059
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 .
29,060
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 .
29,061
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 .
29,062
private void processTemplateExpressions ( ComponentExposedTypeGenerator exposedTypeGenerator , TemplateParserResult templateParserResult ) { for ( TemplateExpression expression : templateParserResult . getExpressions ( ) ) { generateTemplateExpressionMethod ( exposedTypeGenerator , expression , templateParserResult . getTemplateName ( ) ) ; } 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
29,063
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
29,064
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 ; } String componentClassName = componentElement . getSimpleName ( ) . toString ( ) . replaceAll ( "Component$" , "" ) ; 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 .
29,065
public static String directiveToTagName ( String directiveClassName ) { directiveClassName = directiveClassName . replaceAll ( "Directive$" , "" ) ; 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
29,066
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
29,067
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
29,068
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
29,069
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 .
29,070
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 .
29,071
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 .
29,072
private void processElement ( Element element ) { context . setCurrentSegment ( element ) ; currentProp = null ; currentAttribute = null ; boolean shouldPopContext = processElementAttributes ( element ) ; 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 ) ; element . getChildElements ( ) . forEach ( this :: processElement ) ; if ( shouldPopContext ) { context . popContextLayer ( ) ; } }
Recursive method that will process the whole template DOM tree .
29,073
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
29,074
private void registerMandatoryAttributes ( Attributes attributes ) { 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
29,075
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 .
29,076
private String processVForValue ( String vForValue ) { VForDefinition vForDef = new VForDefinition ( vForValue , context , logger ) ; currentExpressionReturnType = vForDef . getInExpressionType ( ) ; String inExpression = this . processExpression ( vForDef . getInExpression ( ) ) ; return vForDef . getVariableDefinition ( ) + " in " + inExpression ; }
Process a v - for value . It will register the loop variables as a local variable in the context stack .
29,077
private String processSlotScopeValue ( String value ) { SlotScopeDefinition slotScopeDefinition = new SlotScopeDefinition ( value , context , logger ) ; return slotScopeDefinition . getSlotScopeVariableName ( ) ; }
Process a scoped - slot value .
29,078
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
29,079
private boolean shouldSkipExpressionProcessing ( String expressionString ) { 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 .
29,080
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 ) ; List < VariableInfo > expressionParameters = new LinkedList < > ( ) ; findExpressionParameters ( expression , expressionParameters ) ; if ( currentProp == null ) { expression = getTypeFromCast ( expression ) ; } expressionString = expression . toString ( ) ; return result . addExpression ( expressionString , currentExpressionReturnType , currentProp == null , expressionParameters ) ; }
Process the given string as a Java expression .
29,081
private void resolveTypesUsingImports ( Expression expression ) { if ( expression instanceof NodeWithType ) { NodeWithType < ? , ? > nodeWithType = ( ( NodeWithType < ? , ? > ) expression ) ; nodeWithType . setType ( getQualifiedName ( nodeWithType . getType ( ) ) ) ; } 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 .
29,082
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 ) ) ; } } expression . getChildNodes ( ) . stream ( ) . filter ( Expression . class :: isInstance ) . map ( Expression . class :: cast ) . forEach ( this :: resolveStaticMethodsUsingImports ) ; }
Resolve static method calls using static imports
29,083
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 .
29,084
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 .
29,085
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 .
29,086
public void addRef ( String name , TypeMirror elementType , boolean isArray ) { refs . add ( new RefInfo ( name , elementType , isArray ) ) ; }
Register a ref found in the template
29,087
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
29,088
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 .
29,089
public final void initRenderFunctions ( Function renderFunctionString , Function [ ] staticRenderFnsStrings ) { this . setRender ( renderFunctionString ) ; this . setStaticRenderFns ( cast ( staticRenderFnsStrings ) ) ; }
Initialise the render functions from our template .
29,090
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 ( 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 .
29,091
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 .
29,092
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
29,093
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 .
29,094
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 .
29,095
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 .
29,096
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
29,097
public void generate ( TypeElement directiveTypeElement ) { ClassName optionsClassName = GeneratorsNameUtil . directiveOptionsName ( directiveTypeElement ) ; Builder componentClassBuilder = TypeSpec . classBuilder ( optionsClassName ) . addModifiers ( Modifier . PUBLIC , Modifier . FINAL ) . superclass ( VueDirectiveOptions . class ) . addAnnotation ( JsType . class ) . addJavadoc ( "VueComponent Directive Options for directive {@link $S}" , directiveTypeElement . getQualifiedName ( ) . toString ( ) ) ; MethodSpec . Builder constructorBuilder = MethodSpec . constructorBuilder ( ) . addModifiers ( Modifier . PUBLIC ) ; constructorBuilder . addStatement ( "this.$L = new $T()" , "vuegwt$javaDirectiveInstance" , TypeName . get ( directiveTypeElement . asType ( ) ) ) ; constructorBuilder . addStatement ( "this.copyHooks()" ) ; componentClassBuilder . addMethod ( constructorBuilder . build ( ) ) ; GeneratorsUtil . toJavaFile ( filer , componentClassBuilder , optionsClassName , directiveTypeElement ) ; }
Generate and save the Java file for the typeElement passed to the constructor
29,098
private void exposeExposedFieldsToJs ( ) { if ( fieldsWithNameExposed . isEmpty ( ) ) { return ; } MethodSpec . Builder exposeFieldMethod = MethodSpec . methodBuilder ( "vg$ef" ) . addAnnotation ( JsMethod . class ) ; fieldsWithNameExposed . forEach ( field -> exposeFieldMethod . addStatement ( "this.$L = $T.v()" , field . getName ( ) , FieldsExposer . class ) ) ; exposeFieldMethod . addStatement ( "$T.e($L)" , FieldsExposer . class , String . join ( "," , fieldsWithNameExposed . stream ( ) . map ( ExposedField :: getName ) . collect ( Collectors . toList ( ) ) ) ) ; componentExposedTypeBuilder . addMethod ( exposeFieldMethod . build ( ) ) ; }
Generate a method that use all the fields we want to determine the name of at runtime . This is to avoid GWT optimizing away assignation on those fields .
29,099
private void processComputed ( ) { getMethodsWithAnnotation ( component , Computed . class ) . forEach ( method -> { ComputedKind kind = ComputedKind . GETTER ; if ( "void" . equals ( method . getReturnType ( ) . toString ( ) ) ) { kind = ComputedKind . SETTER ; } String exposedMethodName = exposeExistingJavaMethodToJs ( method ) ; String fieldName = computedPropertyNameToFieldName ( getComputedPropertyName ( method ) ) ; TypeMirror propertyType = getComputedPropertyTypeFromMethod ( method ) ; fieldsWithNameExposed . add ( new ExposedField ( fieldName , propertyType ) ) ; optionsBuilder . addStatement ( "options.addJavaComputed(p.$L, $T.getFieldName(this, () -> this.$L = $L), $T.$L)" , exposedMethodName , VueGWTTools . class , fieldName , getFieldMarkingValueForType ( propertyType ) , ComputedKind . class , kind ) ; } ) ; addFieldsForComputedMethod ( component , new HashSet < > ( ) ) ; }
Process computed properties from the Component Class .