idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
39,700
|
public void execute ( ) throws MojoExecutionException , MojoFailureException { try { final List < String > command = createCommand ( ) ; checkWorkingDirectory ( ) ; final int status = execute ( command ) ; if ( failOnAnsibleError && status != 0 ) { throw new MojoFailureException ( "Non-zero exit status returned" ) ; } } catch ( IOException e ) { throw new MojoExecutionException ( "Unable to run playbook" , e ) ; } catch ( InterruptedException e ) { throw new MojoExecutionException ( "Run interrupted" , e ) ; } }
|
Constructs a command from the configured parameters and executes it logging output at debug
|
39,701
|
protected void addOptions ( final List < String > command ) { command . addAll ( createOption ( "-c" , connection ) ) ; command . addAll ( createOption ( "-f" , forks ) ) ; command . addAll ( createOption ( "-i" , inventory ) ) ; command . addAll ( createOption ( "-l" , limit ) ) ; command . addAll ( createOption ( "-M" , modulePath ) ) ; command . addAll ( createOption ( "--private-key" , privateKey ) ) ; command . addAll ( createOption ( "-T" , timeout ) ) ; command . addAll ( createOption ( "-u" , remoteUser ) ) ; command . addAll ( createOption ( "--vault-password-file" , vaultPasswordFile ) ) ; }
|
Adds the configured options to the list of command strings
|
39,702
|
protected List < String > createOption ( final String option , final List < String > values ) { if ( values == null ) { return new ArrayList < String > ( ) ; } final List < String > list = new ArrayList < String > ( ) ; for ( String value : values ) { list . add ( option ) ; list . add ( value ) ; } return list ; }
|
Creates a list for the given option an empty list if the option s values is null
|
39,703
|
protected String findClasspathFile ( final String path ) throws IOException { if ( path == null ) { return null ; } final File file = new File ( path ) ; if ( file . exists ( ) ) { return file . getAbsolutePath ( ) ; } return createTmpFile ( path ) . getAbsolutePath ( ) ; }
|
Checks whether the given file is an absolute path or a classpath file
|
39,704
|
private File createTmpFile ( final String path ) throws IOException { getLog ( ) . debug ( "Creating temporary file for: " + path ) ; final File output = new File ( System . getProperty ( "java.io.tmpdir" ) , "ansible-maven-plugin." + System . nanoTime ( ) ) ; final FileOutputStream outputStream = new FileOutputStream ( output ) ; final InputStream inputStream = getClass ( ) . getResourceAsStream ( "/" + path ) ; if ( inputStream == null ) { throw new FileNotFoundException ( "Unable to locate: " + path ) ; } copy ( inputStream , outputStream ) ; return output ; }
|
Copies a classpath resource to the tmp directory to allow it to be run by ansible
|
39,705
|
private void copy ( final InputStream inputStream , final FileOutputStream outputStream ) throws IOException { final byte [ ] buffer = new byte [ 1024 * 4 ] ; int n ; try { while ( - 1 != ( n = inputStream . read ( buffer ) ) ) { outputStream . write ( buffer , 0 , n ) ; } } finally { inputStream . close ( ) ; outputStream . close ( ) ; } }
|
Copies the input stream to the output stream using a 4K buffer
|
39,706
|
private void parseNames ( Document doc , String expression ) throws XPathExpressionException , IOException , SAXException { XPath xPath = XPathFactory . newInstance ( ) . newXPath ( ) ; NodeList nodeList = ( NodeList ) xPath . compile ( expression ) . evaluate ( doc , XPathConstants . NODESET ) ; for ( int i = 0 ; i < nodeList . getLength ( ) ; i ++ ) { if ( nodeList . item ( i ) . getAttributes ( ) . getNamedItem ( "name" ) != null ) { String nodeValue = nodeList . item ( i ) . getAttributes ( ) . getNamedItem ( "name" ) . getNodeValue ( ) ; if ( ! nodeValue . isEmpty ( ) ) { String resolved = getResolvedVariable ( nodeValue ) ; if ( ! names . contains ( resolved ) ) { names . add ( resolved ) ; } } } else { String nodeValue = nodeList . item ( i ) . getAttributes ( ) . getNamedItem ( "location" ) . getNodeValue ( ) ; if ( ! nodeValue . isEmpty ( ) ) { String resolved = getResolvedVariable ( nodeValue ) ; if ( ! namelessLocations . contains ( resolved ) ) { namelessLocations . add ( resolved ) ; } } } } }
|
Checks for application names in the document . Will add locations without names to a Set
|
39,707
|
public static < T , C extends Cell < T , ? > > VirtualFlow < T , C > createHorizontal ( ObservableList < T > items , Function < ? super T , ? extends C > cellFactory ) { return createHorizontal ( items , cellFactory , Gravity . FRONT ) ; }
|
Creates a viewport that lays out content horizontally from left to right
|
39,708
|
public static < T , C extends Cell < T , ? > > VirtualFlow < T , C > createHorizontal ( ObservableList < T > items , Function < ? super T , ? extends C > cellFactory , Gravity gravity ) { return new VirtualFlow < > ( items , cellFactory , new HorizontalHelper ( ) , gravity ) ; }
|
Creates a viewport that lays out content horizontally
|
39,709
|
public static < T , C extends Cell < T , ? > > VirtualFlow < T , C > createVertical ( ObservableList < T > items , Function < ? super T , ? extends C > cellFactory , Gravity gravity ) { return new VirtualFlow < > ( items , cellFactory , new VerticalHelper ( ) , gravity ) ; }
|
Creates a viewport that lays out content vertically from top to bottom
|
39,710
|
public C getCell ( int itemIndex ) { Lists . checkIndex ( itemIndex , items . size ( ) ) ; return cellPositioner . getSizedCell ( itemIndex ) ; }
|
If the item is out of view instantiates a new cell for the item . The returned cell will be properly sized but not properly positioned relative to the cells in the viewport unless it is itself in the viewport .
|
39,711
|
public VirtualFlowHit < C > hit ( double x , double y ) { double bOff = orientation . getX ( x , y ) ; double lOff = orientation . getY ( x , y ) ; bOff += breadthOffset0 . getValue ( ) ; if ( items . isEmpty ( ) ) { return orientation . hitAfterCells ( bOff , lOff ) ; } layout ( ) ; int firstVisible = getFirstVisibleIndex ( ) ; firstVisible = navigator . fillBackwardFrom0 ( firstVisible , lOff ) ; C firstCell = cellPositioner . getVisibleCell ( firstVisible ) ; int lastVisible = getLastVisibleIndex ( ) ; lastVisible = navigator . fillForwardFrom0 ( lastVisible , lOff ) ; C lastCell = cellPositioner . getVisibleCell ( lastVisible ) ; if ( lOff < orientation . minY ( firstCell ) ) { return orientation . hitBeforeCells ( bOff , lOff - orientation . minY ( firstCell ) ) ; } else if ( lOff >= orientation . maxY ( lastCell ) ) { return orientation . hitAfterCells ( bOff , lOff - orientation . maxY ( lastCell ) ) ; } else { for ( int i = firstVisible ; i <= lastVisible ; ++ i ) { C cell = cellPositioner . getVisibleCell ( i ) ; if ( lOff < orientation . maxY ( cell ) ) { return orientation . cellHit ( i , cell , bOff , lOff - orientation . minY ( cell ) ) ; } } throw new AssertionError ( "unreachable code" ) ; } }
|
Hits this virtual flow at the given coordinates .
|
39,712
|
C getSizedCell ( int itemIndex ) { C cell = cellManager . getCell ( itemIndex ) ; double breadth = sizeTracker . breadthFor ( itemIndex ) ; double length = sizeTracker . lengthFor ( itemIndex ) ; orientation . resize ( cell , breadth , length ) ; return cell ; }
|
Returns properly sized but not properly positioned cell for the given index .
|
39,713
|
public void cropTo ( int fromItem , int toItem ) { fromItem = Math . max ( fromItem , 0 ) ; toItem = Math . min ( toItem , cells . size ( ) ) ; cells . forget ( 0 , fromItem ) ; cells . forget ( toItem , cells . size ( ) ) ; }
|
Updates the list of cells to display
|
39,714
|
int fillBackwardFrom0 ( int itemIndex , double upTo ) { double min = orientation . minY ( positioner . getVisibleCell ( itemIndex ) ) ; int i = itemIndex ; while ( min > upTo && i > 0 ) { -- i ; C c = positioner . placeEndFromStart ( i , min ) ; min = orientation . minY ( c ) ; } return i ; }
|
does not re - place the anchor cell
|
39,715
|
private void fillViewportFrom ( int itemIndex ) { int ground = fillTowardsGroundFrom0 ( itemIndex ) ; double gapBefore = distanceFromGround ( ground ) ; if ( gapBefore > 0 ) { shiftCellsTowardsGround ( ground , itemIndex , gapBefore ) ; } int sky = fillTowardsSkyFrom0 ( itemIndex ) ; double gapAfter = distanceFromSky ( sky ) ; if ( gapAfter > 0 ) { ground = fillTowardsGroundFrom0 ( ground , - gapAfter ) ; double extraBefore = - distanceFromGround ( ground ) ; double shift = Math . min ( gapAfter , extraBefore ) ; shiftCellsTowardsGround ( ground , sky , - shift ) ; } int first = Math . min ( ground , sky ) ; int last = Math . max ( ground , sky ) ; while ( first < last && orientation . maxY ( positioner . getVisibleCell ( first ) ) <= 0.0 ) { ++ first ; } while ( last > first && orientation . minY ( positioner . getVisibleCell ( last ) ) >= sizeTracker . getViewportLength ( ) ) { -- last ; } firstVisibleIndex = first ; lastVisibleIndex = last ; positioner . cropTo ( first , last + 1 ) ; }
|
Starting from the anchor cell s node fills the viewport from the anchor to the ground and then from the anchor to the sky .
|
39,716
|
private List < String > getCommand ( Element trNode ) { List < String > result = new ArrayList < String > ( ) ; Elements trChildNodes = trNode . getElementsByTag ( "TD" ) ; for ( Element trChild : trChildNodes ) { result . add ( getTableDataValue ( trChild ) ) ; } if ( result . size ( ) != 1 && result . size ( ) != 3 ) { throw new RuntimeException ( "Something strange" ) ; } return result ; }
|
processing table row
|
39,717
|
private String getTableDataValue ( Element tdNode ) { StringBuffer buf = new StringBuffer ( ) ; List < Node > childNodes = tdNode . childNodes ( ) ; for ( Node tdChild : childNodes ) { if ( tdChild instanceof TextNode ) { buf . append ( ( ( TextNode ) tdChild ) . text ( ) ) ; } else if ( tdChild instanceof Element ) { Element tdChildElement = ( Element ) tdChild ; if ( "br" . equals ( tdChildElement . tagName ( ) ) ) { buf . append ( "<br />" ) ; } } } return buf . toString ( ) ; }
|
processing table data
|
39,718
|
protected Artifact findFrameworkArtifact ( boolean minVersionWins ) { Artifact result = null ; Set < ? > artifacts = project . getArtifacts ( ) ; for ( Iterator < ? > iter = artifacts . iterator ( ) ; iter . hasNext ( ) ; ) { Artifact artifact = ( Artifact ) iter . next ( ) ; if ( "zip" . equals ( artifact . getType ( ) ) ) { if ( "framework" . equals ( artifact . getClassifier ( ) ) ) { result = artifact ; if ( ! minVersionWins ) { break ; } } else if ( "framework-min" . equals ( artifact . getClassifier ( ) ) ) { result = artifact ; if ( minVersionWins ) { break ; } } } } return result ; }
|
used by initialize dist and war mojos
|
39,719
|
protected File filterWebXml ( File webXml , File outputDirectory , String applicationName , String playWarId ) throws IOException { if ( ! outputDirectory . exists ( ) ) { if ( ! outputDirectory . mkdirs ( ) ) { throw new IOException ( String . format ( "Cannot create \"%s\" directory" , outputDirectory . getCanonicalPath ( ) ) ) ; } } File result = new File ( outputDirectory , "filtered-web.xml" ) ; BufferedReader reader = createBufferedFileReader ( webXml , "UTF-8" ) ; try { BufferedWriter writer = createBufferedFileWriter ( result , "UTF-8" ) ; try { getLog ( ) . debug ( "web.xml file:" ) ; String line = reader . readLine ( ) ; while ( line != null ) { getLog ( ) . debug ( " " + line ) ; if ( line . indexOf ( "%APPLICATION_NAME%" ) >= 0 ) { line = line . replace ( "%APPLICATION_NAME%" , applicationName ) ; } if ( line . indexOf ( "%PLAY_ID%" ) >= 0 ) { line = line . replace ( "%PLAY_ID%" , playWarId ) ; } writer . write ( line ) ; writer . newLine ( ) ; line = reader . readLine ( ) ; } } finally { writer . close ( ) ; } } finally { reader . close ( ) ; } return result ; }
|
used by war and war - support mojos
|
39,720
|
private static void executeInPlayContext ( Runner runner , RunNotifier notifier ) throws TestSetFailedException { try { Invoker . invokeInThread ( new TestInvocation ( runner , notifier ) ) ; } catch ( Throwable e ) { throw new TestSetFailedException ( e ) ; } }
|
Play! Framework specific methods
|
39,721
|
protected void kill ( String pid ) throws IOException , InterruptedException { String os = System . getProperty ( "os.name" ) ; String command = ( os . startsWith ( "Windows" ) ) ? "taskkill /F /PID " + pid : "kill " + pid ; Runtime . getRuntime ( ) . exec ( command ) . waitFor ( ) ; }
|
copied from Play! Framework s play . utils . Utils Java class
|
39,722
|
public OAuthFuture < Credential > authorize10a ( final String userId , final OAuthCallback < Credential > callback , Handler handler ) { Preconditions . checkNotNull ( userId ) ; final Future2Task < Credential > task = new Future2Task < Credential > ( handler , callback ) { public void doWork ( ) throws Exception { try { LOGGER . info ( "authorize10a" ) ; OAuthHmacCredential credential = mFlow . load10aCredential ( userId ) ; if ( credential != null && credential . getAccessToken ( ) != null && ( credential . getRefreshToken ( ) != null || credential . getExpiresInSeconds ( ) == null || credential . getExpiresInSeconds ( ) > 60 ) ) { set ( credential ) ; return ; } String redirectUri = mUIController . getRedirectUri ( ) ; OAuthCredentialsResponse tempCredentials = mFlow . new10aTemporaryTokenRequest ( redirectUri ) ; OAuthAuthorizeTemporaryTokenUrl authorizationUrl = mFlow . new10aAuthorizationUrl ( tempCredentials . token ) ; mUIController . requestAuthorization ( authorizationUrl ) ; String code = mUIController . waitForVerifierCode ( ) ; OAuthCredentialsResponse response = mFlow . new10aTokenRequest ( tempCredentials , code ) . execute ( ) ; credential = mFlow . createAndStoreCredential ( response , userId ) ; set ( credential ) ; } finally { mUIController . stop ( ) ; } } } ; submitTaskToExecutor ( task ) ; return task ; }
|
Authorizes the Android application to access user s protected data using the authorization flow in OAuth 1 . 0a .
|
39,723
|
public OAuthFuture < Credential > authorizeExplicitly ( final String userId , final OAuthCallback < Credential > callback , Handler handler ) { Preconditions . checkNotNull ( userId ) ; final Future2Task < Credential > task = new Future2Task < Credential > ( handler , callback ) { public void doWork ( ) throws Exception { try { Credential credential = mFlow . loadCredential ( userId ) ; LOGGER . info ( "authorizeExplicitly" ) ; if ( credential != null && credential . getAccessToken ( ) != null && ( credential . getRefreshToken ( ) != null || credential . getExpiresInSeconds ( ) == null || credential . getExpiresInSeconds ( ) > 60 ) ) { set ( credential ) ; return ; } String redirectUri = mUIController . getRedirectUri ( ) ; AuthorizationCodeRequestUrl authorizationUrl = mFlow . newExplicitAuthorizationUrl ( ) . setRedirectUri ( redirectUri ) ; mUIController . requestAuthorization ( authorizationUrl ) ; String code = mUIController . waitForExplicitCode ( ) ; TokenResponse response = mFlow . newTokenRequest ( code ) . setRedirectUri ( redirectUri ) . execute ( ) ; credential = mFlow . createAndStoreCredential ( response , userId ) ; set ( credential ) ; } finally { mUIController . stop ( ) ; } } } ; submitTaskToExecutor ( task ) ; return task ; }
|
Authorizes the Android application to access user s protected data using the Explicit Authorization Code flow in OAuth 2 . 0 .
|
39,724
|
public OAuthFuture < Credential > authorizeImplicitly ( final String userId , final OAuthCallback < Credential > callback , Handler handler ) { Preconditions . checkNotNull ( userId ) ; final Future2Task < Credential > task = new Future2Task < Credential > ( handler , callback ) { public void doWork ( ) throws TokenResponseException , Exception { try { LOGGER . info ( "authorizeImplicitly" ) ; Credential credential = mFlow . loadCredential ( userId ) ; if ( credential != null && credential . getAccessToken ( ) != null && ( credential . getRefreshToken ( ) != null || credential . getExpiresInSeconds ( ) == null || credential . getExpiresInSeconds ( ) > 60 ) ) { set ( credential ) ; return ; } String redirectUri = mUIController . getRedirectUri ( ) ; BrowserClientRequestUrl authorizationUrl = mFlow . newImplicitAuthorizationUrl ( ) . setRedirectUri ( redirectUri ) ; mUIController . requestAuthorization ( authorizationUrl ) ; ImplicitResponseUrl implicitResponse = mUIController . waitForImplicitResponseUrl ( ) ; credential = mFlow . createAndStoreCredential ( implicitResponse , userId ) ; set ( credential ) ; } finally { mUIController . stop ( ) ; } } } ; submitTaskToExecutor ( task ) ; return task ; }
|
Authorizes the Android application to access user s protected data using the Implicit Authorization flow in OAuth 2 . 0 .
|
39,725
|
public OAuthHmacCredential load10aCredential ( String userId ) throws IOException { if ( getCredentialStore ( ) == null ) { return null ; } OAuthHmacCredential credential = new10aCredential ( userId ) ; if ( ! getCredentialStore ( ) . load ( userId , credential ) ) { return null ; } return credential ; }
|
Loads the OAuth 1 . 0a credential of the given user ID from the credential store .
|
39,726
|
private OAuthHmacCredential new10aCredential ( String userId ) { ClientParametersAuthentication clientAuthentication = ( ClientParametersAuthentication ) getClientAuthentication ( ) ; OAuthHmacCredential . Builder builder = new OAuthHmacCredential . Builder ( getMethod ( ) , clientAuthentication . getClientId ( ) , clientAuthentication . getClientSecret ( ) ) . setTransport ( getTransport ( ) ) . setJsonFactory ( getJsonFactory ( ) ) . setTokenServerEncodedUrl ( getTokenServerEncodedUrl ( ) ) . setClientAuthentication ( getClientAuthentication ( ) ) . setRequestInitializer ( getRequestInitializer ( ) ) . setClock ( getClock ( ) ) ; if ( getCredentialStore ( ) != null ) { builder . addRefreshListener ( new CredentialStoreRefreshListener ( userId , getCredentialStore ( ) ) ) ; } builder . getRefreshListeners ( ) . addAll ( getRefreshListeners ( ) ) ; return builder . build ( ) ; }
|
Returns a new OAuth 1 . 0a credential instance based on the given user ID .
|
39,727
|
private Credential newCredential ( String userId ) { Credential . Builder builder = new Credential . Builder ( getMethod ( ) ) . setTransport ( getTransport ( ) ) . setJsonFactory ( getJsonFactory ( ) ) . setTokenServerEncodedUrl ( getTokenServerEncodedUrl ( ) ) . setClientAuthentication ( getClientAuthentication ( ) ) . setRequestInitializer ( getRequestInitializer ( ) ) . setClock ( getClock ( ) ) ; if ( getCredentialStore ( ) != null ) { builder . addRefreshListener ( new CredentialStoreRefreshListener ( userId , getCredentialStore ( ) ) ) ; } builder . getRefreshListeners ( ) . addAll ( getRefreshListeners ( ) ) ; return builder . build ( ) ; }
|
Returns a new OAuth 2 . 0 credential instance based on the given user ID .
|
39,728
|
public void stop ( ) { if ( container != null ) { container . stop ( ) ; container = null ; } if ( jerseyHandler != null && jerseyHandler . getDelegate ( ) != null ) { ServiceLocatorFactory . getInstance ( ) . destroy ( jerseyHandler . getDelegate ( ) . getServiceLocator ( ) ) ; jerseyHandler = null ; } if ( server != null ) { server . close ( ) ; server = null ; } }
|
Shutdown jersey server and release resources
|
39,729
|
public void start ( ) { if ( started ) { return ; } ApplicationHandler handler = getApplicationHandler ( ) ; if ( handler == null ) { throw new IllegalStateException ( "ApplicationHandler cannot be null" ) ; } handler . onStartup ( this ) ; started = true ; }
|
Starts the container
|
39,730
|
protected void initBridge ( ServiceLocator locator , Injector injector ) { GuiceBridge . getGuiceBridge ( ) . initializeGuiceBridge ( locator ) ; GuiceIntoHK2Bridge guiceBridge = locator . getService ( GuiceIntoHK2Bridge . class ) ; guiceBridge . bridgeGuiceInjector ( injector ) ; injectMultibindings ( locator , injector ) ; ServiceLocatorUtilities . bind ( locator , new AbstractBinder ( ) { protected void configure ( ) { bind ( GuiceScopeContext . class ) . to ( new TypeLiteral < Context < GuiceScope > > ( ) { } ) . in ( Singleton . class ) ; } } ) ; }
|
Initialize the hk2 bridge
|
39,731
|
protected void injectMultibindings ( ServiceLocator locator , Injector injector ) { injectMultiBindings ( locator , injector , new Key < Set < ContainerRequestFilter > > ( ) { } , ContainerRequestFilter . class ) ; injectMultiBindings ( locator , injector , new Key < Set < ContainerResponseFilter > > ( ) { } , ContainerResponseFilter . class ) ; injectMultiBindings ( locator , injector , new Key < Set < ReaderInterceptor > > ( ) { } , ReaderInterceptor . class ) ; injectMultiBindings ( locator , injector , new Key < Set < WriterInterceptor > > ( ) { } , WriterInterceptor . class ) ; injectMultiBindings ( locator , injector , new Key < Set < ModelProcessor > > ( ) { } , ModelProcessor . class ) ; injectMultiBindings ( locator , injector , new Key < Set < ContainerLifecycleListener > > ( ) { } , ContainerLifecycleListener . class ) ; injectMultiBindings ( locator , injector , new Key < Set < ApplicationEventListener > > ( ) { } , ApplicationEventListener . class ) ; injectMultiBindings ( locator , injector , new Key < Set < ExceptionMapper > > ( ) { } , ExceptionMapper . class ) ; }
|
This is a workaround for the hk2 bridge limitations
|
39,732
|
public List < String > getPackages ( ) { List < String > list = new ArrayList < > ( ) ; Consumer < JsonArray > reader = array -> { if ( ( array != null && ! array . isEmpty ( ) ) ) { for ( int i = 0 ; i < array . size ( ) ; i ++ ) { list . add ( array . getString ( i ) ) ; } } } ; JsonArray resources = config . getJsonArray ( CONFIG_RESOURCES , null ) ; JsonArray packages = config . getJsonArray ( CONFIG_PACKAGES , null ) ; reader . accept ( resources ) ; reader . accept ( packages ) ; return list ; }
|
Returns a list of packages to be scanned for resources and components
|
39,733
|
public Map < String , Object > getProperties ( ) { JsonObject json = null ; JsonObject tmp ; tmp = config . getJsonObject ( CONFIG_PROPERTIES ) ; if ( tmp != null ) { json = tmp ; } tmp = config . getJsonObject ( CONFIG_RESOURCE_CONFIG ) ; if ( tmp != null ) { if ( json == null ) { json = tmp ; } else { json . mergeIn ( tmp ) ; } } return json == null ? null : json . getMap ( ) ; }
|
Optional additional properties to be applied to Jersey resource configuration
|
39,734
|
public JksOptions getKeyStoreOptions ( ) { JsonObject json = config . getJsonObject ( CONFIG_JKS_OPTIONS ) ; return json == null ? null : new JksOptions ( json ) ; }
|
Vert . x http server key store options
|
39,735
|
public URI getBaseUri ( ) { String basePath = config . getString ( CONFIG_BASE_PATH , "/" ) ; if ( ! basePath . endsWith ( "/" ) ) { basePath += "/" ; } return URI . create ( basePath ) ; }
|
Returns the base URI used by Jersey
|
39,736
|
public void checkAuthStatus ( SimpleLoginAuthenticatedHandler handler ) { if ( androidContext != null ) { SharedPreferences sharedPreferences = androidContext . getSharedPreferences ( Constants . FIREBASE_ANDROID_SHARED_PREFERENCE , Context . MODE_PRIVATE ) ; String jsonTokenData = sharedPreferences . getString ( "jsonTokenData" , null ) ; if ( jsonTokenData != null ) { try { JSONObject jsonObject = new JSONObject ( jsonTokenData ) ; attemptAuthWithData ( jsonObject , handler ) ; } catch ( JSONException e ) { handler . authenticated ( null , null ) ; } } else { handler . authenticated ( null , null ) ; } } else { handler . authenticated ( null , null ) ; } }
|
Check the authentication status . If there is a previously signed in user it will reauthenticate that user .
|
39,737
|
public void loginAnonymously ( final SimpleLoginAuthenticatedHandler completionHandler ) { HashMap < String , String > data = new HashMap < String , String > ( ) ; makeRequest ( Constants . FIREBASE_AUTH_ANONYMOUS_PATH , data , new RequestHandler ( ) { public void handle ( FirebaseSimpleLoginError error , JSONObject data ) { if ( error != null ) { completionHandler . authenticated ( error , null ) ; } else { try { String token = data . has ( "token" ) ? data . getString ( "token" ) : null ; if ( token == null ) { JSONObject errorDetails = data . has ( "error" ) ? data . getJSONObject ( "error" ) : null ; FirebaseSimpleLoginError theError = FirebaseSimpleLoginError . errorFromResponse ( errorDetails ) ; completionHandler . authenticated ( theError , null ) ; } else { JSONObject userData = data . has ( "user" ) ? data . getJSONObject ( "user" ) : null ; if ( userData == null ) { FirebaseSimpleLoginError theError = FirebaseSimpleLoginError . errorFromResponse ( null ) ; completionHandler . authenticated ( theError , null ) ; } else { attemptAuthWithToken ( token , Provider . ANONYMOUS , userData , completionHandler ) ; } } } catch ( JSONException e ) { e . printStackTrace ( ) ; FirebaseSimpleLoginError theError = FirebaseSimpleLoginError . errorFromResponse ( null ) ; completionHandler . authenticated ( theError , null ) ; } } } } ) ; }
|
Login anonymously .
|
39,738
|
static PrintDrawable initIcon ( Context context , AttributeSet attrs , boolean inEditMode ) { PrintDrawable . Builder iconBuilder = new PrintDrawable . Builder ( context ) ; if ( attrs != null ) { TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . PrintView ) ; if ( a . hasValue ( R . styleable . PrintView_print_iconText ) ) { String iconText = a . getString ( R . styleable . PrintView_print_iconText ) ; iconBuilder . iconText ( iconText ) ; } if ( a . hasValue ( R . styleable . PrintView_print_iconCode ) ) { int iconCode = a . getInteger ( R . styleable . PrintView_print_iconCode , 0 ) ; iconBuilder . iconCode ( iconCode ) ; } if ( ! inEditMode && a . hasValue ( R . styleable . PrintView_print_iconFont ) ) { String iconFontPath = a . getString ( R . styleable . PrintView_print_iconFont ) ; iconBuilder . iconFont ( TypefaceManager . load ( context . getAssets ( ) , iconFontPath ) ) ; } if ( a . hasValue ( R . styleable . PrintView_print_iconColor ) ) { ColorStateList iconColor = a . getColorStateList ( R . styleable . PrintView_print_iconColor ) ; iconBuilder . iconColor ( iconColor ) ; } int iconSize = a . getDimensionPixelSize ( R . styleable . PrintView_print_iconSize , 0 ) ; iconBuilder . iconSize ( TypedValue . COMPLEX_UNIT_PX , iconSize ) ; iconBuilder . inEditMode ( inEditMode ) ; a . recycle ( ) ; } return iconBuilder . build ( ) ; }
|
Initialization of icon for print views .
|
39,739
|
public static void initDefault ( AssetManager assets , String defaultFontPath ) { Typeface defaultFont = TypefaceManager . load ( assets , defaultFontPath ) ; initDefault ( defaultFont ) ; }
|
Define the default iconic font .
|
39,740
|
static Typeface load ( AssetManager assets , String path ) { synchronized ( sTypefaces ) { Typeface typeface ; if ( sTypefaces . containsKey ( path ) ) { typeface = sTypefaces . get ( path ) ; } else { typeface = Typeface . createFromAsset ( assets , path ) ; sTypefaces . put ( path , typeface ) ; } return typeface ; } }
|
Load a typeface from the specified font data .
|
39,741
|
private void buildSoapuiGuiEnvironment ( ) throws DependencyResolutionException , IOException { getLog ( ) . info ( "Building a SoapUI Gui environment" ) ; String version = ProjectInfo . getVersion ( ) ; File soapuiLibDirectory = getBuiltSoapuiGuiLibDirectory ( ) ; resolveAndCopyDependencies ( new DefaultArtifact ( "com.github.redfish4ktc.soapui:maven-soapui-extension-plugin:" + version ) , soapuiLibDirectory ) ; File soapuiBinDirectory = getBuiltSoapuiGuiBinDirectory ( ) ; copySoapuiJar ( soapuiLibDirectory , soapuiBinDirectory ) ; System . setProperty ( "soapui.home" , soapuiBinDirectory . getAbsolutePath ( ) ) ; getLog ( ) . info ( "SoapUI Gui environment built" ) ; }
|
if the soapui . home property if already set we should restore the initial value after the call of this mojo
|
39,742
|
protected boolean runRunner ( ) throws Exception { WsdlProject project = ( WsdlProject ) ProjectFactoryRegistry . getProjectFactory ( "wsdl" ) . createNew ( getProjectFile ( ) , getProjectPassword ( ) ) ; String pFile = getProjectFile ( ) ; project . getSettings ( ) . setString ( ProjectSettings . SHADOW_PASSWORD , null ) ; File tmpProjectFile = new File ( System . getProperty ( "java.io.tmpdir" ) ) ; tmpProjectFile = new File ( tmpProjectFile , project . getName ( ) + "-project.xml" ) ; project . beforeSave ( ) ; project . saveIn ( tmpProjectFile ) ; pFile = tmpProjectFile . getAbsolutePath ( ) ; String endpoint = ( StringUtils . hasContent ( this . getLocalEndpoint ( ) ) ) ? this . getLocalEndpoint ( ) : project . getName ( ) ; this . log . info ( "Creating WAR file with endpoint [" + endpoint + "]" ) ; MockAsWarExtension mockAsWar = new MockAsWarExtension ( pFile , getSettingsFile ( ) , getOutputFolder ( ) , this . getWarFile ( ) , this . isIncludeLibraries ( ) , this . isIncludeActions ( ) , this . isIncludeListeners ( ) , endpoint , this . isEnableWebUI ( ) ) ; mockAsWar . createMockAsWarArchive ( ) ; this . log . info ( "WAR Generation complete" ) ; return true ; }
|
we should provide a PR to let us inject implementation of the MockAsWar
|
39,743
|
public String getAbsoluteOutputFolder ( ModelItem modelItem ) { String folder = PropertyExpander . expandProperties ( modelItem , getOutputFolder ( ) ) ; if ( StringUtils . isNullOrEmpty ( folder ) ) { folder = PathUtils . getExpandedResourceRoot ( modelItem ) ; } else if ( PathUtils . isRelativePath ( folder ) ) { folder = PathUtils . resolveResourcePath ( folder , modelItem ) ; } return folder ; }
|
then not used by this method
|
39,744
|
public static JUnitSecurityReportCollector newReportCollector ( ) { String className = System . getProperty ( "soapui.junit.reportCollector" , null ) ; if ( StringUtils . isNotBlank ( className ) ) { try { return ( JUnitSecurityReportCollector ) Class . forName ( className ) . getConstructor ( ) . newInstance ( ) ; } catch ( Exception e ) { log . warn ( "Failed to create JUnitReportCollector class [" + className + "] so use the default one;" + " error cause: " + e . toString ( ) ) ; } } return new JUnitSecurityReportCollector ( ) ; }
|
currently do not use it as SmartBear JUnitSecurityReportCollector have no constuctor with int argument
|
39,745
|
public void onViewCreated ( View view , Bundle savedInstanceState ) { super . onViewCreated ( view , savedInstanceState ) ; ensureContent ( ) ; }
|
Attach to view once the view hierarchy has been created .
|
39,746
|
public void onDestroyView ( ) { mContentShown = false ; mIsContentEmpty = false ; mProgressContainer = mContentContainer = mContentView = mEmptyView = null ; super . onDestroyView ( ) ; }
|
Detach from view .
|
39,747
|
public void setContentView ( int layoutResId ) { LayoutInflater layoutInflater = LayoutInflater . from ( getActivity ( ) ) ; View contentView = layoutInflater . inflate ( layoutResId , null ) ; setContentView ( contentView ) ; }
|
Set the content content from a layout resource .
|
39,748
|
public void setContentView ( View view ) { ensureContent ( ) ; if ( view == null ) { throw new IllegalArgumentException ( "Content view can't be null" ) ; } if ( mContentContainer instanceof ViewGroup ) { ViewGroup contentContainer = ( ViewGroup ) mContentContainer ; if ( mContentView == null ) { contentContainer . addView ( view ) ; } else { int index = contentContainer . indexOfChild ( mContentView ) ; contentContainer . removeView ( mContentView ) ; contentContainer . addView ( view , index ) ; } mContentView = view ; } else { throw new IllegalStateException ( "Can't be used with a custom content view" ) ; } }
|
Set the content view to an explicit view . If the content view was installed earlier the content will be replaced with a new view .
|
39,749
|
private void setContentShown ( boolean shown , boolean animate ) { ensureContent ( ) ; if ( mContentShown == shown ) { return ; } mContentShown = shown ; if ( shown ) { if ( animate ) { mProgressContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_out ) ) ; mContentContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_in ) ) ; } else { mProgressContainer . clearAnimation ( ) ; mContentContainer . clearAnimation ( ) ; } mProgressContainer . setVisibility ( View . GONE ) ; mContentContainer . setVisibility ( View . VISIBLE ) ; } else { if ( animate ) { mProgressContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_in ) ) ; mContentContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_out ) ) ; } else { mProgressContainer . clearAnimation ( ) ; mContentContainer . clearAnimation ( ) ; } mProgressContainer . setVisibility ( View . VISIBLE ) ; mContentContainer . setVisibility ( View . GONE ) ; } }
|
Control whether the content is being displayed . You can make it not displayed if you are waiting for the initial data to show in it . During this time an indeterminant progress indicator will be shown instead .
|
39,750
|
private void ensureContent ( ) { if ( mContentContainer != null && mProgressContainer != null ) { return ; } View root = getView ( ) ; if ( root == null ) { throw new IllegalStateException ( "Content view not yet created" ) ; } mProgressContainer = root . findViewById ( R . id . progress_container ) ; if ( mProgressContainer == null ) { throw new RuntimeException ( "Your content must have a ViewGroup whose id attribute is 'R.id.progress_container'" ) ; } mContentContainer = root . findViewById ( R . id . content_container ) ; if ( mContentContainer == null ) { throw new RuntimeException ( "Your content must have a ViewGroup whose id attribute is 'R.id.content_container'" ) ; } mEmptyView = root . findViewById ( android . R . id . empty ) ; if ( mEmptyView != null ) { mEmptyView . setVisibility ( View . GONE ) ; } mContentShown = true ; if ( mContentView == null ) { setContentShown ( false , false ) ; } }
|
Initialization views .
|
39,751
|
public void onViewCreated ( View view , Bundle savedInstanceState ) { super . onViewCreated ( view , savedInstanceState ) ; ensureList ( ) ; }
|
Attach to grid view once the view hierarchy has been created .
|
39,752
|
public void onDestroyView ( ) { mHandler . removeCallbacks ( mRequestFocus ) ; mGridView = null ; mGridShown = false ; mEmptyView = mProgressContainer = mGridContainer = null ; mStandardEmptyView = null ; super . onDestroyView ( ) ; }
|
Detach from grid view .
|
39,753
|
private void setGridShown ( boolean shown , boolean animate ) { ensureList ( ) ; if ( mProgressContainer == null ) { throw new IllegalStateException ( "Can't be used with a custom content view" ) ; } if ( mGridShown == shown ) { return ; } mGridShown = shown ; if ( shown ) { if ( animate ) { mProgressContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_out ) ) ; mGridContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_in ) ) ; } else { mProgressContainer . clearAnimation ( ) ; mGridContainer . clearAnimation ( ) ; } mProgressContainer . setVisibility ( View . GONE ) ; mGridContainer . setVisibility ( View . VISIBLE ) ; } else { if ( animate ) { mProgressContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_in ) ) ; mGridContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_out ) ) ; } else { mProgressContainer . clearAnimation ( ) ; mGridContainer . clearAnimation ( ) ; } mProgressContainer . setVisibility ( View . VISIBLE ) ; mGridContainer . setVisibility ( View . GONE ) ; } }
|
Control whether the grid is being displayed . You can make it not displayed if you are waiting for the initial data to show in it . During this time an indeterminant progress indicator will be shown instead .
|
39,754
|
private void setListShown ( boolean shown , boolean animate ) { ensureList ( ) ; if ( mProgressContainer == null ) { throw new IllegalStateException ( "Can't be used with a custom content view" ) ; } if ( mListShown == shown ) { return ; } mListShown = shown ; if ( shown ) { if ( animate ) { mProgressContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_out ) ) ; mListContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_in ) ) ; } else { mProgressContainer . clearAnimation ( ) ; mListContainer . clearAnimation ( ) ; } mProgressContainer . setVisibility ( View . GONE ) ; mListContainer . setVisibility ( View . VISIBLE ) ; } else { if ( animate ) { mProgressContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_in ) ) ; mListContainer . startAnimation ( AnimationUtils . loadAnimation ( getActivity ( ) , android . R . anim . fade_out ) ) ; } else { mProgressContainer . clearAnimation ( ) ; mListContainer . clearAnimation ( ) ; } mProgressContainer . setVisibility ( View . VISIBLE ) ; mListContainer . setVisibility ( View . GONE ) ; } }
|
Control whether the list is being displayed . You can make it not displayed if you are waiting for the initial data to show in it . During this time an indeterminant progress indicator will be shown instead .
|
39,755
|
public static < T > T getExtra ( Bundle extras , String name , boolean nullable ) { T value = null ; if ( extras != null && extras . containsKey ( name ) ) { value = ( T ) extras . get ( name ) ; } if ( ! nullable && value == null ) { throw new TransfuseInjectionException ( "Unable to access Extra " + name ) ; } return value ; }
|
Returns the extras in the given bundle by name . If no extra is found and the extra is considered not nullable this method will throw a TransfuseInjectionException . If no extra is found and the extra is considered nullable this method will of course return null .
|
39,756
|
public static void notNull ( final Object object , final String objectName ) { if ( object == null ) { throw new IllegalArgumentException ( "expecting non-null value for " + maskNullArgument ( objectName ) ) ; } }
|
Throw a null pointer exception if object is null
|
39,757
|
public static void sameSize ( final Collection < ? > collection1 , final Collection < ? > collection2 , final String collection1Name , final String collection2Name ) { notNull ( collection1 , collection1Name ) ; notNull ( collection2 , collection2Name ) ; if ( collection1 . size ( ) != collection2 . size ( ) ) { throw new IllegalArgumentException ( "expecting " + maskNullArgument ( collection1Name ) + " to have the same size as " + maskNullArgument ( collection2Name ) ) ; } }
|
Checks that the collections have the same number of elements otherwise throws an exception
|
39,758
|
public static void atSize ( final Collection < ? > collection , final int size , final String collectionName ) { notNull ( collection , collectionName ) ; notNegative ( size , "size" ) ; if ( collection . size ( ) != size ) { throw new IllegalArgumentException ( "expecting " + maskNullArgument ( collectionName ) + " to be of size " + size + "." ) ; } }
|
Checks that a collection is of a given size
|
39,759
|
public static void notEmpty ( final Collection < ? > collection , final String collectionName ) { notNull ( collection , collectionName ) ; if ( collection . isEmpty ( ) ) { throw new IllegalArgumentException ( "expecting " + maskNullArgument ( collectionName ) + " to contain 1 or more elements" ) ; } }
|
Check that a collection is not empty
|
39,760
|
public static void notEmpty ( final Object [ ] array , final String arrayName ) { notNull ( array , arrayName ) ; if ( array . length == 0 ) { throw new IllegalArgumentException ( "expecting " + maskNullArgument ( arrayName ) + " to contain 1 or more elements" ) ; } }
|
Check that an array is not empty
|
39,761
|
public static void sameLength ( final Object [ ] array1 , final Object [ ] array2 , final String array1Name , final String array2Name ) { notNull ( array1 , array1Name ) ; notNull ( array2 , array2Name ) ; if ( array1 . length != array2 . length ) { throw new IllegalArgumentException ( "expecting " + maskNullArgument ( array1Name ) + " to have the same length as " + maskNullArgument ( array2Name ) ) ; } }
|
Checks that the arrays have the same number of elements otherwise throws and exception
|
39,762
|
public static void atLength ( final Object [ ] array , final int length , final String arrayName ) { notNull ( array , arrayName ) ; notNegative ( length , "length" ) ; if ( array . length != length ) { throw new IllegalArgumentException ( "expecting " + maskNullArgument ( arrayName ) + " to be of length " + length + "." ) ; } }
|
Checks that an array is of a given length
|
39,763
|
public static void inBounds ( final Integer input , final Integer min , final Integer max , final String inputName ) { notNull ( input , inputName ) ; if ( ( min != null ) && ( input < min ) ) { throw new IndexOutOfBoundsException ( "a value of " + input . toString ( ) + " was unexpected for " + maskNullArgument ( inputName ) + ", it is expected to be less than " + min . toString ( ) ) ; } if ( ( max != null ) && ( input > max ) ) { throw new IndexOutOfBoundsException ( "a value of " + input . toString ( ) + " was unexpected for " + maskNullArgument ( inputName ) + ", it is expected to be greater than " + max . toString ( ) ) ; } }
|
Checks that the input value is within the bounds of a maximum or minimum value
|
39,764
|
public static void notNegative ( final Integer input , final String inputName ) { notNull ( input , inputName ) ; if ( input < 0 ) { throw new IllegalArgumentException ( "a value of " + input . toString ( ) + " was unexpected for " + maskNullArgument ( inputName ) + ", it is expected to be positive" ) ; } }
|
Checks that the input value is non - negative
|
39,765
|
public static void notZero ( final Integer input , final String inputName ) { notNull ( input , inputName ) ; if ( input == 0 ) { throw new IllegalArgumentException ( "a zero value for was unexpected for " + maskNullArgument ( inputName ) + ", it is expected to be non zero" ) ; } }
|
Checks that the input value is non - zero
|
39,766
|
public static void notBlank ( final String input , final String inputName ) { notNull ( input , inputName ) ; if ( StringUtils . isBlank ( input ) ) { throw new IllegalArgumentException ( "Expecting " + maskNullArgument ( inputName ) + " to be a non blank value." ) ; } }
|
Checks that an input string is non blank
|
39,767
|
public static void instanceOf ( final Object input , Class < ? > classType , final String inputName ) { notNull ( input , "input" ) ; notNull ( classType , "classType" ) ; if ( ! classType . isInstance ( input ) ) { throw new IllegalArgumentException ( "Expecting " + maskNullArgument ( inputName ) + " to an instance of " + classType . getName ( ) + "." ) ; } }
|
Check that an input of a given class
|
39,768
|
public ImmutableList < ASTParameter > getParameters ( Method method ) { return getParameters ( method . getParameterTypes ( ) , method . getGenericParameterTypes ( ) , method . getParameterAnnotations ( ) ) ; }
|
Builds the parameters for a given method
|
39,769
|
public ASTMethod getMethod ( Method method ) { ImmutableList < ASTParameter > astParameters = getParameters ( method ) ; ASTAccessModifier modifier = ASTAccessModifier . getModifier ( method . getModifiers ( ) ) ; ImmutableSet < ASTType > throwsTypes = getTypes ( method . getExceptionTypes ( ) ) ; return new ASTClassMethod ( method , getType ( method . getReturnType ( ) , method . getGenericReturnType ( ) ) , astParameters , modifier , getAnnotations ( method ) , throwsTypes ) ; }
|
Builds an AST Method fromm the given input method .
|
39,770
|
public ASTField getField ( Field field ) { ASTAccessModifier modifier = ASTAccessModifier . getModifier ( field . getModifiers ( ) ) ; return new ASTClassField ( field , getType ( field . getType ( ) , field . getGenericType ( ) ) , modifier , getAnnotations ( field ) ) ; }
|
Builds an AST Field from the given field
|
39,771
|
public ASTConstructor getConstructor ( Constructor constructor , boolean isEnum , boolean isInnerClass ) { ASTAccessModifier modifier = ASTAccessModifier . getModifier ( constructor . getModifiers ( ) ) ; Annotation [ ] [ ] parameterAnnotations = constructor . getParameterAnnotations ( ) ; if ( constructor . getDeclaringClass ( ) . getEnclosingClass ( ) != null && ! Modifier . isStatic ( constructor . getDeclaringClass ( ) . getModifiers ( ) ) ) { Annotation [ ] [ ] paddedParameterAnnotations = new Annotation [ parameterAnnotations . length + 1 ] [ ] ; paddedParameterAnnotations [ 0 ] = new Annotation [ 0 ] ; System . arraycopy ( parameterAnnotations , 0 , paddedParameterAnnotations , 1 , parameterAnnotations . length ) ; parameterAnnotations = paddedParameterAnnotations ; } ImmutableList < ASTParameter > constructorParameters = getParameters ( constructor . getParameterTypes ( ) , constructor . getGenericParameterTypes ( ) , parameterAnnotations ) ; if ( isEnum ) { constructorParameters = constructorParameters . subList ( 2 , constructorParameters . size ( ) ) ; } if ( isInnerClass ) { constructorParameters = constructorParameters . subList ( 1 , constructorParameters . size ( ) ) ; } ImmutableSet < ASTType > throwsTypes = getTypes ( constructor . getExceptionTypes ( ) ) ; return new ASTClassConstructor ( getAnnotations ( constructor ) , constructor , constructorParameters , modifier , throwsTypes ) ; }
|
Build an AST Constructor from the given constructor
|
39,772
|
private ImmutableSet < ASTAnnotation > getAnnotations ( Annotation [ ] annotations ) { ImmutableSet . Builder < ASTAnnotation > astAnnotationBuilder = ImmutableSet . builder ( ) ; for ( Annotation annotation : annotations ) { astAnnotationBuilder . add ( getAnnotation ( annotation ) ) ; } return astAnnotationBuilder . build ( ) ; }
|
Build the AST Annotations from the given input annotation array .
|
39,773
|
public void execute ( ) { ExecutorService executorService = MoreExecutors . sameThreadExecutor ( ) ; for ( Transaction < V , R > transaction : transactions ) { if ( ! transaction . isComplete ( ) ) { executorService . execute ( transaction ) ; } } try { executorService . shutdown ( ) ; executorService . awaitTermination ( Long . MAX_VALUE , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { throw new TransfuseTransactionException ( "Pool executor interrupted" , e ) ; } }
|
Executes the submitted work and if all transactions complete executes the aggregate on the aggregateWorker .
|
39,774
|
public boolean isComplete ( ) { for ( Transaction < V , R > transaction : transactions ) { if ( ! transaction . isComplete ( ) ) { return false ; } } return true ; }
|
Returns the completion status of the set of transactions . Will only return complete = true if all the transactions have completed successfully .
|
39,775
|
public static < T > Class < T > get ( Class < ? > type ) { return ( Class < T > ) REPOSITORY . get ( type ) ; }
|
Provides the corresponding generated Android Component class for the input Transfuse Component class .
|
39,776
|
public static < T > T getField ( Class < T > returnType , Class < ? > targetClass , Object target , String field ) { try { Field declaredField = targetClass . getDeclaredField ( field ) ; return AccessController . doPrivileged ( new GetFieldPrivilegedAction < T > ( declaredField , target ) ) ; } catch ( NoSuchFieldException e ) { throw new TransfuseInjectionException ( "NoSuchFieldException Exception during field injection: " + field + " in " + target . getClass ( ) , e ) ; } catch ( PrivilegedActionException e ) { throw new TransfuseInjectionException ( "PrivilegedActionException Exception during field injection" , e ) ; } catch ( Exception e ) { throw new TransfuseInjectionException ( "Exception during field injection" , e ) ; } }
|
Returns the value of a field .
|
39,777
|
public static void setField ( Class < ? > targetClass , Object target , String field , Object value ) { try { Field classField = targetClass . getDeclaredField ( field ) ; AccessController . doPrivileged ( new SetFieldPrivilegedAction ( classField , target , value ) ) ; } catch ( NoSuchFieldException e ) { throw new TransfuseInjectionException ( "NoSuchFieldException Exception during field injection: " + field + " in " + target . getClass ( ) , e ) ; } catch ( PrivilegedActionException e ) { throw new TransfuseInjectionException ( "PrivilegedActionException Exception during field injection" , e ) ; } catch ( Exception e ) { throw new TransfuseInjectionException ( "Exception during field injection" , e ) ; } }
|
Updates field with the given value .
|
39,778
|
public static < T > T callMethod ( Class < T > retClass , Class < ? > targetClass , Object target , String method , Class [ ] argClasses , Object [ ] args ) { try { Method classMethod = targetClass . getDeclaredMethod ( method , argClasses ) ; return AccessController . doPrivileged ( new SetMethodPrivilegedAction < T > ( classMethod , target , args ) ) ; } catch ( NoSuchMethodException e ) { throw new TransfuseInjectionException ( "Exception during method injection: NoSuchFieldException" , e ) ; } catch ( PrivilegedActionException e ) { throw new TransfuseInjectionException ( "PrivilegedActionException Exception during field injection" , e ) ; } catch ( Exception e ) { throw new TransfuseInjectionException ( "Exception during field injection" , e ) ; } }
|
Calls a method with the provided arguments as parameters .
|
39,779
|
public synchronized ASTType getType ( final TypeElement typeElement ) { return new LazyASTType ( buildPackageClass ( typeElement ) , typeElement ) { public ASTType lazyLoad ( ) { if ( ! typeCache . containsKey ( typeElement ) ) { typeCache . put ( typeElement , buildType ( typeElement ) ) ; } return typeCache . get ( typeElement ) ; } } ; }
|
Build a ASTType from the provided TypeElement .
|
39,780
|
public ASTField getField ( VariableElement variableElement ) { ASTAccessModifier modifier = buildAccessModifier ( variableElement ) ; return new ASTElementField ( variableElement , astTypeBuilderVisitor , modifier , getAnnotations ( variableElement ) ) ; }
|
Build a ASTElementField from the given VariableElement
|
39,781
|
public ASTMethod getMethod ( ExecutableElement executableElement ) { ImmutableList < ASTParameter > parameters = getParameters ( executableElement . getParameters ( ) ) ; ASTAccessModifier modifier = buildAccessModifier ( executableElement ) ; ImmutableSet < ASTType > throwsTypes = buildASTElementTypes ( executableElement . getThrownTypes ( ) ) ; return new ASTElementMethod ( executableElement , astTypeBuilderVisitor , parameters , modifier , getAnnotations ( executableElement ) , throwsTypes ) ; }
|
Build an ASTMethod from the provided ExecutableElement
|
39,782
|
private ImmutableList < ASTParameter > getParameters ( List < ? extends VariableElement > variableElements ) { ImmutableList . Builder < ASTParameter > astParameterBuilder = ImmutableList . builder ( ) ; for ( VariableElement variables : variableElements ) { astParameterBuilder . add ( getParameter ( variables ) ) ; } return astParameterBuilder . build ( ) ; }
|
Build a list of ASTParameters corresponding tot he input VariableElement list elements
|
39,783
|
public ASTConstructor getConstructor ( ExecutableElement executableElement ) { ImmutableList < ASTParameter > parameters = getParameters ( executableElement . getParameters ( ) ) ; ASTAccessModifier modifier = buildAccessModifier ( executableElement ) ; ImmutableSet < ASTType > throwsTypes = buildASTElementTypes ( executableElement . getThrownTypes ( ) ) ; return new ASTElementConstructor ( executableElement , parameters , modifier , getAnnotations ( executableElement ) , throwsTypes ) ; }
|
Build an ASTConstructor from the input ExecutableElement
|
39,784
|
public ConstructorInjectionPoint buildInjectionPoint ( ASTType containingType , ASTConstructor astConstructor , AnalysisContext context ) { ConstructorInjectionPoint constructorInjectionPoint = new ConstructorInjectionPoint ( containingType , astConstructor ) ; constructorInjectionPoint . addThrows ( astConstructor . getThrowsTypes ( ) ) ; List < ASTAnnotation > methodAnnotations = new ArrayList < ASTAnnotation > ( ) ; if ( astConstructor . getParameters ( ) . size ( ) == 1 ) { methodAnnotations . addAll ( astConstructor . getAnnotations ( ) ) ; } for ( ASTParameter astParameter : astConstructor . getParameters ( ) ) { List < ASTAnnotation > parameterAnnotations = new ArrayList < ASTAnnotation > ( methodAnnotations ) ; parameterAnnotations . addAll ( astParameter . getAnnotations ( ) ) ; constructorInjectionPoint . addInjectionNode ( buildInjectionNode ( parameterAnnotations , astParameter , astParameter . getASTType ( ) , context ) ) ; } return constructorInjectionPoint ; }
|
Build a Constructor InjectionPoint from the given ASTConstructor
|
39,785
|
public MethodInjectionPoint buildInjectionPoint ( ASTType rootContainingType , ASTType containingType , ASTMethod astMethod , AnalysisContext context ) { MethodInjectionPoint methodInjectionPoint = new MethodInjectionPoint ( rootContainingType , containingType , astMethod ) ; methodInjectionPoint . addThrows ( astMethod . getThrowsTypes ( ) ) ; List < ASTAnnotation > methodAnnotations = new ArrayList < ASTAnnotation > ( ) ; if ( astMethod . getParameters ( ) . size ( ) == 1 ) { methodAnnotations . addAll ( astMethod . getAnnotations ( ) ) ; } for ( ASTParameter astParameter : astMethod . getParameters ( ) ) { List < ASTAnnotation > parameterAnnotations = new ArrayList < ASTAnnotation > ( methodAnnotations ) ; parameterAnnotations . addAll ( astParameter . getAnnotations ( ) ) ; methodInjectionPoint . addInjectionNode ( buildInjectionNode ( parameterAnnotations , astParameter , astParameter . getASTType ( ) , context ) ) ; } return methodInjectionPoint ; }
|
Build a Method Injection Point from the given ASTMethod
|
39,786
|
public FieldInjectionPoint buildInjectionPoint ( ASTType rootContainingType , ASTType containingType , ASTField astField , AnalysisContext context ) { return new FieldInjectionPoint ( rootContainingType , containingType , astField , buildInjectionNode ( astField . getAnnotations ( ) , astField , astField . getASTType ( ) , context ) ) ; }
|
Build a Field InjectionPoint from the given ASTField
|
39,787
|
public InjectionNode buildInjectionNode ( ASTType astType , AnalysisContext context ) { return buildInjectionNode ( Collections . EMPTY_LIST , astType , astType , context ) ; }
|
Build a InjectionPoint directly from the given ASTType
|
39,788
|
public < T > void register ( Class < T > event , EventObserver < T > observer ) { if ( event == null ) { throw new IllegalArgumentException ( "Null Event type passed to register" ) ; } if ( observer == null ) { throw new IllegalArgumentException ( "Null observer passed to register" ) ; } nullSafeGet ( event ) . add ( observer ) ; }
|
Register the given observer to be triggered if the given event type is triggered .
|
39,789
|
public void trigger ( Object event ) { Set < Class > eventTypes = getAllInheritedClasses ( event . getClass ( ) ) ; for ( Class eventType : eventTypes ) { if ( observers . containsKey ( eventType ) ) { for ( EventObserver eventObserver : observers . get ( eventType ) ) { executionQueue . get ( ) . add ( new EventExecution ( event , eventObserver ) ) ; } } } triggerQueue ( ) ; }
|
Triggers an event through the EventManager . This will call the registered EventObservers with the provided event .
|
39,790
|
public void unregister ( EventObserver < ? > observer ) { for ( Map . Entry < Class , Set < EventObserver > > entry : observers . entrySet ( ) ) { entry . getValue ( ) . remove ( observer ) ; } }
|
Unregisters an EventObserver by equality .
|
39,791
|
public void start ( IntentFactoryStrategy parameters ) { Intent intent = buildIntent ( parameters ) ; parameters . start ( context , intent ) ; }
|
Start the appropriate target Context specified by the input Strategy .
|
39,792
|
public Intent buildIntent ( IntentFactoryStrategy parameters ) { android . content . Intent intent = intentMockFactory . buildIntent ( context , parameters . getTargetContext ( ) ) ; intent . setFlags ( parameters . getFlags ( ) ) ; for ( String category : parameters . getCategories ( ) ) { intent . addCategory ( category ) ; } intent . putExtras ( parameters . getExtras ( ) ) ; return intent ; }
|
Build an Intent specified by the given input Strategy .
|
39,793
|
public PendingIntent buildPendingIntent ( int requestCode , int flags , IntentFactoryStrategy parameters ) { return PendingIntent . getActivity ( context , requestCode , buildIntent ( parameters ) , flags ) ; }
|
Build a PendingIntent specified by the given input Strategy .
|
39,794
|
public boolean inherits ( ASTType astType , ASTType inheritable ) { if ( astType == null ) { return false ; } if ( inheritable == null || inheritable . equals ( OBJECT_TYPE ) ) { return true ; } if ( astType . equals ( inheritable ) ) { return true ; } for ( ASTType typeInterfaces : astType . getInterfaces ( ) ) { if ( inherits ( typeInterfaces , inheritable ) ) { return true ; } } return inherits ( astType . getSuperClass ( ) , inheritable ) ; }
|
Determines if the given ASTType inherits or extends from the given inheritable ASTType
|
39,795
|
public final void loadRepository ( ClassLoader classLoader , String repositoryPackage , String repositoryName ) { try { Class repositoryClass = classLoader . loadClass ( repositoryPackage + "." + repositoryName ) ; Repository < T > instance = ( Repository < T > ) repositoryClass . newInstance ( ) ; generatedMap . putAll ( instance . get ( ) ) ; } catch ( ClassNotFoundException e ) { } catch ( InstantiationException e ) { throw new TransfuseRuntimeException ( "Unable to instantiate generated Repository" , e ) ; } catch ( IllegalAccessException e ) { throw new TransfuseRuntimeException ( "Unable to access generated Repository" , e ) ; } }
|
Update the repository class from the given classloader . If the given repository class cannot be instantiated then this method will throw a TransfuseRuntimeException .
|
39,796
|
private void createConfigurationsForModuleType ( ImmutableList . Builder < ModuleConfiguration > configurations , ASTType module , ASTType scanTarget , Set < MethodSignature > scanned , Map < String , Set < MethodSignature > > packagePrivateScanned ) { configureModuleAnnotations ( configurations , module , scanTarget , scanTarget . getAnnotations ( ) ) ; configureModuleMethods ( configurations , module , scanTarget , scanTarget . getMethods ( ) , scanned , packagePrivateScanned ) ; for ( ASTMethod astMethod : scanTarget . getMethods ( ) ) { MethodSignature signature = new MethodSignature ( astMethod ) ; if ( astMethod . getAccessModifier ( ) == ASTAccessModifier . PUBLIC || astMethod . getAccessModifier ( ) == ASTAccessModifier . PROTECTED ) { scanned . add ( signature ) ; } else if ( astMethod . getAccessModifier ( ) == ASTAccessModifier . PACKAGE_PRIVATE ) { if ( ! packagePrivateScanned . containsKey ( scanTarget . getPackageClass ( ) . getPackage ( ) ) ) { packagePrivateScanned . put ( scanTarget . getPackageClass ( ) . getPackage ( ) , new HashSet < MethodSignature > ( ) ) ; } packagePrivateScanned . get ( scanTarget . getPackageClass ( ) . getPackage ( ) ) . add ( signature ) ; } } if ( scanTarget . getSuperClass ( ) != null ) { createConfigurationsForModuleType ( configurations , module , scanTarget . getSuperClass ( ) , scanned , packagePrivateScanned ) ; } }
|
Recursive method that finds module methods and annotations on all parents of moduleAncestor and moduleAncestor but creates configuration based on the module . This allows any class in the module hierarchy to contribute annotations or providers that can be overridden by subclasses .
|
39,797
|
public Object invoke ( Object [ ] arguments ) { try { return new MethodInterceptorIterator ( arguments ) . proceed ( ) ; } catch ( Throwable e ) { throw new TransfuseInjectionException ( "Error while invoking Method Interceptor" , e ) ; } }
|
Invoke the method interception chain .
|
39,798
|
protected void setup ( SuggestOracle suggestions ) { if ( itemBoxKeyDownHandler != null ) { itemBoxKeyDownHandler . removeHandler ( ) ; } list . setStyleName ( AddinsCssName . MULTIVALUESUGGESTBOX_LIST ) ; this . suggestions = suggestions ; final ListItem item = new ListItem ( ) ; item . setStyleName ( AddinsCssName . MULTIVALUESUGGESTBOX_INPUT_TOKEN ) ; suggestBox = new SuggestBox ( suggestions , itemBox ) ; suggestBox . addSelectionHandler ( selectionEvent -> { Suggestion selectedItem = selectionEvent . getSelectedItem ( ) ; itemBox . setValue ( "" ) ; if ( addItem ( selectedItem ) ) { ValueChangeEvent . fire ( MaterialAutoComplete . this , getValue ( ) ) ; } itemBox . setFocus ( true ) ; } ) ; loadHandlers ( ) ; setLimit ( this . limit ) ; String autocompleteId = DOM . createUniqueId ( ) ; itemBox . getElement ( ) . setId ( autocompleteId ) ; item . add ( suggestBox ) ; item . add ( label ) ; list . add ( item ) ; panel . add ( list ) ; panel . getElement ( ) . setAttribute ( "onclick" , "document.getElementById('" + autocompleteId + "').focus()" ) ; panel . add ( errorLabel ) ; suggestBox . setFocus ( true ) ; }
|
Generate and build the List Items to be set on Auto Complete box .
|
39,799
|
protected boolean addItem ( final Suggestion suggestion ) { SelectionEvent . fire ( MaterialAutoComplete . this , suggestion ) ; if ( getLimit ( ) > 0 ) { if ( suggestionMap . size ( ) >= getLimit ( ) ) { return false ; } } if ( suggestionMap . containsKey ( suggestion ) ) { return false ; } final ListItem displayItem = new ListItem ( ) ; displayItem . setStyleName ( AddinsCssName . MULTIVALUESUGGESTBOX_TOKEN ) ; if ( getType ( ) == AutocompleteType . TEXT ) { suggestionMap . clear ( ) ; itemBox . setText ( suggestion . getReplacementString ( ) ) ; } else { final MaterialChip chip = chipProvider . getChip ( suggestion ) ; if ( chip == null ) { return false ; } registerHandler ( chip . addClickHandler ( event -> { if ( chipProvider . isChipSelectable ( suggestion ) ) { if ( itemsHighlighted . contains ( displayItem ) ) { chip . removeStyleName ( selectedChipStyle ) ; itemsHighlighted . remove ( displayItem ) ; } else { chip . addStyleName ( selectedChipStyle ) ; itemsHighlighted . add ( displayItem ) ; } } } ) ) ; if ( chip . getIcon ( ) != null ) { registerHandler ( chip . getIcon ( ) . addClickHandler ( event -> { if ( chipProvider . isChipRemovable ( suggestion ) ) { suggestionMap . remove ( suggestion ) ; list . remove ( displayItem ) ; itemsHighlighted . remove ( displayItem ) ; ValueChangeEvent . fire ( MaterialAutoComplete . this , getValue ( ) ) ; suggestBox . showSuggestionList ( ) ; } } ) ) ; } suggestionMap . put ( suggestion , chip ) ; displayItem . add ( chip ) ; list . insert ( displayItem , list . getWidgetCount ( ) - 1 ) ; } return true ; }
|
Adding the item value using Material Chips added on auto complete box
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.