idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
8,100
public Factor getOutsideEntries ( int spanStart , int spanEnd ) { Tensor entries = new DenseTensor ( parentVar . getVariableNumsArray ( ) , parentVar . getVariableSizes ( ) , outsideChart [ spanStart ] [ spanEnd ] ) ; return new TableFactor ( parentVar , entries ) ; }
Get the outside unnormalized probabilities over productions at a particular span in the tree .
8,101
public Factor getMarginalEntries ( int spanStart , int spanEnd ) { return getOutsideEntries ( spanStart , spanEnd ) . product ( getInsideEntries ( spanStart , spanEnd ) ) ; }
Get the marginal unnormalized probabilities over productions at a particular node in the tree .
8,102
public CfgParseTree getBestParseTree ( ) { Factor rootMarginal = getMarginalEntries ( 0 , chartSize ( ) - 1 ) ; Assignment bestAssignment = rootMarginal . getMostLikelyAssignments ( 1 ) . get ( 0 ) ; return getBestParseTree ( bestAssignment . getOnlyValue ( ) ) ; }
Gets the best parse tree spanning the entire sentence .
8,103
public CfgParseTree getBestParseTreeWithSpan ( Object root , int spanStart , int spanEnd ) { Preconditions . checkState ( ! sumProduct ) ; Assignment rootAssignment = parentVar . outcomeArrayToAssignment ( root ) ; int rootNonterminalNum = parentVar . assignmentToIntArray ( rootAssignment ) [ 0 ] ; double prob = insideChart [ spanStart ] [ spanEnd ] [ rootNonterminalNum ] * outsideChart [ spanStart ] [ spanEnd ] [ rootNonterminalNum ] ; if ( prob == 0.0 ) { return null ; } int splitInd = splitBackpointers [ spanStart ] [ spanEnd ] [ rootNonterminalNum ] ; if ( splitInd < 0 ) { long terminalKey = backpointers [ spanStart ] [ spanEnd ] [ rootNonterminalNum ] ; int positiveSplitInd = ( - 1 * splitInd ) - 1 ; int terminalSpanStart = positiveSplitInd / numTerminals ; int terminalSpanEnd = positiveSplitInd % numTerminals ; VariableNumMap vars = parentVar . union ( ruleTypeVar ) ; int [ ] dimKey = TableFactor . zero ( vars ) . getWeights ( ) . keyNumToDimKey ( terminalKey ) ; Assignment a = vars . intArrayToAssignment ( dimKey ) ; Object ruleType = a . getValue ( ruleTypeVar . getOnlyVariableNum ( ) ) ; List < Object > terminalList = Lists . newArrayList ( ) ; terminalList . addAll ( terminals . subList ( terminalSpanStart , terminalSpanEnd + 1 ) ) ; return new CfgParseTree ( root , ruleType , terminalList , prob , spanStart , spanEnd ) ; } else { long binaryRuleKey = backpointers [ spanStart ] [ spanEnd ] [ rootNonterminalNum ] ; int [ ] binaryRuleComponents = binaryRuleDistribution . coerceToDiscrete ( ) . getWeights ( ) . keyNumToDimKey ( binaryRuleKey ) ; Assignment best = binaryRuleDistribution . getVars ( ) . intArrayToAssignment ( binaryRuleComponents ) ; Object leftRoot = best . getValue ( leftVar . getOnlyVariableNum ( ) ) ; Object rightRoot = best . getValue ( rightVar . getOnlyVariableNum ( ) ) ; Object ruleType = best . getValue ( ruleTypeVar . getOnlyVariableNum ( ) ) ; Preconditions . checkArgument ( spanStart + splitInd != spanEnd , "CFG parse decoding error: %s %s %s" , spanStart , spanEnd , splitInd ) ; CfgParseTree leftTree = getBestParseTreeWithSpan ( leftRoot , spanStart , spanStart + splitInd ) ; CfgParseTree rightTree = getBestParseTreeWithSpan ( rightRoot , spanStart + splitInd + 1 , spanEnd ) ; Preconditions . checkState ( leftTree != null ) ; Preconditions . checkState ( rightTree != null ) ; return new CfgParseTree ( root , ruleType , leftTree , rightTree , prob ) ; } }
If this tree contains max - marginals recover the best parse subtree for a given symbol with the specified span .
8,104
public int get ( long idx ) { if ( idx < 0 || idx >= size ) { return 0 ; } return elements [ SafeCast . safeLongToInt ( idx + start ) ] ; }
Gets the idx th entry in the vector .
8,105
protected Element findTag ( String tagName , Element element ) { Node result = element . getFirstChild ( ) ; while ( result != null ) { if ( result instanceof Element && ( tagName . equals ( ( ( Element ) result ) . getNodeName ( ) ) || tagName . equals ( ( ( Element ) result ) . getLocalName ( ) ) ) ) { break ; } result = result . getNextSibling ( ) ; } return ( Element ) result ; }
Find the child element whose tag matches the specified tag name .
8,106
protected NodeList getTagChildren ( String tagName , Element element ) { return element . getNamespaceURI ( ) == null ? element . getElementsByTagName ( tagName ) : element . getElementsByTagNameNS ( element . getNamespaceURI ( ) , tagName ) ; }
Returns the children under the specified tag . Compensates for namespace usage .
8,107
protected void addProperties ( Element element , BeanDefinitionBuilder builder ) { NamedNodeMap attributes = element . getAttributes ( ) ; for ( int i = 0 ; i < attributes . getLength ( ) ; i ++ ) { Node node = attributes . item ( i ) ; String attrName = getNodeName ( node ) ; attrName = "class" . equals ( attrName ) ? "clazz" : attrName ; builder . addPropertyValue ( attrName , node . getNodeValue ( ) ) ; } }
Adds all attributes of the specified elements as properties in the current builder .
8,108
protected String getNodeName ( Node node ) { String result = node . getLocalName ( ) ; return result == null ? node . getNodeName ( ) : result ; }
Returns the node name . First tries local name . If this is null returns instead the full node name .
8,109
protected Object fromXml ( String xml , String tagName ) throws Exception { Document document = XMLUtil . parseXMLFromString ( xml ) ; NodeList nodeList = document . getElementsByTagName ( tagName ) ; if ( nodeList == null || nodeList . getLength ( ) != 1 ) { throw new DOMException ( DOMException . NOT_FOUND_ERR , "Top level tag '" + tagName + "' was not found." ) ; } Element element = ( Element ) nodeList . item ( 0 ) ; Class < ? > beanClass = getBeanClass ( element ) ; BeanDefinitionBuilder builder = BeanDefinitionBuilder . rootBeanDefinition ( beanClass ) ; doParse ( element , builder ) ; DefaultListableBeanFactory factory = new DefaultListableBeanFactory ( ) ; factory . setParentBeanFactory ( SpringUtil . getAppContext ( ) ) ; AbstractBeanDefinition beanDefinition = builder . getBeanDefinition ( ) ; factory . registerBeanDefinition ( tagName , beanDefinition ) ; return factory . getBean ( tagName ) ; }
Parses an xml extension from an xml string .
8,110
protected String getResourcePath ( ParserContext parserContext ) { if ( parserContext != null ) { try { Resource resource = parserContext . getReaderContext ( ) . getResource ( ) ; return resource == null ? null : resource . getURL ( ) . getPath ( ) ; } catch ( IOException e ) { } } return null ; }
Return the path of the resource being parsed .
8,111
protected void removeAction ( ) { component . removeEventListener ( eventName , this ) ; if ( component . getAttribute ( attrName ) == this ) { component . removeAttribute ( attrName ) ; } }
Remove this listener from its associated component .
8,112
public boolean isHelpSetFile ( String fileName ) { if ( helpSetFilter == null ) { helpSetFilter = new WildcardFileFilter ( helpSetPattern ) ; } return helpSetFilter . accept ( new File ( fileName ) ) ; }
Returns true if the file name matches the pattern specified for the main help set file .
8,113
public IResourceIterator load ( String archiveName ) throws Exception { File file = new File ( archiveName ) ; if ( file . isDirectory ( ) ) { return new DirectoryIterator ( file ) ; } return iteratorClass . getConstructor ( String . class ) . newInstance ( archiveName ) ; }
Returns a resource iterator instance for the given archive name .
8,114
public void setUrl ( String url ) { this . url = url ; if ( child != null ) { child . destroy ( ) ; child = null ; } if ( url . startsWith ( "http" ) || ! url . endsWith ( ".fsp" ) ) { child = new Iframe ( ) ; ( ( Iframe ) child ) . setSrc ( url ) ; } else { child = new Import ( ) ; ( ( Import ) child ) . setSrc ( url ) ; } fullSize ( child ) ; root . addChild ( child ) ; }
Sets the URL of the content to be retrieved . If the URL starts with http it is fetched into an iframe . Otherwise an include component is created and used to fetch the content .
8,115
public ISerializer < ? > get ( Class < ? > clazz ) { ISerializer < ? > contextSerializer = super . get ( clazz ) ; if ( contextSerializer != null ) { return contextSerializer ; } for ( ISerializer < ? > item : this ) { if ( item . getType ( ) . isAssignableFrom ( clazz ) ) { return item ; } } return null ; }
Returns the item associated with the specified key or null if not found .
8,116
public ElementUI materialize ( ElementUI parent ) { boolean isDesktop = parent instanceof ElementDesktop ; if ( isDesktop ) { parent . getDefinition ( ) . initElement ( parent , root ) ; } materializeChildren ( parent , root , ! isDesktop ) ; ElementUI element = parent . getLastVisibleChild ( ) ; if ( element != null ) { element . getRoot ( ) . activate ( true ) ; } return element ; }
Materializes the layout under the specified parent starting from the layout origin .
8,117
private void materializeChildren ( ElementBase parent , LayoutElement node , boolean ignoreInternal ) { for ( LayoutNode child : node . getChildren ( ) ) { PluginDefinition def = child . getDefinition ( ) ; ElementBase element = ignoreInternal && def . isInternal ( ) ? null : createElement ( parent , child ) ; if ( element != null ) { materializeChildren ( element , ( LayoutElement ) child , false ) ; } } for ( LayoutTrigger trigger : node . getTriggers ( ) ) { ElementTrigger trg = new ElementTrigger ( ) ; trg . addTarget ( ( ElementUI ) parent ) ; createElement ( trg , trigger . getChild ( LayoutTriggerCondition . class ) ) ; createElement ( trg , trigger . getChild ( LayoutTriggerAction . class ) ) ; ( ( ElementUI ) parent ) . addTrigger ( trg ) ; } }
Materializes the layout under the specified parent .
8,118
public void setName ( String value ) { layoutName = value ; if ( root != null ) { root . getAttributes ( ) . put ( "name" , value ) ; } }
Sets the name of the current layout .
8,119
public boolean saveToProperty ( LayoutIdentifier layoutId ) { setName ( layoutId . name ) ; try { LayoutUtil . saveLayout ( layoutId , toString ( ) ) ; } catch ( Exception e ) { log . error ( "Error saving application layout." , e ) ; return false ; } return true ; }
Saves the layout as a property value using the specified identifier .
8,120
public Class < ? extends ElementBase > getRootClass ( ) { LayoutElement top = root == null ? null : root . getChild ( LayoutElement . class ) ; return top == null ? null : top . getDefinition ( ) . getClazz ( ) ; }
Returns the class of the element at the root of the layout .
8,121
public Layout fromClipboard ( String data ) { init ( LayoutParser . parseText ( data ) . root ) ; return this ; }
Converts from clipboard format .
8,122
public boolean publish ( String channel , Message message , Recipient ... recipients ) { boolean result = false ; prepare ( channel , message , recipients ) ; for ( IMessageProducer producer : producers ) { result |= producer . publish ( channel , message ) ; } return result ; }
Publish a message .
8,123
private boolean publish ( String channel , Message message , IMessageProducer producer , Recipient [ ] recipients ) { if ( producer != null ) { prepare ( channel , message , recipients ) ; return producer . publish ( channel , message ) ; } return false ; }
Publish a message to the specified producer . Use this only when publishing to a single producer .
8,124
private IMessageProducer findRegisteredProducer ( Class < ? > clazz ) { for ( IMessageProducer producer : producers ) { if ( clazz . isInstance ( producer ) ) { return producer ; } } return null ; }
Returns a producer of the specified class .
8,125
private Message prepare ( String channel , Message message , Recipient [ ] recipients ) { message . setMetadata ( "cwf.pub.node" , nodeId ) ; message . setMetadata ( "cwf.pub.channel" , channel ) ; message . setMetadata ( "cwf.pub.event" , UUID . randomUUID ( ) . toString ( ) ) ; message . setMetadata ( "cwf.pub.when" , System . currentTimeMillis ( ) ) ; message . setMetadata ( "cwf.pub.recipients" , recipients ) ; return message ; }
Adds publication - specific metadata to the message .
8,126
protected Interest replaceFinalComponent ( Interest interest , long segmentNumber , byte marker ) { Interest copied = new Interest ( interest ) ; Component lastComponent = Component . fromNumberWithMarker ( segmentNumber , marker ) ; Name newName = ( SegmentationHelper . isSegmented ( copied . getName ( ) , marker ) ) ? copied . getName ( ) . getPrefix ( - 1 ) : new Name ( copied . getName ( ) ) ; copied . setName ( newName . append ( lastComponent ) ) ; return copied ; }
Replace the final component of an interest name with a segmented component ; if the interest name does not have a segmented component this will add one .
8,127
public static void setTime ( Datebox datebox , Timebox timebox , Date value ) { value = value == null ? new Date ( ) : value ; datebox . setValue ( DateUtil . stripTime ( value ) ) ; timebox . setValue ( value ) ; }
Sets the UI to reflect the specified time .
8,128
private boolean isFresh ( Record record ) { double period = record . data . getMetaInfo ( ) . getFreshnessPeriod ( ) ; return period < 0 || record . addedAt + ( long ) period > System . currentTimeMillis ( ) ; }
Check if a record is fresh .
8,129
private boolean sameTopic ( HelpTopic topic1 , HelpTopic topic2 ) { return topic1 == topic2 || ( topic1 != null && topic2 != null && topic1 . equals ( topic2 ) ) ; }
Because the HelpTopic class does not implement its own equals method have to implement equality test here . Two topics are considered equal if the are the same instance or if their targets are equal .
8,130
private String lookupItemName ( String itemName , boolean autoAdd ) { String indexedName = index . get ( itemName . toLowerCase ( ) ) ; if ( indexedName == null && autoAdd ) { index . put ( itemName . toLowerCase ( ) , itemName ) ; } return indexedName == null ? itemName : indexedName ; }
Performs a case - insensitive lookup of the item name in the index .
8,131
private String lookupItemName ( String itemName , String suffix , boolean autoAdd ) { return lookupItemName ( itemName + "." + suffix , autoAdd ) ; }
Performs a case - insensitive lookup of the item name + suffix in the index .
8,132
public void removeSubject ( String subject ) { String prefix = normalizePrefix ( subject ) ; for ( String suffix : getSuffixes ( prefix ) . keySet ( ) ) { setItem ( prefix + suffix , null ) ; } }
Remove all context items for the specified subject .
8,133
private Map < String , String > getSuffixes ( String prefix , Boolean firstOnly ) { HashMap < String , String > matches = new HashMap < > ( ) ; prefix = normalizePrefix ( prefix ) ; int i = prefix . length ( ) ; for ( String itemName : index . keySet ( ) ) { if ( itemName . startsWith ( prefix ) ) { String suffix = lookupItemName ( itemName , false ) . substring ( i ) ; matches . put ( suffix , getItem ( itemName ) ) ; if ( firstOnly ) { break ; } } } return matches ; }
Returns a map consisting of suffixes of context items that match the specified prefix .
8,134
public String getItem ( String itemName , String suffix ) { return items . get ( lookupItemName ( itemName , suffix , false ) ) ; }
Retrieves a context item qualified by a suffix .
8,135
@ SuppressWarnings ( "unchecked" ) public < T > T getItem ( String itemName , Class < T > clazz ) throws ContextException { String item = getItem ( itemName ) ; if ( item == null || item . isEmpty ( ) ) { return null ; } ISerializer < ? > contextSerializer = ContextSerializerRegistry . getInstance ( ) . get ( clazz ) ; if ( contextSerializer == null ) { throw new ContextException ( "No serializer found for type " + clazz . getName ( ) ) ; } return ( T ) contextSerializer . deserialize ( item ) ; }
Returns an object of the specified class . The class must have an associated context serializer registered .
8,136
public void setItem ( String itemName , String value , String suffix ) { itemName = lookupItemName ( itemName , suffix , value != null ) ; items . put ( itemName , value ) ; }
Sets a context item value qualified with the specified suffix .
8,137
public void setDate ( String itemName , Date date ) { if ( date == null ) { setItem ( itemName , null ) ; } else { setItem ( itemName , DateUtil . toHL7 ( date ) ) ; } }
Saves a date item object as a context item .
8,138
public Date getDate ( String itemName ) { try { return DateUtil . parseDate ( getItem ( itemName ) ) ; } catch ( Exception e ) { return null ; } }
Returns a date item associated with the specified item name .
8,139
public void addItems ( String values ) throws Exception { for ( String line : values . split ( "[\\r\\n]" ) ) { String [ ] pcs = line . split ( "\\=" , 2 ) ; if ( pcs . length == 2 ) { setItem ( pcs [ 0 ] , pcs [ 1 ] ) ; } } }
Adds context items from a serialized string .
8,140
private void addItems ( Map < String , String > values ) { for ( String itemName : values . keySet ( ) ) { setItem ( itemName , values . get ( itemName ) ) ; } }
Adds property values to the context item list .
8,141
public static String [ ] getLibraryPaths ( ) { String libraryPathString = System . getProperty ( "java.library.path" ) ; String pathSeparator = System . getProperty ( "path.separator" ) ; return libraryPathString . split ( pathSeparator ) ; }
Get java . library . path in system property .
8,142
public String put ( final String key , final String Value ) { return parameters . put ( key , Value ) ; }
Convenience method for adding a parameter to the command .
8,143
public static long [ ] insertEntry ( long [ ] a , int idx , long val ) { long [ ] b = new long [ a . length + 1 ] ; for ( int i = 0 ; i < b . length ; i ++ ) { if ( i < idx ) { b [ i ] = a [ i ] ; } else if ( i == idx ) { b [ idx ] = val ; } else { b [ i ] = a [ i - 1 ] ; } } return b ; }
Gets a copy of the array with an entry inserted .
8,144
public int getIndex ( ) { if ( parent != null ) { for ( int i = 0 ; i < parent . children . size ( ) ; i ++ ) { if ( parent . children . get ( i ) == this ) { return i ; } } } return - 1 ; }
Returns the position of this node among its siblings .
8,145
public HelpTopicNode getNextSibling ( ) { int i = getIndex ( ) + 1 ; return i == 0 || i == parent . children . size ( ) ? null : parent . children . get ( i ) ; }
Returns the first sibling node after this one .
8,146
public HelpTopicNode getPreviousSibling ( ) { int i = getIndex ( ) - 1 ; return i < 0 ? null : parent . children . get ( i ) ; }
Returns the first sibling node before this one .
8,147
public void addChild ( HelpTopicNode node , int index ) { node . detach ( ) ; node . parent = this ; if ( index < 0 ) { children . add ( node ) ; } else { children . add ( index , node ) ; } }
Inserts a child node at the specified position .
8,148
public static DialogControl < String > create ( String message , String title , String styles , String responses , String excludeResponses , String defaultResponse , String saveResponseId , IPromptCallback < String > callback ) { return new DialogControl < > ( message , title , styles , toList ( responses ) , toList ( excludeResponses ) , defaultResponse , saveResponseId , callback ) ; }
Parameters for the dialog .
8,149
public DialogResponse < T > getLastResponse ( ) { String saved = saveResponseId == null ? null : PropertyUtil . getValue ( SAVED_RESPONSE_PROP_NAME , saveResponseId ) ; int i = NumberUtils . toInt ( saved , - 1 ) ; DialogResponse < T > response = i < 0 || i >= responses . size ( ) ? null : responses . get ( i ) ; return response == null || response . isExcluded ( ) ? null : response ; }
Returns the last saved response for this dialog .
8,150
public void saveLastResponse ( DialogResponse < T > response ) { if ( saveResponseId != null && ( response == null || ! response . isExcluded ( ) ) ) { int index = response == null ? - 1 : responses . indexOf ( response ) ; PropertyUtil . saveValue ( SAVED_RESPONSE_PROP_NAME , saveResponseId , false , index < 0 ? null : Integer . toString ( index ) ) ; } }
Saves the last response under the named responseId .
8,151
public void uniq ( ) { if ( size <= 1 ) { return ; } int cursor = 0 ; for ( int i = 1 ; i < size ; i ++ ) { if ( elements [ cursor ] != elements [ i ] ) { cursor ++ ; elements [ cursor ] = elements [ i ] ; } } size = cursor + 1 ; }
Removes all identical neighboring elements resizing the array list accordingly .
8,152
private static Object selfConvert ( String parsingMethod , String value , Class < ? > type ) { try { Method method = type . getMethod ( parsingMethod , String . class ) ; return method . invoke ( null , value ) ; } catch ( InvocationTargetException e ) { throw new IllegalArgumentException ( "Can't convert " + value + " to " + type . getName ( ) , e . getCause ( ) ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Can't convert " + value + " to " + type . getName ( ) , e ) ; } }
SelfConversion implies that if a class has the given static method named that receive a String and that returns a instance of the class then it can serve for conversion purpose .
8,153
public Calendar convertDateToCalendar ( java . util . Date date ) { Calendar calendar = null ; if ( date != null ) { calendar = Calendar . getInstance ( ) ; calendar . setTime ( date ) ; calendar . clear ( Calendar . ZONE_OFFSET ) ; calendar . clear ( Calendar . DST_OFFSET ) ; } return calendar ; }
This method is used to get Calendar date for the corresponding date object .
8,154
public void execute ( ) throws MojoExecutionException { if ( StringUtils . isEmpty ( moduleSource ) && ignoreMissingSource ) { getLog ( ) . info ( "No help module source specified." ) ; return ; } init ( "help" , moduleBase ) ; registerLoader ( new SourceLoader ( "javahelp" , "*.hs" , ZipIterator . class ) ) ; registerLoader ( new SourceLoader ( "ohj" , "*.hs" , ZipIterator . class ) ) ; registerLoader ( new ChmSourceLoader ( ) ) ; registerExternalLoaders ( ) ; SourceLoader loader = sourceLoaders . get ( moduleFormat ) ; if ( loader == null ) { throw new MojoExecutionException ( "No source loader found for format " + moduleFormat ) ; } try { String sourceFilename = FileUtils . normalize ( baseDirectory + "/" + moduleSource ) ; HelpProcessor processor = new HelpProcessor ( this , sourceFilename , loader ) ; processor . transform ( ) ; addConfigEntry ( "help" , moduleId , processor . getHelpSetFile ( ) , moduleName , getModuleVersion ( ) , moduleFormat , moduleLocale ) ; assembleArchive ( ) ; } catch ( Exception e ) { throw new MojoExecutionException ( "Unexpected error." , e ) ; } }
Main execution entry point for plug - in .
8,155
private void registerExternalLoaders ( ) throws MojoExecutionException { if ( archiveLoaders != null ) { for ( String entry : archiveLoaders ) { try { SourceLoader loader = ( SourceLoader ) Class . forName ( entry ) . newInstance ( ) ; registerLoader ( loader ) ; } catch ( Exception e ) { throw new MojoExecutionException ( "Error registering archive loader for class: " + entry , e ) ; } } } }
Adds any additional source loaders specified in configuration .
8,156
public boolean verify ( String base64Signature , String content , String timestamp ) throws Exception { return verify ( base64Signature , content , timestamp , keyName ) ; }
Verifies the validity of the digital signature using stored key name .
8,157
protected static SessionController create ( String sessionId , boolean originator ) { Map < String , Object > args = new HashMap < > ( ) ; args . put ( "id" , sessionId ) ; args . put ( "title" , StrUtil . formatMessage ( "@cwf.chat.session.title" ) ) ; args . put ( "originator" , originator ? true : null ) ; Window dlg = PopupDialog . show ( DIALOG , args , true , true , false , null ) ; return ( SessionController ) FrameworkController . getController ( dlg ) ; }
Creates a chat session bound to the specified session id .
8,158
public void afterInitialized ( BaseComponent comp ) { super . afterInitialized ( comp ) ; window = ( Window ) comp ; sessionId = ( String ) comp . getAttribute ( "id" ) ; lstParticipants . setRenderer ( new ParticipantRenderer ( chatService . getSelf ( ) , null ) ) ; model . add ( chatService . getSelf ( ) ) ; lstParticipants . setModel ( model ) ; clearMessage ( ) ; if ( comp . getAttribute ( "originator" ) != null ) { invite ( ( result ) -> { if ( ! result ) { close ( ) ; } else { initSession ( ) ; } } ) ; } }
Initialize the dialog .
8,159
public Listitem findMatchingItem ( String label ) { for ( Listitem item : getChildren ( Listitem . class ) ) { if ( label . equalsIgnoreCase ( item . getLabel ( ) ) ) { return item ; } } return null ; }
Searches for a Listitem that has a label that matches the specified value . The search is case insensitive .
8,160
public Date getStartDate ( ) { DateRange range = getSelectedRange ( ) ; return range == null ? null : range . getStartDate ( ) ; }
Returns the selected start date . This may be null if there is no active selection or if the selected date range has no start date .
8,161
public Date getEndDate ( ) { DateRange range = getSelectedRange ( ) ; return range == null ? null : range . getEndDate ( ) ; }
Returns the selected end date . This may be null if there is no active selection or if the selected date range has no end date .
8,162
public static String shortMessage ( List < CompilerError > messages ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( "Compilation failure" ) ; if ( messages . size ( ) == 1 ) { sb . append ( LS ) ; CompilerError compilerError = ( CompilerError ) messages . get ( 0 ) ; sb . append ( compilerError ) . append ( LS ) ; } return sb . toString ( ) ; }
Short message will have the error message if there s only one useful for errors forking the compiler
8,163
public void sortAttachments ( ByteArrayInputStream byteArrayInputStream ) { List < String > attachmentNameList = new ArrayList < > ( ) ; List < AttachmentData > attacmentList = getAttachments ( ) ; List < AttachmentData > tempAttacmentList = new ArrayList < > ( ) ; try { DocumentBuilderFactory domParserFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder domParser = domParserFactory . newDocumentBuilder ( ) ; Document document = domParser . parse ( byteArrayInputStream ) ; byteArrayInputStream . close ( ) ; NodeList fileLocationList = document . getElementsByTagName ( NARRATIVE_ATTACHMENT_FILE_LOCATION ) ; for ( int itemLocation = 0 ; itemLocation < fileLocationList . getLength ( ) ; itemLocation ++ ) { String attachmentName = fileLocationList . item ( itemLocation ) . getAttributes ( ) . item ( 0 ) . getNodeValue ( ) ; String [ ] name = attachmentName . split ( KEY_VALUE_SEPARATOR ) ; String fileName = name [ name . length - 1 ] ; attachmentNameList . add ( fileName ) ; } } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e ) ; } for ( String attachmentName : attachmentNameList ) { for ( AttachmentData attachment : attacmentList ) { String [ ] names = attachment . getContentId ( ) . split ( KEY_VALUE_SEPARATOR ) ; String fileName = names [ names . length - 1 ] ; if ( fileName . equalsIgnoreCase ( attachmentName ) ) { tempAttacmentList . add ( attachment ) ; } } } if ( tempAttacmentList . size ( ) > 0 ) { attachments . clear ( ) ; for ( AttachmentData tempAttachment : tempAttacmentList ) { attachments . add ( tempAttachment ) ; } } }
Sort the attachments .
8,164
public boolean hasBadValues ( ) { for ( int i = 0 ; i < top ; i ++ ) { double v = vals [ i ] ; boolean bad = Double . isNaN ( v ) || Double . isInfinite ( v ) ; if ( bad ) return true ; } return false ; }
returns true if any values are NaN or Inf
8,165
public void setCharsetName ( final String charsetName ) { if ( Charset . isSupported ( charsetName ) ) { this . charsetName = charsetName ; } else { throw new UnsupportedCharsetException ( "No support for, " + charsetName + ", is available in this instance of the JVM" ) ; } }
Setter for property charsetName .
8,166
protected byte [ ] serialize ( IMessage < ID , DATA > msg ) { return msg != null ? SerializationUtils . toByteArray ( msg ) : null ; }
Serialize a queue message to store in Redis .
8,167
protected < T extends IMessage < ID , DATA > > T deserialize ( byte [ ] msgData , Class < T > clazz ) { return msgData != null ? SerializationUtils . fromByteArray ( msgData , clazz ) : null ; }
Deserialize a message .
8,168
private IQueryResult < T > filteredResult ( IQueryResult < T > unfilteredResult ) { List < T > unfilteredList = unfilteredResult . getResults ( ) ; List < T > filteredList = unfilteredList == null ? null : filters . filter ( unfilteredList ) ; Map < String , Object > metadata = Collections . < String , Object > singletonMap ( "unfiltered" , unfilteredResult ) ; return QueryUtil . packageResult ( filteredList , unfilteredResult . getStatus ( ) , metadata ) ; }
Repackages the query result as the filtered result with the unfiltered version stored in the metadata under the unfiltered key .
8,169
public static ApplicationContext contextMergedBeans ( String xmlPath , Map < String , ? > extraBeans ) { final DefaultListableBeanFactory parentBeanFactory = buildListableBeanFactory ( extraBeans ) ; GenericApplicationContext parentContext = new GenericApplicationContext ( parentBeanFactory ) ; XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader ( parentContext ) ; xmlReader . loadBeanDefinitions ( xmlPath ) ; parentContext . refresh ( ) ; return parentContext ; }
Loads a context from a XML and inject all objects in the Map
8,170
public static ApplicationContext contextMergedBeans ( Map < String , ? > extraBeans , Class < ? > config ) { final DefaultListableBeanFactory parentBeanFactory = buildListableBeanFactory ( extraBeans ) ; GenericApplicationContext parentContext = new GenericApplicationContext ( parentBeanFactory ) ; AnnotatedBeanDefinitionReader annotationReader = new AnnotatedBeanDefinitionReader ( parentContext ) ; annotationReader . registerBean ( config ) ; parentContext . refresh ( ) ; return parentContext ; }
Loads a context from the annotations config and inject all objects in the Map
8,171
private static void setProperties ( GenericApplicationContext newContext , Properties properties ) { PropertiesPropertySource pps = new PropertiesPropertySource ( "external-props" , properties ) ; newContext . getEnvironment ( ) . getPropertySources ( ) . addFirst ( pps ) ; }
Set properties into the context .
8,172
private static DefaultListableBeanFactory buildListableBeanFactory ( Map < String , ? > extraBeans ) { final DefaultListableBeanFactory parentBeanFactory = new DefaultListableBeanFactory ( ) ; for ( String key : extraBeans . keySet ( ) ) { parentBeanFactory . registerSingleton ( key , extraBeans . get ( key ) ) ; } return parentBeanFactory ; }
Builds a listable bean factory with the given beans .
8,173
protected boolean validateBudgetForForm ( ProposalDevelopmentDocumentContract pdDoc ) throws S2SException { boolean valid = true ; ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService . getBudget ( pdDoc . getDevelopmentProposal ( ) ) ; if ( budget != null ) { for ( BudgetPeriodContract period : budget . getBudgetPeriods ( ) ) { List < String > participantSupportCode = new ArrayList < > ( ) ; participantSupportCode . add ( s2sBudgetCalculatorService . getParticipantSupportCategoryCode ( ) ) ; List < ? extends BudgetLineItemContract > participantSupportLineItems = s2sBudgetCalculatorService . getMatchingLineItems ( period . getBudgetLineItems ( ) , participantSupportCode ) ; int numberOfParticipants = period . getNumberOfParticipants ( ) == null ? 0 : period . getNumberOfParticipants ( ) ; if ( ! participantSupportLineItems . isEmpty ( ) && numberOfParticipants == 0 ) { AuditError auditError = s2SErrorHandlerService . getError ( PARTICIPANT_COUNT_REQUIRED , getFormName ( ) ) ; AuditError error = new AuditError ( auditError . getErrorKey ( ) , auditError . getMessageKey ( ) + period . getBudgetPeriod ( ) , auditError . getLink ( ) ) ; getAuditErrors ( ) . add ( error ) ; valid = false ; } else if ( numberOfParticipants > 0 && participantSupportLineItems . isEmpty ( ) ) { getAuditErrors ( ) . add ( s2SErrorHandlerService . getError ( PARTICIPANT_COSTS_REQUIRED , getFormName ( ) ) ) ; valid = false ; } } } return valid ; }
Perform manual validations on the budget . Similarly done in RRBudgetBaseGenerator .
8,174
public static IStopWatch create ( ) { if ( factory == null ) { throw new IllegalStateException ( "No stopwatch factory registered." ) ; } try { return factory . clazz . newInstance ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "Could not create stopwatch instance." , e ) ; } }
Returns an uninitialized stopwatch instance .
8,175
public static IStopWatch create ( String tag , Map < String , Object > data ) { IStopWatch sw = create ( ) ; sw . init ( tag , data ) ; return sw ; }
Returns a stopwatch instance initialized with the specified tag and data .
8,176
private CumulativeTravels getCumulativeTravels ( BudgetSummaryDto budgetSummaryData ) { CumulativeTravels cumulativeTravels = CumulativeTravels . Factory . newInstance ( ) ; SummaryDataType summary = SummaryDataType . Factory . newInstance ( ) ; if ( budgetSummaryData != null ) { if ( budgetSummaryData . getCumTravel ( ) != null ) { summary . setFederalSummary ( budgetSummaryData . getCumTravel ( ) . bigDecimalValue ( ) ) ; } if ( budgetSummaryData . getCumTravelNonFund ( ) != null ) { summary . setNonFederalSummary ( budgetSummaryData . getCumTravelNonFund ( ) . bigDecimalValue ( ) ) ; if ( budgetSummaryData . getCumTravel ( ) != null ) { summary . setTotalFedNonFedSummary ( budgetSummaryData . getCumTravel ( ) . add ( budgetSummaryData . getCumTravelNonFund ( ) ) . bigDecimalValue ( ) ) ; } else { summary . setTotalFedNonFedSummary ( budgetSummaryData . getCumTravelNonFund ( ) . bigDecimalValue ( ) ) ; } } TotalDataType totalDomestic = TotalDataType . Factory . newInstance ( ) ; if ( budgetSummaryData . getCumDomesticTravel ( ) != null ) { totalDomestic . setFederal ( budgetSummaryData . getCumDomesticTravel ( ) . bigDecimalValue ( ) ) ; } if ( budgetSummaryData . getCumDomesticTravelNonFund ( ) != null ) { totalDomestic . setNonFederal ( budgetSummaryData . getCumDomesticTravelNonFund ( ) . bigDecimalValue ( ) ) ; if ( budgetSummaryData . getCumDomesticTravel ( ) != null ) { totalDomestic . setTotalFedNonFed ( budgetSummaryData . getCumDomesticTravel ( ) . add ( budgetSummaryData . getCumDomesticTravelNonFund ( ) ) . bigDecimalValue ( ) ) ; } else { totalDomestic . setTotalFedNonFed ( budgetSummaryData . getCumDomesticTravelNonFund ( ) . bigDecimalValue ( ) ) ; } } cumulativeTravels . setCumulativeDomesticTravelCosts ( totalDomestic ) ; TotalDataType totalForeign = TotalDataType . Factory . newInstance ( ) ; if ( budgetSummaryData . getCumForeignTravel ( ) != null ) { totalForeign . setFederal ( budgetSummaryData . getCumForeignTravel ( ) . bigDecimalValue ( ) ) ; } if ( budgetSummaryData . getCumForeignTravelNonFund ( ) != null ) { totalForeign . setNonFederal ( budgetSummaryData . getCumForeignTravelNonFund ( ) . bigDecimalValue ( ) ) ; if ( budgetSummaryData . getCumForeignTravel ( ) != null ) { totalForeign . setTotalFedNonFed ( budgetSummaryData . getCumForeignTravel ( ) . add ( budgetSummaryData . getCumForeignTravelNonFund ( ) ) . bigDecimalValue ( ) ) ; } else { totalForeign . setTotalFedNonFed ( budgetSummaryData . getCumForeignTravelNonFund ( ) . bigDecimalValue ( ) ) ; } } cumulativeTravels . setCumulativeForeignTravelCosts ( totalForeign ) ; } cumulativeTravels . setCumulativeTotalFundsRequestedTravel ( summary ) ; return cumulativeTravels ; }
This method gets CumulativeTravels details CumulativeTotalFundsRequestedTravel CumulativeDomesticTravelCosts and CumulativeForeignTravelCosts based on BudgetSummaryInfo for the RRFedNonFedBudget .
8,177
private GraduateStudents getGraduateStudents ( OtherPersonnelDto otherPersonnel ) { GraduateStudents graduate = GraduateStudents . Factory . newInstance ( ) ; if ( otherPersonnel != null ) { graduate . setNumberOfPersonnel ( otherPersonnel . getNumberPersonnel ( ) ) ; graduate . setProjectRole ( otherPersonnel . getRole ( ) ) ; graduate . setCompensation ( getSectBCompensationDataType ( otherPersonnel . getCompensation ( ) ) ) ; } return graduate ; }
This method gets the GraduateStudents details ProjectRole NumberOfPersonnel Compensation based on OtherPersonnelInfo for the RRFedNonFedBudget if it is a GraduateStudents type .
8,178
private UndergraduateStudents getUndergraduateStudents ( OtherPersonnelDto otherPersonnel ) { UndergraduateStudents undergraduate = UndergraduateStudents . Factory . newInstance ( ) ; if ( otherPersonnel != null ) { undergraduate . setNumberOfPersonnel ( otherPersonnel . getNumberPersonnel ( ) ) ; undergraduate . setProjectRole ( otherPersonnel . getRole ( ) ) ; undergraduate . setCompensation ( getSectBCompensationDataType ( otherPersonnel . getCompensation ( ) ) ) ; } return undergraduate ; }
This method is to get the UndergraduateStudents details ProjectRole NumberOfPersonnel Compensation based on OtherPersonnelInfo for the RRFedNonFedBudget if it is a UndergraduateStudents type .
8,179
private Others getOthersForOtherDirectCosts ( BudgetPeriodDto periodInfo ) { Others othersDirect = Others . Factory . newInstance ( ) ; if ( periodInfo != null && periodInfo . getOtherDirectCosts ( ) != null ) { Others . Other otherArray [ ] = new Others . Other [ periodInfo . getOtherDirectCosts ( ) . size ( ) ] ; int Otherscount = 0 ; Others . Other other = Others . Other . Factory . newInstance ( ) ; for ( OtherDirectCostInfoDto otherDirectCostInfo : periodInfo . getOtherDirectCosts ( ) ) { TotalDataType total = TotalDataType . Factory . newInstance ( ) ; if ( otherDirectCostInfo . getOtherCosts ( ) != null && otherDirectCostInfo . getOtherCosts ( ) . size ( ) > 0 ) { total . setFederal ( new BigDecimal ( otherDirectCostInfo . getOtherCosts ( ) . get ( 0 ) . get ( CostConstants . KEY_COST ) ) ) ; total . setNonFederal ( new BigDecimal ( otherDirectCostInfo . getOtherCosts ( ) . get ( 0 ) . get ( CostConstants . KEY_COSTSHARING ) ) ) ; if ( otherDirectCostInfo . getOtherCosts ( ) . get ( 0 ) . get ( CostConstants . KEY_COST ) != null ) { total . setTotalFedNonFed ( new BigDecimal ( otherDirectCostInfo . getOtherCosts ( ) . get ( 0 ) . get ( CostConstants . KEY_COST ) ) . add ( new BigDecimal ( otherDirectCostInfo . getOtherCosts ( ) . get ( 0 ) . get ( CostConstants . KEY_COSTSHARING ) ) ) ) ; } else { total . setTotalFedNonFed ( new BigDecimal ( otherDirectCostInfo . getOtherCosts ( ) . get ( 0 ) . get ( CostConstants . KEY_COSTSHARING ) ) ) ; } } other . setCost ( total ) ; other . setDescription ( OTHERCOST_DESCRIPTION ) ; otherArray [ Otherscount ] = other ; Otherscount ++ ; } othersDirect . setOtherArray ( otherArray ) ; } return othersDirect ; }
This method is to get Other type description and total cost OtherDirectCosts details in BudgetYearDataType based on BudgetPeriodInfo for the RRFedNonFedBudget .
8,180
public static void applyThemeClass ( BaseUIComponent component , IThemeClass ... themeClasses ) { StringBuilder sb = new StringBuilder ( ) ; for ( IThemeClass themeClass : themeClasses ) { String cls = themeClass == null ? null : themeClass . getThemeClass ( ) ; if ( cls != null ) { sb . append ( sb . length ( ) > 0 ? " " : "" ) . append ( themeClass . getThemeClass ( ) ) ; } } component . addClass ( sb . toString ( ) ) ; }
Applies one or more theme classes to a component .
8,181
public void setUrl ( String url ) { this . url = url ; if ( clazz == null && url != null ) { setClazz ( ElementPlugin . class ) ; } }
Sets the URL of the principal cwf page for the plugin .
8,182
@ SuppressWarnings ( "unchecked" ) public < E extends IPluginResource > List < E > getResources ( Class < E > clazz ) { List < E > list = new ArrayList < > ( ) ; for ( IPluginResource resource : resources ) { if ( clazz . isInstance ( resource ) ) { list . add ( ( E ) resource ) ; } } return list ; }
Returns the list of plugin resources belonging to the specified resource class . Never null .
8,183
public void setClazz ( Class < ? extends ElementBase > clazz ) { this . clazz = clazz ; try { Class . forName ( clazz . getName ( ) ) ; } catch ( ClassNotFoundException e ) { MiscUtil . toUnchecked ( e ) ; } }
Sets the UI element class associated with this definition .
8,184
public boolean isForbidden ( ) { if ( authorities . size ( ) == 0 ) { return false ; } boolean result = true ; for ( Authority priv : authorities ) { result = ! SecurityUtil . isGranted ( priv . name ) ; if ( requiresAll == result ) { break ; } } return result ; }
Returns true if access to the plugin is restricted .
8,185
public void setPath ( String path ) { if ( path != null ) { manifest = ManifestIterator . getInstance ( ) . findByPath ( path ) ; } }
Sets the path of the resource containing the plugin definition . This is used to locate the manifest entry from which version and source information can be extracted .
8,186
private String getValueWithDefault ( String value , String manifestKey ) { if ( StringUtils . isEmpty ( value ) && manifest != null ) { value = manifest . getMainAttributes ( ) . getValue ( manifestKey ) ; } return value ; }
Returns a value s default if the initial value is null or empty .
8,187
public ElementBase createElement ( ElementBase parent , IPropertyProvider propertyProvider , boolean deserializing ) { try { ElementBase element = null ; if ( isForbidden ( ) ) { log . info ( "Access to plugin " + getName ( ) + " is restricted." ) ; } else if ( isDisabled ( ) ) { log . info ( "Plugin " + getName ( ) + " has been disabled." ) ; } else { Class < ? extends ElementBase > clazz = getClazz ( ) ; if ( isInternal ( ) ) { element = parent . getChild ( clazz , null ) ; } else { element = clazz . newInstance ( ) ; } if ( element == null ) { CWFException . raise ( "Failed to create UI element " + id + "." ) ; } element . setDefinition ( this ) ; element . beforeInitialize ( deserializing ) ; initElement ( element , propertyProvider ) ; if ( parent != null ) { element . setParent ( parent ) ; } element . afterInitialize ( deserializing ) ; } return element ; } catch ( Exception e ) { throw MiscUtil . toUnchecked ( e ) ; } }
Creates an instance of the element based on its definition . If a property source is specified the source is used to initialize properties on the newly created element .
8,188
public void initElement ( ElementBase element , IPropertyProvider propertyProvider ) { if ( propertyProvider != null ) { for ( PropertyInfo propInfo : getProperties ( ) ) { String key = propInfo . getId ( ) ; if ( propertyProvider . hasProperty ( key ) ) { String value = propertyProvider . getProperty ( key ) ; propInfo . setPropertyValue ( element , value ) ; } } } }
Initialize the element s properties using the specified property provider .
8,189
public Person nextPerson ( ) { if ( ! initialized ) { init ( ) ; } Person person = new Person ( ) ; Gender gender = this . gender == null ? ( random . nextBoolean ( ) ? Gender . FEMALE : Gender . MALE ) : this . gender ; person . setGender ( gender ) ; List < String > givenNamesPool = gender == Gender . FEMALE ? givenFemaleNames : givenMaleNames ; List < String > givenNames = new ArrayList < String > ( 2 ) ; givenNames . add ( getNameWord ( givenNamesPool ) ) ; givenNames . add ( getNameWord ( givenNamesPool ) ) ; person . setGivenNames ( givenNames ) ; person . setLastName ( getNameWord ( lastNames ) ) ; generateDOB ( person ) ; Map < String , Object > spewDetails = generateSpewDetails ( person ) ; person . setUsername ( usernameGenerator . nextLine ( spewDetails ) ) ; spewDetails . put ( "USERNAME" , person . getUsername ( ) ) ; person . setEmail ( emailGenerator . nextLine ( spewDetails ) ) ; person . setTwitterUsername ( random . nextInt ( 2 ) == 1 ? "@" + usernameGenerator . nextLine ( spewDetails ) : null ) ; return person ; }
Returns a randomly generated person .
8,190
public List < Person > nextPeople ( int num ) { List < Person > names = new ArrayList < Person > ( num ) ; for ( int i = 0 ; i < num ; i ++ ) { names . add ( nextPerson ( ) ) ; } return names ; }
Will generate the given number of random people
8,191
public String marshal ( ContextItems contextItems ) { SimpleDateFormat timestampFormat = new SimpleDateFormat ( "yyyyMMddHHmmssz" ) ; contextItems . setItem ( PROPNAME_TIME , timestampFormat . format ( new Date ( ) ) ) ; contextItems . setItem ( PROPNAME_KEY , signer . getKeyName ( ) ) ; return contextItems . toString ( ) ; }
Marshals the current context as a string .
8,192
public ContextItems unmarshal ( String marshaledContext , String authSignature ) throws Exception { ContextItems contextItems = new ContextItems ( ) ; contextItems . addItems ( marshaledContext ) ; String whichKey = contextItems . getItem ( PROPNAME_KEY ) ; String timestamp = contextItems . getItem ( PROPNAME_TIME ) ; if ( authSignature != null && ! signer . verify ( authSignature , marshaledContext , timestamp , whichKey ) ) { throw new MarshalException ( "Invalid digital signature" ) ; } return contextItems ; }
Unmarshals the marshaled context . Performs digital signature verification then returns the unmarshaled context items .
8,193
private Travel getTravel ( BudgetPeriodDto periodInfo ) { Travel travel = Travel . Factory . newInstance ( ) ; if ( periodInfo != null ) { TotalDataType total = TotalDataType . Factory . newInstance ( ) ; if ( periodInfo . getDomesticTravelCost ( ) != null ) { total . setFederal ( periodInfo . getDomesticTravelCost ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getDomesticTravelCostSharing ( ) != null ) { total . setNonFederal ( periodInfo . getDomesticTravelCostSharing ( ) . bigDecimalValue ( ) ) ; if ( periodInfo . getDomesticTravelCost ( ) != null ) { total . setTotalFedNonFed ( periodInfo . getDomesticTravelCost ( ) . add ( periodInfo . getDomesticTravelCostSharing ( ) ) . bigDecimalValue ( ) ) ; } else { total . setTotalFedNonFed ( periodInfo . getDomesticTravelCostSharing ( ) . bigDecimalValue ( ) ) ; } } travel . setDomesticTravelCost ( total ) ; TotalDataType totalForeign = TotalDataType . Factory . newInstance ( ) ; if ( periodInfo . getForeignTravelCost ( ) != null ) { totalForeign . setFederal ( periodInfo . getForeignTravelCost ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getForeignTravelCostSharing ( ) != null ) { totalForeign . setNonFederal ( periodInfo . getForeignTravelCostSharing ( ) . bigDecimalValue ( ) ) ; if ( periodInfo . getForeignTravelCost ( ) != null ) { totalForeign . setTotalFedNonFed ( periodInfo . getForeignTravelCost ( ) . add ( periodInfo . getForeignTravelCostSharing ( ) ) . bigDecimalValue ( ) ) ; } else { totalForeign . setTotalFedNonFed ( periodInfo . getForeignTravelCostSharing ( ) . bigDecimalValue ( ) ) ; } } travel . setForeignTravelCost ( totalForeign ) ; SummaryDataType summary = SummaryDataType . Factory . newInstance ( ) ; if ( periodInfo . getTotalTravelCost ( ) != null ) { summary . setFederalSummary ( periodInfo . getTotalTravelCost ( ) . bigDecimalValue ( ) ) ; } if ( periodInfo . getTotalTravelCostSharing ( ) != null ) { summary . setNonFederalSummary ( periodInfo . getTotalTravelCostSharing ( ) . bigDecimalValue ( ) ) ; if ( periodInfo . getTotalTravelCost ( ) != null ) { summary . setTotalFedNonFedSummary ( periodInfo . getTotalTravelCost ( ) . add ( periodInfo . getTotalTravelCostSharing ( ) ) . bigDecimalValue ( ) ) ; } else { summary . setTotalFedNonFedSummary ( periodInfo . getTotalTravelCostSharing ( ) . bigDecimalValue ( ) ) ; } } travel . setTotalTravelCost ( summary ) ; } return travel ; }
This method gets Travel cost information including DomesticTravelCost ForeignTravelCost and TotalTravelCost in the BudgetYearDataType based on BudgetPeriodInfo for the RRFedNonFedBudget .
8,194
public static int count ( int [ ] array , int value ) { int count = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == value ) { count ++ ; } } return count ; }
Counts the number of times value appears in array .
8,195
public static void reorder ( int [ ] array , int [ ] order ) { int [ ] original = copyOf ( array ) ; for ( int i = 0 ; i < array . length ; i ++ ) { array [ i ] = original [ order [ i ] ] ; } }
Reorder array in place .
8,196
public static int countUnique ( int [ ] indices1 , int [ ] indices2 ) { int numUniqueIndices = 0 ; int i = 0 ; int j = 0 ; while ( i < indices1 . length && j < indices2 . length ) { if ( indices1 [ i ] < indices2 [ j ] ) { numUniqueIndices ++ ; i ++ ; } else if ( indices2 [ j ] < indices1 [ i ] ) { numUniqueIndices ++ ; j ++ ; } else { i ++ ; j ++ ; } } for ( ; i < indices1 . length ; i ++ ) { numUniqueIndices ++ ; } for ( ; j < indices2 . length ; j ++ ) { numUniqueIndices ++ ; } return numUniqueIndices ; }
Counts the number of unique indices in two arrays .
8,197
public static IActionType < ? > getType ( String script ) { for ( IActionType < ? > actionType : instance ) { if ( actionType . matches ( script ) ) { return actionType ; } } throw new IllegalArgumentException ( "Script type was not recognized: " + script ) ; }
Returns the action type given a script .
8,198
public static boolean collectionExists ( MongoDatabase db , String collectionName ) { return db . listCollections ( ) . filter ( Filters . eq ( "name" , collectionName ) ) . first ( ) != null ; }
Check if a collection exists .
8,199
public static MongoCollection < Document > createCollection ( MongoDatabase db , String collectionName , CreateCollectionOptions options ) { db . createCollection ( collectionName , options ) ; return db . getCollection ( collectionName ) ; }
Create a new collection .