idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
20,900
protected char [ ] removeFragmentIdentifier ( char [ ] component ) { if ( component == null ) { return null ; } int lastIndex = new String ( component ) . indexOf ( '#' ) ; if ( lastIndex != - 1 ) { component = new String ( component ) . substring ( 0 , lastIndex ) . toCharArray ( ) ; } return component ; }
Remove the fragment identifier of the given component .
20,901
protected char [ ] normalize ( char [ ] path ) throws URIException { if ( path == null ) { return null ; } String normalized = new String ( path ) ; if ( normalized . startsWith ( "./" ) ) { normalized = normalized . substring ( 1 ) ; } else if ( normalized . startsWith ( "../" ) ) { normalized = normalized . substring ( 2 ) ; } else if ( normalized . startsWith ( ".." ) ) { normalized = normalized . substring ( 2 ) ; } int index = - 1 ; while ( ( index = normalized . indexOf ( "/./" ) ) != - 1 ) { normalized = normalized . substring ( 0 , index ) + normalized . substring ( index + 2 ) ; } if ( normalized . endsWith ( "/." ) ) { normalized = normalized . substring ( 0 , normalized . length ( ) - 1 ) ; } int startIndex = 0 ; while ( ( index = normalized . indexOf ( "/../" , startIndex ) ) != - 1 ) { int slashIndex = normalized . lastIndexOf ( '/' , index - 1 ) ; if ( slashIndex >= 0 ) { normalized = normalized . substring ( 0 , slashIndex ) + normalized . substring ( index + 3 ) ; } else { startIndex = index + 3 ; } } if ( normalized . endsWith ( "/.." ) ) { int slashIndex = normalized . lastIndexOf ( '/' , normalized . length ( ) - 4 ) ; if ( slashIndex >= 0 ) { normalized = normalized . substring ( 0 , slashIndex + 1 ) ; } } while ( ( index = normalized . indexOf ( "/../" ) ) != - 1 ) { int slashIndex = normalized . lastIndexOf ( '/' , index - 1 ) ; if ( slashIndex >= 0 ) { break ; } else { normalized = normalized . substring ( index + 3 ) ; } } if ( normalized . endsWith ( "/.." ) ) { int slashIndex = normalized . lastIndexOf ( '/' , normalized . length ( ) - 4 ) ; if ( slashIndex < 0 ) { normalized = "/" ; } } return normalized . toCharArray ( ) ; }
Normalize the given hier path part .
20,902
public int compareTo ( Object obj ) throws ClassCastException { URI another = ( URI ) obj ; if ( ! equals ( _authority , another . getRawAuthority ( ) ) ) { return - 1 ; } return toString ( ) . compareTo ( another . toString ( ) ) ; }
Compare this URI to another object .
20,903
public char [ ] getRawURIReference ( ) { if ( _fragment == null ) { return _uri ; } if ( _uri == null ) { return _fragment ; } String uriReference = new String ( _uri ) + "#" + new String ( _fragment ) ; return uriReference . toCharArray ( ) ; }
Get the URI reference character sequence .
20,904
public String getURIReference ( ) throws URIException { char [ ] uriReference = getRawURIReference ( ) ; return ( uriReference == null ) ? null : decode ( uriReference , getProtocolCharset ( ) ) ; }
Get the original URI reference string .
20,905
public void setProxyExcludedDomains ( List < DomainMatcher > proxyExcludedDomains ) { if ( proxyExcludedDomains == null || proxyExcludedDomains . isEmpty ( ) ) { ( ( HierarchicalConfiguration ) getConfig ( ) ) . clearTree ( ALL_PROXY_EXCLUDED_DOMAINS_KEY ) ; this . proxyExcludedDomains = Collections . emptyList ( ) ; this . proxyExcludedDomainsEnabled = Collections . emptyList ( ) ; return ; } this . proxyExcludedDomains = new ArrayList < > ( proxyExcludedDomains ) ; ( ( HierarchicalConfiguration ) getConfig ( ) ) . clearTree ( ALL_PROXY_EXCLUDED_DOMAINS_KEY ) ; int size = proxyExcludedDomains . size ( ) ; ArrayList < DomainMatcher > enabledExcludedDomains = new ArrayList < > ( size ) ; for ( int i = 0 ; i < size ; ++ i ) { String elementBaseKey = ALL_PROXY_EXCLUDED_DOMAINS_KEY + "(" + i + ")." ; DomainMatcher excludedDomain = proxyExcludedDomains . get ( i ) ; getConfig ( ) . setProperty ( elementBaseKey + PROXY_EXCLUDED_DOMAIN_VALUE_KEY , excludedDomain . getValue ( ) ) ; getConfig ( ) . setProperty ( elementBaseKey + PROXY_EXCLUDED_DOMAIN_REGEX_KEY , excludedDomain . isRegex ( ) ) ; getConfig ( ) . setProperty ( elementBaseKey + PROXY_EXCLUDED_DOMAIN_ENABLED_KEY , excludedDomain . isEnabled ( ) ) ; if ( excludedDomain . isEnabled ( ) ) { enabledExcludedDomains . add ( excludedDomain ) ; } } enabledExcludedDomains . trimToSize ( ) ; this . proxyExcludedDomainsEnabled = enabledExcludedDomains ; }
Sets the domains that will be excluded from the outgoing proxy .
20,906
public void addStructuralNodeModifier ( StructuralNodeModifier snm ) { this . snms . add ( snm ) ; this . fireTableRowsInserted ( this . snms . size ( ) - 1 , this . snms . size ( ) - 1 ) ; }
Adds a new structural node modifiers to this model
20,907
private JScrollPane getJScrollPane ( ) { if ( jScrollPane == null ) { jScrollPane = new JScrollPane ( ) ; jScrollPane . setViewportView ( getMainPanel ( ) ) ; jScrollPane . setName ( "ScanProgressScrollPane" ) ; jScrollPane . setHorizontalScrollBarPolicy ( JScrollPane . HORIZONTAL_SCROLLBAR_NEVER ) ; jScrollPane . setVerticalScrollBarPolicy ( JScrollPane . VERTICAL_SCROLLBAR_AS_NEEDED ) ; } return jScrollPane ; }
Get the dialog scroll panel
20,908
private JTable getMainPanel ( ) { if ( table == null ) { model = new ScanProgressTableModel ( ) ; table = new JTable ( ) ; table . setModel ( model ) ; table . setRowSelectionAllowed ( false ) ; table . setColumnSelectionAllowed ( false ) ; table . setDoubleBuffered ( true ) ; table . getColumnModel ( ) . getColumn ( 0 ) . setPreferredWidth ( 256 ) ; table . getColumnModel ( ) . getColumn ( 1 ) . setPreferredWidth ( 80 ) ; table . getColumnModel ( ) . getColumn ( 2 ) . setPreferredWidth ( 80 ) ; table . getColumnModel ( ) . getColumn ( 2 ) . setCellRenderer ( new ScanProgressBarRenderer ( ) ) ; DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer ( ) ; centerRenderer . setHorizontalAlignment ( JLabel . CENTER ) ; table . getColumnModel ( ) . getColumn ( 3 ) . setPreferredWidth ( 85 ) ; table . getColumnModel ( ) . getColumn ( 3 ) . setCellRenderer ( centerRenderer ) ; DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer ( ) ; rightRenderer . setHorizontalAlignment ( JLabel . RIGHT ) ; table . getColumnModel ( ) . getColumn ( 4 ) . setPreferredWidth ( 60 ) ; table . getColumnModel ( ) . getColumn ( 4 ) . setCellRenderer ( rightRenderer ) ; table . getColumnModel ( ) . getColumn ( 5 ) . setPreferredWidth ( 60 ) ; table . getColumnModel ( ) . getColumn ( 5 ) . setCellRenderer ( rightRenderer ) ; table . getColumnModel ( ) . getColumn ( 6 ) . setPreferredWidth ( 40 ) ; table . getColumnModel ( ) . getColumn ( 6 ) . setCellRenderer ( new ScanProgressActionRenderer ( ) ) ; ScanProgressActionListener listener = new ScanProgressActionListener ( table , model ) ; table . addMouseListener ( listener ) ; table . addMouseMotionListener ( listener ) ; } return table ; }
Get the main content panel of the dialog
20,909
public void setActiveScan ( ActiveScan scan ) { this . scan = scan ; if ( scan == null ) { return ; } getHostSelect ( ) . removeAll ( ) ; for ( HostProcess hp : scan . getHostProcesses ( ) ) { getHostSelect ( ) . addItem ( hp . getHostAndPort ( ) ) ; } Thread thread = new Thread ( ) { public void run ( ) { while ( ! stopThread ) { SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { updateProgress ( ) ; } } ) ; try { sleep ( 200 ) ; } catch ( InterruptedException e ) { } } } } ; thread . start ( ) ; }
Set the scan that will be shown in this dialog .
20,910
private void removeHelpProperties ( JComponent component ) { component . putClientProperty ( HELP_ID_PROPERTY , null ) ; component . putClientProperty ( HELP_SET_PROPERTY , null ) ; }
Removes the help properties from the given component .
20,911
public static void showHelp ( String helpindex ) { if ( getHelpBroker ( ) == null ) { return ; } try { getHelpBroker ( ) . showID ( helpindex , "javax.help.SecondaryWindow" , null ) ; } catch ( Exception e ) { logger . error ( "error loading help with index: " + helpindex , e ) ; } }
Shows a specific help topic
20,912
public void setParameter ( String parameterName , String parameterValue ) { log . trace ( "enter PostMethod.setParameter(String, String)" ) ; removeParameter ( parameterName ) ; addParameter ( parameterName , parameterValue ) ; }
Sets the value of parameter with parameterName to parameterValue . This method does not preserve the initial insertion order .
20,913
public NameValuePair getParameter ( String paramName ) { log . trace ( "enter PostMethod.getParameter(String)" ) ; if ( paramName == null ) { return null ; } Iterator < NameValuePair > iter = this . params . iterator ( ) ; while ( iter . hasNext ( ) ) { NameValuePair parameter = iter . next ( ) ; if ( paramName . equals ( parameter . getName ( ) ) ) { return parameter ; } } return null ; }
Gets the parameter of the specified name . If there exists more than one parameter with the name paramName then only the first one is returned .
20,914
public NameValuePair [ ] getParameters ( ) { log . trace ( "enter PostMethod.getParameters()" ) ; int numPairs = this . params . size ( ) ; Object [ ] objectArr = this . params . toArray ( ) ; NameValuePair [ ] nvPairArr = new NameValuePair [ numPairs ] ; for ( int i = 0 ; i < numPairs ; i ++ ) { nvPairArr [ i ] = ( NameValuePair ) objectArr [ i ] ; } return nvPairArr ; }
Gets the parameters currently added to the PostMethod . If there are no parameters a valid array is returned with zero elements . The returned array object contains an array of pointers to the internal data members .
20,915
public void addParameters ( NameValuePair [ ] parameters ) { log . trace ( "enter PostMethod.addParameters(NameValuePair[])" ) ; if ( parameters == null ) { log . warn ( "Attempt to addParameters(null) ignored" ) ; } else { super . clearRequestBody ( ) ; for ( int i = 0 ; i < parameters . length ; i ++ ) { this . params . add ( parameters [ i ] ) ; } } }
Adds an array of parameters to be used in the POST request body . Logs a warning if the parameters argument is null .
20,916
public boolean removeParameter ( String paramName ) throws IllegalArgumentException { log . trace ( "enter PostMethod.removeParameter(String)" ) ; if ( paramName == null ) { throw new IllegalArgumentException ( "Argument passed to removeParameter(String) cannot be null" ) ; } boolean removed = false ; Iterator < NameValuePair > iter = this . params . iterator ( ) ; while ( iter . hasNext ( ) ) { NameValuePair pair = iter . next ( ) ; if ( paramName . equals ( pair . getName ( ) ) ) { iter . remove ( ) ; removed = true ; } } return removed ; }
Removes all parameters with the given paramName . If there is more than one parameter with the given paramName all of them are removed . If there is just one it is removed . If there are none then the request is ignored .
20,917
public void setRequestBody ( NameValuePair [ ] parametersBody ) throws IllegalArgumentException { log . trace ( "enter PostMethod.setRequestBody(NameValuePair[])" ) ; if ( parametersBody == null ) { throw new IllegalArgumentException ( "Array of parameters may not be null" ) ; } clearRequestBody ( ) ; addParameters ( parametersBody ) ; }
Sets an array of parameters to be used in the POST request body
20,918
public void setFormParams ( TreeSet < HtmlParameter > postParams ) { if ( postParams . isEmpty ( ) ) { this . setBody ( "" ) ; return ; } StringBuilder postData = new StringBuilder ( ) ; for ( HtmlParameter parameter : postParams ) { if ( parameter . getType ( ) != HtmlParameter . Type . form ) { continue ; } postData . append ( parameter . getName ( ) ) ; postData . append ( '=' ) ; postData . append ( parameter . getValue ( ) ) ; postData . append ( '&' ) ; } String data = "" ; if ( postData . length ( ) != 0 ) { data = postData . substring ( 0 , postData . length ( ) - 1 ) ; } this . setBody ( data ) ; }
Construct a HTTP POST Body from the variables in postParams
20,919
void setWorkbenchLayout ( Layout layout ) { validateNotNull ( layout , "layout" ) ; if ( this . layout == layout ) { return ; } requestTabIndex = getCurrentRequestTabIndex ( ) ; Layout previousLayout = this . layout ; this . layout = layout ; componentMaximiser . unmaximiseComponent ( ) ; removeAll ( ) ; List < AbstractPanel > visiblePanels ; switch ( layout ) { case FULL : visiblePanels = getTabbedStatus ( ) . getVisiblePanels ( ) ; getTabbedStatus ( ) . hideAllTabs ( ) ; visiblePanels . addAll ( getTabbedWork ( ) . getVisiblePanels ( ) ) ; getTabbedWork ( ) . hideAllTabs ( ) ; visiblePanels . addAll ( getTabbedSelect ( ) . getVisiblePanels ( ) ) ; getTabbedSelect ( ) . hideAllTabs ( ) ; getTabbedFull ( ) . setVisiblePanels ( visiblePanels ) ; updateFullLayout ( ) ; this . add ( getFullLayoutPanel ( ) ) ; break ; case EXPAND_SELECT : case EXPAND_STATUS : default : this . add ( layout == Layout . EXPAND_STATUS ? createStatusPanelsSplit ( ) : createSelectPanelsSplit ( ) ) ; if ( previousLayout == Layout . FULL ) { visiblePanels = getTabbedFull ( ) . getVisiblePanels ( ) ; getTabbedFull ( ) . hideAllTabs ( ) ; getTabbedStatus ( ) . setVisiblePanels ( visiblePanels ) ; getTabbedWork ( ) . setVisiblePanels ( visiblePanels ) ; getTabbedSelect ( ) . setVisiblePanels ( visiblePanels ) ; setResponsePanelPosition ( responsePanelPosition ) ; } break ; } this . validate ( ) ; this . repaint ( ) ; }
Sets the layout of the workbench panel .
20,920
private JPanel getPaneStatus ( ) { if ( paneStatus == null ) { paneStatus = new JPanel ( ) ; paneStatus . setLayout ( new BorderLayout ( 0 , 0 ) ) ; paneStatus . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 0 , 0 ) ) ; paneStatus . add ( getTabbedStatus ( ) ) ; } return paneStatus ; }
This method initializes paneStatus
20,921
private JPanel getPaneSelect ( ) { if ( paneSelect == null ) { paneSelect = new JPanel ( ) ; paneSelect . setLayout ( new BorderLayout ( 0 , 0 ) ) ; paneSelect . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 0 , 0 ) ) ; paneSelect . add ( getTabbedSelect ( ) ) ; } return paneSelect ; }
This method initializes paneSelect
20,922
public void addPanels ( List < AbstractPanel > panels , PanelType panelType ) { validateNotNull ( panels , "panels" ) ; validateNotNull ( panelType , "panelType" ) ; boolean fullLayout = layout == Layout . FULL ; addPanels ( getTabbedFull ( ) , panels , fullLayout ) ; switch ( panelType ) { case SELECT : addPanels ( getTabbedSelect ( ) , panels , ! fullLayout ) ; break ; case STATUS : addPanels ( getTabbedStatus ( ) , panels , ! fullLayout ) ; break ; case WORK : addPanels ( getTabbedWork ( ) , panels , ! fullLayout ) ; break ; default : break ; } }
Adds the given panels to the workbench hinting with the given panel type .
20,923
public void addPanel ( AbstractPanel panel , PanelType panelType ) { validateNotNull ( panel , "panel" ) ; validateNotNull ( panelType , "panelType" ) ; boolean fullLayout = layout == Layout . FULL ; addPanel ( getTabbedFull ( ) , panel , fullLayout ) ; switch ( panelType ) { case SELECT : addPanel ( getTabbedSelect ( ) , panel , ! fullLayout ) ; getTabbedSelect ( ) . revalidate ( ) ; break ; case STATUS : addPanel ( getTabbedStatus ( ) , panel , ! fullLayout ) ; getTabbedStatus ( ) . revalidate ( ) ; break ; case WORK : addPanel ( getTabbedWork ( ) , panel , ! fullLayout ) ; getTabbedWork ( ) . revalidate ( ) ; break ; default : break ; } }
Adds the given panel to the workbench hinting with the given panel type .
20,924
public void removePanels ( List < AbstractPanel > panels , PanelType panelType ) { validateNotNull ( panels , "panels" ) ; validateNotNull ( panelType , "panelType" ) ; removePanels ( getTabbedFull ( ) , panels ) ; switch ( panelType ) { case SELECT : removePanels ( getTabbedSelect ( ) , panels ) ; break ; case STATUS : removePanels ( getTabbedStatus ( ) , panels ) ; break ; case WORK : removePanels ( getTabbedWork ( ) , panels ) ; break ; default : break ; } }
Removes the given panels of given panel type from the workbench panel .
20,925
public void removePanel ( AbstractPanel panel , PanelType panelType ) { validateNotNull ( panel , "panel" ) ; validateNotNull ( panelType , "panelType" ) ; removeTabPanel ( getTabbedFull ( ) , panel ) ; getTabbedFull ( ) . revalidate ( ) ; switch ( panelType ) { case SELECT : removeTabPanel ( getTabbedSelect ( ) , panel ) ; getTabbedSelect ( ) . revalidate ( ) ; break ; case STATUS : removeTabPanel ( getTabbedStatus ( ) , panel ) ; getTabbedStatus ( ) . revalidate ( ) ; break ; case WORK : removeTabPanel ( getTabbedWork ( ) , panel ) ; getTabbedWork ( ) . revalidate ( ) ; break ; default : break ; } }
Removes the given panel of given panel type from the workbench panel .
20,926
public List < AbstractPanel > getPanels ( PanelType panelType ) { validateNotNull ( panelType , "panelType" ) ; List < AbstractPanel > panels = new ArrayList < > ( ) ; switch ( panelType ) { case SELECT : panels . addAll ( getTabbedSelect ( ) . getPanels ( ) ) ; break ; case STATUS : panels . addAll ( getTabbedStatus ( ) . getPanels ( ) ) ; break ; case WORK : panels . addAll ( getTabbedWork ( ) . getPanels ( ) ) ; break ; default : break ; } return panels ; }
Gets the panels that were added to the workbench with the given panel type .
20,927
public SortedSet < AbstractPanel > getSortedPanels ( PanelType panelType ) { validateNotNull ( panelType , "panelType" ) ; List < AbstractPanel > panels = getPanels ( panelType ) ; SortedSet < AbstractPanel > sortedPanels = new TreeSet < > ( new Comparator < AbstractPanel > ( ) { public int compare ( AbstractPanel abstractPanel , AbstractPanel otherAbstractPanel ) { String name = abstractPanel . getName ( ) ; String otherName = otherAbstractPanel . getName ( ) ; if ( name == null ) { if ( otherName == null ) { return 0 ; } return - 1 ; } else if ( otherName == null ) { return 1 ; } return name . compareTo ( otherName ) ; } } ) ; sortedPanels . addAll ( panels ) ; return sortedPanels ; }
Gets the panels sorted by name that were added to the workbench with the given panel type .
20,928
public void pinVisiblePanels ( ) { if ( layout == Layout . FULL ) { getTabbedFull ( ) . pinVisibleTabs ( ) ; } else { getTabbedSelect ( ) . pinVisibleTabs ( ) ; getTabbedWork ( ) . pinVisibleTabs ( ) ; getTabbedStatus ( ) . pinVisibleTabs ( ) ; } }
Pins all visible panels .
20,929
public void unpinVisiblePanels ( ) { if ( layout == Layout . FULL ) { getTabbedFull ( ) . unpinTabs ( ) ; } else { getTabbedSelect ( ) . unpinTabs ( ) ; getTabbedWork ( ) . unpinTabs ( ) ; getTabbedStatus ( ) . unpinTabs ( ) ; } }
Unpins all visible panels .
20,930
void setResponsePanelPosition ( ResponsePanelPosition position ) { validateNotNull ( position , "position" ) ; requestTabIndex = getCurrentRequestTabIndex ( ) ; responsePanelPosition = position ; if ( layout == Layout . FULL ) { updateFullLayout ( ) ; return ; } Component currentTabbedPanel = componentMaximiser . getMaximisedComponent ( ) ; if ( componentMaximiser . isComponentMaximised ( ) ) { componentMaximiser . unmaximiseComponent ( ) ; } boolean selectRequest = removeSplitRequestAndResponsePanel ( tabbedWork ) ; switch ( position ) { case PANEL_ABOVE : splitResponsePanelWithWorkTabbedPanel ( JSplitPane . VERTICAL_SPLIT ) ; break ; case PANELS_SIDE_BY_SIDE : splitResponsePanelWithWorkTabbedPanel ( JSplitPane . HORIZONTAL_SPLIT ) ; break ; case TAB_SIDE_BY_SIDE : splitResponsePanelWithRequestPanel ( JSplitPane . HORIZONTAL_SPLIT , tabbedWork ) ; getPaneWork ( ) . removeAll ( ) ; getPaneWork ( ) . add ( getTabbedWork ( ) ) ; getPaneWork ( ) . validate ( ) ; break ; case TABS_SIDE_BY_SIDE : default : if ( currentTabbedPanel == responseTabbedPanel ) { currentTabbedPanel = tabbedWork ; } insertResponseTab ( tabbedWork ) ; getPaneWork ( ) . removeAll ( ) ; getPaneWork ( ) . add ( getTabbedWork ( ) ) ; getPaneWork ( ) . validate ( ) ; } if ( selectRequest || getTabbedWork ( ) . getSelectedComponent ( ) == null ) { getTabbedWork ( ) . setSelectedComponent ( responsePanelPosition == ResponsePanelPosition . TAB_SIDE_BY_SIDE ? splitRequestAndResponsePanel : requestPanel ) ; } if ( currentTabbedPanel != null ) { componentMaximiser . maximiseComponent ( currentTabbedPanel ) ; } }
Sets the position of the response panel .
20,931
private void analyse ( StructuralNode node ) throws Exception { if ( node . getHistoryReference ( ) == null ) { return ; } if ( ! parent . nodeInScope ( node . getName ( ) ) ) { return ; } HttpMessage baseMsg = node . getHistoryReference ( ) . getHttpMessage ( ) ; URI baseUri = ( URI ) baseMsg . getRequestHeader ( ) . getURI ( ) . clone ( ) ; baseUri . setQuery ( null ) ; if ( mapVisited . get ( baseUri . toString ( ) ) != null ) { return ; } String path = getRandomPathSuffix ( node , baseUri ) ; HttpMessage msg = baseMsg . cloneRequest ( ) ; URI uri = ( URI ) baseUri . clone ( ) ; uri . setPath ( path ) ; msg . getRequestHeader ( ) . setURI ( uri ) ; sendAndReceive ( msg ) ; if ( msg . getResponseHeader ( ) . getStatusCode ( ) == HttpStatusCode . NOT_FOUND ) { addAnalysedHost ( baseUri , msg , SampleResponse . ERROR_PAGE_RFC ) ; return ; } if ( HttpStatusCode . isRedirection ( msg . getResponseHeader ( ) . getStatusCode ( ) ) ) { addAnalysedHost ( baseUri , msg , SampleResponse . ERROR_PAGE_REDIRECT ) ; return ; } if ( msg . getResponseHeader ( ) . getStatusCode ( ) != HttpStatusCode . OK ) { addAnalysedHost ( baseUri , msg , SampleResponse . ERROR_PAGE_NON_RFC ) ; return ; } HttpMessage msg2 = baseMsg . cloneRequest ( ) ; URI uri2 = msg2 . getRequestHeader ( ) . getURI ( ) ; String path2 = getRandomPathSuffix ( node , uri2 ) ; uri2 = ( URI ) baseUri . clone ( ) ; uri2 . setPath ( path2 ) ; msg2 . getRequestHeader ( ) . setURI ( uri2 ) ; sendAndReceive ( msg2 ) ; String resBody1 = msg . getResponseBody ( ) . toString ( ) . replaceAll ( p_REMOVE_HEADER , "" ) ; String resBody2 = msg2 . getResponseBody ( ) . toString ( ) . replaceAll ( p_REMOVE_HEADER , "" ) ; if ( resBody1 . equals ( resBody2 ) ) { msg . getResponseBody ( ) . setBody ( resBody1 ) ; addAnalysedHost ( baseUri , msg , SampleResponse . ERROR_PAGE_STATIC ) ; return ; } resBody1 = resBody1 . replaceAll ( getPathRegex ( uri ) , "" ) . replaceAll ( "\\s[012]\\d:[0-5]\\d:[0-5]\\d\\s" , "" ) ; resBody2 = resBody2 . replaceAll ( getPathRegex ( uri2 ) , "" ) . replaceAll ( "\\s[012]\\d:[0-5]\\d:[0-5]\\d\\s" , "" ) ; if ( resBody1 . equals ( resBody2 ) ) { msg . getResponseBody ( ) . setBody ( resBody1 ) ; addAnalysedHost ( baseUri , msg , SampleResponse . ERROR_PAGE_DYNAMIC_BUT_DETERMINISTIC ) ; return ; } addAnalysedHost ( baseUri , msg , SampleResponse . ERROR_PAGE_UNDETERMINISTIC ) ; }
Analyse a single folder entity . Results are stored into mAnalysedEntityTable .
20,932
private String getChildSuffix ( StructuralNode node , boolean performRecursiveCheck ) { String resultSuffix = "" ; String suffix = null ; StructuralNode child = null ; try { for ( int i = 0 ; i < staticSuffixList . length ; i ++ ) { suffix = staticSuffixList [ i ] ; Iterator < StructuralNode > iter = node . getChildIterator ( ) ; while ( iter . hasNext ( ) ) { child = iter . next ( ) ; try { if ( child . getURI ( ) . getPath ( ) . endsWith ( suffix ) ) { return suffix ; } } catch ( Exception e ) { } } } if ( performRecursiveCheck ) { Iterator < StructuralNode > iter = node . getChildIterator ( ) ; while ( iter . hasNext ( ) ) { child = iter . next ( ) ; resultSuffix = getChildSuffix ( child , performRecursiveCheck ) ; if ( ! resultSuffix . equals ( "" ) ) { return resultSuffix ; } } } } catch ( Exception e ) { } return resultSuffix ; }
Get a suffix from the children which exists in staticSuffixList . An option is provided to check recursively . Note that the immediate children are always checked first before further recursive check is done .
20,933
private String getRandomPathSuffix ( StructuralNode node , URI uri ) throws URIException { String resultSuffix = getChildSuffix ( node , true ) ; String path = "" ; path = ( uri . getPath ( ) == null ) ? "" : uri . getPath ( ) ; path = path + ( path . endsWith ( "/" ) ? "" : "/" ) + Long . toString ( getRndPositiveLong ( ) ) ; path = path + resultSuffix ; return path ; }
Get a random path relative to the current entity . Whenever possible use a suffix exist in the children according to a priority of staticSuffixList .
20,934
public void setCheckOnStart ( boolean checkOnStart ) { this . checkOnStart = checkOnStart ; getConfig ( ) . setProperty ( CHECK_ON_START , checkOnStart ) ; if ( dayLastChecked . length ( ) == 0 ) { dayLastChecked = "Never" ; getConfig ( ) . setProperty ( DAY_LAST_CHECKED , dayLastChecked ) ; } }
Sets whether or not the check for updates on start up is enabled .
20,935
protected JToolBar getFooterStatusBar ( ) { if ( footerToolbar == null ) { footerToolbar = new JToolBar ( ) ; footerToolbar . setEnabled ( true ) ; footerToolbar . setFloatable ( false ) ; footerToolbar . setRollover ( true ) ; footerToolbar . setName ( "Footer Toolbar Left" ) ; footerToolbar . setBorder ( BorderFactory . createEtchedBorder ( ) ) ; } return footerToolbar ; }
Return the footer status bar object
20,936
public Socket createSocket ( final String host , final int port , final InetAddress localAddress , final int localPort , final HttpConnectionParams params ) throws IOException , UnknownHostException , ConnectTimeoutException { if ( params == null ) { throw new IllegalArgumentException ( "Parameters may not be null" ) ; } int timeout = params . getConnectionTimeout ( ) ; if ( timeout == 0 ) { InetAddress hostAddress = getCachedMisconfiguredHost ( host , port ) ; if ( hostAddress != null ) { return clientSSLSockFactory . createSocket ( hostAddress , port , localAddress , localPort ) ; } try { SSLSocket sslSocket = ( SSLSocket ) clientSSLSockFactory . createSocket ( host , port , localAddress , localPort ) ; sslSocket . startHandshake ( ) ; return sslSocket ; } catch ( SSLException e ) { if ( ! e . getMessage ( ) . contains ( CONTENTS_UNRECOGNIZED_NAME_EXCEPTION ) ) { throw e ; } hostAddress = InetAddress . getByName ( host ) ; cacheMisconfiguredHost ( host , port , hostAddress ) ; return clientSSLSockFactory . createSocket ( hostAddress , port , localAddress , localPort ) ; } } Socket socket = clientSSLSockFactory . createSocket ( ) ; SocketAddress localAddr = new InetSocketAddress ( localAddress , localPort ) ; socket . bind ( localAddr ) ; SocketAddress remoteAddr = new InetSocketAddress ( host , port ) ; socket . connect ( remoteAddr , timeout ) ; return socket ; }
Attempts to get a new socket connection to the given host within the given time limit .
20,937
public String getScopeText ( ) { StringBuilder scopeTextStringBuilder = new StringBuilder ( "" ) ; for ( DomainAlwaysInScopeMatcher domainInScope : domainsAlwaysInScope ) { if ( ! domainInScope . isRegex ( ) ) { scopeTextStringBuilder . append ( domainInScope . getValue ( ) ) . append ( ';' ) ; } } return scopeTextStringBuilder . toString ( ) ; }
Gets the text describing the text .
20,938
public String getScope ( ) { StringBuilder scopeTextStringBuilder = new StringBuilder ( ) ; for ( DomainAlwaysInScopeMatcher domainInScope : domainsAlwaysInScope ) { if ( domainInScope . isRegex ( ) ) { scopeTextStringBuilder . append ( "\\Q" ) . append ( domainInScope . getValue ( ) ) . append ( "\\E" ) ; } else { scopeTextStringBuilder . append ( domainInScope . getValue ( ) ) ; } scopeTextStringBuilder . append ( '|' ) ; } if ( scopeTextStringBuilder . length ( ) != 0 ) { scopeTextStringBuilder . append ( "(" ) ; scopeTextStringBuilder . replace ( scopeTextStringBuilder . length ( ) - 1 , scopeTextStringBuilder . length ( ) - 1 , ")$" ) ; } return scopeTextStringBuilder . toString ( ) ; }
Gets the scope s regex .
20,939
public void setThreadCount ( int thread ) { this . threadCount = thread ; getConfig ( ) . setProperty ( SPIDER_THREAD , Integer . toString ( this . threadCount ) ) ; }
Sets the thread count .
20,940
public void setProcessForm ( boolean processForm ) { this . processForm = processForm ; getConfig ( ) . setProperty ( SPIDER_PROCESS_FORM , Boolean . toString ( processForm ) ) ; }
Sets if the forms should be processed .
20,941
public void setSkipURLString ( String skipURL ) { this . skipURL = skipURL ; getConfig ( ) . setProperty ( SPIDER_SKIP_URL , this . skipURL ) ; parseSkipURL ( this . skipURL ) ; }
Sets the skip url string . This string is being parsed into a pattern which is used to check if a url should be skipped while crawling .
20,942
public boolean isSkipURL ( URI uri ) { if ( patternSkipURL == null || uri == null ) { return false ; } String sURI = uri . toString ( ) ; return patternSkipURL . matcher ( sURI ) . find ( ) ; }
Checks if is this url should be skipped .
20,943
private void parseSkipURL ( String skipURL ) { patternSkipURL = null ; if ( skipURL == null || skipURL . equals ( "" ) ) { return ; } skipURL = skipURL . replaceAll ( "\\." , "\\\\." ) ; skipURL = skipURL . replaceAll ( "\\*" , ".*?" ) . replaceAll ( "(\\s+$)|(^\\s+)" , "" ) ; skipURL = "\\A(" + skipURL . replaceAll ( "\\s+" , "|" ) + ")" ; patternSkipURL = Pattern . compile ( skipURL , Pattern . CASE_INSENSITIVE | Pattern . MULTILINE ) ; }
Parses the skip url string .
20,944
public void setRequestWaitTime ( int requestWait ) { this . requestWait = requestWait ; this . getConfig ( ) . setProperty ( SPIDER_REQUEST_WAIT , Integer . toString ( requestWait ) ) ; }
Sets the time between the requests sent to a server .
20,945
public void setParseComments ( boolean parseComments ) { this . parseComments = parseComments ; getConfig ( ) . setProperty ( SPIDER_PARSE_COMMENTS , Boolean . toString ( parseComments ) ) ; }
Sets the whether the spider parses the comments .
20,946
public void setParseSitemapXml ( boolean parseSitemapXml ) { this . parseSitemapXml = parseSitemapXml ; getConfig ( ) . setProperty ( SPIDER_PARSE_SITEMAP_XML , Boolean . toString ( parseSitemapXml ) ) ; }
Sets the whether the spider parses the sitemap . xml for URIs .
20,947
public void setParseGit ( boolean parseGit ) { this . parseGit = parseGit ; getConfig ( ) . setProperty ( SPIDER_PARSE_GIT , Boolean . toString ( parseGit ) ) ; }
Sets the whether the spider parses Git files for URIs
20,948
public void setDomainsAlwaysInScope ( List < DomainAlwaysInScopeMatcher > domainsAlwaysInScope ) { if ( domainsAlwaysInScope == null || domainsAlwaysInScope . isEmpty ( ) ) { ( ( HierarchicalConfiguration ) getConfig ( ) ) . clearTree ( ALL_DOMAINS_ALWAYS_IN_SCOPE_KEY ) ; this . domainsAlwaysInScope = Collections . emptyList ( ) ; this . domainsAlwaysInScopeEnabled = Collections . emptyList ( ) ; return ; } this . domainsAlwaysInScope = new ArrayList < > ( domainsAlwaysInScope ) ; ( ( HierarchicalConfiguration ) getConfig ( ) ) . clearTree ( ALL_DOMAINS_ALWAYS_IN_SCOPE_KEY ) ; int size = domainsAlwaysInScope . size ( ) ; ArrayList < DomainAlwaysInScopeMatcher > enabledExcludedDomains = new ArrayList < > ( size ) ; for ( int i = 0 ; i < size ; ++ i ) { String elementBaseKey = ALL_DOMAINS_ALWAYS_IN_SCOPE_KEY + "(" + i + ")." ; DomainAlwaysInScopeMatcher excludedDomain = domainsAlwaysInScope . get ( i ) ; getConfig ( ) . setProperty ( elementBaseKey + DOMAIN_ALWAYS_IN_SCOPE_VALUE_KEY , excludedDomain . getValue ( ) ) ; getConfig ( ) . setProperty ( elementBaseKey + DOMAIN_ALWAYS_IN_SCOPE_REGEX_KEY , excludedDomain . isRegex ( ) ) ; getConfig ( ) . setProperty ( elementBaseKey + DOMAIN_ALWAYS_IN_SCOPE_ENABLED_KEY , excludedDomain . isEnabled ( ) ) ; if ( excludedDomain . isEnabled ( ) ) { enabledExcludedDomains . add ( excludedDomain ) ; } } enabledExcludedDomains . trimToSize ( ) ; this . domainsAlwaysInScopeEnabled = enabledExcludedDomains ; }
Sets the domains that will be always in scope .
20,949
public void setSendRefererHeader ( boolean send ) { if ( send == sendRefererHeader ) { return ; } this . sendRefererHeader = send ; getConfig ( ) . setProperty ( SPIDER_SENDER_REFERER_HEADER , this . sendRefererHeader ) ; }
Sets whether or not the Referer header should be sent in spider requests .
20,950
public void setPaused ( boolean paused ) { pauseLock . lock ( ) ; this . paused = paused ; if ( ! this . paused ) pausedCondition . signalAll ( ) ; pauseLock . unlock ( ) ; }
Sets the paused state of the thread and if the thread needs to be resumed and was paused and sleeping it gets signaled .
20,951
private void checkDuplicate ( ) { KeyboardShortcut ks = this . getDuplicate ( ) ; if ( ks != null ) { this . setFieldValue ( FIELD_INFO , Constant . messages . getString ( "keyboard.dialog.warning.dup" , ks . getName ( ) ) ) ; } else { this . setFieldValue ( FIELD_INFO , "" ) ; } }
Checks to see if the chosen shortcut is already being used and if so shows a message warning the user
20,952
@ SuppressWarnings ( "unchecked" ) public MainNode < K , V > READ_PREV ( ) { return ( MainNode < K , V > ) updater . get ( this ) ; }
irregardless of whether there are concurrent ARFU updates
20,953
public static int avalanche ( int h ) { h ^= h >>> 16 ; h *= 0x85ebca6b ; h ^= h >>> 13 ; h *= 0xc2b2ae35 ; h ^= h >>> 16 ; return h ; }
Force all bits of the hash to avalanche . Used for finalizing the hash .
20,954
private static int typeCode ( Object a ) { if ( a instanceof java . lang . Integer ) return INT ; if ( a instanceof java . lang . Double ) return DOUBLE ; if ( a instanceof java . lang . Long ) return LONG ; if ( a instanceof java . lang . Character ) return CHAR ; if ( a instanceof java . lang . Float ) return FLOAT ; if ( ( a instanceof java . lang . Byte ) || ( a instanceof java . lang . Short ) ) return INT ; return OTHER ; }
We don t need to return BYTE and SHORT as everything which might care widens to INT .
20,955
public static boolean equals2 ( Object x , Object y ) { if ( x instanceof java . lang . Number ) return equalsNumObject ( ( java . lang . Number ) x , y ) ; if ( x instanceof java . lang . Character ) return equalsCharObject ( ( java . lang . Character ) x , y ) ; if ( x == null ) return y == null ; return x . equals ( y ) ; }
Since all applicable logic has to be present in the equals method of a ScalaNumber in any case we dispatch to it as soon as we spot one on either side .
20,956
public static Object add ( Object arg1 , Object arg2 ) throws NoSuchMethodException { int code1 = typeCode ( arg1 ) ; int code2 = typeCode ( arg2 ) ; int maxcode = ( code1 < code2 ) ? code2 : code1 ; if ( maxcode <= INT ) { return boxToInteger ( unboxCharOrInt ( arg1 , code1 ) + unboxCharOrInt ( arg2 , code2 ) ) ; } if ( maxcode <= LONG ) { return boxToLong ( unboxCharOrLong ( arg1 , code1 ) + unboxCharOrLong ( arg2 , code2 ) ) ; } if ( maxcode <= FLOAT ) { return boxToFloat ( unboxCharOrFloat ( arg1 , code1 ) + unboxCharOrFloat ( arg2 , code2 ) ) ; } if ( maxcode <= DOUBLE ) { return boxToDouble ( unboxCharOrDouble ( arg1 , code1 ) + unboxCharOrDouble ( arg2 , code2 ) ) ; } throw new NoSuchMethodException ( ) ; }
arg1 + arg2
20,957
public static Object shiftSignedRight ( Object arg1 , Object arg2 ) throws NoSuchMethodException { int code1 = typeCode ( arg1 ) ; int code2 = typeCode ( arg2 ) ; if ( code1 <= INT ) { int val1 = unboxCharOrInt ( arg1 , code1 ) ; if ( code2 <= INT ) { int val2 = unboxCharOrInt ( arg2 , code2 ) ; return boxToInteger ( val1 >> val2 ) ; } if ( code2 <= LONG ) { long val2 = unboxCharOrLong ( arg2 , code2 ) ; return boxToInteger ( val1 >> val2 ) ; } } if ( code1 <= LONG ) { long val1 = unboxCharOrLong ( arg1 , code1 ) ; if ( code2 <= INT ) { int val2 = unboxCharOrInt ( arg2 , code2 ) ; return boxToLong ( val1 >> val2 ) ; } if ( code2 <= LONG ) { long val2 = unboxCharOrLong ( arg2 , code2 ) ; return boxToLong ( val1 >> val2 ) ; } } throw new NoSuchMethodException ( ) ; }
arg1 >> arg2
20,958
public static Object takeAnd ( Object arg1 , Object arg2 ) throws NoSuchMethodException { if ( ( arg1 instanceof Boolean ) || ( arg2 instanceof Boolean ) ) { if ( ( arg1 instanceof Boolean ) && ( arg2 instanceof Boolean ) ) return boxToBoolean ( ( ( java . lang . Boolean ) arg1 ) . booleanValue ( ) & ( ( java . lang . Boolean ) arg2 ) . booleanValue ( ) ) ; else throw new NoSuchMethodException ( ) ; } int code1 = typeCode ( arg1 ) ; int code2 = typeCode ( arg2 ) ; int maxcode = ( code1 < code2 ) ? code2 : code1 ; if ( maxcode <= INT ) return boxToInteger ( unboxCharOrInt ( arg1 , code1 ) & unboxCharOrInt ( arg2 , code2 ) ) ; if ( maxcode <= LONG ) return boxToLong ( unboxCharOrLong ( arg1 , code1 ) & unboxCharOrLong ( arg2 , code2 ) ) ; throw new NoSuchMethodException ( ) ; }
arg1 & arg2
20,959
public static Object takeConditionalAnd ( Object arg1 , Object arg2 ) throws NoSuchMethodException { if ( ( arg1 instanceof Boolean ) && ( arg2 instanceof Boolean ) ) { return boxToBoolean ( ( ( java . lang . Boolean ) arg1 ) . booleanValue ( ) && ( ( java . lang . Boolean ) arg2 ) . booleanValue ( ) ) ; } throw new NoSuchMethodException ( ) ; }
arg1 && arg2
20,960
public static java . lang . Character toCharacter ( Object arg ) throws NoSuchMethodException { if ( arg instanceof java . lang . Integer ) return boxToCharacter ( ( char ) unboxToInt ( arg ) ) ; if ( arg instanceof java . lang . Short ) return boxToCharacter ( ( char ) unboxToShort ( arg ) ) ; if ( arg instanceof java . lang . Character ) return ( java . lang . Character ) arg ; if ( arg instanceof java . lang . Long ) return boxToCharacter ( ( char ) unboxToLong ( arg ) ) ; if ( arg instanceof java . lang . Byte ) return boxToCharacter ( ( char ) unboxToByte ( arg ) ) ; if ( arg instanceof java . lang . Float ) return boxToCharacter ( ( char ) unboxToFloat ( arg ) ) ; if ( arg instanceof java . lang . Double ) return boxToCharacter ( ( char ) unboxToDouble ( arg ) ) ; throw new NoSuchMethodException ( ) ; }
arg . toChar
20,961
public static java . lang . Byte toByte ( Object arg ) throws NoSuchMethodException { if ( arg instanceof java . lang . Integer ) return boxToByte ( ( byte ) unboxToInt ( arg ) ) ; if ( arg instanceof java . lang . Character ) return boxToByte ( ( byte ) unboxToChar ( arg ) ) ; if ( arg instanceof java . lang . Byte ) return ( java . lang . Byte ) arg ; if ( arg instanceof java . lang . Long ) return boxToByte ( ( byte ) unboxToLong ( arg ) ) ; if ( arg instanceof java . lang . Short ) return boxToByte ( ( byte ) unboxToShort ( arg ) ) ; if ( arg instanceof java . lang . Float ) return boxToByte ( ( byte ) unboxToFloat ( arg ) ) ; if ( arg instanceof java . lang . Double ) return boxToByte ( ( byte ) unboxToDouble ( arg ) ) ; throw new NoSuchMethodException ( ) ; }
arg . toByte
20,962
public static java . lang . Short toShort ( Object arg ) throws NoSuchMethodException { if ( arg instanceof java . lang . Integer ) return boxToShort ( ( short ) unboxToInt ( arg ) ) ; if ( arg instanceof java . lang . Long ) return boxToShort ( ( short ) unboxToLong ( arg ) ) ; if ( arg instanceof java . lang . Character ) return boxToShort ( ( short ) unboxToChar ( arg ) ) ; if ( arg instanceof java . lang . Byte ) return boxToShort ( ( short ) unboxToByte ( arg ) ) ; if ( arg instanceof java . lang . Short ) return ( java . lang . Short ) arg ; if ( arg instanceof java . lang . Float ) return boxToShort ( ( short ) unboxToFloat ( arg ) ) ; if ( arg instanceof java . lang . Double ) return boxToShort ( ( short ) unboxToDouble ( arg ) ) ; throw new NoSuchMethodException ( ) ; }
arg . toShort
20,963
public static java . lang . Integer toInteger ( Object arg ) throws NoSuchMethodException { if ( arg instanceof java . lang . Integer ) return ( java . lang . Integer ) arg ; if ( arg instanceof java . lang . Long ) return boxToInteger ( ( int ) unboxToLong ( arg ) ) ; if ( arg instanceof java . lang . Double ) return boxToInteger ( ( int ) unboxToDouble ( arg ) ) ; if ( arg instanceof java . lang . Float ) return boxToInteger ( ( int ) unboxToFloat ( arg ) ) ; if ( arg instanceof java . lang . Character ) return boxToInteger ( ( int ) unboxToChar ( arg ) ) ; if ( arg instanceof java . lang . Byte ) return boxToInteger ( ( int ) unboxToByte ( arg ) ) ; if ( arg instanceof java . lang . Short ) return boxToInteger ( ( int ) unboxToShort ( arg ) ) ; throw new NoSuchMethodException ( ) ; }
arg . toInt
20,964
public static java . lang . Long toLong ( Object arg ) throws NoSuchMethodException { if ( arg instanceof java . lang . Integer ) return boxToLong ( ( long ) unboxToInt ( arg ) ) ; if ( arg instanceof java . lang . Double ) return boxToLong ( ( long ) unboxToDouble ( arg ) ) ; if ( arg instanceof java . lang . Float ) return boxToLong ( ( long ) unboxToFloat ( arg ) ) ; if ( arg instanceof java . lang . Long ) return ( java . lang . Long ) arg ; if ( arg instanceof java . lang . Character ) return boxToLong ( ( long ) unboxToChar ( arg ) ) ; if ( arg instanceof java . lang . Byte ) return boxToLong ( ( long ) unboxToByte ( arg ) ) ; if ( arg instanceof java . lang . Short ) return boxToLong ( ( long ) unboxToShort ( arg ) ) ; throw new NoSuchMethodException ( ) ; }
arg . toLong
20,965
public static java . lang . Float toFloat ( Object arg ) throws NoSuchMethodException { if ( arg instanceof java . lang . Integer ) return boxToFloat ( ( float ) unboxToInt ( arg ) ) ; if ( arg instanceof java . lang . Long ) return boxToFloat ( ( float ) unboxToLong ( arg ) ) ; if ( arg instanceof java . lang . Float ) return ( java . lang . Float ) arg ; if ( arg instanceof java . lang . Double ) return boxToFloat ( ( float ) unboxToDouble ( arg ) ) ; if ( arg instanceof java . lang . Character ) return boxToFloat ( ( float ) unboxToChar ( arg ) ) ; if ( arg instanceof java . lang . Byte ) return boxToFloat ( ( float ) unboxToByte ( arg ) ) ; if ( arg instanceof java . lang . Short ) return boxToFloat ( ( float ) unboxToShort ( arg ) ) ; throw new NoSuchMethodException ( ) ; }
arg . toFloat
20,966
public static java . lang . Double toDouble ( Object arg ) throws NoSuchMethodException { if ( arg instanceof java . lang . Integer ) return boxToDouble ( ( double ) unboxToInt ( arg ) ) ; if ( arg instanceof java . lang . Float ) return boxToDouble ( ( double ) unboxToFloat ( arg ) ) ; if ( arg instanceof java . lang . Double ) return ( java . lang . Double ) arg ; if ( arg instanceof java . lang . Long ) return boxToDouble ( ( double ) unboxToLong ( arg ) ) ; if ( arg instanceof java . lang . Character ) return boxToDouble ( ( double ) unboxToChar ( arg ) ) ; if ( arg instanceof java . lang . Byte ) return boxToDouble ( ( double ) unboxToByte ( arg ) ) ; if ( arg instanceof java . lang . Short ) return boxToDouble ( ( double ) unboxToShort ( arg ) ) ; throw new NoSuchMethodException ( ) ; }
arg . toDouble
20,967
public List < Invocation > find ( List < ? > mocks ) { List < Invocation > unused = new LinkedList < Invocation > ( ) ; for ( Object mock : mocks ) { List < Stubbing > fromSingleMock = MockUtil . getInvocationContainer ( mock ) . getStubbingsDescending ( ) ; for ( Stubbing s : fromSingleMock ) { if ( ! s . wasUsed ( ) ) { unused . add ( s . getInvocation ( ) ) ; } } } return unused ; }
Finds all unused stubs for given mocks
20,968
private void computeStackTraceInformation ( StackTraceFilter stackTraceFilter , Throwable stackTraceHolder , boolean isInline ) { StackTraceElement filtered = stackTraceFilter . filterFirst ( stackTraceHolder , isInline ) ; if ( filtered == null ) { this . stackTraceLine = "-> at <<unknown line>>" ; this . sourceFile = "<unknown source file>" ; } else { this . stackTraceLine = "-> at " + filtered . toString ( ) ; this . sourceFile = filtered . getFileName ( ) ; } }
Eagerly compute the stacktrace line from the stackTraceHolder . Storing the Throwable is memory - intensive for tests that have large stacktraces and have a lot of invocations on mocks .
20,969
public static MockInjectionStrategy nop ( ) { return new MockInjectionStrategy ( ) { protected boolean processInjection ( Field field , Object fieldOwner , Set < Object > mockCandidates ) { return false ; } } ; }
NOP Strategy that will always try the next strategy .
20,970
public MockInjectionStrategy thenTry ( MockInjectionStrategy strategy ) { if ( nextStrategy != null ) { nextStrategy . thenTry ( strategy ) ; } else { nextStrategy = strategy ; } return strategy ; }
Enqueue next injection strategy .
20,971
public boolean process ( Field onField , Object fieldOwnedBy , Set < Object > mockCandidates ) { if ( processInjection ( onField , fieldOwnedBy , mockCandidates ) ) { return true ; } return relayProcessToNextStrategy ( onField , fieldOwnedBy , mockCandidates ) ; }
Actually inject mockCandidates on field .
20,972
private Object newDeepStubMock ( GenericMetadataSupport returnTypeGenericMetadata , Object parentMock ) { MockCreationSettings parentMockSettings = MockUtil . getMockSettings ( parentMock ) ; return mockitoCore ( ) . mock ( returnTypeGenericMetadata . rawType ( ) , withSettingsUsing ( returnTypeGenericMetadata , parentMockSettings ) ) ; }
Creates a mock using the Generics Metadata .
20,973
public String findSourceFile ( StackTraceElement [ ] target , String defaultValue ) { for ( StackTraceElement e : target ) { if ( CLEANER . isIn ( e ) ) { return e . getFileName ( ) ; } } return defaultValue ; }
Finds the source file of the target stack trace . Returns the default value if source file cannot be found .
20,974
public static void writeText ( String text , File output ) { PrintWriter pw = null ; try { pw = new PrintWriter ( new FileWriter ( output ) ) ; pw . write ( text ) ; } catch ( Exception e ) { throw new MockitoException ( "Problems writing text to file: " + output , e ) ; } finally { close ( pw ) ; } }
Writes text to file
20,975
public static < A , B , C , D , E > Answer < Void > toAnswer ( final VoidAnswer5 < A , B , C , D , E > answer ) { return new Answer < Void > ( ) { @ SuppressWarnings ( "unchecked" ) public Void answer ( InvocationOnMock invocation ) throws Throwable { answer . answer ( ( A ) invocation . getArgument ( 0 ) , ( B ) invocation . getArgument ( 1 ) , ( C ) invocation . getArgument ( 2 ) , ( D ) invocation . getArgument ( 3 ) , ( E ) invocation . getArgument ( 4 ) ) ; return null ; } } ; }
Construct an answer from a five parameter answer interface
20,976
public static < T , A , B , C , D , E , F > Answer < T > toAnswer ( final Answer6 < T , A , B , C , D , E , F > answer ) { return new Answer < T > ( ) { @ SuppressWarnings ( "unchecked" ) public T answer ( InvocationOnMock invocation ) throws Throwable { return answer . answer ( ( A ) invocation . getArgument ( 0 ) , ( B ) invocation . getArgument ( 1 ) , ( C ) invocation . getArgument ( 2 ) , ( D ) invocation . getArgument ( 3 ) , ( E ) invocation . getArgument ( 4 ) , ( F ) invocation . getArgument ( 5 ) ) ; } } ; }
Construct an answer from a six parameter answer interface
20,977
public FieldInitializationReport initialize ( ) { final AccessibilityChanger changer = new AccessibilityChanger ( ) ; changer . enableAccess ( field ) ; try { return acquireFieldInstance ( ) ; } catch ( IllegalAccessException e ) { throw new MockitoException ( "Problems initializing field '" + field . getName ( ) + "' of type '" + field . getType ( ) . getSimpleName ( ) + "'" , e ) ; } finally { changer . safelyDisableAccess ( field ) ; } }
Initialize field if not initialized and return the actual instance .
20,978
public static < T > Answer < T > answersWithDelay ( long sleepyTime , Answer < T > answer ) { return ( Answer < T > ) new AnswersWithDelay ( sleepyTime , ( Answer < Object > ) answer ) ; }
Returns an answer after a delay with a defined length .
20,979
public static < T > T any ( Class < T > type ) { reportMatcher ( new InstanceOf . VarArgAware ( type , "<any " + type . getCanonicalName ( ) + ">" ) ) ; return defaultValue ( type ) ; }
Matches any object of given type excluding nulls .
20,980
public static < T > T eq ( T value ) { reportMatcher ( new Equals ( value ) ) ; if ( value == null ) return null ; return ( T ) Primitives . defaultValue ( value . getClass ( ) ) ; }
Object argument that is equal to the given value .
20,981
public static < T > T refEq ( T value , String ... excludeFields ) { reportMatcher ( new ReflectionEquals ( value , excludeFields ) ) ; return null ; }
Object argument that is reflection - equal to the given value with support for excluding selected fields from a class .
20,982
public static < T > T same ( T value ) { reportMatcher ( new Same ( value ) ) ; if ( value == null ) return null ; return ( T ) Primitives . defaultValue ( value . getClass ( ) ) ; }
Object argument that is the same as the given value .
20,983
public Invocation getLastInvocation ( ) { OngoingStubbingImpl ongoingStubbing = ( ( OngoingStubbingImpl ) mockingProgress ( ) . pullOngoingStubbing ( ) ) ; List < Invocation > allInvocations = ongoingStubbing . getRegisteredInvocations ( ) ; return allInvocations . get ( allInvocations . size ( ) - 1 ) ; }
For testing purposes only . Is not the part of main API .
20,984
public < A extends Annotation > A annotation ( Class < A > annotationClass ) { return field . getAnnotation ( annotationClass ) ; }
Returns the annotation instance for the given annotation type .
20,985
public void safelyDisableAccess ( AccessibleObject accessibleObject ) { assert wasAccessible != null : "accessibility info shall not be null" ; try { accessibleObject . setAccessible ( wasAccessible ) ; } catch ( Throwable t ) { } }
safely disables access
20,986
public static List < Invocation > find ( Iterable < ? > mocks ) { Set < Invocation > invocationsInOrder = new TreeSet < Invocation > ( new InvocationComparator ( ) ) ; for ( Object mock : mocks ) { Collection < Invocation > fromSingleMock = new DefaultMockingDetails ( mock ) . getInvocations ( ) ; invocationsInOrder . addAll ( fromSingleMock ) ; } return new LinkedList < Invocation > ( invocationsInOrder ) ; }
gets all invocations from mocks . Invocations are ordered earlier first .
20,987
public static Set < Stubbing > findStubbings ( Iterable < ? > mocks ) { Set < Stubbing > stubbings = new TreeSet < Stubbing > ( new StubbingComparator ( ) ) ; for ( Object mock : mocks ) { Collection < ? extends Stubbing > fromSingleMock = new DefaultMockingDetails ( mock ) . getStubbings ( ) ; stubbings . addAll ( fromSingleMock ) ; } return stubbings ; }
Gets all stubbings from mocks . Invocations are ordered earlier first .
20,988
public void verify ( VerificationData data ) { AssertionError error = null ; timer . start ( ) ; while ( timer . isCounting ( ) ) { try { delegate . verify ( data ) ; if ( returnOnSuccess ) { return ; } else { error = null ; } } catch ( MockitoAssertionError e ) { error = handleVerifyException ( e ) ; } catch ( AssertionError e ) { error = handleVerifyException ( e ) ; } } if ( error != null ) { throw error ; } }
Verify the given ongoing verification data and confirm that it satisfies the delegate verification mode before the full duration has passed .
20,989
public void verify ( VerificationData data ) { try { verification . verify ( data ) ; } catch ( MockitoAssertionError e ) { throw new MockitoAssertionError ( e , description ) ; } }
Performs verification using the wrapped verification mode implementation . Prepends the custom failure message if verification fails .
20,990
public InternalRunner create ( Class < ? > klass ) throws InvocationTargetException { return create ( klass , new Supplier < MockitoTestListener > ( ) { public MockitoTestListener get ( ) { return new NoOpTestListener ( ) ; } } ) ; }
Creates silent runner implementation
20,991
public InternalRunner createStrict ( Class < ? > klass ) throws InvocationTargetException { return create ( klass , new Supplier < MockitoTestListener > ( ) { public MockitoTestListener get ( ) { return new MismatchReportingTestListener ( Plugins . getMockitoLogger ( ) ) ; } } ) ; }
Creates strict runner implementation
20,992
public InternalRunner createStrictStubs ( Class < ? > klass ) throws InvocationTargetException { return create ( klass , new Supplier < MockitoTestListener > ( ) { public MockitoTestListener get ( ) { return new StrictStubsRunnerTestListener ( ) ; } } ) ; }
Creates strict stubs runner implementation
20,993
public InternalRunner create ( Class < ? > klass , Supplier < MockitoTestListener > listenerSupplier ) throws InvocationTargetException { try { String runnerClassName = "org.mockito.internal.runners.DefaultInternalRunner" ; return new RunnerProvider ( ) . newInstance ( runnerClassName , klass , listenerSupplier ) ; } catch ( InvocationTargetException e ) { if ( ! hasTestMethods ( klass ) ) { throw new MockitoException ( "\n" + "\n" + "No tests found in " + klass . getSimpleName ( ) + "\n" + "Is the method annotated with @Test?\n" + "Is the method public?\n" , e ) ; } throw e ; } catch ( Throwable t ) { throw new MockitoException ( "\n" + "\n" + "MockitoRunner can only be used with JUnit 4.5 or higher.\n" + "You can upgrade your JUnit version or write your own Runner (please consider contributing your runner to the Mockito community).\n" + "Bear in mind that you can still enjoy all features of the framework without using runners (they are completely optional).\n" + "If you get this error despite using JUnit 4.5 or higher then please report this error to the mockito mailing list.\n" , t ) ; } }
Creates runner implementation with provided listener supplier
20,994
private static Object invokeNullaryFactoryMethod ( final String fqcn , final String methodName ) { try { final Class < ? > type = Class . forName ( fqcn ) ; final Method method = type . getMethod ( methodName ) ; return method . invoke ( null ) ; } catch ( final Exception e ) { throw new InstantiationException ( String . format ( "Could not create %s#%s(): %s" , fqcn , methodName , e ) , e ) ; } }
Invokes a nullary static factory method using reflection to stay backwards - compatible with older JDKs .
20,995
private String setterName ( String fieldName ) { return new StringBuilder ( SET_PREFIX ) . append ( fieldName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) ) . append ( fieldName . substring ( 1 ) ) . toString ( ) ; }
Retrieve the setter name from the field name .
20,996
public static Object [ ] expandArgs ( MockitoMethod method , Object [ ] args ) { int nParams = method . getParameterTypes ( ) . length ; if ( args != null && args . length > nParams ) args = Arrays . copyOf ( args , nParams ) ; return expandVarArgs ( method . isVarArgs ( ) , args ) ; }
and expands varargs
20,997
protected void registerAllTypeVariables ( Type classType ) { Queue < Type > typesToRegister = new LinkedList < Type > ( ) ; Set < Type > registeredTypes = new HashSet < Type > ( ) ; typesToRegister . add ( classType ) ; while ( ! typesToRegister . isEmpty ( ) ) { Type typeToRegister = typesToRegister . poll ( ) ; if ( typeToRegister == null || registeredTypes . contains ( typeToRegister ) ) { continue ; } registerTypeVariablesOn ( typeToRegister ) ; registeredTypes . add ( typeToRegister ) ; Class < ? > rawType = extractRawTypeOf ( typeToRegister ) ; typesToRegister . add ( rawType . getGenericSuperclass ( ) ) ; typesToRegister . addAll ( Arrays . asList ( rawType . getGenericInterfaces ( ) ) ) ; } }
Registers the type variables for the given type and all of its superclasses and superinterfaces .
20,998
public static < T > T defaultValue ( Class < T > primitiveOrWrapperType ) { return ( T ) PRIMITIVE_OR_WRAPPER_DEFAULT_VALUES . get ( primitiveOrWrapperType ) ; }
Returns the boxed default value for a primitive or a primitive wrapper .
20,999
private < T > T create ( Class < T > pluginType , String className ) { if ( className == null ) { throw new IllegalStateException ( "No default implementation for requested Mockito plugin type: " + pluginType . getName ( ) + "\n" + "Is this a valid Mockito plugin type? If yes, please report this problem to Mockito team.\n" + "Otherwise, please check if you are passing valid plugin type.\n" + "Examples of valid plugin types: MockMaker, StackTraceCleanerProvider." ) ; } try { return pluginType . cast ( Class . forName ( className ) . newInstance ( ) ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Internal problem occurred, please report it. " + "Mockito is unable to load the default implementation of class that is a part of Mockito distribution. " + "Failed to load " + pluginType , e ) ; } }
Creates an instance of given plugin type using specific implementation class .