idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
8,700
public static KeyStore getKeyStore ( String keystoreLocation , String keystoreType ) throws NoSuchAlgorithmException , CertificateException , IOException , KeyStoreException { KeyStore keystore = KeyStore . getInstance ( keystoreType ) ; InputStream is = CipherUtil . class . getResourceAsStream ( keystoreLocation ) ; i...
Returns a key store instance of the specified type from the specified resource .
106
14
8,701
public static boolean verify ( PublicKey key , String base64Signature , String content , String timestamp , int duration ) throws Exception { if ( key == null || base64Signature == null || content == null || timestamp == null ) { return false ; } try { if ( timestamp != null && duration > 0 ) { validateTime ( timestamp...
Verifies a digitally signed payload .
171
7
8,702
public static String sign ( PrivateKey key , String content ) throws Exception { Signature signature = Signature . getInstance ( SIGN_ALGORITHM ) ; signature . initSign ( key ) ; signature . update ( content . getBytes ( ) ) ; return Base64 . encodeBase64String ( signature . sign ( ) ) ; }
Returns the digital signature for the specified content .
69
9
8,703
public static void validateTime ( String timestamp , int duration ) throws Exception { Date date = getTimestampFormatter ( ) . parse ( timestamp ) ; long sign_time = date . getTime ( ) ; long now_time = System . currentTimeMillis ( ) ; long diff = now_time - sign_time ; long min_diff = diff / ( 60 * 1000 ) ; if ( min_d...
Validates the timestamp and insures that it falls within the specified duration .
107
15
8,704
public static String getTimestamp ( Date time ) { return getTimestampFormatter ( ) . format ( time == null ? new Date ( ) : time ) ; }
Converts a time to timestamp format .
35
8
8,705
public static String encrypt ( Key key , String content ) throws Exception { try { Cipher cipher = Cipher . getInstance ( CRYPTO_ALGORITHM ) ; cipher . init ( Cipher . ENCRYPT_MODE , key ) ; return Base64 . encodeBase64String ( cipher . doFinal ( content . getBytes ( ) ) ) ; } catch ( Exception e ) { log . error ( "Err...
Encrypts the content with the specified key using the default algorithm .
100
14
8,706
public static String decrypt ( Key key , String content ) throws Exception { try { Cipher cipher = Cipher . getInstance ( CRYPTO_ALGORITHM ) ; cipher . init ( Cipher . DECRYPT_MODE , key ) ; return new String ( cipher . doFinal ( Base64 . decodeBase64 ( content ) ) ) ; } catch ( Exception e ) { log . error ( "Error whi...
Decrypts the content with the specified key using the default algorithm .
97
14
8,707
public String getManifestAttribute ( String attributeName ) { if ( attributeName != null ) { Map < Object , Object > mf = getManifestAttributes ( ) ; for ( Object att : mf . keySet ( ) ) { if ( attributeName . equals ( att . toString ( ) ) ) { return mf . get ( att ) . toString ( ) ; } } } //In case not found return nu...
Retrieves a value for a specific manifest attribute . Or null if not found
95
16
8,708
public Map < Object , Object > getManifestAttributes ( ) { Map < Object , Object > manifestAttributes = null ; manifestAttributes = getExplodedWarManifestAttributes ( ) ; if ( manifestAttributes == null ) { manifestAttributes = getPackagedWarManifestAttributes ( ) ; } if ( manifestAttributes == null ) { manifestAttribu...
Reads the manifest entries for this application . Returns empty if anything fails . First tries from Exploded WAR second Packaged WAR third from classpath . if not found returns an empty map
106
37
8,709
private Map < Object , Object > getExplodedWarManifestAttributes ( ) { Map < Object , Object > manifestAttributes = null ; FileInputStream fis = null ; try { if ( servletContext != null ) { final String appServerHome = servletContext . getRealPath ( "" ) ; final File manifestFile = new File ( appServerHome , MANIFEST )...
reads the manifest from a exploded WAR
207
7
8,710
private Map < Object , Object > getPackagedWarManifestAttributes ( ) { Map < Object , Object > manifestAttributes = null ; try { LOGGER . debug ( "Using Manifest file:{}" , servletContext . getResource ( MANIFEST ) . getPath ( ) ) ; Manifest manifest = new Manifest ( servletContext . getResourceAsStream ( MANIFEST ) ) ...
Retrieve the Manifest from a packaged war
144
8
8,711
@ Override public CountryContract getCountryFromCode ( String countryCode ) { if ( StringUtils . isBlank ( countryCode ) ) return null ; CountryContract country = getKcCountryService ( ) . getCountryByAlternateCode ( countryCode ) ; if ( country == null ) { country = getKcCountryService ( ) . getCountry ( countryCode )...
This method is to get a Country object from the country code
85
12
8,712
@ Override public StateContract getStateFromName ( String countryAlternateCode , String stateName ) { CountryContract country = getCountryFromCode ( countryAlternateCode ) ; return getKcStateService ( ) . getState ( country . getCode ( ) , stateName ) ; }
This method is to get a State object from the state name
61
12
8,713
public static boolean isSegmented ( Name name , byte marker ) { return name . size ( ) > 0 && name . get ( - 1 ) . getValue ( ) . buf ( ) . get ( 0 ) == marker ; }
Determine if a name is segmented i . e . if it ends with the correct marker type .
48
22
8,714
public static long parseSegment ( Name name , byte marker ) throws EncodingException { if ( name . size ( ) == 0 ) { throw new EncodingException ( "No components to parse." ) ; } return name . get ( - 1 ) . toNumberWithMarker ( marker ) ; }
Retrieve the segment number from the last component of a name .
63
13
8,715
public static Name removeSegment ( Name name , byte marker ) { return isSegmented ( name , marker ) ? name . getPrefix ( - 1 ) : new Name ( name ) ; }
Remove a segment component from the end of a name
41
10
8,716
public static List < Data > segment ( Data template , InputStream bytes ) throws IOException { return segment ( template , bytes , DEFAULT_SEGMENT_SIZE ) ; }
Segment a stream of bytes into a list of Data packets ; this must read all the bytes first in order to determine the end segment for FinalBlockId .
37
32
8,717
public static byte [ ] readAll ( InputStream bytes ) throws IOException { ByteArrayOutputStream builder = new ByteArrayOutputStream ( ) ; int read = bytes . read ( ) ; while ( read != - 1 ) { builder . write ( read ) ; read = bytes . read ( ) ; } builder . flush ( ) ; bytes . close ( ) ; return builder . toByteArray ( ...
Read all of the bytes in an input stream .
85
10
8,718
@ Override protected void init ( Object target , PropertyInfo propInfo , PropertyGrid propGrid ) { propInfo . getConfig ( ) . setProperty ( "readonly" , Boolean . toString ( ! SecurityUtil . hasDebugRole ( ) ) ) ; super . init ( target , propInfo , propGrid ) ; List < IAction > actions = new ArrayList <> ( ActionRegist...
Initialize the list from the action registry .
141
9
8,719
public CountryCodeDataType . Enum getCountryCodeDataType ( String countryCode ) { CountryCodeDataType . Enum countryCodeDataType = null ; CountryContract country = s2SLocationService . getCountryFromCode ( countryCode ) ; if ( country != null ) { StringBuilder countryDetail = new StringBuilder ( ) ; countryDetail . app...
Create a CountryCodeDataType . Enum as defined in UniversalCodes 2 . 0 from the given country code .
153
24
8,720
public StateCodeDataType . Enum getStateCodeDataType ( String countryAlternateCode , String stateName ) { StateCodeDataType . Enum stateCodeDataType = null ; StateContract state = s2SLocationService . getStateFromName ( countryAlternateCode , stateName ) ; if ( state != null ) { StringBuilder stateDetail = new StringBu...
Create a StateCodeDataType . Enum as defined in UniversalCodes 2 . 0 from the given name of the state .
230
26
8,721
public AddressDataType getAddressDataType ( RolodexContract rolodex ) { AddressDataType addressDataType = AddressDataType . Factory . newInstance ( ) ; if ( rolodex != null ) { String street1 = rolodex . getAddressLine1 ( ) ; addressDataType . setStreet1 ( street1 ) ; String street2 = rolodex . getAddressLine2 ( ) ; if...
Create AddressDataType from rolodex entry
387
10
8,722
public HumanNameDataType getHumanNameDataType ( ProposalPersonContract person ) { HumanNameDataType humanName = HumanNameDataType . Factory . newInstance ( ) ; if ( person != null ) { humanName . setFirstName ( person . getFirstName ( ) ) ; humanName . setLastName ( person . getLastName ( ) ) ; String middleName = pers...
Create HumanNameDataType from ProposalPerson object
123
10
8,723
public HumanNameDataType getHumanNameDataType ( RolodexContract rolodex ) { HumanNameDataType humanName = HumanNameDataType . Factory . newInstance ( ) ; if ( rolodex != null ) { humanName . setFirstName ( rolodex . getFirstName ( ) ) ; humanName . setLastName ( rolodex . getLastName ( ) ) ; String middleName = rolodex...
Create a HumanNameDataType from Rolodex object
139
12
8,724
public ContactPersonDataType getContactPersonDataType ( ProposalPersonContract person ) { ContactPersonDataType contactPerson = ContactPersonDataType . Factory . newInstance ( ) ; if ( person != null ) { contactPerson . setName ( ( getHumanNameDataType ( person ) ) ) ; String phone = person . getOfficePhone ( ) ; if ( ...
Create ContactPersonDataType from ProposalPerson object
226
10
8,725
public Map < String , URL > nextImageSet ( ) { return buildImageSet ( dirs . get ( random . nextInt ( dirs . size ( ) ) ) ) ; }
Returns a random image set found as a subdirectory of the base directory .
39
15
8,726
public static Object getController ( BaseComponent comp , boolean recurse ) { return recurse ? comp . findAttribute ( Constants . ATTR_COMPOSER ) : comp . getAttribute ( Constants . ATTR_COMPOSER ) ; }
Returns the controller associated with the specified component if any .
52
11
8,727
@ SuppressWarnings ( "unchecked" ) public static < T > T getController ( BaseComponent comp , Class < T > type ) { while ( comp != null ) { Object controller = getController ( comp ) ; if ( type . isInstance ( controller ) ) { return ( T ) controller ; } comp = comp . getParent ( ) ; } return null ; }
Locates and returns a controller of the given type by searching up the component tree starting at the specified component .
80
22
8,728
@ Override public void afterInitialized ( BaseComponent comp ) { root = ( BaseUIComponent ) comp ; this . comp = root ; comp . setAttribute ( Constants . ATTR_COMPOSER , this ) ; comp . addEventListener ( ThreadEx . ON_THREAD_COMPLETE , threadCompletionListener ) ; appContext = SpringUtil . getAppContext ( ) ; appFrame...
Override the doAfterCompose method to set references to the application context and the framework and register the controller with the framework .
115
25
8,729
public static DropContainer render ( BaseComponent dropRoot , BaseComponent droppedItem ) { IDropRenderer dropRenderer = DropUtil . getDropRenderer ( droppedItem ) ; if ( dropRenderer == null || ! dropRenderer . isEnabled ( ) ) { return null ; } BaseComponent renderedItem = dropRenderer . renderDroppedItem ( droppedIte...
Renders a droppedItem in a container .
200
9
8,730
private static DropContainer create ( BaseComponent dropRoot , BaseComponent cmpt , String title , List < ActionListener > actionListeners ) { DropContainer dc = ( DropContainer ) PageUtil . createPage ( TEMPLATE , null ) ; dc . actionListeners = actionListeners ; dc . setTitle ( title ) ; dc . setDropid ( SCLASS ) ; d...
Creates a new container for the contents to be rendered by the drop provider .
128
16
8,731
@ Override public void doAction ( Action action ) { switch ( action ) { case REMOVE : close ( ) ; break ; case HIDE : setVisible ( false ) ; break ; case SHOW : setVisible ( true ) ; break ; case COLLAPSE : setSize ( Size . MINIMIZED ) ; break ; case EXPAND : setSize ( Size . NORMAL ) ; break ; case TOP : moveToTop ( )...
Perform the specified action on the drop container .
100
10
8,732
@ EventHandler ( "drop" ) private void onDrop ( DropEvent event ) { BaseComponent dragged = event . getRelatedTarget ( ) ; if ( dragged instanceof DropContainer ) { getParent ( ) . addChild ( dragged , this ) ; } }
Supports dragging drop container to a new position in the stream .
54
13
8,733
public Span addContent ( Row row , String label ) { Span cell = new Span ( ) ; cell . addChild ( CWFUtil . getTextComponent ( label ) ) ; row . addChild ( cell ) ; return cell ; }
Adds a cell with the specified content to the grid row .
50
12
8,734
public Cell addCell ( Row row , String label ) { Cell cell = new Cell ( label ) ; row . addChild ( cell ) ; return cell ; }
Adds a cell to the grid row .
33
8
8,735
public Column addColumn ( Grid grid , String label , String width , String sortBy ) { Column column = new Column ( ) ; grid . getColumns ( ) . addChild ( column ) ; column . setLabel ( label ) ; column . setWidth ( width ) ; column . setSortComparator ( sortBy ) ; column . setSortOrder ( SortOrder . ASCENDING ) ; retur...
Adds a column to a grid .
86
7
8,736
public String outputNameFor ( String output ) { Report report = openReport ( output ) ; return outputNameOf ( report ) ; }
Utility method to guess the output name generated for this output parameter .
28
14
8,737
@ Override protected void init ( Object target , PropertyInfo propInfo , PropertyGrid propGrid ) { super . init ( target , propInfo , propGrid ) ; Iterable < ? > iter = ( Iterable < ? > ) propInfo . getPropertyType ( ) . getSerializer ( ) ; for ( Object value : iter ) { appendItem ( value . toString ( ) , value ) ; } }
Initialize the list based on the configuration data which can specify an enumeration class an iterable class or the id of an iterable bean .
86
29
8,738
public Jashing bootstrap ( ) { if ( bootstrapped . compareAndSet ( false , true ) ) { /* bootstrap event sources* */ ServiceManager eventSources = injector . getInstance ( ServiceManager . class ) ; eventSources . startAsync ( ) ; /* bootstrap server */ Service application = injector . getInstance ( JashingServer . cla...
Bootstaps Jashing . This operation is allowed only once . Bootstrapping already started Jashing is not permitted
139
23
8,739
public void shutdown ( ) { if ( bootstrapped . compareAndSet ( true , false ) ) { LOGGER . info ( "Shutting down Jashing..." ) ; injector . getInstance ( ServiceManager . class ) . stopAsync ( ) . awaitStopped ( ) ; injector . getInstance ( JashingServer . class ) . stopAsync ( ) . awaitTerminated ( ) ; /* shutdown met...
Shutdowns Jashing . Permitted only for bootstrapped instance
176
13
8,740
public static void copyAttributes ( Element source , Map < String , String > dest ) { NamedNodeMap attributes = source . getAttributes ( ) ; if ( attributes != null ) { for ( int i = 0 ; i < attributes . getLength ( ) ; i ++ ) { Node attribute = attributes . item ( i ) ; dest . put ( attribute . getNodeName ( ) , attri...
Copy attributes from a DOM node to a map .
91
10
8,741
public static void copyAttributes ( Map < String , String > source , Element dest ) { for ( Entry < String , String > entry : source . entrySet ( ) ) { dest . setAttribute ( entry . getKey ( ) , entry . getValue ( ) ) ; } }
Copy attributes from a map to a DOM node .
58
10
8,742
private void initTopicTree ( ) { DefaultMutableTreeNode topicTree = getDataAsTree ( ) ; if ( topicTree != null ) { initTopicTree ( rootNode , topicTree . getRoot ( ) ) ; } }
Initializes the topic tree if there is one associated with this view .
49
14
8,743
private void initTopicTree ( HelpTopicNode htnParent , TreeNode ttnParent ) { for ( int i = 0 ; i < ttnParent . getChildCount ( ) ; i ++ ) { TreeNode ttnChild = ttnParent . getChildAt ( i ) ; HelpTopic ht = getTopic ( ttnChild ) ; HelpTopicNode htnChild = new HelpTopicNode ( ht ) ; htnParent . addChild ( htnChild ) ; i...
Duplicates JavaHelp topic tree into HelpTopicNode - based tree .
116
15
8,744
protected DefaultMutableTreeNode getDataAsTree ( ) { try { return ( DefaultMutableTreeNode ) MethodUtils . invokeMethod ( view , "getDataAsTree" , null ) ; } catch ( Exception e ) { return null ; } }
Invokes the getDataAsTree method on the underlying view if such a method exists .
54
18
8,745
public static Treenode findNodeByLabel ( Treeview tree , String label , boolean caseSensitive ) { for ( Treenode item : tree . getChildren ( Treenode . class ) ) { if ( caseSensitive ? label . equals ( item . getLabel ( ) ) : label . equalsIgnoreCase ( item . getLabel ( ) ) ) { return item ; } } return null ; }
Search the entire tree for a tree item matching the specified label .
86
13
8,746
public static String getPath ( Treenode item , boolean useLabels ) { StringBuilder sb = new StringBuilder ( ) ; boolean needsDelim = false ; while ( item != null ) { if ( needsDelim ) { sb . insert ( 0 , ' ' ) ; } else { needsDelim = true ; } sb . insert ( 0 , useLabels ? item . getLabel ( ) : item . getIndex ( ) ) ; i...
Returns the path of the specified tree node . This consists of the indexes or labels of this and all parent nodes separated by a \ character .
121
28
8,747
public static void sort ( BaseComponent parent , boolean recurse ) { if ( parent == null || parent . getChildren ( ) . size ( ) < 2 ) { return ; } int i = 1 ; int size = parent . getChildren ( ) . size ( ) ; while ( i < size ) { Treenode item1 = ( Treenode ) parent . getChildren ( ) . get ( i - 1 ) ; Treenode item2 = (...
Alphabetically sorts children under the specified parent .
188
10
8,748
private static int compare ( Treenode item1 , Treenode item2 ) { String label1 = item1 . getLabel ( ) ; String label2 = item2 . getLabel ( ) ; return label1 == label2 ? 0 : label1 == null ? - 1 : label2 == null ? - 1 : label1 . compareToIgnoreCase ( label2 ) ; }
Case insensitive comparison of labels of two tree items .
81
10
8,749
private static Treenode search ( Iterable < Treenode > root , String text , ITreenodeSearch search ) { for ( Treenode node : root ) { if ( search . isMatch ( node , text ) ) { return node ; } } return null ; }
Search the tree for a tree node whose label contains the specified text .
58
14
8,750
public Command get ( String commandName , boolean forceCreate ) { Command command = commands . get ( commandName ) ; if ( command == null && forceCreate ) { command = new Command ( commandName ) ; add ( command ) ; } return command ; }
Retrieves the command associated with the specified name from the registry .
53
14
8,751
private void bindShortcuts ( Map < Object , Object > shortcuts ) { for ( Object commandName : shortcuts . keySet ( ) ) { bindShortcuts ( commandName . toString ( ) , shortcuts . get ( commandName ) . toString ( ) ) ; } }
Binds the shortcuts specified in the map to the associated commands . The map key is the command name and the associated value is a list of shortcuts bound to the command .
57
34
8,752
public PropertiesLoaderBuilder loadProperty ( String name ) { if ( env . containsProperty ( name ) ) { props . put ( name , env . getProperty ( name ) ) ; } return this ; }
Loads a property from Spring Context by the name .
42
11
8,753
public PropertiesLoaderBuilder addProperty ( String name , String value ) { props . put ( name , value ) ; return this ; }
Adds a new property . Giving both name and value . This methods does not lookup in the Spring Context it only adds property and value as given .
27
29
8,754
protected < C extends BaseUIComponent > C createCell ( BaseComponent parent , Object value , String prefix , String style , String width , Class < C > clazz ) { C container = null ; try { container = clazz . newInstance ( ) ; container . setParent ( parent ) ; container . setStyles ( cellStyle ) ; if ( width != null ) ...
Creates a component containing a label with the specified parameters .
147
12
8,755
public static byte [ ] removeEntry ( byte [ ] a , int idx ) { byte [ ] b = new byte [ a . length - 1 ] ; for ( int i = 0 ; i < b . length ; i ++ ) { if ( i < idx ) { b [ i ] = a [ i ] ; } else { b [ i ] = a [ i + 1 ] ; } } return b ; }
Gets a copy of the array with the specified entry removed .
89
13
8,756
private Map < String , Object > getConfigParams ( Class < ? > clazz ) { Map < String , Object > params = new HashMap <> ( ) ; for ( Field field : clazz . getDeclaredFields ( ) ) { if ( Modifier . isStatic ( field . getModifiers ( ) ) && field . getName ( ) . endsWith ( "_CONFIG" ) ) { try { String key = field . get ( n...
A bit of a hack to return configuration parameters from the Spring property store as a map which is required to initialize Kafka consumers and producers . Uses reflection on the specified class to enumerate static fields with a name ending in _CONFIG . By Kafka convention these fields contain the names of configuration...
163
59
8,757
public static String buildWhereClause ( Object object , MapSqlParameterSource params ) throws IllegalAccessException , InvocationTargetException , NoSuchMethodException { LOGGER . debug ( "Building query" ) ; final StringBuilder query = new StringBuilder ( ) ; boolean first = true ; for ( Field field : object . getClas...
Builds a where clause based upon the object values
552
10
8,758
public static void show ( boolean manage , String deflt , IEventListener closeListener ) { Map < String , Object > args = new HashMap <> ( ) ; args . put ( "manage" , manage ) ; args . put ( "deflt" , deflt ) ; PopupDialog . show ( RESOURCE_PREFIX + "layoutManager.fsp" , args , true , true , true , closeListener ) ; }
Invokes the layout manager dialog .
94
7
8,759
@ Override public int compareTo ( IManagedContext < DomainClass > o ) { int pri1 = o . getPriority ( ) ; int pri2 = getPriority ( ) ; return this == o ? 0 : pri1 < pri2 ? - 1 : 1 ; }
Compares by priority with higher priorities collating first .
60
11
8,760
public static void pruneMenus ( BaseComponent parent ) { while ( parent != null && parent instanceof BaseMenuComponent ) { if ( parent . getChildren ( ) . isEmpty ( ) ) { BaseComponent newParent = parent . getParent ( ) ; parent . destroy ( ) ; parent = newParent ; } else { break ; } } }
Recursively remove empty menu container elements . This is done after removing menu items to keep the menu structure lean .
73
23
8,761
public static BaseMenuComponent findMenu ( BaseComponent parent , String label , BaseComponent insertBefore ) { for ( BaseMenuComponent child : parent . getChildren ( BaseMenuComponent . class ) ) { if ( label . equalsIgnoreCase ( child . getLabel ( ) ) ) { return child ; } } BaseMenuComponent cmp = createMenuOrMenuite...
Returns the menu with the specified label or creates one if it does not exist .
106
16
8,762
public static void sortMenu ( BaseComponent parent , int startIndex , int endIndex ) { List < BaseComponent > items = parent . getChildren ( ) ; int bottom = startIndex + 1 ; for ( int i = startIndex ; i < endIndex ; ) { BaseComponent item1 = items . get ( i ++ ) ; BaseComponent item2 = items . get ( i ) ; if ( item1 i...
Alphabetically sorts a range of menu items .
166
10
8,763
public static String getPath ( BaseMenuComponent comp ) { StringBuilder sb = new StringBuilder ( ) ; getPath ( comp , sb ) ; return sb . toString ( ) ; }
Returns the path of the given menu or menu item .
42
11
8,764
private static void getPath ( BaseComponent comp , StringBuilder sb ) { while ( comp instanceof BaseMenuComponent ) { sb . insert ( 0 , "\\" + ( ( BaseMenuComponent ) comp ) . getLabel ( ) ) ; comp = comp . getParent ( ) ; } }
Recurses parent menu nodes to build the menu path .
63
11
8,765
@ Override public void onPluginEvent ( PluginEvent event ) { switch ( event . getAction ( ) ) { case SUBSCRIBE : // Upon initial subscription, begin listening for specified generic events. plugin = event . getPlugin ( ) ; doSubscribe ( true ) ; break ; case LOAD : // Stop listening once loaded. plugin . unregisterListe...
Listen for plugin lifecycle events .
112
7
8,766
@ Override public void retry ( Face face , Interest interest , OnData onData , OnTimeout onTimeout ) throws IOException { RetryContext context = new RetryContext ( face , interest , onData , onTimeout ) ; retryInterest ( context ) ; }
On timeout retry the request until the maximum number of allowed retries is reached .
57
17
8,767
private synchronized void retryInterest ( RetryContext context ) throws IOException { LOGGER . info ( "Retrying interest: " + context . interest . toUri ( ) ) ; context . face . expressInterest ( context . interest , context , context ) ; totalRetries ++ ; }
Synchronized helper method to prevent multiple threads from mashing totalRetries
61
15
8,768
public void register ( ) throws IOException { try { registeredPrefixId = face . registerPrefix ( prefix , this , new OnRegisterFailed ( ) { @ Override public void onRegisterFailed ( Name prefix ) { registeredPrefixId = UNREGISTERED ; logger . log ( Level . SEVERE , "Failed to register prefix: " + prefix . toUri ( ) ) ;...
Register a prefix for responding to interests .
166
8
8,769
public static boolean isMessageExcluded ( Message message , Recipient recipient ) { return isMessageExcluded ( message , recipient . getType ( ) , recipient . getValue ( ) ) ; }
Returns true if the message should be excluded based on the given recipient . A message is considered excluded if it has any constraint on the recipient s type and does not have a matching recipient for that type .
40
40
8,770
public static boolean isMessageExcluded ( Message message , RecipientType recipientType , String recipientValue ) { Recipient [ ] recipients = ( Recipient [ ] ) message . getMetadata ( "cwf.pub.recipients" ) ; if ( recipients == null || recipients . length == 0 ) { return false ; } boolean excluded = false ; for ( Reci...
Returns true if the message should be excluded based on the given recipient values . A message is considered excluded if it has any constraint on the recipient type and does not have a matching recipient for that type .
127
40
8,771
public String getLabel ( ) { String label = getProperty ( labelProperty ) ; label = label == null ? node . getLabel ( ) : label ; if ( label == null ) { label = getDefaultInstanceName ( ) ; setProperty ( labelProperty , label ) ; } return label ; }
Returns the label property value .
62
6
8,772
private String getProperty ( String propertyName ) { return propertyName == null ? null : ( String ) getPropertyValue ( propertyName ) ; }
Returns a property value .
30
5
8,773
public QueueSpec setField ( String fieldName , Object value ) { fieldData . put ( fieldName , value ) ; return this ; }
Set a field s value .
30
6
8,774
public static void changeUser ( IUser user ) { try { getUserContext ( ) . requestContextChange ( user ) ; } catch ( Exception e ) { log . error ( "Error during user context change." , e ) ; } }
Request a user context change .
50
6
8,775
@ SuppressWarnings ( "unchecked" ) public static ISharedContext < IUser > getUserContext ( ) { return ( ISharedContext < IUser > ) ContextManager . getInstance ( ) . getSharedContext ( UserContext . class . getName ( ) ) ; }
Returns the managed user context .
64
6
8,776
private PHSCoverLetter12Document getPHSCoverLetter ( ) { PHSCoverLetter12Document phsCoverLetterDocument = PHSCoverLetter12Document . Factory . newInstance ( ) ; PHSCoverLetter12 phsCoverLetter = PHSCoverLetter12 . Factory . newInstance ( ) ; CoverLetterFile coverLetterFile = CoverLetterFile . Factory . newInstance ( )...
This method is used to get PHSCoverLetter12Document attachment from the narrative attachments .
280
18
8,777
private void setBudgetYearDataType ( RRBudget1013 rrBudget , BudgetPeriodDto periodInfo ) { BudgetYearDataType budgetYear = rrBudget . addNewBudgetYear ( ) ; if ( periodInfo != null ) { budgetYear . setBudgetPeriodStartDate ( s2SDateTimeService . convertDateToCalendar ( periodInfo . getStartDate ( ) ) ) ; budgetYear . ...
This method gets BudgetYearDataType details like BudgetPeriodStartDate BudgetPeriodEndDate BudgetPeriod KeyPersons OtherPersonnel TotalCompensation Equipment ParticipantTraineeSupportCosts Travel OtherDirectCosts DirectCosts IndirectCosts CognizantFederalAgency TotalCosts based on BudgetPeriodInfo for the RRBudget1013 ...
462
73
8,778
@ Override public void setApplicationContext ( ApplicationContext appContext ) throws BeansException { try ( InputStream is = originalResource . getInputStream ( ) ; ) { ConfigurableListableBeanFactory beanFactory = ( ( AbstractRefreshableApplicationContext ) appContext ) . getBeanFactory ( ) ; StringBuilder sb = new S...
Use the application context to resolve any embedded property values within the original resource .
212
15
8,779
protected List < String > getCellLines ( String explanation ) { int startPos = 0 ; List < String > cellLines = new ArrayList <> ( ) ; for ( int commaPos = 0 ; commaPos > - 1 ; ) { commaPos = explanation . indexOf ( "," , startPos ) ; if ( commaPos >= 0 ) { String cellLine = ( explanation . substring ( startPos , commaP...
This method splits the passed explanation comprising cell line information puts into a list and returns the list .
167
19
8,780
public void reset ( ) throws IOException { if ( t1 == null || t2 == null ) { throw new IllegalStateException ( "Cannot swap after close." ) ; } if ( getOutput ( ) . length ( ) > 0 ) { toggle = ! toggle ; // reset the new output to length()=0 try ( OutputStream unused = new FileOutputStream ( getOutput ( ) ) ) { //this ...
Resets the input and output file before writing to the output again
118
13
8,781
public void close ( ) throws IOException { if ( t1 == null || t2 == null ) { return ; } try { if ( getOutput ( ) . length ( ) > 0 ) { Files . copy ( getOutput ( ) . toPath ( ) , output . toPath ( ) , StandardCopyOption . REPLACE_EXISTING ) ; } else if ( getInput ( ) . length ( ) > 0 ) { Files . copy ( getInput ( ) . to...
Closes the temporary files and copies the result to the output file . Closing the TempFileHandler is a mandatory last step after which no other calls to the object should be made .
169
36
8,782
public AddressRequireCountryDataType getAddressRequireCountryDataType ( DepartmentalPersonDto person ) { AddressRequireCountryDataType address = AddressRequireCountryDataType . Factory . newInstance ( ) ; if ( person != null ) { String street1 = person . getAddress1 ( ) ; address . setStreet1 ( street1 ) ; String stree...
Create AddressRequireCountryDataType from DepartmentalPerson object
278
12
8,783
public HumanNameDataType getHumanNameDataType ( KeyPersonDto keyPerson ) { HumanNameDataType humanName = HumanNameDataType . Factory . newInstance ( ) ; humanName . setFirstName ( keyPerson . getFirstName ( ) ) ; humanName . setLastName ( keyPerson . getLastName ( ) ) ; String middleName = keyPerson . getMiddleName ( )...
Create HumanNameDataType from KeyPersonInfo object
119
10
8,784
public void sendMessage ( String channel , Message message ) { ensureChannel ( channel ) ; admin . getRabbitTemplate ( ) . convertAndSend ( exchange . getName ( ) , channel , message ) ; }
Sends an event to the default exchange .
44
9
8,785
protected boolean putToQueue ( IQueueMessage < ID , DATA > msg ) { try { BytesMessage message = getProducerSession ( ) . createBytesMessage ( ) ; message . writeBytes ( serialize ( msg ) ) ; getMessageProducer ( ) . send ( message ) ; return true ; } catch ( Exception e ) { throw e instanceof QueueException ? ( QueueEx...
Puts a message to ActiveMQ queue .
96
9
8,786
public boolean hasException ( Class < ? extends Throwable > type ) { for ( Throwable exception : exceptions ) { if ( type . isInstance ( exception ) ) { return true ; } } return false ; }
Returns true if this instance contains an exception of the given type .
44
13
8,787
@ Override public StackTraceElement [ ] getStackTrace ( ) { ArrayList < StackTraceElement > stackTrace = new ArrayList <> ( ) ; for ( Throwable exception : exceptions ) { stackTrace . addAll ( Arrays . asList ( exception . getStackTrace ( ) ) ) ; } return stackTrace . toArray ( new StackTraceElement [ stackTrace . size...
Returns the stack trace which is the union of all stack traces of contained exceptions .
96
16
8,788
public int dot ( int [ ] other ) { int dot = 0 ; for ( int c = 0 ; c < used && indices [ c ] < other . length ; c ++ ) { if ( indices [ c ] > Integer . MAX_VALUE ) { break ; } dot += values [ c ] * other [ SafeCast . safeLongToInt ( indices [ c ] ) ] ; } return dot ; }
Computes the dot product of this vector with the given vector .
85
13
8,789
public int dot ( int [ ] [ ] matrix , int col ) { int ret = 0 ; for ( int c = 0 ; c < used && indices [ c ] < matrix . length ; c ++ ) { if ( indices [ c ] > Integer . MAX_VALUE ) { break ; } ret += values [ c ] * matrix [ SafeCast . safeLongToInt ( indices [ c ] ) ] [ col ] ; } return ret ; }
Computes the dot product of this vector with the column of the given matrix .
93
16
8,790
public static void copyResourceToFile ( String resourceAbsoluteClassPath , File targetFile ) throws IOException { InputStream is = ResourceUtil . class . getResourceAsStream ( resourceAbsoluteClassPath ) ; if ( is == null ) { throw new IOException ( "Resource not found! " + resourceAbsoluteClassPath ) ; } OutputStream ...
Copy resources to file system .
177
6
8,791
public static String getAbsolutePath ( String classPath ) { URL configUrl = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( classPath . substring ( 1 ) ) ; if ( configUrl == null ) { configUrl = ResourceUtil . class . getResource ( classPath ) ; } if ( configUrl == null ) { return null ; } try { ...
Get absolute path in file system from a classPath . If this resource not exists return null .
118
19
8,792
@ Override public void setFocus ( ) { Radiobutton radio = editor . getSelected ( ) ; if ( radio == null ) { radio = ( Radiobutton ) editor . getChildren ( ) . get ( 0 ) ; } radio . setFocus ( true ) ; }
Sets focus to the selected radio button .
61
9
8,793
public static DesignContextMenu getInstance ( ) { Page page = ExecutionContext . getPage ( ) ; DesignContextMenu contextMenu = page . getAttribute ( DesignConstants . ATTR_DESIGN_MENU , DesignContextMenu . class ) ; if ( contextMenu == null ) { contextMenu = create ( ) ; page . setAttribute ( DesignConstants . ATTR_DES...
Returns an instance of the design context menu . This is a singleton with the page scope and is cached once created .
95
24
8,794
public static DesignContextMenu create ( ) { return PageUtil . createPage ( DesignConstants . RESOURCE_PREFIX + "designContextMenu.fsp" , ExecutionContext . getPage ( ) ) . get ( 0 ) . getAttribute ( "controller" , DesignContextMenu . class ) ; }
Creates an instance of the design context menu .
66
10
8,795
private void disable ( IDisable comp , boolean disabled ) { if ( comp != null ) { comp . setDisabled ( disabled ) ; if ( comp instanceof BaseUIComponent ) { ( ( BaseUIComponent ) comp ) . addStyle ( "opacity" , disabled ? ".2" : "1" ) ; } } }
Sets the disabled state of the specified component .
73
10
8,796
public static double logAdd ( double x , double y ) { if ( FastMath . useLogAddTable ) { return SmoothedLogAddTable . logAdd ( x , y ) ; } else { return FastMath . logAddExact ( x , y ) ; } }
Adds two probabilities that are stored as log probabilities .
59
10
8,797
public static int mod ( int val , int mod ) { val = val % mod ; if ( val < 0 ) { val += mod ; } return val ; }
Modulo operator where all numbers evaluate to a positive remainder .
34
12
8,798
protected void prepareXMLReader ( ) throws VerifierConfigurationException { try { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; reader = factory . newSAXParser ( ) . getXMLReader ( ) ; } catch ( SAXException e ) { throw new VerifierConfigurationException ( e ) ; ...
Creates and sets a sole instance of XMLReader which will be used by this verifier .
104
19
8,799
private Mode makeBuiltinMode ( String name , Class cls ) { // lookup/create a mode with the given name. Mode mode = lookupCreateMode ( name ) ; // Init the element action set for this mode. ActionSet actions = new ActionSet ( ) ; // from the current mode we will use further the built in mode. ModeUsage modeUsage = new ...
Makes a built in mode .
388
7