idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
152,900 | public float getFloat ( int columnIndex ) { Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return 0.0f ; } if ( fieldValue instanceof Number ) { return ( ( Number ) fieldValue ) . floatValue ( ) ; } throw new DBFException ( "Unsupported type for Number at column:" + columnIndex + " " + fieldValu... | Reads the data as Float |
152,901 | public int getInt ( int columnIndex ) { Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return 0 ; } if ( fieldValue instanceof Number ) { return ( ( Number ) fieldValue ) . intValue ( ) ; } throw new DBFException ( "Unsupported type for Number at column:" + columnIndex + " " + fieldValue . getCl... | Reads the data as int |
152,902 | public long getLong ( int columnIndex ) { Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return 0 ; } if ( fieldValue instanceof Number ) { return ( ( Number ) fieldValue ) . longValue ( ) ; } throw new DBFException ( "Unsupported type for Number at column:" + columnIndex + " " + fieldValue . ge... | Reads the data as long |
152,903 | public static byte [ ] textPadding ( String text , String characterSetName , int length , int alignment , byte paddingByte ) throws UnsupportedEncodingException { DBFAlignment align = DBFAlignment . RIGHT ; if ( alignment == ALIGN_LEFT ) { align = DBFAlignment . LEFT ; } return textPadding ( text , characterSetName , l... | Text is truncated if exceed field capacity . Uses spaces as padding |
152,904 | public static byte [ ] textPadding ( String text , String characterSetName , int length , DBFAlignment alignment , byte paddingByte ) throws UnsupportedEncodingException { return textPadding ( text , Charset . forName ( characterSetName ) , length , alignment , paddingByte ) ; } | Obtais the data to store in file for a text field . Text is truncated if exceed field capacity |
152,905 | TomcatRuntime getTomcatRuntime ( WebResourceRoot resources ) { TomcatRuntime result = null ; if ( isUberJar ( resources ) ) { result = TomcatRuntime . UBER_JAR ; } else if ( isUberWar ( resources ) ) { result = TomcatRuntime . UBER_WAR ; } else if ( isTesting ( resources ) ) { result = TomcatRuntime . TEST ; } else if ... | Inform tomcat runtime setup . UNPACKAGED_WAR not covered yet . |
152,906 | protected void writeClassList ( File file , Collection < String > classNames ) throws IOException { File baseDir = file . getParentFile ( ) ; if ( baseDir . isDirectory ( ) || baseDir . mkdirs ( ) ) { Files . write ( file . toPath ( ) , classNames , StandardCharsets . UTF_8 ) ; } else { throw new IOException ( baseDir ... | Helper method which writes a list of class names to the given file . |
152,907 | protected void writeClassMap ( File file , Map < String , ? extends Collection < String > > classMap ) throws IOException { File baseDir = file . getParentFile ( ) ; if ( baseDir . isDirectory ( ) || baseDir . mkdirs ( ) ) { try ( PrintWriter printWriter = new PrintWriter ( file , "UTF-8" ) ) { classMap . forEach ( ( k... | Helper method which writes a map of class names to the given file . |
152,908 | public static boolean areAllGranted ( String authorities ) throws IOException { AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag ( ) ; authorizeTag . setIfAllGranted ( authorities ) ; return authorizeTag . authorize ( ) ; } | Returns true if the user has all of of the given authorities . |
152,909 | public static boolean areAnyGranted ( String authorities ) throws IOException { AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag ( ) ; authorizeTag . setIfAnyGranted ( authorities ) ; return authorizeTag . authorize ( ) ; } | Returns true if the user has any of the given authorities . |
152,910 | public static boolean areNotGranted ( String authorities ) throws IOException { AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag ( ) ; authorizeTag . setIfNotGranted ( authorities ) ; return authorizeTag . authorize ( ) ; } | Returns true if the user does not have any of the given authorities . |
152,911 | public static boolean isAllowed ( String url , String method ) throws IOException { AuthorizeFaceletsTag authorizeTag = new AuthorizeFaceletsTag ( ) ; authorizeTag . setUrl ( url ) ; authorizeTag . setMethod ( method ) ; return authorizeTag . authorizeUsingUrlCheck ( ) ; } | Returns true if the user is allowed to access the given URL and HTTP method combination . The HTTP method is optional and case insensitive . |
152,912 | private void registerJsfCdiToSpring ( BeanDefinition definition ) { if ( definition instanceof AnnotatedBeanDefinition ) { AnnotatedBeanDefinition annDef = ( AnnotatedBeanDefinition ) definition ; String scopeName = null ; if ( annDef . getFactoryMethodMetadata ( ) != null ) { scopeName = deduceScopeName ( annDef . get... | Checks how is bean defined and deduces scope name from JSF CDI annotations . |
152,913 | private String getPropertyPath ( Expression reference , String alias ) { if ( reference instanceof Property ) { Property property = ( Property ) reference ; if ( alias . equals ( property . getScope ( ) ) ) { return property . getPath ( ) ; } else if ( property . getSource ( ) != null ) { String subPath = getPropertyPa... | Collapse a property path expression back to it s qualified form for use as the path attribute of the retrieve . |
152,914 | public boolean isCompatibleWith ( DataType other ) { if ( other instanceof ChoiceType ) { for ( DataType choice : ( ( ChoiceType ) other ) . getTypes ( ) ) { if ( this . isSubTypeOf ( choice ) ) { return true ; } } } return this . equals ( other ) ; } | literal to any other type or casting a class to an equivalent tuple . |
152,915 | public T visitTypeSpecifier ( TypeSpecifier elm , C context ) { if ( elm instanceof NamedTypeSpecifier ) return visitNamedTypeSpecifier ( ( NamedTypeSpecifier ) elm , context ) ; else if ( elm instanceof IntervalTypeSpecifier ) return visitIntervalTypeSpecifier ( ( IntervalTypeSpecifier ) elm , context ) ; else if ( el... | Visit a TypeSpecifier . This method will be called for every node in the tree that is a descendant of the TypeSpecifier type . |
152,916 | public T visitIntervalTypeSpecifier ( IntervalTypeSpecifier elm , C context ) { visitElement ( elm . getPointType ( ) , context ) ; return null ; } | Visit a IntervalTypeSpecifier . This method will be called for every node in the tree that is a IntervalTypeSpecifier . |
152,917 | public T visitListTypeSpecifier ( ListTypeSpecifier elm , C context ) { visitElement ( elm . getElementType ( ) , context ) ; return null ; } | Visit a ListTypeSpecifier . This method will be called for every node in the tree that is a ListTypeSpecifier . |
152,918 | public T visitTupleElementDefinition ( TupleElementDefinition elm , C context ) { visitElement ( elm . getType ( ) , context ) ; return null ; } | Visit a TupleElementDefinition . This method will be called for every node in the tree that is a TupleElementDefinition . |
152,919 | public T visitTupleTypeSpecifier ( TupleTypeSpecifier elm , C context ) { for ( TupleElementDefinition element : elm . getElement ( ) ) { visitElement ( element , context ) ; } return null ; } | Visit a TupleTypeSpecifier . This method will be called for every node in the tree that is a TupleTypeSpecifier . |
152,920 | public T visitTernaryExpression ( TernaryExpression elm , C context ) { for ( Expression element : elm . getOperand ( ) ) { visitElement ( element , context ) ; } return null ; } | Visit a TernaryExpression . This method will be called for every node in the tree that is a TernaryExpression . |
152,921 | public T visitNaryExpression ( NaryExpression elm , C context ) { if ( elm instanceof Coalesce ) return visitCoalesce ( ( Coalesce ) elm , context ) ; else if ( elm instanceof Concatenate ) return visitConcatenate ( ( Concatenate ) elm , context ) ; else if ( elm instanceof Except ) return visitExcept ( ( Except ) elm ... | Visit a NaryExpression . This method will be called for every node in the tree that is a NaryExpression . |
152,922 | public T visitExpressionDef ( ExpressionDef elm , C context ) { visitElement ( elm . getExpression ( ) , context ) ; return null ; } | Visit a ExpressionDef . This method will be called for every node in the tree that is a ExpressionDef . |
152,923 | public T visitFunctionDef ( FunctionDef elm , C context ) { for ( OperandDef element : elm . getOperand ( ) ) { visitElement ( element , context ) ; } visitElement ( elm . getExpression ( ) , context ) ; return null ; } | Visit a FunctionDef . This method will be called for every node in the tree that is a FunctionDef . |
152,924 | public T visitFunctionRef ( FunctionRef elm , C context ) { for ( Expression element : elm . getOperand ( ) ) { visitElement ( element , context ) ; } return null ; } | Visit a FunctionRef . This method will be called for every node in the tree that is a FunctionRef . |
152,925 | public T visitParameterDef ( ParameterDef elm , C context ) { if ( elm . getParameterTypeSpecifier ( ) != null ) { visitElement ( elm . getParameterTypeSpecifier ( ) , context ) ; } if ( elm . getDefault ( ) != null ) { visitElement ( elm . getDefault ( ) , context ) ; } return null ; } | Visit a ParameterDef . This method will be called for every node in the tree that is a ParameterDef . |
152,926 | public T visitOperandDef ( OperandDef elm , C context ) { if ( elm . getOperandTypeSpecifier ( ) != null ) { visitElement ( elm . getOperandTypeSpecifier ( ) , context ) ; } return null ; } | Visit a OperandDef . This method will be called for every node in the tree that is a OperandDef . |
152,927 | public T visitTupleElement ( TupleElement elm , C context ) { visitElement ( elm . getValue ( ) , context ) ; return null ; } | Visit a TupleElement . This method will be called for every node in the tree that is a TupleElement . |
152,928 | public T visitTuple ( Tuple elm , C context ) { for ( TupleElement element : elm . getElement ( ) ) { visitTupleElement ( element , context ) ; } return null ; } | Visit a Tuple . This method will be called for every node in the tree that is a Tuple . |
152,929 | public T visitInstanceElement ( InstanceElement elm , C context ) { visitElement ( elm . getValue ( ) , context ) ; return null ; } | Visit a InstanceElement . This method will be called for every node in the tree that is a InstanceElement . |
152,930 | public T visitInstance ( Instance elm , C context ) { for ( InstanceElement element : elm . getElement ( ) ) { visitInstanceElement ( element , context ) ; } return null ; } | Visit a Instance . This method will be called for every node in the tree that is a Instance . |
152,931 | public T visitInterval ( Interval elm , C context ) { if ( elm . getLow ( ) != null ) { visitElement ( elm . getLow ( ) , context ) ; } if ( elm . getLowClosedExpression ( ) != null ) { visitElement ( elm . getLowClosedExpression ( ) , context ) ; } if ( elm . getHigh ( ) != null ) { visitElement ( elm . getHigh ( ) , ... | Visit a Interval . This method will be called for every node in the tree that is a Interval . |
152,932 | public T visitList ( List elm , C context ) { if ( elm . getTypeSpecifier ( ) != null ) { visitElement ( elm . getTypeSpecifier ( ) , context ) ; } for ( Expression element : elm . getElement ( ) ) { visitElement ( element , context ) ; } return null ; } | Visit a List . This method will be called for every node in the tree that is a List . |
152,933 | public void recordParsingException ( CqlTranslatorException e ) { addException ( e ) ; if ( shouldReport ( e . getSeverity ( ) ) ) { CqlToElmError err = af . createCqlToElmError ( ) ; err . setMessage ( e . getMessage ( ) ) ; err . setErrorType ( e instanceof CqlSyntaxException ? ErrorType . SYNTAX : ( e instanceof Cql... | Record any errors while parsing in both the list of errors but also in the library itself so they can be processed easily by a remote client |
152,934 | private CalculateAge resolveCalculateAge ( Expression e , DateTimePrecision p ) { CalculateAge operator = of . createCalculateAge ( ) . withPrecision ( p ) . withOperand ( e ) ; builder . resolveUnaryCall ( "System" , "CalculateAge" , operator ) ; return operator ; } | Age - Related Function Support |
152,935 | private Round resolveRound ( FunctionRef fun ) { if ( fun . getOperand ( ) . isEmpty ( ) || fun . getOperand ( ) . size ( ) > 2 ) { throw new IllegalArgumentException ( "Could not resolve call to system operator Round. Expected 1 or 2 arguments." ) ; } final Round round = of . createRound ( ) . withOperand ( fun . get... | Arithmetic Function Support |
152,936 | private DateTime resolveDateTime ( FunctionRef fun ) { final DateTime dt = of . createDateTime ( ) ; DateTimeInvocation . setDateTimeFieldsFromOperands ( dt , fun . getOperand ( ) ) ; builder . resolveCall ( "System" , "DateTime" , new DateTimeInvocation ( dt ) ) ; return dt ; } | DateTime Function Support |
152,937 | private IndexOf resolveIndexOf ( FunctionRef fun ) { checkNumberOfOperands ( fun , 2 ) ; final IndexOf indexOf = of . createIndexOf ( ) ; indexOf . setSource ( fun . getOperand ( ) . get ( 0 ) ) ; indexOf . setElement ( fun . getOperand ( ) . get ( 1 ) ) ; builder . resolveCall ( "System" , "IndexOf" , new IndexOfInvoc... | List Function Support |
152,938 | private Combine resolveCombine ( FunctionRef fun ) { if ( fun . getOperand ( ) . isEmpty ( ) || fun . getOperand ( ) . size ( ) > 2 ) { throw new IllegalArgumentException ( "Could not resolve call to system operator Combine. Expected 1 or 2 arguments." ) ; } final Combine combine = of . createCombine ( ) . withSource ... | String Function Support |
152,939 | private UnaryExpression resolveUnary ( FunctionRef fun ) { UnaryExpression operator = null ; try { Class clazz = Class . forName ( "org.hl7.elm.r1." + fun . getName ( ) ) ; if ( UnaryExpression . class . isAssignableFrom ( clazz ) ) { operator = ( UnaryExpression ) clazz . newInstance ( ) ; checkNumberOfOperands ( fun ... | General Function Support |
152,940 | public void setStatusBarTintEnabled ( boolean enabled ) { mStatusBarTintEnabled = enabled ; if ( mStatusBarAvailable ) { mStatusBarTintView . setVisibility ( enabled ? View . VISIBLE : View . GONE ) ; } } | Enable tinting of the system status bar . |
152,941 | public void setNavigationBarTintEnabled ( boolean enabled ) { mNavBarTintEnabled = enabled ; if ( mNavBarAvailable ) { mNavBarTintView . setVisibility ( enabled ? View . VISIBLE : View . GONE ) ; } } | Enable tinting of the system navigation bar . |
152,942 | @ TargetApi ( 11 ) public void setStatusBarAlpha ( float alpha ) { if ( mStatusBarAvailable && Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ) { mStatusBarTintView . setAlpha ( alpha ) ; } } | Apply the specified alpha to the system status bar . |
152,943 | @ TargetApi ( 11 ) public void setNavigationBarAlpha ( float alpha ) { if ( mNavBarAvailable && Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ) { mNavBarTintView . setAlpha ( alpha ) ; } } | Apply the specified alpha to the system navigation bar . |
152,944 | public Completable addProduct ( Product product ) { List < Product > updatedShoppingCart = new ArrayList < > ( ) ; updatedShoppingCart . addAll ( itemsInShoppingCart . getValue ( ) ) ; updatedShoppingCart . add ( product ) ; itemsInShoppingCart . onNext ( updatedShoppingCart ) ; return Completable . complete ( ) ; } | Adds a product to the shopping cart |
152,945 | public Completable removeProduct ( Product product ) { List < Product > updatedShoppingCart = new ArrayList < > ( ) ; updatedShoppingCart . addAll ( itemsInShoppingCart . getValue ( ) ) ; updatedShoppingCart . remove ( product ) ; itemsInShoppingCart . onNext ( updatedShoppingCart ) ; return Completable . complete ( ) ... | Remove a product to the shopping cart |
152,946 | public Completable removeProducts ( List < Product > products ) { List < Product > updatedShoppingCart = new ArrayList < > ( ) ; updatedShoppingCart . addAll ( itemsInShoppingCart . getValue ( ) ) ; updatedShoppingCart . removeAll ( products ) ; itemsInShoppingCart . onNext ( updatedShoppingCart ) ; return Completable ... | Remove a list of Products from the shopping cart |
152,947 | public void subscribe ( Observable < M > observable , final boolean pullToRefresh ) { if ( isViewAttached ( ) ) { getView ( ) . showLoading ( pullToRefresh ) ; } unsubscribe ( ) ; subscriber = new Subscriber < M > ( ) { private boolean ptr = pullToRefresh ; public void onCompleted ( ) { BaseRxLcePresenter . this . onCo... | Subscribes the presenter himself as subscriber on the observable |
152,948 | protected ActivityMvpDelegate < V , P > getMvpDelegate ( ) { if ( mvpDelegate == null ) { mvpDelegate = new ActivityMvpDelegateImpl ( this , this , true ) ; } return mvpDelegate ; } | Get the mvp delegate . This is internally used for creating presenter attaching and detaching view from presenter . |
152,949 | private void subscribeViewStateConsumerActually ( final V view ) { if ( view == null ) { throw new NullPointerException ( "View is null" ) ; } if ( viewStateConsumer == null ) { throw new NullPointerException ( ViewStateConsumer . class . getSimpleName ( ) + " is null. This is a Mosby internal bug. Please file an issue... | Actually subscribes the view as consumer to the internally view relay . |
152,950 | public Observable < Account > doLogin ( AuthCredentials credentials ) { return Observable . just ( credentials ) . flatMap ( new Func1 < AuthCredentials , Observable < Account > > ( ) { public Observable < Account > call ( AuthCredentials credentials ) { try { Thread . sleep ( 3000 ) ; } catch ( InterruptedException e ... | Returns the Account observable |
152,951 | public static void showErrorView ( final View loadingView , final View contentView , final View errorView ) { contentView . setVisibility ( View . GONE ) ; final Resources resources = loadingView . getResources ( ) ; AnimatorSet set = new AnimatorSet ( ) ; ObjectAnimator in = ObjectAnimator . ofFloat ( errorView , View... | Shows the error view instead of the loading view |
152,952 | public static void showContent ( final View loadingView , final View contentView , final View errorView ) { if ( contentView . getVisibility ( ) == View . VISIBLE ) { errorView . setVisibility ( View . GONE ) ; loadingView . setVisibility ( View . GONE ) ; } else { errorView . setVisibility ( View . GONE ) ; final Reso... | Display the content instead of the loadingView |
152,953 | private boolean isSubTypeOfMvpView ( Class < ? > klass ) { if ( klass . equals ( MvpView . class ) ) { return true ; } Class [ ] superInterfaces = klass . getInterfaces ( ) ; for ( int i = 0 ; i < superInterfaces . length ; i ++ ) { if ( isSubTypeOfMvpView ( superInterfaces [ i ] ) ) { return true ; } } return false ; ... | Scans the interface inheritance hierarchy and checks if on the root is MvpView . class |
152,954 | public static int dpToPx ( Context context , float dp ) { DisplayMetrics displayMetrics = context . getResources ( ) . getDisplayMetrics ( ) ; return ( int ) ( ( dp * displayMetrics . density ) + 0.5 ) ; } | Converts a dp value to a px value |
152,955 | public static int pxToDp ( Context context , int px ) { DisplayMetrics displayMetrics = context . getResources ( ) . getDisplayMetrics ( ) ; return ( int ) ( ( px / displayMetrics . density ) + 0.5 ) ; } | Converts pixel in dp |
152,956 | public static float pxToSp ( Context context , Float px ) { float scaledDensity = context . getResources ( ) . getDisplayMetrics ( ) . scaledDensity ; return px / scaledDensity ; } | Convertes pixels to sp |
152,957 | private P restorePresenterOrRecreateNewPresenterAfterProcessDeath ( ) { P presenter ; if ( keepPresenterInstanceDuringScreenOrientationChanges ) { if ( mosbyViewId != null && ( presenter = PresenterManager . getPresenter ( getActivity ( ) , mosbyViewId ) ) != null ) { if ( DEBUG ) { Log . d ( DEBUG_TAG , "Reused presen... | Creates the presenter instance if not able to reuse presenter from PresenterManager |
152,958 | private VS createViewState ( ) { VS viewState = delegateCallback . createViewState ( ) ; if ( viewState == null ) { throw new NullPointerException ( "ViewState returned from createViewState() is null. Fragment is " + fragment ) ; } if ( keepPresenterInstanceDuringScreenOrientationChanges ) { PresenterManager . putViewS... | Creates a new ViewState instance |
152,959 | public Observable < ProductDetailsViewState > getDetails ( int productId ) { return getProductWithShoppingCartInfo ( productId ) . subscribeOn ( Schedulers . io ( ) ) . map ( ProductDetailsViewState . DataState :: new ) . cast ( ProductDetailsViewState . class ) . startWith ( new ProductDetailsViewState . LoadingState ... | Get the details of a given product |
152,960 | public Observable < List < Product > > getAllProducts ( ) { return Observable . zip ( getProducts ( 0 ) , getProducts ( 1 ) , getProducts ( 2 ) , getProducts ( 3 ) , ( products0 , products1 , products2 , products3 ) -> { List < Product > productList = new ArrayList < Product > ( ) ; productList . addAll ( products0 ) ;... | Get a list with all products from backend |
152,961 | public Observable < List < Product > > getAllProductsOfCategory ( String categoryName ) { return getAllProducts ( ) . flatMap ( Observable :: fromIterable ) . filter ( product -> product . getCategory ( ) . equals ( categoryName ) ) . toList ( ) . toObservable ( ) ; } | Get all products of a certain category |
152,962 | public Observable < List < String > > getAllCategories ( ) { return getAllProducts ( ) . map ( products -> { Set < String > categories = new HashSet < String > ( ) ; for ( Product p : products ) { categories . add ( p . getCategory ( ) ) ; } List < String > result = new ArrayList < String > ( categories . size ( ) ) ; ... | Get a list with all categories |
152,963 | public Observable < Product > getProduct ( int productId ) { return getAllProducts ( ) . flatMap ( products -> Observable . fromIterable ( products ) ) . filter ( product -> product . getId ( ) == productId ) . take ( 1 ) ; } | Get the product with the given id |
152,964 | public Observable < List < Product > > loadProductsOfCategory ( String categoryName ) { return backendApi . getAllProductsOfCategory ( categoryName ) . delay ( 3 , TimeUnit . SECONDS ) ; } | Loads all items of a given category |
152,965 | private void runQueuedActions ( ) { V view = viewRef == null ? null : viewRef . get ( ) ; if ( view != null ) { while ( ! viewActionQueue . isEmpty ( ) ) { ViewAction < V > action = viewActionQueue . poll ( ) ; action . run ( view ) ; } } } | Runs the queued actions . |
152,966 | public static boolean hideKeyboard ( View view ) { if ( view == null ) { throw new NullPointerException ( "View is null!" ) ; } try { InputMethodManager imm = ( InputMethodManager ) view . getContext ( ) . getSystemService ( Context . INPUT_METHOD_SERVICE ) ; if ( imm == null ) { return false ; } imm . hideSoftInputFro... | Hides the soft keyboard from screen |
152,967 | public Observable < SearchViewState > search ( String searchString ) { if ( searchString . isEmpty ( ) ) { return Observable . just ( new SearchViewState . SearchNotStartedYet ( ) ) ; } return searchEngine . searchFor ( searchString ) . map ( products -> { if ( products . isEmpty ( ) ) { return new SearchViewState . Em... | Search for items |
152,968 | public Observable < List < Label > > getLabels ( ) { return Observable . just ( mails ) . flatMap ( new Func1 < List < Mail > , Observable < List < Label > > > ( ) { public Observable < List < Label > > call ( List < Mail > mails ) { delay ( ) ; Observable error = checkExceptions ( ) ; if ( error != null ) { return err... | Get the labels with the number of unread mails . |
152,969 | public Observable < List < Mail > > getMailsOfLabel ( final String l ) { return getFilteredMailList ( new Func1 < Mail , Boolean > ( ) { public Boolean call ( Mail mail ) { return mail . getLabel ( ) . equals ( l ) ; } } ) ; } | Get a list of mails with the given label |
152,970 | public Observable < Mail > starMail ( int mailId , final boolean star ) { return getMail ( mailId ) . map ( new Func1 < Mail , Mail > ( ) { public Mail call ( Mail mail ) { mail . setStarred ( star ) ; return mail ; } } ) ; } | Star or unstar a mail |
152,971 | public Observable < Mail > addMailWithDelay ( final Mail mail ) { return Observable . defer ( new Func0 < Observable < Mail > > ( ) { public Observable < Mail > call ( ) { delay ( ) ; Observable o = checkExceptions ( ) ; if ( o != null ) { return o ; } return Observable . just ( mail ) ; } } ) . flatMap ( new Func1 < M... | Creates and saves a new mail |
152,972 | private Observable < List < Mail > > getFilteredMailList ( Func1 < Mail , Boolean > filterFnc , final boolean withDelayAndError ) { return Observable . defer ( new Func0 < Observable < Mail > > ( ) { public Observable < Mail > call ( ) { if ( withDelayAndError ) { delay ( ) ; Observable o = checkExceptions ( ) ; if ( o... | Filters the list of mails by the given criteria |
152,973 | public Mail findMail ( int id ) { if ( items == null ) { return null ; } for ( Mail m : items ) { if ( m . getId ( ) == id ) { return m ; } } return null ; } | Finds a mail by his id if displayed in this adapter |
152,974 | private boolean isProductMatchingSearchCriteria ( Product product , String searchQueryText ) { String words [ ] = searchQueryText . split ( " " ) ; for ( String w : words ) { if ( product . getName ( ) . contains ( w ) ) return true ; if ( product . getDescription ( ) . contains ( w ) ) return true ; if ( product . get... | Filters those items that contains the search query text in name description or category |
152,975 | public void addAndStartListener ( final ProcessorListener < ApiType > processorListener ) { lock . writeLock ( ) . lock ( ) ; try { addListenerLocked ( processorListener ) ; executorService . execute ( processorListener ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } | addAndStartListener first adds the specific processorListener then starts the listener with executor . |
152,976 | public void addListener ( final ProcessorListener < ApiType > processorListener ) { lock . writeLock ( ) . lock ( ) ; try { addListenerLocked ( processorListener ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } | addListener adds the specific processorListener but not start it . |
152,977 | public void run ( ) { lock . readLock ( ) . lock ( ) ; try { if ( Collections . isEmptyCollection ( listeners ) ) { return ; } for ( ProcessorListener listener : listeners ) { executorService . execute ( listener ) ; } } finally { lock . readLock ( ) . unlock ( ) ; } } | starts the processor listeners . |
152,978 | public void distribute ( ProcessorListener . Notification < ApiType > obj , boolean isSync ) { lock . readLock ( ) . lock ( ) ; try { if ( isSync ) { for ( ProcessorListener < ApiType > listener : syncingListeners ) { listener . add ( obj ) ; } } else { for ( ProcessorListener < ApiType > listener : listeners ) { liste... | distribute the object among listeners . |
152,979 | public void setUsername ( String username ) { for ( Authentication auth : authentications . values ( ) ) { if ( auth instanceof HttpBasicAuth ) { ( ( HttpBasicAuth ) auth ) . setUsername ( username ) ; return ; } } throw new RuntimeException ( "No HTTP basic authentication configured!" ) ; } | Helper method to set username for the first HTTP basic authentication . |
152,980 | public void setPassword ( String password ) { for ( Authentication auth : authentications . values ( ) ) { if ( auth instanceof HttpBasicAuth ) { ( ( HttpBasicAuth ) auth ) . setPassword ( password ) ; return ; } } throw new RuntimeException ( "No HTTP basic authentication configured!" ) ; } | Helper method to set password for the first HTTP basic authentication . |
152,981 | public void setApiKey ( String apiKey ) { for ( Authentication auth : authentications . values ( ) ) { if ( auth instanceof ApiKeyAuth ) { ( ( ApiKeyAuth ) auth ) . setApiKey ( apiKey ) ; return ; } } throw new RuntimeException ( "No API key authentication configured!" ) ; } | Helper method to set API key value for the first API key authentication . |
152,982 | public void setApiKeyPrefix ( String apiKeyPrefix ) { for ( Authentication auth : authentications . values ( ) ) { if ( auth instanceof ApiKeyAuth ) { ( ( ApiKeyAuth ) auth ) . setApiKeyPrefix ( apiKeyPrefix ) ; return ; } } throw new RuntimeException ( "No API key authentication configured!" ) ; } | Helper method to set API key prefix for the first API key authentication . |
152,983 | public void setAccessToken ( String accessToken ) { for ( Authentication auth : authentications . values ( ) ) { if ( auth instanceof OAuth ) { ( ( OAuth ) auth ) . setAccessToken ( accessToken ) ; return ; } } throw new RuntimeException ( "No OAuth2 authentication configured!" ) ; } | Helper method to set access token for the first OAuth2 authentication . |
152,984 | @ SuppressWarnings ( "unchecked" ) public < T > T deserialize ( Response response , Type returnType ) throws ApiException { if ( response == null || returnType == null ) { return null ; } if ( "byte[]" . equals ( returnType . toString ( ) ) ) { try { return ( T ) response . body ( ) . bytes ( ) ; } catch ( IOException ... | Deserialize response body to Java object according to the return type and the Content - Type response header . |
152,985 | public RequestBody serialize ( Object obj , String contentType ) throws ApiException { if ( obj instanceof byte [ ] ) { return RequestBody . create ( MediaType . parse ( contentType ) , ( byte [ ] ) obj ) ; } else if ( obj instanceof File ) { return RequestBody . create ( MediaType . parse ( contentType ) , ( File ) ob... | Serialize the given Java object into request body according to the object s class and the request Content - Type . |
152,986 | public File downloadFileFromResponse ( Response response ) throws ApiException { try { File file = prepareDownloadFile ( response ) ; BufferedSink sink = Okio . buffer ( Okio . sink ( file ) ) ; sink . writeAll ( response . body ( ) . source ( ) ) ; sink . close ( ) ; return file ; } catch ( IOException e ) { throw new... | Download file from the given response . |
152,987 | public < T > ApiResponse < T > execute ( Call call , Type returnType ) throws ApiException { try { Response response = call . execute ( ) ; T data = handleResponse ( response , returnType ) ; return new ApiResponse < T > ( response . code ( ) , response . headers ( ) . toMultimap ( ) , data ) ; } catch ( IOException e ... | Execute HTTP call and deserialize the HTTP response body into the given return type . |
152,988 | @ SuppressWarnings ( "unchecked" ) public < T > void executeAsync ( Call call , final Type returnType , final ApiCallback < T > callback ) { call . enqueue ( new Callback ( ) { public void onFailure ( Request request , IOException e ) { callback . onFailure ( new ApiException ( e ) , 0 , null ) ; } public void onRespon... | Execute HTTP call asynchronously . |
152,989 | public Call buildCall ( String path , String method , List < Pair > queryParams , List < Pair > collectionQueryParams , Object body , Map < String , String > headerParams , Map < String , Object > formParams , String [ ] authNames , ProgressRequestBody . ProgressRequestListener progressRequestListener ) throws ApiExcep... | Build HTTP call with the given options . |
152,990 | public Request buildRequest ( String path , String method , List < Pair > queryParams , List < Pair > collectionQueryParams , Object body , Map < String , String > headerParams , Map < String , Object > formParams , String [ ] authNames , ProgressRequestBody . ProgressRequestListener progressRequestListener ) throws Ap... | Build an HTTP request with the given options . |
152,991 | public void processHeaderParams ( Map < String , String > headerParams , Request . Builder reqBuilder ) { for ( Entry < String , String > param : headerParams . entrySet ( ) ) { reqBuilder . header ( param . getKey ( ) , parameterToString ( param . getValue ( ) ) ) ; } for ( Entry < String , String > header : defaultHe... | Set header parameters to the request builder including default headers . |
152,992 | public void updateParamsForAuth ( String [ ] authNames , List < Pair > queryParams , Map < String , String > headerParams ) { for ( String authName : authNames ) { Authentication auth = authentications . get ( authName ) ; if ( auth == null ) throw new RuntimeException ( "Authentication undefined: " + authName ) ; auth... | Update query and header parameters based on authentication settings . |
152,993 | public RequestBody buildRequestBodyFormEncoding ( Map < String , Object > formParams ) { FormEncodingBuilder formBuilder = new FormEncodingBuilder ( ) ; for ( Entry < String , Object > param : formParams . entrySet ( ) ) { formBuilder . add ( param . getKey ( ) , parameterToString ( param . getValue ( ) ) ) ; } return ... | Build a form - encoding request body with the given form parameters . |
152,994 | private void applySslSettings ( ) { try { TrustManager [ ] trustManagers = null ; HostnameVerifier hostnameVerifier = null ; if ( ! verifyingSsl ) { TrustManager trustAll = new X509TrustManager ( ) { public void checkClientTrusted ( X509Certificate [ ] chain , String authType ) throws CertificateException { } public vo... | Apply SSL related settings to httpClient according to the current values of verifyingSsl and sslCaCert . |
152,995 | public void stop ( ) { reflector . stop ( ) ; reflectorFuture . cancel ( true ) ; reflectExecutor . shutdown ( ) ; if ( resyncFuture != null ) { resyncFuture . cancel ( true ) ; resyncExecutor . shutdown ( ) ; } } | stops the resync thread pool firstly then stop the reflector |
152,996 | private void processLoop ( ) { while ( true ) { try { this . queue . pop ( this . processFunc ) ; } catch ( InterruptedException t ) { log . error ( "DefaultController#processLoop get interrupted {}" , t . getMessage ( ) , t ) ; } } } | processLoop drains the work queue . |
152,997 | public void add ( Object obj ) { lock . writeLock ( ) . lock ( ) ; try { populated = true ; this . queueActionLocked ( DeltaType . Added , obj ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } | Add items to the delta FIFO . |
152,998 | public void update ( Object obj ) { lock . writeLock ( ) . lock ( ) ; try { populated = true ; this . queueActionLocked ( DeltaType . Updated , obj ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } } | Update items in the delta FIFO . |
152,999 | public void delete ( Object obj ) { String id = this . keyOf ( obj ) ; lock . writeLock ( ) . lock ( ) ; try { this . populated = true ; if ( this . knownObjects == null ) { if ( ! this . items . containsKey ( id ) ) { return ; } } else { if ( this . knownObjects . getByKey ( id ) == null && ! this . items . containsKe... | Delete items from the delta FIFO . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.