idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
4,500
public boolean checkResponseForException ( ) { if ( ! finished && rsp != null ) { Exception e ; if ( ( e = rsp . getException ( ) ) != null ) { setError ( e . getMessage ( ) ) ; setFinished ( ) ; return true ; } } return false ; }
Check response on exception .
4,501
private SimpleOrderedMap < Object > createOutput ( boolean detailed ) { SimpleOrderedMap < Object > output = new SimpleOrderedMap < > ( ) ; updateShardInfo ( ) ; output . add ( NAME_KEY , key ) ; output . add ( NAME_REQUEST , request ) ; if ( errorStatus ) { output . add ( NAME_ERROR , errorMessage ) ; } if ( abortStatus ) { output . add ( NAME_ABORT , abortMessage ) ; } output . add ( NAME_FINISHED , finished ) ; if ( totalTime != null ) { output . add ( NAME_TIME_TOTAL , totalTime ) ; } output . add ( NAME_TIME_START , ( new Date ( startTime ) ) . toString ( ) ) ; output . add ( NAME_SHARDREQUEST , shardRequest ) ; if ( shardNumberTotal > 0 ) { if ( detailed ) { output . add ( NAME_STATUS_DISTRIBUTED , createShardsOutput ( ) ) ; } else { output . add ( NAME_STATUS_DISTRIBUTED , true ) ; } } else if ( detailed ) { output . add ( NAME_STATUS_DISTRIBUTED , false ) ; } if ( status . numberSegmentsTotal != null ) { output . add ( NAME_STATUS_SEGMENT_NUMBER_TOTAL , status . numberSegmentsTotal ) ; output . add ( NAME_STATUS_SEGMENT_NUMBER_FINISHED , status . numberSegmentsFinished ) ; if ( ! status . subNumberSegmentsFinished . isEmpty ( ) ) { output . add ( NAME_STATUS_SEGMENT_SUB_NUMBER_FINISHED , status . subNumberSegmentsFinished ) ; output . add ( NAME_STATUS_SEGMENT_SUB_NUMBER_TOTAL , status . subNumberSegmentsTotal ) ; output . add ( NAME_STATUS_SEGMENT_SUB_NUMBER_FINISHED_TOTAL , status . subNumberSegmentsFinishedTotal ) ; } } if ( status . numberDocumentsTotal != null ) { output . add ( NAME_STATUS_DOCUMENT_NUMBER_TOTAL , status . numberDocumentsTotal ) ; output . add ( NAME_STATUS_DOCUMENT_NUMBER_FOUND , status . numberDocumentsFound ) ; output . add ( NAME_STATUS_DOCUMENT_NUMBER_FINISHED , status . numberDocumentsFinished ) ; if ( ! status . subNumberDocumentsFinished . isEmpty ( ) ) { output . add ( NAME_STATUS_DOCUMENT_SUB_NUMBER_FINISHED , status . subNumberDocumentsFinished ) ; output . add ( NAME_STATUS_DOCUMENT_SUB_NUMBER_TOTAL , status . subNumberDocumentsTotal ) ; output . add ( NAME_STATUS_DOCUMENT_SUB_NUMBER_FINISHED_TOTAL , status . subNumberDocumentsFinishedTotal ) ; } } return output ; }
Creates the output .
4,502
private final SimpleOrderedMap < Object > createShardsOutput ( ) { SimpleOrderedMap < Object > output = new SimpleOrderedMap < > ( ) ; if ( shardStageStatus != null && ! shardStageStatus . isEmpty ( ) ) { List < SimpleOrderedMap < Object > > list = new ArrayList < > ( ) ; for ( StageStatus stageStatus : shardStageStatus . values ( ) ) { list . add ( stageStatus . createOutput ( ) ) ; } output . add ( NAME_STATUS_STAGES , list ) ; } if ( shards != null && ! shards . isEmpty ( ) ) { List < SimpleOrderedMap < Object > > list = new ArrayList < > ( ) ; for ( ShardStatus shardStatus : shards . values ( ) ) { list . add ( shardStatus . createOutput ( ) ) ; } output . add ( NAME_STATUS_SHARDS , list ) ; } return output ; }
Creates the shards output .
4,503
private final Integer getInteger ( NamedList < Object > response , String ... args ) { Object objectItem = response . findRecursive ( args ) ; if ( objectItem != null && objectItem instanceof Integer ) { return ( Integer ) objectItem ; } else { return null ; } }
Gets the integer .
4,504
private final Map < String , Integer > getIntegerMap ( NamedList < Object > response , String ... args ) { Object objectItem = response . findRecursive ( args ) ; Map < String , Integer > result = null ; if ( objectItem != null && objectItem instanceof Map ) { result = ( Map ) objectItem ; } return result ; }
Gets the integer map .
4,505
private final Long getLong ( NamedList < Object > response , String ... args ) { Object objectItem = response . findRecursive ( args ) ; if ( objectItem != null && objectItem instanceof Long ) { return ( Long ) objectItem ; } else { return null ; } }
Gets the long .
4,506
private final Map < String , Long > getLongMap ( NamedList < Object > response , String ... args ) { Object objectItem = response . findRecursive ( args ) ; if ( objectItem != null && objectItem instanceof Map ) { return ( Map ) objectItem ; } else { return null ; } }
Gets the long map .
4,507
public static base_response add ( nitro_service client , vpnformssoaction resource ) throws Exception { vpnformssoaction addresource = new vpnformssoaction ( ) ; addresource . name = resource . name ; addresource . actionurl = resource . actionurl ; addresource . userfield = resource . userfield ; addresource . passwdfield = resource . passwdfield ; addresource . ssosuccessrule = resource . ssosuccessrule ; addresource . namevaluepair = resource . namevaluepair ; addresource . responsesize = resource . responsesize ; addresource . nvtype = resource . nvtype ; addresource . submitmethod = resource . submitmethod ; return addresource . add_resource ( client ) ; }
Use this API to add vpnformssoaction .
4,508
public static base_response update ( nitro_service client , vpnformssoaction resource ) throws Exception { vpnformssoaction updateresource = new vpnformssoaction ( ) ; updateresource . name = resource . name ; updateresource . actionurl = resource . actionurl ; updateresource . userfield = resource . userfield ; updateresource . passwdfield = resource . passwdfield ; updateresource . ssosuccessrule = resource . ssosuccessrule ; updateresource . responsesize = resource . responsesize ; updateresource . namevaluepair = resource . namevaluepair ; updateresource . nvtype = resource . nvtype ; updateresource . submitmethod = resource . submitmethod ; return updateresource . update_resource ( client ) ; }
Use this API to update vpnformssoaction .
4,509
public static base_responses update ( nitro_service client , vpnformssoaction resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { vpnformssoaction updateresources [ ] = new vpnformssoaction [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { updateresources [ i ] = new vpnformssoaction ( ) ; updateresources [ i ] . name = resources [ i ] . name ; updateresources [ i ] . actionurl = resources [ i ] . actionurl ; updateresources [ i ] . userfield = resources [ i ] . userfield ; updateresources [ i ] . passwdfield = resources [ i ] . passwdfield ; updateresources [ i ] . ssosuccessrule = resources [ i ] . ssosuccessrule ; updateresources [ i ] . responsesize = resources [ i ] . responsesize ; updateresources [ i ] . namevaluepair = resources [ i ] . namevaluepair ; updateresources [ i ] . nvtype = resources [ i ] . nvtype ; updateresources [ i ] . submitmethod = resources [ i ] . submitmethod ; } result = update_bulk_request ( client , updateresources ) ; } return result ; }
Use this API to update vpnformssoaction resources .
4,510
public static vpnformssoaction [ ] get ( nitro_service service ) throws Exception { vpnformssoaction obj = new vpnformssoaction ( ) ; vpnformssoaction [ ] response = ( vpnformssoaction [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch all the vpnformssoaction resources that are configured on netscaler .
4,511
public static vpnformssoaction get ( nitro_service service , String name ) throws Exception { vpnformssoaction obj = new vpnformssoaction ( ) ; obj . set_name ( name ) ; vpnformssoaction response = ( vpnformssoaction ) obj . get_resource ( service ) ; return response ; }
Use this API to fetch vpnformssoaction resource of given name .
4,512
public static dnsview_dnspolicy_binding [ ] get ( nitro_service service , String viewname ) throws Exception { dnsview_dnspolicy_binding obj = new dnsview_dnspolicy_binding ( ) ; obj . set_viewname ( viewname ) ; dnsview_dnspolicy_binding response [ ] = ( dnsview_dnspolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch dnsview_dnspolicy_binding resources of given name .
4,513
public static base_response kill ( nitro_service client , aaasession resource ) throws Exception { aaasession killresource = new aaasession ( ) ; killresource . username = resource . username ; killresource . groupname = resource . groupname ; killresource . iip = resource . iip ; killresource . netmask = resource . netmask ; killresource . all = resource . all ; return killresource . perform_operation ( client , "kill" ) ; }
Use this API to kill aaasession .
4,514
public static base_responses kill ( nitro_service client , aaasession resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { aaasession killresources [ ] = new aaasession [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { killresources [ i ] = new aaasession ( ) ; killresources [ i ] . username = resources [ i ] . username ; killresources [ i ] . groupname = resources [ i ] . groupname ; killresources [ i ] . iip = resources [ i ] . iip ; killresources [ i ] . netmask = resources [ i ] . netmask ; killresources [ i ] . all = resources [ i ] . all ; } result = perform_operation_bulk_request ( client , killresources , "kill" ) ; } return result ; }
Use this API to kill aaasession resources .
4,515
public static aaasession [ ] get ( nitro_service service ) throws Exception { aaasession obj = new aaasession ( ) ; aaasession [ ] response = ( aaasession [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch all the aaasession resources that are configured on netscaler .
4,516
public static aaasession [ ] get ( nitro_service service , aaasession_args args ) throws Exception { aaasession obj = new aaasession ( ) ; options option = new options ( ) ; option . set_args ( nitro_util . object_to_string_withoutquotes ( args ) ) ; aaasession [ ] response = ( aaasession [ ] ) obj . get_resources ( service , option ) ; return response ; }
Use this API to fetch all the aaasession resources that are configured on netscaler . This uses aaasession_args which is a way to provide additional arguments while fetching the resources .
4,517
public static base_response add ( nitro_service client , aaakcdaccount resource ) throws Exception { aaakcdaccount addresource = new aaakcdaccount ( ) ; addresource . kcdaccount = resource . kcdaccount ; addresource . keytab = resource . keytab ; addresource . realmstr = resource . realmstr ; addresource . delegateduser = resource . delegateduser ; addresource . kcdpassword = resource . kcdpassword ; addresource . usercert = resource . usercert ; addresource . cacert = resource . cacert ; return addresource . add_resource ( client ) ; }
Use this API to add aaakcdaccount .
4,518
public static base_responses add ( nitro_service client , aaakcdaccount resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { aaakcdaccount addresources [ ] = new aaakcdaccount [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { addresources [ i ] = new aaakcdaccount ( ) ; addresources [ i ] . kcdaccount = resources [ i ] . kcdaccount ; addresources [ i ] . keytab = resources [ i ] . keytab ; addresources [ i ] . realmstr = resources [ i ] . realmstr ; addresources [ i ] . delegateduser = resources [ i ] . delegateduser ; addresources [ i ] . kcdpassword = resources [ i ] . kcdpassword ; addresources [ i ] . usercert = resources [ i ] . usercert ; addresources [ i ] . cacert = resources [ i ] . cacert ; } result = add_bulk_request ( client , addresources ) ; } return result ; }
Use this API to add aaakcdaccount resources .
4,519
public static base_response delete ( nitro_service client , String kcdaccount ) throws Exception { aaakcdaccount deleteresource = new aaakcdaccount ( ) ; deleteresource . kcdaccount = kcdaccount ; return deleteresource . delete_resource ( client ) ; }
Use this API to delete aaakcdaccount of given name .
4,520
public static base_responses delete ( nitro_service client , String kcdaccount [ ] ) throws Exception { base_responses result = null ; if ( kcdaccount != null && kcdaccount . length > 0 ) { aaakcdaccount deleteresources [ ] = new aaakcdaccount [ kcdaccount . length ] ; for ( int i = 0 ; i < kcdaccount . length ; i ++ ) { deleteresources [ i ] = new aaakcdaccount ( ) ; deleteresources [ i ] . kcdaccount = kcdaccount [ i ] ; } result = delete_bulk_request ( client , deleteresources ) ; } return result ; }
Use this API to delete aaakcdaccount resources of given names .
4,521
public static base_response update ( nitro_service client , aaakcdaccount resource ) throws Exception { aaakcdaccount updateresource = new aaakcdaccount ( ) ; updateresource . kcdaccount = resource . kcdaccount ; updateresource . keytab = resource . keytab ; updateresource . realmstr = resource . realmstr ; updateresource . delegateduser = resource . delegateduser ; updateresource . kcdpassword = resource . kcdpassword ; updateresource . usercert = resource . usercert ; updateresource . cacert = resource . cacert ; return updateresource . update_resource ( client ) ; }
Use this API to update aaakcdaccount .
4,522
public static base_responses update ( nitro_service client , aaakcdaccount resources [ ] ) throws Exception { base_responses result = null ; if ( resources != null && resources . length > 0 ) { aaakcdaccount updateresources [ ] = new aaakcdaccount [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { updateresources [ i ] = new aaakcdaccount ( ) ; updateresources [ i ] . kcdaccount = resources [ i ] . kcdaccount ; updateresources [ i ] . keytab = resources [ i ] . keytab ; updateresources [ i ] . realmstr = resources [ i ] . realmstr ; updateresources [ i ] . delegateduser = resources [ i ] . delegateduser ; updateresources [ i ] . kcdpassword = resources [ i ] . kcdpassword ; updateresources [ i ] . usercert = resources [ i ] . usercert ; updateresources [ i ] . cacert = resources [ i ] . cacert ; } result = update_bulk_request ( client , updateresources ) ; } return result ; }
Use this API to update aaakcdaccount resources .
4,523
public static base_response unset ( nitro_service client , aaakcdaccount resource , String [ ] args ) throws Exception { aaakcdaccount unsetresource = new aaakcdaccount ( ) ; unsetresource . kcdaccount = resource . kcdaccount ; unsetresource . keytab = resource . keytab ; unsetresource . usercert = resource . usercert ; unsetresource . cacert = resource . cacert ; return unsetresource . unset_resource ( client , args ) ; }
Use this API to unset the properties of aaakcdaccount resource . Properties that need to be unset are specified in args array .
4,524
public static aaakcdaccount [ ] get ( nitro_service service ) throws Exception { aaakcdaccount obj = new aaakcdaccount ( ) ; aaakcdaccount [ ] response = ( aaakcdaccount [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch all the aaakcdaccount resources that are configured on netscaler .
4,525
public static aaakcdaccount get ( nitro_service service , String kcdaccount ) throws Exception { aaakcdaccount obj = new aaakcdaccount ( ) ; obj . set_kcdaccount ( kcdaccount ) ; aaakcdaccount response = ( aaakcdaccount ) obj . get_resource ( service ) ; return response ; }
Use this API to fetch aaakcdaccount resource of given name .
4,526
public static aaakcdaccount [ ] get ( nitro_service service , String kcdaccount [ ] ) throws Exception { if ( kcdaccount != null && kcdaccount . length > 0 ) { aaakcdaccount response [ ] = new aaakcdaccount [ kcdaccount . length ] ; aaakcdaccount obj [ ] = new aaakcdaccount [ kcdaccount . length ] ; for ( int i = 0 ; i < kcdaccount . length ; i ++ ) { obj [ i ] = new aaakcdaccount ( ) ; obj [ i ] . set_kcdaccount ( kcdaccount [ i ] ) ; response [ i ] = ( aaakcdaccount ) obj [ i ] . get_resource ( service ) ; } return response ; } return null ; }
Use this API to fetch aaakcdaccount resources of given names .
4,527
public static base_response update ( nitro_service client , nsparam resource ) throws Exception { nsparam updateresource = new nsparam ( ) ; updateresource . httpport = resource . httpport ; updateresource . maxconn = resource . maxconn ; updateresource . maxreq = resource . maxreq ; updateresource . cip = resource . cip ; updateresource . cipheader = resource . cipheader ; updateresource . cookieversion = resource . cookieversion ; updateresource . securecookie = resource . securecookie ; updateresource . pmtumin = resource . pmtumin ; updateresource . pmtutimeout = resource . pmtutimeout ; updateresource . ftpportrange = resource . ftpportrange ; updateresource . crportrange = resource . crportrange ; updateresource . timezone = resource . timezone ; updateresource . grantquotamaxclient = resource . grantquotamaxclient ; updateresource . exclusivequotamaxclient = resource . exclusivequotamaxclient ; updateresource . grantquotaspillover = resource . grantquotaspillover ; updateresource . exclusivequotaspillover = resource . exclusivequotaspillover ; updateresource . useproxyport = resource . useproxyport ; updateresource . internaluserlogin = resource . internaluserlogin ; updateresource . aftpallowrandomsourceport = resource . aftpallowrandomsourceport ; updateresource . icaports = resource . icaports ; return updateresource . update_resource ( client ) ; }
Use this API to update nsparam .
4,528
public static base_response unset ( nitro_service client , nsparam resource , String [ ] args ) throws Exception { nsparam unsetresource = new nsparam ( ) ; return unsetresource . unset_resource ( client , args ) ; }
Use this API to unset the properties of nsparam resource . Properties that need to be unset are specified in args array .
4,529
public static nsparam get ( nitro_service service ) throws Exception { nsparam obj = new nsparam ( ) ; nsparam [ ] response = ( nsparam [ ] ) obj . get_resources ( service ) ; return response [ 0 ] ; }
Use this API to fetch all the nsparam resources that are configured on netscaler .
4,530
public static boolean checkOffsets ( CoreMap docAnnotation ) { boolean okay = true ; String docText = docAnnotation . get ( CoreAnnotations . TextAnnotation . class ) ; String docId = docAnnotation . get ( CoreAnnotations . DocIDAnnotation . class ) ; List < CoreLabel > docTokens = docAnnotation . get ( CoreAnnotations . TokensAnnotation . class ) ; List < CoreMap > sentences = docAnnotation . get ( CoreAnnotations . SentencesAnnotation . class ) ; for ( CoreMap sentence : sentences ) { String sentText = sentence . get ( CoreAnnotations . TextAnnotation . class ) ; List < CoreLabel > sentTokens = sentence . get ( CoreAnnotations . TokensAnnotation . class ) ; int sentBeginChar = sentence . get ( CoreAnnotations . CharacterOffsetBeginAnnotation . class ) ; int sentEndChar = sentence . get ( CoreAnnotations . CharacterOffsetEndAnnotation . class ) ; int sentBeginToken = sentence . get ( CoreAnnotations . TokenBeginAnnotation . class ) ; int sentEndToken = sentence . get ( CoreAnnotations . TokenEndAnnotation . class ) ; String docTextSpan = docText . substring ( sentBeginChar , sentEndChar ) ; List < CoreLabel > docTokenSpan = new ArrayList < CoreLabel > ( docTokens . subList ( sentBeginToken , sentEndToken ) ) ; logger . finer ( "Checking Document " + docId + " span (" + sentBeginChar + "," + sentEndChar + ") " ) ; if ( ! docTextSpan . equals ( sentText ) ) { okay = false ; logger . finer ( "WARNING: Document " + docId + " span does not match sentence" ) ; logger . finer ( "DocSpanText: " + docTextSpan ) ; logger . finer ( "SentenceText: " + sentText ) ; } String sentTokenStr = getTokenText ( sentTokens , CoreAnnotations . TextAnnotation . class ) ; String docTokenStr = getTokenText ( docTokenSpan , CoreAnnotations . TextAnnotation . class ) ; if ( ! docTokenStr . equals ( sentTokenStr ) ) { okay = false ; logger . finer ( "WARNING: Document " + docId + " tokens does not match sentence" ) ; logger . finer ( "DocSpanTokens: " + docTokenStr ) ; logger . finer ( "SentenceTokens: " + sentTokenStr ) ; } } return okay ; }
Checks if offsets of doc and sentence matches
4,531
public static void copyUnsetAnnotations ( CoreMap src , CoreMap dest ) { Set < Class < ? > > otherKeys = src . keySet ( ) ; for ( Class key : otherKeys ) { if ( ! dest . has ( key ) ) { dest . set ( key , src . get ( key ) ) ; } } }
Copies annotation over to this coremap if not already set
4,532
public static Interval < Integer > getChunkOffsetsUsingCharOffsets ( List < ? extends CoreMap > chunkList , int charStart , int charEnd ) { int chunkStart = 0 ; int chunkEnd = chunkList . size ( ) ; for ( int i = 0 ; i < chunkList . size ( ) ; i ++ ) { int start = chunkList . get ( i ) . get ( CoreAnnotations . CharacterOffsetBeginAnnotation . class ) ; if ( start > charStart ) { break ; } chunkStart = i ; } for ( int i = chunkStart ; i < chunkList . size ( ) ; i ++ ) { int start = chunkList . get ( i ) . get ( CoreAnnotations . CharacterOffsetBeginAnnotation . class ) ; if ( start >= charEnd ) { chunkEnd = i ; break ; } } return Interval . toInterval ( chunkStart , chunkEnd , Interval . INTERVAL_OPEN_END ) ; }
Return chunk offsets
4,533
public static void annotateChunkText ( CoreMap chunk , CoreMap origAnnotation ) { String annoText = origAnnotation . get ( CoreAnnotations . TextAnnotation . class ) ; Integer annoBeginCharOffset = origAnnotation . get ( CoreAnnotations . CharacterOffsetBeginAnnotation . class ) ; if ( annoBeginCharOffset == null ) { annoBeginCharOffset = 0 ; } int chunkBeginCharOffset = chunk . get ( CoreAnnotations . CharacterOffsetBeginAnnotation . class ) - annoBeginCharOffset ; int chunkEndCharOffset = chunk . get ( CoreAnnotations . CharacterOffsetEndAnnotation . class ) - annoBeginCharOffset ; if ( chunkBeginCharOffset < 0 ) { logger . fine ( "Adjusting begin char offset from " + chunkBeginCharOffset + " to 0" ) ; logger . fine ( "Chunk begin offset: " + chunk . get ( CoreAnnotations . CharacterOffsetBeginAnnotation . class ) + ", Source text begin offset " + annoBeginCharOffset ) ; chunkBeginCharOffset = 0 ; } if ( chunkBeginCharOffset > annoText . length ( ) ) { logger . fine ( "Adjusting begin char offset from " + chunkBeginCharOffset + " to " + annoText . length ( ) ) ; logger . fine ( "Chunk begin offset: " + chunk . get ( CoreAnnotations . CharacterOffsetBeginAnnotation . class ) + ", Source text begin offset " + annoBeginCharOffset ) ; chunkBeginCharOffset = annoText . length ( ) ; } if ( chunkEndCharOffset < 0 ) { logger . fine ( "Adjusting end char offset from " + chunkEndCharOffset + " to 0" ) ; logger . fine ( "Chunk end offset: " + chunk . get ( CoreAnnotations . CharacterOffsetEndAnnotation . class ) + ", Source text begin offset " + annoBeginCharOffset ) ; chunkEndCharOffset = 0 ; } if ( chunkEndCharOffset > annoText . length ( ) ) { logger . fine ( "Adjusting end char offset from " + chunkEndCharOffset + " to " + annoText . length ( ) ) ; logger . fine ( "Chunk end offset: " + chunk . get ( CoreAnnotations . CharacterOffsetEndAnnotation . class ) + ", Source text begin offset " + annoBeginCharOffset ) ; chunkEndCharOffset = annoText . length ( ) ; } if ( chunkEndCharOffset < chunkBeginCharOffset ) { logger . fine ( "Adjusting end char offset from " + chunkEndCharOffset + " to " + chunkBeginCharOffset ) ; logger . fine ( "Chunk end offset: " + chunk . get ( CoreAnnotations . CharacterOffsetEndAnnotation . class ) + ", Source text begin offset " + annoBeginCharOffset ) ; chunkEndCharOffset = chunkBeginCharOffset ; } String chunkText = annoText . substring ( chunkBeginCharOffset , chunkEndCharOffset ) ; chunk . set ( CoreAnnotations . TextAnnotation . class , chunkText ) ; }
Annotates a CoreMap representing a chunk with text information TextAnnotation - String extracted from the origAnnotation using character offset information for this chunk
4,534
public static void annotateChunkTokens ( CoreMap chunk , Class tokenChunkKey , Class tokenLabelKey ) { List < CoreLabel > chunkTokens = chunk . get ( CoreAnnotations . TokensAnnotation . class ) ; if ( tokenLabelKey != null ) { String text = chunk . get ( CoreAnnotations . TextAnnotation . class ) ; for ( CoreLabel t : chunkTokens ) { t . set ( tokenLabelKey , text ) ; } } if ( tokenChunkKey != null ) { for ( CoreLabel t : chunkTokens ) { t . set ( tokenChunkKey , chunk ) ; } } }
Annotates tokens in chunk
4,535
private void computeComparableValue ( ) { recomputeComparableSortValue = false ; try { int type = getCompareValueType ( ) ; switch ( type ) { case 0 : comparableSortValue = getCompareValue0 ( ) ; break ; case 1 : comparableSortValue = getCompareValue1 ( ) ; break ; case 2 : comparableSortValue = getCompareValue2 ( ) ; break ; default : comparableSortValue = null ; break ; } } catch ( IOException e ) { log . debug ( e ) ; comparableSortValue = null ; } }
Compute comparable value .
4,536
public static service_scpolicy_binding [ ] get ( nitro_service service , String name ) throws Exception { service_scpolicy_binding obj = new service_scpolicy_binding ( ) ; obj . set_name ( name ) ; service_scpolicy_binding response [ ] = ( service_scpolicy_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch service_scpolicy_binding resources of given name .
4,537
public static appfwpolicy_appfwglobal_binding [ ] get ( nitro_service service , String name ) throws Exception { appfwpolicy_appfwglobal_binding obj = new appfwpolicy_appfwglobal_binding ( ) ; obj . set_name ( name ) ; appfwpolicy_appfwglobal_binding response [ ] = ( appfwpolicy_appfwglobal_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch appfwpolicy_appfwglobal_binding resources of given name .
4,538
public static transformpolicy_lbvserver_binding [ ] get ( nitro_service service , String name ) throws Exception { transformpolicy_lbvserver_binding obj = new transformpolicy_lbvserver_binding ( ) ; obj . set_name ( name ) ; transformpolicy_lbvserver_binding response [ ] = ( transformpolicy_lbvserver_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch transformpolicy_lbvserver_binding resources of given name .
4,539
public static base_response update ( nitro_service client , systemparameter resource ) throws Exception { systemparameter updateresource = new systemparameter ( ) ; updateresource . rbaonresponse = resource . rbaonresponse ; updateresource . promptstring = resource . promptstring ; updateresource . natpcbforceflushlimit = resource . natpcbforceflushlimit ; updateresource . natpcbrstontimeout = resource . natpcbrstontimeout ; updateresource . timeout = resource . timeout ; return updateresource . update_resource ( client ) ; }
Use this API to update systemparameter .
4,540
public static base_response unset ( nitro_service client , systemparameter resource , String [ ] args ) throws Exception { systemparameter unsetresource = new systemparameter ( ) ; return unsetresource . unset_resource ( client , args ) ; }
Use this API to unset the properties of systemparameter resource . Properties that need to be unset are specified in args array .
4,541
public static systemparameter get ( nitro_service service ) throws Exception { systemparameter obj = new systemparameter ( ) ; systemparameter [ ] response = ( systemparameter [ ] ) obj . get_resources ( service ) ; return response [ 0 ] ; }
Use this API to fetch all the systemparameter resources that are configured on netscaler .
4,542
public static auditnslogpolicy_appfwglobal_binding [ ] get ( nitro_service service , String name ) throws Exception { auditnslogpolicy_appfwglobal_binding obj = new auditnslogpolicy_appfwglobal_binding ( ) ; obj . set_name ( name ) ; auditnslogpolicy_appfwglobal_binding response [ ] = ( auditnslogpolicy_appfwglobal_binding [ ] ) obj . get_resources ( service ) ; return response ; }
Use this API to fetch auditnslogpolicy_appfwglobal_binding resources of given name .
4,543
public static clusterinstance_stats [ ] get ( nitro_service service ) throws Exception { clusterinstance_stats obj = new clusterinstance_stats ( ) ; clusterinstance_stats [ ] response = ( clusterinstance_stats [ ] ) obj . stat_resources ( service ) ; return response ; }
Use this API to fetch the statistics of all clusterinstance_stats resources that are configured on netscaler .
4,544
public static clusterinstance_stats get ( nitro_service service , Long clid ) throws Exception { clusterinstance_stats obj = new clusterinstance_stats ( ) ; obj . set_clid ( clid ) ; clusterinstance_stats response = ( clusterinstance_stats ) obj . stat_resource ( service ) ; return response ; }
Use this API to fetch statistics of clusterinstance_stats resource of given name .
4,545
public Arguments set ( final int index , final Fixed f ) { this . argumentRefs . add ( f ) ; this . pointer . get ( index ) . setF ( f . getRaw ( ) ) ; return this ; }
wl_fixed_t f ; fixed point
4,546
public static void store ( final long pointer , final Object object ) { final Object oldValue = MAPPED_OBJECTS . put ( pointer , object ) ; if ( oldValue != null ) { MAPPED_OBJECTS . put ( pointer , oldValue ) ; throw new IllegalStateException ( String . format ( "Can not re-map existing pointer.\n" + "Pointer=%s\n" + "old value=%s" + "\nnew value=%s" , pointer , oldValue , object ) ) ; } }
Maps a native pointer to a POJO . This method should be used to easily store a POJO with a native context .
4,547
public static Optional < Map < QName , XMLElementReader < List < ModelNode > > > > mapParserNamespaces ( AbstractParserFactory factory ) { Map < QName , XMLElementReader < List < ModelNode > > > result = factory . create ( ) . entrySet ( ) . stream ( ) . collect ( Collectors . toMap ( e -> new QName ( e . getKey ( ) . getNamespaceURI ( ) , SUBSYSTEM ) , e -> e . getValue ( ) ) ) ; return Optional . of ( result ) ; }
Parsers retain the namespace but the local part becomes subsystem
4,548
public Resource < ? > getObject ( final int id ) { return ObjectCache . from ( WaylandServerCore . INSTANCE ( ) . wl_client_get_object ( this . pointer , id ) ) ; }
Look up an object in the client name space . This looks up an object in the client object name space by its object ID .
4,549
public int getIndexForPosition ( int position ) { int nSections = 0 ; Set < Entry < String , Integer > > entrySet = mSections . entrySet ( ) ; for ( Entry < String , Integer > entry : entrySet ) { if ( entry . getValue ( ) < position ) { nSections ++ ; } } return position - nSections ; }
Returns the actual index of the object in the data source linked to the this list item .
4,550
public void init ( ProcessingEnvironment processingEnv ) { super . init ( processingEnv ) ; trees = Trees . instance ( processingEnv ) ; messager = processingEnv . getMessager ( ) ; types = processingEnv . getTypeUtils ( ) ; elements = processingEnv . getElementUtils ( ) ; try { logInvocationScanner = new LogInvocationScanner ( processingEnv ) ; } catch ( IOException e ) { messager . printMessage ( Diagnostic . Kind . ERROR , "IOException caught" ) ; initFailed = true ; } catch ( PackageNameException e ) { messager . printMessage ( Diagnostic . Kind . ERROR , "generatedEventsPackage compiler argument is not valid, either it contains java keyword or subpackage or class name starts with number" ) ; initFailed = true ; } final String schemasRoot = processingEnv . getOptions ( ) . get ( "schemasRoot" ) ; if ( schemasRoot != null ) { try { new URI ( schemasRoot ) ; } catch ( URISyntaxException e ) { initFailed = true ; messager . printMessage ( Diagnostic . Kind . ERROR , format ( "Provided schemasRoot compiler argument value [%s] is not valid path" , schemasRoot ) ) ; } SchemaGenerator schemaGenerator = new SchemaGenerator ( generatedClassesInfo , schemasRoot ) ; JavacTask . instance ( processingEnv ) . addTaskListener ( schemaGenerator ) ; } else { messager . printMessage ( Diagnostic . Kind . MANDATORY_WARNING , "schemasRoot compiler argument is not set, no schemas will be created" ) ; } }
flag that init method has errors
4,551
private < J , T extends Proxy < J > > T marshalConstructor ( final int opcode , final J implementation , final int version , final Class < T > newProxyCls , final long argsPointer ) { try { final long wlProxy = WaylandClientCore . INSTANCE ( ) . wl_proxy_marshal_array_constructor ( this . pointer , opcode , argsPointer , InterfaceMeta . get ( newProxyCls ) . pointer . address ) ; return marshalProxy ( wlProxy , implementation , version , newProxyCls ) ; } catch ( final NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e ) { throw new RuntimeException ( "Uh oh, this is a bug!" , e ) ; } }
called from generated proxies
4,552
public void destroy ( ) { WaylandClientCore . INSTANCE ( ) . wl_proxy_destroy ( this . pointer ) ; ObjectCache . remove ( this . pointer ) ; this . jObjectPointer . close ( ) ; }
Destroy a proxy object
4,553
public static void main ( String ... args ) throws Exception { if ( System . getProperty ( "boot.module.loader" ) == null ) { System . setProperty ( "boot.module.loader" , "org.wildfly.swarm.bootstrap.modules.BootModuleLoader" ) ; } Module bootstrap = Module . getBootModuleLoader ( ) . loadModule ( ModuleIdentifier . create ( "swarm.application" ) ) ; ServiceLoader < ContainerFactory > factory = bootstrap . loadService ( ContainerFactory . class ) ; Iterator < ContainerFactory > factoryIter = factory . iterator ( ) ; if ( ! factoryIter . hasNext ( ) ) { simpleMain ( args ) ; } else { factoryMain ( factoryIter . next ( ) , args ) ; } }
Main entry - point .
4,554
public final void bindToView ( final ViewGroup parent , final View view , final T instance , final int position ) { SparseArray < Holder > holders = ( SparseArray < Holder > ) view . getTag ( mLayoutResourceId ) ; updateAnnotatedViews ( holders , view , instance , position ) ; executeViewHandlers ( holders , parent , view , instance , position ) ; }
Method binds a POJO to the inflated View .
4,555
public final View createNewView ( final Context context , final ViewGroup parent ) { View view = mLayoutInflater . inflate ( mLayoutResourceId , parent , false ) ; SparseArray < Holder > holders = new SparseArray < Holder > ( ) ; int size = mViewIdsAndMetaCache . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { int viewId = mViewIdsAndMetaCache . keyAt ( i ) ; Meta meta = mViewIdsAndMetaCache . get ( viewId ) ; View viewFromLayout = view . findViewById ( viewId ) ; if ( viewFromLayout == null ) { String message = String . format ( "Cannot find View, check the 'viewId' " + "attribute on method %s.%s()" , mDataType . getName ( ) , meta . method . getName ( ) ) ; throw new IllegalStateException ( message ) ; } holders . append ( viewId , new Holder ( viewFromLayout , meta ) ) ; mAnnotatedViewIds . add ( viewId ) ; } view . setTag ( mLayoutResourceId , holders ) ; return view ; }
Create a new view by inflating the associated XML layout .
4,556
private < T > void visitFractions ( Container container , T context , FractionProcessor < T > fn ) { OUTER : for ( ServerConfiguration eachConfig : this . configList ) { boolean found = false ; INNER : for ( Fraction eachFraction : container . fractions ( ) ) { if ( eachConfig . getType ( ) . isAssignableFrom ( eachFraction . getClass ( ) ) ) { found = true ; fn . accept ( context , eachConfig , eachFraction ) ; break INNER ; } } if ( ! found && ! eachConfig . isIgnorable ( ) ) { System . err . println ( "*** unable to find fraction for: " + eachConfig . getType ( ) ) ; } } }
Wraps common iteration pattern over fraction and server configurations
4,557
private void handle ( final JCTree . JCFieldAccess fieldAccess , final Stack < MethodAndParameter > stack , final MethodInvocationTree node , final StatementInfo statementInfo , final ScannerParams scannerParams ) { if ( fieldAccess . getExpression ( ) . getKind ( ) . equals ( Tree . Kind . MEMBER_SELECT ) ) { final MemberSelectTree expression = ( MemberSelectTree ) fieldAccess . getExpression ( ) ; final Name name = expression . getIdentifier ( ) ; if ( scannerParams . getFields ( ) . containsKey ( name ) ) { handleStructLogExpression ( stack , node , name , statementInfo , scannerParams ) ; } } else if ( fieldAccess . getExpression ( ) . getKind ( ) . equals ( Tree . Kind . IDENTIFIER ) ) { final JCTree . JCIdent ident = ( JCTree . JCIdent ) fieldAccess . getExpression ( ) ; final Name name = ident . getName ( ) ; if ( scannerParams . getFields ( ) . containsKey ( name ) ) { handleStructLogExpression ( stack , node , name , statementInfo , scannerParams ) ; } } }
checks whether fieldAccess node s expression is MEMBER_SELECT or IDENTIFIER and if so then checks that accessed field name corresponds with some declared structlogger field and if it does correspond then whole statement is handled as structlogger expression
4,558
private String formatWithStatementLocation ( String format , StatementInfo statementInfo , Object ... args ) { return format ( format , args ) + format ( " [%s:%s]" , statementInfo . getSourceFileName ( ) , statementInfo . getLineNumber ( ) ) ; }
System . format with string representing statement location added at the end
4,559
private void addVariablesToBuffer ( final java . util . List < VariableAndValue > usedVariables , final ListBuffer listBuffer ) { for ( VariableAndValue variableAndValue : usedVariables ) { listBuffer . add ( variableAndValue . getValue ( ) ) ; } }
all used variables are added to listbuffer
4,560
public Command [ ] toArgs ( final String line ) { if ( line == null || line . isEmpty ( ) ) { throw new IllegalArgumentException ( "Empty command." ) ; } final List < Command > commands = new ArrayList < > ( ) ; final List < String > result = new ArrayList < > ( ) ; final StringBuilder current = new StringBuilder ( ) ; char waitChar = ' ' ; boolean copyNextChar = false ; boolean inEscaped = false ; for ( final char c : line . toCharArray ( ) ) { if ( copyNextChar ) { current . append ( c ) ; copyNextChar = false ; } else if ( waitChar == c ) { if ( current . length ( ) > 0 ) { result . add ( current . toString ( ) ) ; current . setLength ( 0 ) ; } waitChar = ' ' ; inEscaped = false ; } else { switch ( c ) { case '"' : case '\'' : if ( ! inEscaped ) { waitChar = c ; inEscaped = true ; break ; } else { current . append ( c ) ; } break ; case '\\' : copyNextChar = true ; break ; case '|' : flush ( commands , result , current ) ; break ; default : current . append ( c ) ; } } } if ( waitChar != ' ' ) { throw new IllegalStateException ( "Missing closing " + Character . toString ( waitChar ) ) ; } flush ( commands , result , current ) ; return commands . toArray ( new Command [ commands . size ( ) ] ) ; }
designed as a class in case we add config
4,561
public static LoggingFraction createDefaultLoggingFraction ( Level level ) { return new LoggingFraction ( ) . defaultColorFormatter ( ) . consoleHandler ( level , COLOR_PATTERN ) . rootLogger ( level , CONSOLE ) ; }
Create a default logging fraction for the specified level .
4,562
public LoggingFraction formatter ( String name , String pattern ) { patternFormatter ( new PatternFormatter ( name ) . pattern ( pattern ) ) ; return this ; }
Add a new PatternFormatter to this Logger
4,563
public LoggingFraction consoleHandler ( Level level , String formatter ) { consoleHandler ( new ConsoleHandler ( CONSOLE ) . level ( level ) . namedFormatter ( formatter ) ) ; return this ; }
Add a ConsoleHandler to the list of handlers for this logger .
4,564
public LoggingFraction fileHandler ( String name , String path , Level level , String formatter ) { Map < Object , Object > fileProperties = new HashMap < > ( ) ; fileProperties . put ( "path" , path ) ; fileProperties . put ( "relative-to" , "jboss.server.log.dir" ) ; fileHandler ( new FileHandler ( name ) . level ( level ) . formatter ( formatter ) . file ( fileProperties ) ) ; return this ; }
Add a FileHandler to the list of handlers for this logger
4,565
public LoggingFraction customHandler ( String name , String module , String className , Properties properties , String formatter ) { Map < Object , Object > handlerProperties = new HashMap < > ( ) ; final Enumeration < ? > names = properties . propertyNames ( ) ; while ( names . hasMoreElements ( ) ) { final String nextElement = ( String ) names . nextElement ( ) ; handlerProperties . put ( nextElement , properties . getProperty ( nextElement ) ) ; } customHandler ( new CustomHandler ( name ) . module ( module ) . attributeClass ( className ) . formatter ( formatter ) . properties ( handlerProperties ) ) ; return this ; }
Add a CustomHandler to this logger
4,566
public LoggingFraction rootLogger ( Level level , String ... handlers ) { rootLogger ( new RootLogger ( ) . level ( level ) . handlers ( handlers ) ) ; return this ; }
Add a root logger to this fraction
4,567
private Condition buildIdCondition ( Object argument ) { if ( argument instanceof String && ObjectId . isValid ( ( String ) argument ) ) { return new Condition ( ID_FIELD , new ObjectId ( ( String ) argument ) ) ; } else if ( Iterable . class . isAssignableFrom ( argument . getClass ( ) ) ) { List < Object > objectIds = new ArrayList < Object > ( ) ; for ( Object argumentItem : ( Iterable ) argument ) { if ( argumentItem instanceof String && ObjectId . isValid ( ( String ) argumentItem ) ) { objectIds . add ( new ObjectId ( ( String ) argumentItem ) ) ; } else if ( argumentItem instanceof ObjectId ) { objectIds . add ( argumentItem ) ; } } return new Condition ( ID_FIELD , new BasicDBObject ( "$in" , objectIds ) ) ; } else { return new Condition ( ID_FIELD , argument ) ; } }
Special case for id queries as it maps to _id within MongoDB .
4,568
public void audit ( final LoggingEvent e ) { try { logger . info ( MarkerFactory . getMarker ( AUDIT ) , serialize ( e ) ) ; } catch ( Exception ex ) { throw new RuntimeException ( "unable to serialize event" , ex ) ; } }
This implementation uses INFO level of slf4j and marks these logged messages with AUDIT marker
4,569
public String getUsage ( ) { String commandName = name ; Class < ? > declaringClass = method . getDeclaringClass ( ) ; Map < String , Cmd > commands = Commands . get ( declaringClass ) ; if ( commands . size ( ) == 1 && commands . values ( ) . iterator ( ) . next ( ) instanceof CmdGroup ) { final CmdGroup cmdGroup = ( CmdGroup ) commands . values ( ) . iterator ( ) . next ( ) ; commandName = cmdGroup . getName ( ) + " " + name ; } final String usage = usage ( ) ; if ( usage != null ) { if ( ! usage . startsWith ( commandName ) ) { return commandName + " " + usage ; } else { return usage ; } } final List < Object > args = new ArrayList < > ( ) ; for ( final Param parameter : spec . arguments ) { boolean skip = Environment . class . isAssignableFrom ( parameter . getType ( ) ) ; for ( final Annotation a : parameter . getAnnotations ( ) ) { final CrestAnnotation crestAnnotation = a . annotationType ( ) . getAnnotation ( CrestAnnotation . class ) ; if ( crestAnnotation != null ) { skip = crestAnnotation . skipUsage ( ) ; break ; } } if ( ! skip ) { skip = parameter . getAnnotation ( NotAService . class ) == null && Environment . ENVIRONMENT_THREAD_LOCAL . get ( ) . findService ( parameter . getType ( ) ) != null ; } if ( skip ) { continue ; } args . add ( parameter . getDisplayType ( ) . replace ( "[]" , "..." ) ) ; } return String . format ( "%s %s %s" , commandName , args . size ( ) == method . getParameterTypes ( ) . length ? "" : "[options]" , Join . join ( " " , args ) ) . trim ( ) ; }
Returns a single line description of the command
4,570
public BatchFraction defaultJobRepository ( final String name , final DatasourcesFraction datasource ) { jdbcJobRepository ( name , datasource ) ; return defaultJobRepository ( name ) ; }
Adds a new JDBC job repository and sets it as the default job repository .
4,571
public BatchFraction jdbcJobRepository ( final String name , final DatasourcesFraction datasource ) { return jdbcJobRepository ( new JDBCJobRepository < > ( name ) . dataSource ( datasource . getKey ( ) ) ) ; }
Creates a new JDBC job repository .
4,572
public BatchFraction defaultThreadPool ( final String name , final int maxThreads , final int keepAliveTime , final TimeUnit keepAliveUnits ) { threadPool ( name , maxThreads , keepAliveTime , keepAliveUnits ) ; return defaultThreadPool ( name ) ; }
Creates a new thread - pool and sets the created thread - pool as the default thread - pool for batch jobs .
4,573
public BatchFraction threadPool ( final String name , final int maxThreads , final int keepAliveTime , final TimeUnit keepAliveUnits ) { final ThreadPool < ? > threadPool = new ThreadPool < > ( name ) ; threadPool . maxThreads ( maxThreads ) . keepaliveTime ( "time" , Integer . toBinaryString ( keepAliveTime ) ) . keepaliveTime ( "unit" , keepAliveUnits . name ( ) . toLowerCase ( Locale . ROOT ) ) ; return threadPool ( threadPool ) ; }
Creates a new thread - pool that can be used for batch jobs .
4,574
@ Warmup ( iterations = 5 ) @ Measurement ( iterations = 5 ) public void structLoggerLogging1Call ( ) { structLoggerNoMessageParametrization . info ( "Event with double and boolean" ) . varDouble ( 1.2 ) . varBoolean ( false ) . log ( ) ; }
structured logging with no message parametrization
4,575
@ Warmup ( iterations = 5 ) @ Measurement ( iterations = 5 ) public void logstashStructuredParametrizedMessageLogging1Call ( ) { loggerLogstashParametrizedMessage . info ( "Event with double={} and boolean={}" , value ( "varDouble" , 1.2 ) , value ( "varBoolean" , false ) ) ; }
structured logging with parametrization with logstash
4,576
@ Warmup ( iterations = 5 ) @ Measurement ( iterations = 5 ) public void logstashStructuredLogging1Calls ( ) { loggerLogstash . info ( "Event with double and boolean" , keyValue ( "varDouble" , 1.2 ) , keyValue ( "varBoolean" , false ) ) ; }
structured logging without parametrization with logstash
4,577
public JavaFile createPojo ( final String name , final JCTree . JCLiteral literal , final List < VariableAndValue > usedVariables ) throws PackageNameException { String eventName ; String packageName ; if ( name != null ) { final String [ ] split = name . split ( "\\." ) ; eventName = split [ split . length - 1 ] ; checkStringIsValidName ( eventName ) ; final StringBuffer stringBuffer = new StringBuffer ( ) ; for ( int i = 0 ; i < split . length - 1 ; i ++ ) { if ( i != 0 ) { stringBuffer . append ( "." ) ; } stringBuffer . append ( split [ i ] ) ; checkStringIsValidName ( split [ i ] ) ; } packageName = stringBuffer . toString ( ) ; } else { eventName = "Event" + hash ( literal . getValue ( ) . toString ( ) ) ; packageName = generatedEventsPackage ; } final TypeSpec . Builder classBuilder = TypeSpec . classBuilder ( eventName ) . addModifiers ( Modifier . PUBLIC ) . superclass ( TypeName . get ( LoggingEvent . class ) ) ; final MethodSpec . Builder constructorBuilder = MethodSpec . constructorBuilder ( ) . addModifiers ( Modifier . PUBLIC ) ; addCommonLoggingEventFieldsToConstructor ( constructorBuilder ) ; for ( VariableAndValue variableAndValue : usedVariables ) { addPojoField ( classBuilder , constructorBuilder , variableAndValue . getVariable ( ) . getName ( ) . toString ( ) , TypeName . get ( variableAndValue . getVariable ( ) . getType ( ) ) ) ; } final TypeSpec build = classBuilder . addMethod ( constructorBuilder . build ( ) ) . build ( ) ; return JavaFile . builder ( packageName , build ) . build ( ) ; }
Create JavaFile representing POJO based on String literal and usedVariables of log statement
4,578
private void checkStringIsValidName ( final String s ) throws PackageNameException { final boolean packageContainsJavaKeyword = javaKeywords . stream ( ) . anyMatch ( s :: equals ) ; if ( packageContainsJavaKeyword || s . matches ( "\\d.*" ) ) { throw new PackageNameException ( "string is not valid" ) ; } }
Checks that string is not java keyword and is qualified java name
4,579
private void addCommonLoggingEventFieldsToConstructor ( final MethodSpec . Builder constructorBuilder ) { constructorBuilder . addParameter ( TypeName . get ( String . class ) , "message" , Modifier . FINAL ) ; constructorBuilder . addParameter ( TypeName . get ( String . class ) , "sourceFile" , Modifier . FINAL ) ; constructorBuilder . addParameter ( TypeName . LONG , "lineNumber" , Modifier . FINAL ) ; constructorBuilder . addParameter ( TypeName . get ( String . class ) , "type" , Modifier . FINAL ) ; constructorBuilder . addParameter ( TypeName . LONG , "sid" , Modifier . FINAL ) ; constructorBuilder . addParameter ( TypeName . get ( String . class ) , "logLevel" , Modifier . FINAL ) ; constructorBuilder . addParameter ( TypeName . LONG , "timestamp" , Modifier . FINAL ) ; constructorBuilder . addCode ( "super(message,sourceFile,lineNumber,type,sid,logLevel,timestamp);" ) ; }
add common attributes to constructor
4,580
private void addPojoField ( final TypeSpec . Builder classBuilder , final MethodSpec . Builder constructorBuilder , final String fieldName , final TypeName fieldClass ) { classBuilder . addField ( fieldClass , fieldName , Modifier . PRIVATE , Modifier . FINAL ) ; addGetter ( classBuilder , fieldName , fieldClass ) ; addConstructorParameter ( constructorBuilder , fieldName , fieldClass ) ; }
adds field to POJO adds getter and adds parameter to constructor
4,581
private void addConstructorParameter ( final MethodSpec . Builder constructorBuilder , final String attributeName , final TypeName type ) { constructorBuilder . addParameter ( type , attributeName , Modifier . FINAL ) ; constructorBuilder . addCode ( "this." + attributeName + "=" + attributeName + ";" ) ; }
adds attribute to constructor
4,582
private void addGetter ( final TypeSpec . Builder classBuilder , final String attributeName , final TypeName type ) { final String getterMethodName = "get" + attributeName . substring ( 0 , 1 ) . toUpperCase ( ) + attributeName . substring ( 1 ) ; final MethodSpec . Builder getterBuilder = MethodSpec . methodBuilder ( getterMethodName ) ; getterBuilder . returns ( type ) ; getterBuilder . addModifiers ( Modifier . PUBLIC ) ; getterBuilder . addCode ( "return this." + attributeName + ";" ) ; classBuilder . addMethod ( getterBuilder . build ( ) ) ; }
adds getter for field to class
4,583
private String hash ( String string ) { final String sha1Hex = DigestUtils . sha1Hex ( string ) ; return StringUtils . substring ( sha1Hex , 0 , 8 ) ; }
hash String with stable hash function
4,584
public T newInstance ( ) { try { return getEnhancedClass ( ) . newInstance ( ) ; } catch ( Exception e ) { logger . error ( "Could not instantiate enhanced object." , e ) ; throw ExceptionUtil . propagate ( e ) ; } }
Creates a new object that is enhanced .
4,585
public T enhance ( T t ) { if ( ! needsEnhancement ( t ) ) { return t ; } try { return getEnhancedClass ( ) . getConstructor ( baseClass ) . newInstance ( t ) ; } catch ( Exception e ) { throw new RuntimeException ( String . format ( "Could not enhance object %s (%s)" , t , t . getClass ( ) ) , e ) ; } }
Enhances the given object .
4,586
public static boolean objectIsMutable ( Object object ) { if ( object == null ) { return false ; } Class < ? > clazz = object . getClass ( ) ; return Collection . class . isAssignableFrom ( clazz ) ; }
Returns true if the given object is a mutable type that needs to be enhanced as DirtyableDBObject to prevent lost changes . Array types are ok because the default isDirty method will detect changes there .
4,587
public Container fraction ( Fraction fraction ) { if ( fraction != null ) { this . fractions . put ( fractionRoot ( fraction . getClass ( ) ) , fraction ) ; this . fractionsBySimpleName . put ( fraction . simpleName ( ) , fraction ) ; fraction . initialize ( new InitContext ( ) ) ; } return this ; }
Add a fraction to the container .
4,588
public Container iface ( String name , String expression ) { this . interfaces . add ( new Interface ( name , expression ) ) ; return this ; }
Configure a network interface .
4,589
public Archive createDefaultDeployment ( ) { try { Iterator < DefaultDeploymentFactory > providerIter = Module . getBootModuleLoader ( ) . loadModule ( ModuleIdentifier . create ( "swarm.application" ) ) . loadService ( DefaultDeploymentFactory . class ) . iterator ( ) ; if ( ! providerIter . hasNext ( ) ) { providerIter = ServiceLoader . load ( DefaultDeploymentFactory . class , ClassLoader . getSystemClassLoader ( ) ) . iterator ( ) ; } final Map < String , DefaultDeploymentFactory > factories = new HashMap < > ( ) ; while ( providerIter . hasNext ( ) ) { final DefaultDeploymentFactory factory = providerIter . next ( ) ; final DefaultDeploymentFactory current = factories . get ( factory . getType ( ) ) ; if ( current == null ) { factories . put ( factory . getType ( ) , factory ) ; } else { if ( factory . getPriority ( ) > current . getPriority ( ) ) { factories . put ( factory . getType ( ) , factory ) ; } } } final DefaultDeploymentFactory factory = factories . get ( determineDeploymentType ( ) ) ; return factory != null ? factory . create ( ) : ShrinkWrap . create ( JARArchive . class ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Provides access to the default ShrinkWrap deployment .
4,590
protected CliEnvironment createMainEnvironment ( final AtomicReference < InputReader > dynamicInputReaderRef , final AtomicReference < History > dynamicHistoryAtomicReference ) { final Map < String , ? > data = new HashMap < String , Object > ( ) ; return new CliEnv ( ) { public History history ( ) { return dynamicHistoryAtomicReference . get ( ) ; } public InputReader reader ( ) { return dynamicInputReaderRef . get ( ) ; } public Map < String , ? > userData ( ) { return data ; } } ; }
java 8 would have use Supplier which is cleaner
4,591
public Set < Explanation < OWLAxiom > > getExplanations ( OWLAxiom entailment ) throws ExplanationException { return getExplanations ( entailment , Integer . MAX_VALUE ) ; }
Gets explanations for an entailment . All explanations for the entailment will be returned .
4,592
private Object tryInitiatingObject ( String targetType , String initMethodName , List < Object > fieldObjects ) throws TransformationOperationException { Class < ? > targetClass = loadClassByName ( targetType ) ; try { if ( initMethodName == null ) { return initiateByConstructor ( targetClass , fieldObjects ) ; } else { return initiateByMethodName ( targetClass , initMethodName , fieldObjects ) ; } } catch ( Exception e ) { String message = "Unable to create the desired object. The instantiate operation will be ignored." ; message = String . format ( message , targetType ) ; getLogger ( ) . error ( message ) ; throw new TransformationOperationException ( message , e ) ; } }
Try to perform the actual initiating of the target class object . Returns the target class object or throws a TransformationOperationException if something went wrong .
4,593
private Object initiateByMethodName ( Class < ? > targetClass , String initMethodName , List < Object > objects ) throws Exception { Method method = targetClass . getMethod ( initMethodName , getClassList ( objects ) ) ; if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { return method . invoke ( null , objects . toArray ( ) ) ; } else { return method . invoke ( targetClass . newInstance ( ) , objects . toArray ( ) ) ; } }
Tries to initiate an object of the target class through the given init method name with the given object as parameter .
4,594
private Object initiateByConstructor ( Class < ? > targetClass , List < Object > objects ) throws Exception { Constructor < ? > constr = targetClass . getConstructor ( getClassList ( objects ) ) ; return constr . newInstance ( objects . toArray ( ) ) ; }
Tries to initiate an object of the target class through a constructor with the given object as parameter .
4,595
private Class < ? > [ ] getClassList ( List < Object > objects ) { Class < ? > [ ] classes = new Class < ? > [ objects . size ( ) ] ; for ( int i = 0 ; i < objects . size ( ) ; i ++ ) { classes [ i ] = objects . get ( i ) . getClass ( ) ; } return classes ; }
Returns a list containing the classes of the elements in the given object list as array .
4,596
private Class < ? > loadClassByName ( String className ) throws TransformationOperationException { Exception e ; if ( className . contains ( ";" ) ) { try { String [ ] parts = className . split ( ";" ) ; ModelDescription description = new ModelDescription ( ) ; description . setModelClassName ( parts [ 0 ] ) ; if ( parts . length > 1 ) { description . setVersionString ( new Version ( parts [ 1 ] ) . toString ( ) ) ; } return modelRegistry . loadModel ( description ) ; } catch ( Exception ex ) { e = ex ; } } else { try { return this . getClass ( ) . getClassLoader ( ) . loadClass ( className ) ; } catch ( Exception ex ) { e = ex ; } } String message = "The class %s can't be found. The instantiate operation will be ignored." ; message = String . format ( message , className ) ; getLogger ( ) . error ( message ) ; throw new TransformationOperationException ( message , e ) ; }
Tries to load the class with the given name . Throws a TransformationOperationException if this is not possible .
4,597
public void update ( Object target ) { if ( target == null ) { throw new IllegalArgumentException ( "Target to update cannot be null" ) ; } BeanWrapper bw = new BeanWrapperImpl ( target ) ; bw . registerCustomEditor ( Date . class , new CustomDateEditor ( new SimpleDateFormat ( "yyyy-MM-dd" ) , true ) ) ; for ( Map . Entry < String , Object > property : m_properties . entrySet ( ) ) { String propertyName = property . getKey ( ) ; Object value = property . getValue ( ) ; if ( value instanceof Map ) { PropertyDescriptor pd = bw . getPropertyDescriptor ( propertyName ) ; if ( ! Map . class . isAssignableFrom ( pd . getPropertyType ( ) ) || pd . getWriteMethod ( ) == null ) { value = new DynamicObject ( ( Map < String , Object > ) value ) ; } } if ( value instanceof DynamicObject ) { ( ( DynamicObject ) value ) . update ( bw . getPropertyValue ( propertyName ) ) ; } else { bw . setPropertyValue ( propertyName , value ) ; } } }
Update specified target from this object .
4,598
private IntervalCategoryDataset createDataset ( ) { TaskSeries ts = null ; TaskSeriesCollection collection = new TaskSeriesCollection ( ) ; if ( solver . getVariables ( ) . length == 0 ) { return collection ; } ts = new TaskSeries ( "All" ) ; for ( int i = 0 ; i < solver . getVariables ( ) . length ; i ++ ) { String label = solver . getVariables ( ) [ i ] . getComponent ( ) ; if ( this . selectedVariables == null || this . selectedVariables . contains ( label ) ) { SymbolicTimeline tl1 = new SymbolicTimeline ( solver , label ) ; for ( int j = 0 ; j < tl1 . getPulses ( ) . length - 1 ; j ++ ) { if ( tl1 . getValues ( ) [ j ] != null ) { long startTime = tl1 . getPulses ( ) [ j ] . longValue ( ) ; long endTime = startTime + tl1 . getDurations ( ) [ j ] . longValue ( ) ; Date startTask = new Date ( startTime ) ; Date endTask = new Date ( endTime ) ; Task task ; String value = tl1 . getValues ( ) [ j ] . toString ( ) . replace ( "[" , "" ) . replace ( "]" , "" ) ; if ( value . equals ( "true" ) ) task = new Task ( label , startTask , endTask ) ; else task = new Task ( label + " := " + value , startTask , endTask ) ; ts . add ( task ) ; } } } } collection . add ( ts ) ; return collection ; }
Creates a sample data set for a Gantt chart .
4,599
public void paint ( Graphics g , int p0 , int p1 , Shape bounds , JTextComponent c ) { try { Rectangle r = c . modelToView ( c . getCaretPosition ( ) ) ; g . setColor ( color ) ; g . fillRect ( 0 , r . y , c . getWidth ( ) , r . height ) ; if ( lastView == null ) lastView = r ; } catch ( BadLocationException ble ) { System . out . println ( ble ) ; } }
Paint the background highlight