idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
7,300
protected Color getHeaderBackground ( ) { Color c = UIManager . getColor ( "SimpleInternalFrame.activeTitleBackground" ) ; return c != null ? c : UIManager . getColor ( "InternalFrame.activeTitleBackground" ) ; }
Determines and answers the header s background color . Tries to lookup a special color from the L&amp ; F . In case it is absent it uses the standard internal frame background .
7,301
protected String getFullPropertyPath ( String propertyPath ) { if ( basePropertyPath . equals ( "" ) ) { return propertyPath ; } else if ( propertyPath . equals ( "" ) ) { return basePropertyPath ; } else { return basePropertyPath + '.' + propertyPath ; } }
Returns a property path that includes the base property path of the class .
7,302
protected String getPropertyName ( String propertyPath ) { int lastSeparator = getLastPropertySeparatorIndex ( propertyPath ) ; if ( lastSeparator == - 1 ) { return propertyPath ; } if ( propertyPath . charAt ( lastSeparator ) == PropertyAccessor . NESTED_PROPERTY_SEPARATOR_CHAR ) return propertyPath . substring ( lastSeparator + 1 ) ; return propertyPath . substring ( lastSeparator ) ; }
Extracts the property name from a propertyPath .
7,303
protected String getParentPropertyPath ( String propertyPath ) { int lastSeparator = getLastPropertySeparatorIndex ( propertyPath ) ; return lastSeparator == - 1 ? "" : propertyPath . substring ( 0 , lastSeparator ) ; }
Returns the property name component of the provided property path .
7,304
protected void setId ( String id ) { if ( ! StringUtils . hasText ( id ) ) { id = null ; } this . id = id ; }
Set the id . In most cases this is provided by the constructor or through the beanId provided in the applicationContext .
7,305
private CommandFaceDescriptor getOrCreateFaceDescriptor ( ) { if ( ! isFaceConfigured ( ) ) { if ( logger . isInfoEnabled ( ) ) { logger . info ( "Lazily instantiating default face descriptor on behalf of caller to prevent npe; " + "command is being configured manually, right?" ) ; } if ( ValkyrieRepository . isCurrentlyRunningInContext ( ) ) { ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . commandConfigurer ( ) . configure ( this ) ; } else { setFaceDescriptor ( new CommandFaceDescriptor ( ) ) ; } } return getFaceDescriptor ( ) ; }
Returns the defaultFaceDescriptor . Creates one if needed .
7,306
public final AbstractButton createButton ( String faceDescriptorId , ButtonFactory buttonFactory ) { return createButton ( faceDescriptorId , buttonFactory , getDefaultButtonConfigurer ( ) ) ; }
Create a button using the default buttonConfigurer .
7,307
public final AbstractButton createButton ( ButtonFactory buttonFactory , CommandButtonConfigurer buttonConfigurer ) { return createButton ( getDefaultFaceDescriptorId ( ) , buttonFactory , buttonConfigurer ) ; }
Create a button using the default buttonFactory .
7,308
public AbstractButton createButton ( String faceDescriptorId , ButtonFactory buttonFactory , CommandButtonConfigurer buttonConfigurer ) { AbstractButton button = buttonFactory . createButton ( ) ; attach ( button , faceDescriptorId , buttonConfigurer ) ; return button ; }
Creates a button using the provided id factory and configurer .
7,309
public final JMenuItem createMenuItem ( String faceDescriptorId , MenuFactory menuFactory ) { return createMenuItem ( faceDescriptorId , menuFactory , getMenuItemButtonConfigurer ( ) ) ; }
Create a menuItem using the default and menuItemButtonConfigurer .
7,310
public final JMenuItem createMenuItem ( MenuFactory menuFactory , CommandButtonConfigurer buttonConfigurer ) { return createMenuItem ( getDefaultFaceDescriptorId ( ) , menuFactory , buttonConfigurer ) ; }
Create a menuItem using the default faceDescriptorId .
7,311
public JMenuItem createMenuItem ( String faceDescriptorId , MenuFactory menuFactory , CommandButtonConfigurer buttonConfigurer ) { JMenuItem menuItem = menuFactory . createMenuItem ( ) ; attach ( menuItem , faceDescriptorId , buttonConfigurer ) ; return menuItem ; }
Create a menuItem using the provided id factory and configurer .
7,312
public void attach ( AbstractButton button , String faceDescriptorId , CommandButtonConfigurer configurer ) { getButtonManager ( faceDescriptorId ) . attachAndConfigure ( button , configurer ) ; onButtonAttached ( button ) ; }
Attach and configure the button to the faceDescriptorId using the configurer .
7,313
protected void onButtonAttached ( AbstractButton button ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Configuring newly attached button for command '" + getId ( ) + "' enabled=" + isEnabled ( ) + ", visible=" + isVisible ( ) ) ; } button . setEnabled ( isEnabled ( ) ) ; button . setVisible ( isVisible ( ) ) ; }
Additional code to execute when attaching a button .
7,314
public boolean requestFocusIn ( Container container ) { AbstractButton button = getButtonIn ( container ) ; if ( button != null ) { return button . requestFocusInWindow ( ) ; } return false ; }
Search for a button representing this command in the provided container and let it request the focus .
7,315
public AbstractButton getButtonIn ( Container container ) { Iterator it = buttonIterator ( ) ; while ( it . hasNext ( ) ) { AbstractButton button = ( AbstractButton ) it . next ( ) ; if ( SwingUtilities . isDescendingFrom ( button , container ) ) { return button ; } } return null ; }
Search for the first button of this command that is a child component of the given container .
7,316
public static void initializeClass ( Class clazz ) { try { Class . forName ( clazz . getName ( ) , true , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } }
Intializes the specified class if not initialized already .
7,317
public static Object getFieldValue ( String qualifiedFieldName ) { Class clazz ; try { clazz = classForName ( ClassUtils . qualifier ( qualifiedFieldName ) ) ; } catch ( ClassNotFoundException cnfe ) { return null ; } try { return clazz . getField ( ClassUtils . unqualify ( qualifiedFieldName ) ) . get ( null ) ; } catch ( Exception e ) { return null ; } }
Gets the field value for the specified qualified field name .
7,318
public static Class classForName ( String name ) throws ClassNotFoundException { try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( name ) ; } catch ( Exception e ) { return Class . forName ( name ) ; } }
Load the class with the specified name .
7,319
public static String qualifier ( String qualifiedName ) { int loc = qualifiedName . lastIndexOf ( '.' ) ; if ( loc < 0 ) return "" ; return qualifiedName . substring ( 0 , loc ) ; }
Returns the qualifier for a name separated by dots . The qualified part is everything up to the last dot separator .
7,320
public static Class convertPrimitiveToWrapper ( Class clazz ) { if ( clazz == null || ! clazz . isPrimitive ( ) ) return clazz ; return ( Class ) primativeToWrapperMap . get ( clazz ) ; }
Gets the equivalent class to convert to if the given clazz is a primitive .
7,321
protected void setTargetClass ( Class targetClass ) { this . targetClass = targetClass ; this . readAccessors . clear ( ) ; this . writeAccessors . clear ( ) ; introspectMethods ( targetClass , new HashSet ( ) ) ; if ( isFieldAccessEnabled ( ) ) { introspectFields ( targetClass , new HashSet ( ) ) ; } }
Clears all cached members and introspect methods again . If fieldAccess is enabled introspect fields as well .
7,322
private void introspectFields ( Class type , Set introspectedClasses ) { if ( type == null || Object . class . equals ( type ) || type . isInterface ( ) || introspectedClasses . contains ( type ) ) { return ; } introspectedClasses . add ( type ) ; introspectFields ( type . getSuperclass ( ) , introspectedClasses ) ; Field [ ] fields = type . getDeclaredFields ( ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { if ( ! Modifier . isStatic ( fields [ i ] . getModifiers ( ) ) ) { readAccessors . put ( fields [ i ] . getName ( ) , fields [ i ] ) ; if ( ! Modifier . isFinal ( fields [ i ] . getModifiers ( ) ) ) { writeAccessors . put ( fields [ i ] . getName ( ) , fields [ i ] ) ; } } } }
Introspect fields of a class . This excludes static fields and handles final fields as readOnly .
7,323
private void introspectMethods ( Class type , Set introspectedClasses ) { if ( type == null || Object . class . equals ( type ) || introspectedClasses . contains ( type ) ) { return ; } introspectedClasses . add ( type ) ; Class [ ] interfaces = type . getInterfaces ( ) ; for ( int i = 0 ; i < interfaces . length ; i ++ ) { introspectMethods ( interfaces [ i ] , introspectedClasses ) ; } introspectMethods ( type . getSuperclass ( ) , introspectedClasses ) ; Method [ ] methods = type . getDeclaredMethods ( ) ; for ( int i = 0 ; i < methods . length ; i ++ ) { String methodName = methods [ i ] . getName ( ) ; if ( methodName . startsWith ( "get" ) && methods [ i ] . getParameterTypes ( ) . length == 0 ) { readAccessors . put ( getPropertyName ( methodName , 3 ) , methods [ i ] ) ; } else if ( methodName . startsWith ( "is" ) && methods [ i ] . getParameterTypes ( ) . length == 0 ) { readAccessors . put ( getPropertyName ( methodName , 2 ) , methods [ i ] ) ; } else if ( methodName . startsWith ( "set" ) && methods [ i ] . getParameterTypes ( ) . length == 1 ) { writeAccessors . put ( getPropertyName ( methodName , 3 ) , methods [ i ] ) ; } } }
Introspect class for accessor methods . This includes methods starting with get set and is .
7,324
protected Member getPropertyAccessor ( String propertyName ) { if ( readAccessors . containsKey ( propertyName ) ) { return ( Member ) readAccessors . get ( propertyName ) ; } else { return ( Member ) writeAccessors . get ( propertyName ) ; } }
Return any accessor be it read or write for the given property .
7,325
protected String getPropertyName ( String methodName , int prefixLength ) { return Character . toLowerCase ( methodName . charAt ( prefixLength ) ) + methodName . substring ( prefixLength + 1 ) ; }
Returns the propertyName based on the methodName . Cuts of the prefix and removes first capital .
7,326
protected String getRootPropertyName ( String propertyName ) { int location = propertyName . indexOf ( PROPERTY_KEY_PREFIX ) ; return location == - 1 ? propertyName : propertyName . substring ( 0 , location ) ; }
Returns the root property of an indexed property . The root property is the property that contains no indices .
7,327
protected String getParentPropertyName ( String propertyName ) { if ( ! PropertyAccessorUtils . isIndexedProperty ( propertyName ) ) { return "" ; } else { return propertyName . substring ( 0 , propertyName . lastIndexOf ( PROPERTY_KEY_PREFIX_CHAR ) ) ; } }
Return the parent property name of an indexed property or the empty string .
7,328
protected Object setAssemblageValue ( Class assemblageType , Object assemblage , Object index , Object value ) { if ( assemblageType . isArray ( ) ) { int i = ( ( Integer ) index ) . intValue ( ) ; if ( Array . getLength ( assemblage ) <= i ) { Object newAssemblage = Array . newInstance ( assemblageType . getComponentType ( ) , i + 1 ) ; System . arraycopy ( assemblage , 0 , newAssemblage , 0 , Array . getLength ( assemblage ) ) ; assemblage = newAssemblage ; } Array . set ( assemblage , i , value ) ; } else if ( List . class . isAssignableFrom ( assemblageType ) ) { int i = ( ( Integer ) index ) . intValue ( ) ; List list = ( List ) assemblage ; if ( list . size ( ) > i ) { list . set ( i , value ) ; } else { while ( list . size ( ) < i ) { list . add ( null ) ; } list . add ( value ) ; } } else if ( Map . class . isAssignableFrom ( assemblageType ) ) { ( ( Map ) assemblage ) . put ( index , value ) ; } else if ( assemblage instanceof Collection ) { ( ( Collection ) assemblage ) . add ( value ) ; } else { throw new IllegalArgumentException ( "assemblage must be of type array, collection or map." ) ; } return assemblage ; }
Helper method for subclasses to set values of indexed properties like map - values collection - values or array - values .
7,329
protected Binding createBinding ( String fieldName , JComponent component ) { return getBindingFactory ( ) . bindControl ( component , fieldName ) ; }
Create a binding that uses the given component instead of its default component .
7,330
protected JLabel createLabelFor ( String fieldName , JComponent component ) { JLabel label = getComponentFactory ( ) . createLabel ( "" ) ; getFormModel ( ) . getFieldFace ( fieldName ) . configure ( label ) ; label . setLabelFor ( component ) ; FormComponentInterceptor interceptor = getFormComponentInterceptor ( ) ; if ( interceptor != null ) { interceptor . processLabel ( fieldName , label ) ; } return label ; }
Create a label for the property .
7,331
public static Point getCenteringPointOnScreen ( Dimension dimension ) { Dimension screen = Toolkit . getDefaultToolkit ( ) . getScreenSize ( ) ; if ( dimension . width > screen . width ) { dimension . width = screen . width ; } if ( dimension . height > screen . height ) { dimension . height = screen . height ; } return new Point ( ( screen . width - dimension . width ) / 2 , ( screen . height - dimension . height ) / 2 ) ; }
Return the centering point on the screen for the object with the specified dimension .
7,332
public static void centerOnScreenAndSetVisible ( Window window ) { window . pack ( ) ; centerOnScreen ( window ) ; window . setVisible ( true ) ; }
Pack the window center it on the screen and set the window visible .
7,333
public static void centerOnParentAndSetVisible ( Window window ) { window . pack ( ) ; centerOnParent ( window , window . getParent ( ) ) ; window . setVisible ( true ) ; }
Pack the window center it relative to it s parent and set the window visible .
7,334
public static void centerOnParent ( Window window , Component parent ) { if ( parent == null || ! parent . isShowing ( ) ) { centerOnScreen ( window ) ; } else { window . setLocationRelativeTo ( parent ) ; } }
Center the window relative to it s parent . If the parent is null or not showing the window will be centered on the screen
7,335
public void setAuthenticationToken ( Authentication authentication ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "New authentication token: " + authentication ) ; } HttpComponentsHttpInvokerRequestExecutor executor = ( HttpComponentsHttpInvokerRequestExecutor ) getHttpInvokerRequestExecutor ( ) ; DefaultHttpClient httpClient = ( DefaultHttpClient ) executor . getHttpClient ( ) ; BasicCredentialsProvider provider = new BasicCredentialsProvider ( ) ; httpClient . setCredentialsProvider ( provider ) ; httpClient . addRequestInterceptor ( new PreemptiveAuthInterceptor ( ) ) ; UsernamePasswordCredentials usernamePasswordCredentials ; if ( authentication != null ) { usernamePasswordCredentials = new UsernamePasswordCredentials ( authentication . getName ( ) , authentication . getCredentials ( ) . toString ( ) ) ; } else { usernamePasswordCredentials = null ; } provider . setCredentials ( AuthScope . ANY , usernamePasswordCredentials ) ; }
Handle a change in the current authentication token . This method will fail fast if the executor isn t a CommonsHttpInvokerRequestExecutor .
7,336
public final void setPageDescriptor ( PageDescriptor pageDescriptor ) { Assert . notNull ( pageDescriptor , "pageDescriptor" ) ; setId ( pageDescriptor . getId ( ) ) ; setLabel ( pageDescriptor . getShowPageCommandLabel ( ) ) ; setIcon ( pageDescriptor . getIcon ( ) ) ; setCaption ( pageDescriptor . getCaption ( ) ) ; this . pageDescriptor = pageDescriptor ; }
Sets the descriptor for the page that is to be opened by this command object . This command object will be assigned the id label icon and caption from the given page descriptor .
7,337
protected Component createContentPane ( ) { JPanel content = new JPanel ( new BorderLayout ( ) ) ; Component component = super . createContentPane ( ) ; if ( component != null ) content . add ( component ) ; JProgressBar progressBar = getProgressBar ( ) ; progressBar . setIndeterminate ( isIndeterminate ( ) ) ; progressBar . setStringPainted ( isShowProgressLabel ( ) ) ; content . add ( progressBar , BorderLayout . SOUTH ) ; return content ; }
Returns a component that displays an image above a progress bar .
7,338
protected JProgressBar getProgressBar ( ) { if ( progressBar == null ) { progressBar = createProgressBar ( ) ; Assert . notNull ( progressBar , "createProgressBar should not return null" ) ; } return progressBar ; }
Returns the progress bar .
7,339
public void uncaughtException ( Thread thread , Throwable throwable ) { if ( exceptionPurger != null ) { throwable = exceptionPurger . purge ( throwable ) ; } for ( ExceptionHandlerDelegate delegate : delegateList ) { if ( delegate . hasAppropriateHandler ( throwable ) ) { delegate . uncaughtException ( thread , throwable ) ; return ; } } logger . error ( "No exception handler found for throwable" , throwable ) ; }
Delegates the throwable to the appropriate delegate exception handler .
7,340
public void setValue ( Object newValue ) { int [ ] newSelection = ( int [ ] ) newValue ; if ( hasChanged ( currentSelection , newSelection ) ) { int [ ] oldValue = currentSelection ; currentSelection = newSelection ; fireValueChange ( oldValue , currentSelection ) ; if ( ! skipSelectionModelUpdate ) { model . removeListSelectionListener ( this ) ; model . clearSelection ( ) ; int i = 0 ; int len = newSelection . length ; while ( i < len ) { int start = newSelection [ i ] ; while ( i < len - 1 && newSelection [ i ] == newSelection [ i + 1 ] - 1 ) { i ++ ; } int end = newSelection [ i ] ; model . addSelectionInterval ( start , end ) ; i ++ ; } model . addListSelectionListener ( this ) ; } } }
Set the selection value .
7,341
private boolean hasChanged ( int [ ] oldValue , int [ ] newValue ) { if ( oldValue . length == newValue . length ) { for ( int i = 0 ; i < newValue . length ; i ++ ) { if ( oldValue [ i ] != newValue [ i ] ) { return true ; } } return false ; } return true ; }
See if two arrays are different .
7,342
private int [ ] getSelectedRows ( ) { int iMin = model . getMinSelectionIndex ( ) ; int iMax = model . getMaxSelectionIndex ( ) ; if ( ( iMin == - 1 ) || ( iMax == - 1 ) ) { return new int [ 0 ] ; } int [ ] rvTmp = new int [ 1 + ( iMax - iMin ) ] ; int n = 0 ; for ( int i = iMin ; i <= iMax ; i ++ ) { if ( model . isSelectedIndex ( i ) ) { rvTmp [ n ++ ] = i ; } } int [ ] rv = new int [ n ] ; System . arraycopy ( rvTmp , 0 , rv , 0 , n ) ; return rv ; }
Returns the indices of all selected rows in the model .
7,343
public ViewDescriptor getViewDescriptor ( String viewName ) { Assert . notNull ( viewName , "viewName" ) ; try { return ( ViewDescriptor ) applicationContext . getBean ( viewName , ViewDescriptor . class ) ; } catch ( NoSuchBeanDefinitionException e ) { return null ; } }
Returns the view descriptor with the given identifier or null if no such bean definition with the given name exists in the current application context .
7,344
public void setLayout ( FormLayout layout , JPanel panel ) { this . panel = panel ; this . layout = layout ; panel . setLayout ( layout ) ; cc = new CellConstraints ( ) ; row = - 1 ; }
Set a panel with the provided layout layout .
7,345
public JComponent addBinding ( Binding binding , int column , int row , int widthSpan , int heightSpan ) { ( ( SwingBindingFactory ) getBindingFactory ( ) ) . interceptBinding ( binding ) ; JComponent component = binding . getControl ( ) ; addComponent ( component , column , row , widthSpan , heightSpan ) ; return component ; }
Add a binder to a column and a row with width and height spanning .
7,346
protected void showPopupMenu ( MouseEvent e ) { if ( onAboutToShow ( e ) ) { JPopupMenu popupToShow = getPopupMenu ( e ) ; if ( popupToShow == null ) { return ; } popupToShow . show ( e . getComponent ( ) , e . getX ( ) , e . getY ( ) ) ; popupToShow . setVisible ( true ) ; } }
Called to display the popup menu .
7,347
protected JComponent createViewToolBar ( ) { if ( getPageComponent ( ) instanceof AbstractEditor ) { AbstractEditor editor = ( AbstractEditor ) getPageComponent ( ) ; return editor . getEditorToolBar ( ) ; } return null ; }
Returns the view specific toolbar if the underlying view implementation supports it .
7,348
protected JComponent createViewMenuBar ( ) { if ( getPageComponent ( ) instanceof AbstractEditor ) { AbstractEditor editor = ( AbstractEditor ) getPageComponent ( ) ; return editor . getEditorMenuBar ( ) ; } return null ; }
Returns the view specific menubar if the underlying view implementation supports it .
7,349
public final Object buildModel ( CommandGroup commandGroup ) { Object model = buildRootModel ( commandGroup ) ; recurse ( commandGroup , model , 0 ) ; return model ; }
Main service method of this method to call .
7,350
public AuthenticationManager getAuthenticationManager ( ) { if ( ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . applicationContext ( ) . getBeansOfType ( AuthenticationManager . class ) . size ( ) != 0 ) return ValkyrieRepository . getInstance ( ) . getBean ( AuthenticationManager . class ) ; else { return null ; } }
Get the authentication manager in use .
7,351
public boolean isUserInRole ( String role ) { boolean inRole = false ; Authentication authentication = getAuthentication ( ) ; if ( authentication != null ) { Collection < ? extends GrantedAuthority > authorities = authentication . getAuthorities ( ) ; for ( GrantedAuthority authority : authorities ) { if ( role . equals ( authority . getAuthority ( ) ) ) { inRole = true ; break ; } } } return inRole ; }
Determine if the currently authenticated user has the role provided . Note that role comparisons are case sensitive .
7,352
protected < T > boolean tryToWire ( Class < T > type ) { boolean success = false ; String className = type . getName ( ) ; Map < String , T > map = getApplicationConfig ( ) . applicationContext ( ) . getBeansOfType ( type ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Search for '" + className + "' found: " + map ) ; } if ( map . size ( ) == 1 ) { Map . Entry entry = map . entrySet ( ) . iterator ( ) . next ( ) ; String name = ( String ) entry . getKey ( ) ; AuthenticationManager am = ( AuthenticationManager ) entry . getValue ( ) ; setAuthenticationManager ( am ) ; success = true ; if ( logger . isInfoEnabled ( ) ) { logger . info ( "Auto-configuration using '" + name + "' as authenticationManager" ) ; } } else if ( map . size ( ) > 1 ) { if ( logger . isInfoEnabled ( ) ) { logger . info ( "Need a single '" + className + "', found: " + map . keySet ( ) ) ; } } else { if ( logger . isInfoEnabled ( ) ) { logger . info ( "Auto-configuration did not find a suitable authenticationManager of type " + type ) ; } } return success ; }
Try to locate and wire in a suitable authentication manager .
7,353
private static void checkForValidEscapedCharacter ( int index , String labelDescriptor ) { if ( index >= labelDescriptor . length ( ) ) { throw new IllegalArgumentException ( "The label descriptor contains an invalid escape sequence. Backslash " + "characters (\\) must be followed by either an ampersand (&) or another " + "backslash." ) ; } char escapedChar = labelDescriptor . charAt ( index ) ; if ( escapedChar != '&' && escapedChar != '\\' ) { throw new IllegalArgumentException ( "The label descriptor [" + labelDescriptor + "] contains an invalid escape sequence. Backslash " + "characters (\\) must be followed by either an ampersand (&) or another " + "backslash." ) ; } }
Confirms that the character at the specified index within the given label descriptor is a valid escapable character . i . e . either an ampersand or backslash .
7,354
public void configureLabel ( JLabel label ) { Assert . notNull ( label , "label" ) ; label . setText ( this . text ) ; label . setDisplayedMnemonic ( getMnemonic ( ) ) ; if ( getMnemonicIndex ( ) >= - 1 ) { label . setDisplayedMnemonicIndex ( getMnemonicIndex ( ) ) ; } }
Configures the given label with the parameters from this instance .
7,355
public void configureLabelFor ( JLabel label , JComponent component ) { Assert . notNull ( label , "label" ) ; Assert . notNull ( component , "component" ) ; configureLabel ( label ) ; if ( ! ( component instanceof JPanel ) ) { String labelText = label . getText ( ) ; if ( ! labelText . endsWith ( ":" ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Appending colon to text field label text '" + this . text + "'" ) ; } label . setText ( labelText + ":" ) ; } } label . setLabelFor ( component ) ; }
Configures the given label with the property values described by this instance and then sets it as the label for the given component .
7,356
public void configureButton ( AbstractButton button ) { Assert . notNull ( button ) ; button . setText ( this . text ) ; button . setMnemonic ( getMnemonic ( ) ) ; button . setDisplayedMnemonicIndex ( getMnemonicIndex ( ) ) ; }
Configures the given button with the properties held in this instance . Note that this instance doesn t hold any keystroke accelerator information .
7,357
private void updateErrors ( ) { boolean oldErrors = hasErrors ; hasErrors = false ; if ( validationResults . getHasErrors ( ) ) { hasErrors = true ; } else { Iterator childIter = children . iterator ( ) ; while ( childIter . hasNext ( ) ) { ValidationResultsModel childModel = ( ValidationResultsModel ) childIter . next ( ) ; if ( childModel . getHasErrors ( ) ) { hasErrors = true ; break ; } } } firePropertyChange ( HAS_ERRORS_PROPERTY , oldErrors , hasErrors ) ; }
Revaluate the hasErrors property and fire an event if things have changed .
7,358
private void updateInfo ( ) { boolean oldInfo = hasInfo ; hasInfo = false ; if ( validationResults . getHasInfo ( ) ) { hasInfo = true ; } else { Iterator childIter = children . iterator ( ) ; while ( childIter . hasNext ( ) ) { ValidationResultsModel childModel = ( ValidationResultsModel ) childIter . next ( ) ; if ( childModel . getHasInfo ( ) ) { hasInfo = true ; break ; } } } firePropertyChange ( HAS_INFO_PROPERTY , oldInfo , hasInfo ) ; }
Revaluate the hasInfo property and fire an event if things have changed .
7,359
private void updateWarnings ( ) { boolean oldWarnings = hasWarnings ; hasWarnings = false ; if ( validationResults . getHasWarnings ( ) ) { hasWarnings = true ; } else { Iterator childIter = children . iterator ( ) ; while ( childIter . hasNext ( ) ) { ValidationResultsModel childModel = ( ValidationResultsModel ) childIter . next ( ) ; if ( childModel . getHasWarnings ( ) ) { hasWarnings = true ; break ; } } } firePropertyChange ( HAS_WARNINGS_PROPERTY , oldWarnings , hasWarnings ) ; }
Revaluate the hasWarnings property and fire an event if things have changed .
7,360
public void add ( ValidationResultsModel validationResultsModel ) { if ( children . add ( validationResultsModel ) ) { validationResultsModel . addValidationListener ( this ) ; validationResultsModel . addPropertyChangeListener ( HAS_ERRORS_PROPERTY , this ) ; validationResultsModel . addPropertyChangeListener ( HAS_WARNINGS_PROPERTY , this ) ; validationResultsModel . addPropertyChangeListener ( HAS_INFO_PROPERTY , this ) ; if ( ( validationResultsModel . getMessageCount ( ) > 0 ) ) fireChangedEvents ( ) ; } }
Add a validationResultsModel as a child to this one . Attach listeners and if it already has messages fire events .
7,361
public void remove ( ValidationResultsModel validationResultsModel ) { if ( children . remove ( validationResultsModel ) ) { validationResultsModel . removeValidationListener ( this ) ; validationResultsModel . removePropertyChangeListener ( HAS_ERRORS_PROPERTY , this ) ; validationResultsModel . removePropertyChangeListener ( HAS_WARNINGS_PROPERTY , this ) ; validationResultsModel . removePropertyChangeListener ( HAS_INFO_PROPERTY , this ) ; if ( validationResultsModel . getMessageCount ( ) > 0 ) fireChangedEvents ( ) ; } }
Remove the given validationResultsModel from the list of children . Remove listeners and if it had messages fire events .
7,362
public void propertyChange ( PropertyChangeEvent evt ) { if ( evt . getPropertyName ( ) == HAS_ERRORS_PROPERTY ) updateErrors ( ) ; else if ( evt . getPropertyName ( ) == HAS_WARNINGS_PROPERTY ) updateWarnings ( ) ; else if ( evt . getPropertyName ( ) == HAS_INFO_PROPERTY ) updateInfo ( ) ; }
Forwarding of known property events coming from child models . Each event triggers a specific evaluation of the parent property which will trigger events as needed .
7,363
private void addAndPrepareControlledObject ( Authorizable controlledObject ) { controlledObjects . add ( new WeakReference < Authorizable > ( controlledObject ) ) ; boolean authorize = shouldAuthorize ( getLastAuthentication ( ) , controlledObject ) ; updateControlledObject ( controlledObject , authorize ) ; }
Add a new object to the list of controlled objects . Install our last known authorization decision so newly created objects will reflect the current security state .
7,364
protected void runAuthorization ( ) { for ( Iterator iter = controlledObjects . iterator ( ) ; iter . hasNext ( ) ; ) { WeakReference ref = ( WeakReference ) iter . next ( ) ; Authorizable controlledObject = ( Authorizable ) ref . get ( ) ; if ( controlledObject == null ) { iter . remove ( ) ; } else { updateControlledObject ( controlledObject , shouldAuthorize ( getLastAuthentication ( ) , controlledObject ) ) ; } } }
securityAwareConfigurer Update the authorization of all controlled objects .
7,365
public static Rectangle getInteriorRectangle ( Component c , Border b , int x , int y , int width , int height ) { final Insets insets ; if ( b != null ) { insets = b . getBorderInsets ( c ) ; } else { insets = new Insets ( 0 , 0 , 0 , 0 ) ; } return new Rectangle ( x + insets . left , y + insets . top , width - insets . right - insets . left , height - insets . top - insets . bottom ) ; }
Gets the interior rectangle .
7,366
public void setAuthenticationToken ( Authentication authentication ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "New authentication token: " + authentication ) ; } final HttpInvokerRequestExecutor hire = getHttpInvokerRequestExecutor ( ) ; if ( hire instanceof BasicAuthHttpInvokerRequestExecutor ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Pass it along to executor" ) ; } ( ( BasicAuthHttpInvokerRequestExecutor ) hire ) . setAuthenticationToken ( authentication ) ; } }
Handle a change in the current authentication token . Pass it along to the executor if it s of the proper type .
7,367
@ SuppressWarnings ( "unchecked" ) public Boolean execute ( ) { for ( int i = 0 ; i < agents . length ; i ++ ) { createRoom ( i ) ; } return Boolean . TRUE ; }
Execute to create list of room
7,368
private void createRoom ( int index ) { ApiRoom agent = agents [ index ] ; try { CreateRoomSettings settings = createRoomSettings ( agent ) ; User owner = CommandUtil . getSfsUser ( agent . getOwner ( ) , api ) ; Room room = api . createRoom ( extension . getParentZone ( ) , settings , owner ) ; room . setProperty ( APIKey . ROOM , agent ) ; agent . setId ( room . getId ( ) ) ; agent . setPasswordProtected ( room . isPasswordProtected ( ) ) ; agent . setCommand ( context . command ( RoomInfo . class ) . room ( room . getId ( ) ) ) ; } catch ( SFSCreateRoomException e ) { throw new IllegalStateException ( "Can not create room " + agent . getName ( ) , e ) ; } }
Create a room at index
7,369
private CreateRoomSettings createRoomSettings ( ApiRoom agent ) { validateRoomAgentClass ( agent ) ; CreateRoomSettings settings = new CreateRoomSettings ( ) ; settings . setName ( agent . getName ( ) ) ; settings . setPassword ( agent . getPassword ( ) ) ; settings . setDynamic ( agent . isDynamic ( ) ) ; settings . setGame ( agent . isGame ( ) ) ; settings . setHidden ( agent . isHidden ( ) ) ; settings . setMaxSpectators ( agent . getMaxSpectators ( ) ) ; settings . setMaxUsers ( agent . getMaxUsers ( ) ) ; settings . setMaxVariablesAllowed ( agent . getMaxRoomVariablesAllowed ( ) ) ; settings . setRoomProperties ( agent . getProperties ( ) ) ; settings . setGroupId ( agent . getGroupdId ( ) ) ; settings . setUseWordsFilter ( agent . isUseWordsFilter ( ) ) ; settings . setAutoRemoveMode ( SFSRoomRemoveMode . fromString ( agent . getRemoveMode ( ) . name ( ) ) ) ; if ( agent . getExtension ( ) != null ) settings . setExtension ( new RoomExtensionSettings ( agent . getExtension ( ) . getName ( ) , agent . getExtension ( ) . getClazz ( ) ) ) ; return settings ; }
Create smartfox CreateRoomSettings object
7,370
@ SuppressWarnings ( "unchecked" ) public < T > T execute ( ) { User sfsUser = CommandUtil . getSfsUser ( agent , api ) ; if ( sfsUser == null ) return null ; try { AgentClassUnwrapper unwrapper = context . getUserAgentClass ( agent . getClass ( ) ) . getUnwrapper ( ) ; List < UserVariable > variables = new UserAgentSerializer ( ) . serialize ( unwrapper , agent ) ; List < UserVariable > answer = variables ; if ( includedVars . size ( ) > 0 ) answer = getVariables ( variables , includedVars ) ; answer . removeAll ( getVariables ( answer , excludedVars ) ) ; if ( toClient ) api . setUserVariables ( sfsUser , answer ) ; else sfsUser . setVariables ( answer ) ; } catch ( SFSVariableException e ) { throw new IllegalStateException ( e ) ; } return ( T ) agent ; }
Execute to update user variables
7,371
public Set < String > getVocab ( ) { Set < String > vocab = new HashSet < String > ( ) ; for ( Sentence sent : this ) { for ( String label : sent ) { vocab . add ( label ) ; } } return vocab ; }
Vocabulary of the sentences .
7,372
public static < R > ImmutableGrid < R > of ( int rowCount , int columnCount ) { return new EmptyGrid < R > ( rowCount , columnCount ) ; }
Obtains an empty immutable grid of the specified row - column count .
7,373
public static < R > ImmutableGrid < R > of ( int rowCount , int columnCount , int row , int column , R value ) { return new SingletonGrid < R > ( rowCount , columnCount , row , column , value ) ; }
Obtains an immutable grid of the specified row - column count with a single cell .
7,374
public static < R > ImmutableGrid < R > copyOf ( int rowCount , int columnCount , Cell < R > cell ) { if ( cell == null ) { throw new IllegalArgumentException ( "Cell must not be null" ) ; } return new SingletonGrid < R > ( rowCount , columnCount , cell ) ; }
Obtains an immutable grid with one cell .
7,375
public static < R > ImmutableGrid < R > copyOf ( int rowCount , int columnCount , Iterable < ? extends Cell < R > > cells ) { if ( cells == null ) { throw new IllegalArgumentException ( "Cells must not be null" ) ; } if ( ! cells . iterator ( ) . hasNext ( ) ) { return new EmptyGrid < R > ( rowCount , columnCount ) ; } return new SparseImmutableGrid < R > ( rowCount , columnCount , cells ) ; }
Obtains an immutable grid by copying a set of cells .
7,376
public FgInferencer decode ( FgModel model , UFgExample ex ) { FactorGraph fgLatPred = ex . getFactorGraph ( ) ; fgLatPred . updateFromModel ( model ) ; FgInferencer infLatPred = prm . infFactory . getInferencer ( fgLatPred ) ; infLatPred . run ( ) ; decode ( infLatPred , ex ) ; return infLatPred ; }
Runs inference and computes the MBR variable configuration . The outputs are stored on the class and can be queried after this call to decode .
7,377
public void decode ( FgInferencer infLatPred , UFgExample ex ) { FactorGraph fgLatPred = ex . getFactorGraph ( ) ; mbrVarConfig = new VarConfig ( ) ; margs = new ArrayList < VarTensor > ( ) ; varMargMap = new HashMap < Var , Double > ( ) ; if ( prm . loss == Loss . L1 || prm . loss == Loss . MSE ) { for ( int varId = 0 ; varId < fgLatPred . getNumVars ( ) ; varId ++ ) { Var var = fgLatPred . getVar ( varId ) ; VarTensor marg = infLatPred . getMarginalsForVarId ( varId ) ; margs . add ( marg ) ; int argmaxState = marg . getArgmaxConfigId ( ) ; mbrVarConfig . put ( var , argmaxState ) ; varMargMap . put ( var , marg . getValue ( argmaxState ) ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Variable marginal: " + marg ) ; } } } else { throw new RuntimeException ( "Loss type not implemented: " + prm . loss ) ; } }
Computes the MBR variable configuration from the marginals cached in the inferencer which is assumed to have already been run . The outputs are stored on the class and can be queried after this call to decode .
7,378
protected AttributeList getAttributeList ( ) throws IOException { int i ; int quote ; String name = null ; String value = null ; StringBuilder buffer = new StringBuilder ( ) ; Map < String , String > attributes = new LinkedHashMap < String , String > ( ) ; Stream stream = this . stream ; while ( true ) { while ( ( i = stream . peek ( ) ) != Stream . EOF ) { if ( Character . isLetter ( i ) || Character . isDigit ( i ) || i == ':' || i == '-' || i == '_' || i == '%' || i == '/' || i == '>' ) { break ; } else { stream . read ( ) ; } } if ( i == Stream . EOF ) { break ; } if ( i == '>' ) { break ; } else if ( i == '%' || i == '/' ) { if ( stream . peek ( 1 ) == '>' ) { break ; } continue ; } else { } while ( ( i = stream . peek ( ) ) != - 1 ) { if ( Character . isLetter ( i ) || Character . isDigit ( i ) || i == ':' || i == '-' || i == '_' ) { buffer . append ( ( char ) i ) ; stream . read ( ) ; } else { break ; } } name = buffer . toString ( ) ; buffer . setLength ( 0 ) ; if ( name . length ( ) < 1 ) { continue ; } this . stream . skipWhitespace ( ) ; i = this . stream . peek ( ) ; if ( i != '=' ) { attributes . put ( name , "" ) ; continue ; } else { this . stream . read ( ) ; } this . stream . skipWhitespace ( ) ; i = stream . peek ( ) ; if ( i == '"' ) { quote = '"' ; stream . read ( ) ; } else if ( i == '\'' ) { quote = '\'' ; stream . read ( ) ; } else { quote = ' ' ; } if ( quote == ' ' ) { value = this . getAttributeValue ( buffer ) ; } else { value = this . getAttributeValue ( buffer , quote ) ; } attributes . put ( name , value ) ; buffer . setLength ( 0 ) ; } this . stream . skipWhitespace ( ) ; return this . getAttributeList ( attributes ) ; }
read node name after read nodeName
7,379
@ SuppressWarnings ( "unchecked" ) private static List < Object > filterConstantMsgs ( List < Object > order , FactorGraph fg ) { ArrayList < Object > filt = new ArrayList < Object > ( ) ; for ( Object item : order ) { if ( item instanceof List ) { List < Object > items = filterConstantMsgs ( ( List < Object > ) item , fg ) ; if ( items . size ( ) > 0 ) { filt . add ( items ) ; } } else if ( item instanceof Integer ) { if ( ! isConstantMsg ( ( Integer ) item , fg ) ) { filt . add ( item ) ; } } else if ( item instanceof GlobalFactor ) { filt . add ( item ) ; } else { throw new RuntimeException ( "Invalid type in order: " + item . getClass ( ) ) ; } } return filt ; }
Filters edges from a leaf node .
7,380
public String getAsPennTreebankString ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "(" ) ; getAsPennTreebankString ( 1 , 1 , sb ) ; sb . append ( ")" ) ; return sb . toString ( ) ; }
Gets a string representation of this parse that looks like the typical Penn Treebank style parse .
7,381
public void postOrderFilterNodes ( final NaryTreeNodeFilter filter ) { postOrderTraversal ( new FnO1ToVoid < IntNaryTree > ( ) { public void call ( IntNaryTree node ) { if ( ! node . isLeaf ( ) ) { ArrayList < IntNaryTree > filtChildren = new ArrayList < IntNaryTree > ( ) ; for ( IntNaryTree child : node . children ) { if ( filter . accept ( child ) ) { filtChildren . add ( child ) ; } } node . children = filtChildren ; } } } ) ; updateStartEnd ( ) ; }
Keep only those nodes which the filter accepts .
7,382
public VarConfig getGoldConfigPred ( int factorId ) { VarSet vars = fgLatPred . getFactor ( factorId ) . getVars ( ) ; return goldConfig . getIntersection ( VarSet . getVarsOfType ( vars , VarType . PREDICTED ) ) ; }
Gets the gold configuration of the predicted variables ONLY for the given factor .
7,383
public int getGoldConfigIdxPred ( int factorId ) { VarSet vars = VarSet . getVarsOfType ( fgLatPred . getFactor ( factorId ) . getVars ( ) , VarType . PREDICTED ) ; return goldConfig . getConfigIndexOfSubset ( vars ) ; }
Gets the gold configuration index of the predicted variables for the given factor .
7,384
protected void clip ( Node node , int type ) { if ( node . getNodeType ( ) != NodeType . TEXT ) { return ; } char c ; int j = 0 ; String content = node . getTextContent ( ) ; if ( type == 1 ) { for ( j = content . length ( ) - 1 ; j > - 1 ; j -- ) { c = content . charAt ( j ) ; if ( c == ' ' || c == '\t' ) { continue ; } else { break ; } } content = content . substring ( 0 , j + 1 ) ; } else { int length = content . length ( ) ; for ( j = 0 ; j < length ; j ++ ) { c = content . charAt ( j ) ; if ( c == '\r' ) { continue ; } else if ( c == '\n' ) { j ++ ; break ; } else { break ; } } if ( j <= length ) { content = content . substring ( j , length ) ; } } ( ( TextNode ) node ) . setTextContent ( content ) ; }
type == 1 prefix clip type == 2 suffix clip
7,385
public static Tensor edgeScoresToTensor ( EdgeScores es , Algebra s ) { int n = es . child . length ; Tensor m = new Tensor ( s , n , n ) ; for ( int p = - 1 ; p < n ; p ++ ) { for ( int c = 0 ; c < n ; c ++ ) { if ( p == c ) { continue ; } int pp = getTensorParent ( p , c ) ; m . set ( es . getScore ( p , c ) , pp , c ) ; } } return m ; }
Convert an EdgeScores object to a Tensor where the wall node is indexed as position n + 1 in the Tensor .
7,386
public static EdgeScores tensorToEdgeScores ( Tensor t ) { if ( t . getDims ( ) . length != 2 ) { throw new IllegalArgumentException ( "Tensor must be an nxn matrix." ) ; } int n = t . getDims ( ) [ 1 ] ; EdgeScores es = new EdgeScores ( n , 0 ) ; for ( int p = - 1 ; p < n ; p ++ ) { for ( int c = 0 ; c < n ; c ++ ) { if ( p == c ) { continue ; } int pp = getTensorParent ( p , c ) ; es . setScore ( p , c , t . get ( pp , c ) ) ; } } return es ; }
Convert a Tensor object to an EdgeScores where the wall node is indexed as position n + 1 in the Tensor .
7,387
public static double [ ] [ ] combine ( double [ ] fracRoot , double [ ] [ ] fracChild ) { int nplus = fracChild . length + 1 ; double [ ] [ ] scores = new double [ nplus ] [ nplus ] ; for ( int p = 0 ; p < nplus ; p ++ ) { for ( int c = 0 ; c < nplus ; c ++ ) { if ( c == 0 ) { scores [ p ] [ c ] = Double . NEGATIVE_INFINITY ; } else if ( p == 0 && c > 0 ) { scores [ p ] [ c ] = fracRoot [ c - 1 ] ; } else { scores [ p ] [ c ] = fracChild [ p - 1 ] [ c - 1 ] ; } } } return scores ; }
Combines a set of edge weights represented as wall and child weights into a single set of weights . The combined weights are indexed such that the wall has index 0 and the tokens of the sentence are 1 - indexed .
7,388
public static FactorGraph getFgLat ( FactorGraph fgLatPred , VarConfig goldConfig ) { List < Var > predictedVars = VarSet . getVarsOfType ( fgLatPred . getVars ( ) , VarType . PREDICTED ) ; VarConfig predConfig = goldConfig . getIntersection ( predictedVars ) ; FactorGraph fgLat = fgLatPred . getClamped ( predConfig ) ; assert ( fgLatPred . getNumFactors ( ) <= fgLat . getNumFactors ( ) ) ; return fgLat ; }
Get a copy of the factor graph where the predicted variables are clamped .
7,389
public static FeatureVector getExpectedFeatureCounts ( FgExampleList data , FgInferencerFactory infFactory , FgModel model , double [ ] params ) { model . updateModelFromDoubles ( params ) ; FgModel feats = model . getDenseCopy ( ) ; feats . zero ( ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { LFgExample ex = data . get ( i ) ; FactorGraph fgLatPred = ex . getFactorGraph ( ) ; fgLatPred . updateFromModel ( model ) ; FgInferencer infLatPred = infFactory . getInferencer ( fgLatPred ) ; infLatPred . run ( ) ; addExpectedPartials ( fgLatPred , infLatPred , 1.0 * ex . getWeight ( ) , feats ) ; } double [ ] f = new double [ model . getNumParams ( ) ] ; feats . updateDoublesFromModel ( f ) ; return new FeatureVector ( f ) ; }
Gets the expected feature counts .
7,390
public static FeatureVector getObservedFeatureCounts ( FgExampleList data , FgInferencerFactory infFactory , FgModel model , double [ ] params ) { model . updateModelFromDoubles ( params ) ; FgModel feats = model . getDenseCopy ( ) ; feats . zero ( ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { LFgExample ex = data . get ( i ) ; FactorGraph fgLat = getFgLat ( ex . getFactorGraph ( ) , ex . getGoldConfig ( ) ) ; fgLat . updateFromModel ( model ) ; FgInferencer infLat = infFactory . getInferencer ( fgLat ) ; infLat . run ( ) ; addExpectedPartials ( fgLat , infLat , 1.0 * ex . getWeight ( ) , feats ) ; } double [ ] f = new double [ model . getNumParams ( ) ] ; feats . updateDoublesFromModel ( f ) ; return new FeatureVector ( f ) ; }
Gets the observed feature counts .
7,391
public PublicKey get ( KeyStoreChooser keyStoreChooser , PublicKeyChooserByAlias publicKeyChooserByAlias ) { CacheKey cacheKey = new CacheKey ( keyStoreChooser . getKeyStoreName ( ) , publicKeyChooserByAlias . getAlias ( ) ) ; PublicKey retrievedPublicKey = cache . get ( cacheKey ) ; if ( retrievedPublicKey != null ) { return retrievedPublicKey ; } KeyStore keyStore = keyStoreRegistry . get ( keyStoreChooser ) ; if ( keyStore != null ) { PublicKeyFactoryBean factory = new PublicKeyFactoryBean ( ) ; factory . setKeystore ( keyStore ) ; factory . setAlias ( publicKeyChooserByAlias . getAlias ( ) ) ; try { factory . afterPropertiesSet ( ) ; PublicKey publicKey = ( PublicKey ) factory . getObject ( ) ; if ( publicKey != null ) { cache . put ( cacheKey , publicKey ) ; } return publicKey ; } catch ( Exception e ) { throw new PublicKeyException ( "error initializing the public key factory bean" , e ) ; } } return null ; }
Returns the selected public key or null if not found .
7,392
public void add ( N node ) { if ( ! node . added ) { nodes . add ( node ) ; node . added = true ; } }
Adds the node if it s not already present in the graph .
7,393
public void add ( E edge ) { if ( ! edge . added ) { edges . add ( edge ) ; edge . added = true ; add ( edge . getChild ( ) ) ; add ( edge . getParent ( ) ) ; } }
Adds the edge and its nodes if not already present in the graph .
7,394
private void dfs ( Node root ) { root . setMarked ( true ) ; for ( Edge e : root . getOutEdges ( ) ) { N n = e . getChild ( ) ; if ( ! n . isMarked ( ) ) { dfs ( n ) ; } } }
Runs depth - first search on the graph starting at node n marking each node as it is encountered .
7,395
public void preOrderTraversal ( N root , Visitor < N > v ) { setMarkedAllNodes ( false ) ; preOrderTraveralRecursive ( root , v ) ; }
Visits the nodes in a pre - order traversal .
7,396
protected void onCreate ( Bundle icicle ) { super . onCreate ( icicle ) ; mAccountAuthenticatorResponse = getIntent ( ) . getParcelableExtra ( AccountManager . KEY_ACCOUNT_AUTHENTICATOR_RESPONSE ) ; if ( mAccountAuthenticatorResponse != null ) { mAccountAuthenticatorResponse . onRequestContinued ( ) ; } }
Retreives the AccountAuthenticatorResponse from either the intent of the icicle if the icicle is non - zero .
7,397
public void finish ( ) { if ( mAccountAuthenticatorResponse != null ) { if ( mResultBundle != null ) { mAccountAuthenticatorResponse . onResult ( mResultBundle ) ; } else { mAccountAuthenticatorResponse . onError ( AccountManager . ERROR_CODE_CANCELED , "canceled" ) ; } mAccountAuthenticatorResponse = null ; } super . finish ( ) ; }
Sends the result or a Constants . ERROR_CODE_CANCELED error if a result isn t present .
7,398
public static boolean containsZeros ( Tensor tmFalseIn ) { Algebra s = tmFalseIn . getAlgebra ( ) ; for ( int c = 0 ; c < tmFalseIn . size ( ) ; c ++ ) { if ( tmFalseIn . getValue ( c ) == s . zero ( ) ) { return true ; } } return false ; }
Returns true if the tensor contains zeros .
7,399
public static final void parseSentence ( final int [ ] sent , final CnfGrammar grammar , final LoopOrder loopOrder , final Chart chart , final Scorer scorer ) { for ( int i = 0 ; i <= sent . length - 1 ; i ++ ) { ChartCell cell = chart . getCell ( i , i + 1 ) ; for ( final Rule r : grammar . getLexicalRulesWithChild ( sent [ i ] ) ) { double score = scorer . score ( r , i , i + 1 , i + 1 ) ; cell . updateCell ( r . getParent ( ) , score , i + 1 , r ) ; } } for ( int width = 1 ; width <= sent . length ; width ++ ) { for ( int start = 0 ; start <= sent . length - width ; start ++ ) { int end = start + width ; ChartCell cell = chart . getCell ( start , end ) ; if ( loopOrder == LoopOrder . CARTESIAN_PRODUCT ) { processCellCartesianProduct ( grammar , chart , start , end , cell , scorer ) ; } else if ( loopOrder == LoopOrder . LEFT_CHILD ) { processCellLeftChild ( grammar , chart , start , end , cell , scorer ) ; } else if ( loopOrder == LoopOrder . RIGHT_CHILD ) { processCellRightChild ( grammar , chart , start , end , cell , scorer ) ; } else { throw new RuntimeException ( "Not implemented: " + loopOrder ) ; } processCellUnaryRules ( grammar , start , end , cell , scorer ) ; if ( width == sent . length ) { processCellUnaryRules ( grammar , start , end , cell , scorer ) ; } cell . close ( ) ; } } }
Runs CKY and populates the chart .