idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
29,200 | public static boolean isPureAscii ( byte [ ] data ) { if ( data == null ) { return false ; } for ( byte b : data ) { if ( b < 0x20 ) { return false ; } } return true ; } | Test if the data in the array is pure ASCII |
29,201 | public static byte [ ] trimRightSpaces ( byte [ ] b_array ) { if ( b_array == null || b_array . length == 0 ) { return new byte [ 0 ] ; } int pos = getRightPos ( b_array ) ; int length = pos + 1 ; byte [ ] newBytes = new byte [ length ] ; System . arraycopy ( b_array , 0 , newBytes , 0 , length ) ; return newBytes ; } | Trims right spaces from string |
29,202 | public void setFields ( DBFField [ ] fields ) { if ( this . closed ) { throw new IllegalStateException ( "You can not set fields to a closed DBFWriter" ) ; } if ( this . header . fieldArray != null ) { throw new DBFException ( "Fields has already been set" ) ; } if ( fields == null || fields . length == 0 ) { throw new... | Sets fields definition |
29,203 | public void addRecord ( Object [ ] values ) { if ( this . closed ) { throw new IllegalStateException ( "You can add records a closed DBFWriter" ) ; } if ( this . header . fieldArray == null ) { throw new DBFException ( "Fields should be set before adding records" ) ; } if ( values == null ) { throw new DBFException ( "... | Add a record . |
29,204 | public void close ( ) { if ( this . closed ) { return ; } this . closed = true ; if ( this . raf != null ) { try { this . header . numberOfRecords = this . recordCount ; this . raf . seek ( 0 ) ; this . header . write ( this . raf ) ; this . raf . seek ( this . raf . length ( ) ) ; this . raf . writeByte ( END_OF_DATA ... | In sync mode write the header and close the file |
29,205 | public String getString ( int columnIndex ) { if ( columnIndex < 0 || columnIndex >= data . length ) { throw new IllegalArgumentException ( "Invalid index field: (" + columnIndex + "). Valid range is 0 to " + ( data . length - 1 ) ) ; } Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return null ... | Reads the data as string |
29,206 | public BigDecimal getBigDecimal ( int columnIndex ) { Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return null ; } if ( fieldValue instanceof BigDecimal ) { return ( BigDecimal ) fieldValue ; } throw new DBFException ( "Unsupported type for BigDecimal at column:" + columnIndex + " " + fieldVal... | Reads the data as BigDecimal |
29,207 | public boolean getBoolean ( int columnIndex ) { Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return Boolean . FALSE ; } if ( fieldValue instanceof Boolean ) { return ( Boolean ) fieldValue ; } throw new DBFException ( "Unsupported type for Boolean at column:" + columnIndex + " " + fieldValue .... | Reads the data as Boolean |
29,208 | public Date getDate ( int columnIndex ) { Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return null ; } if ( fieldValue instanceof Date ) { return ( Date ) fieldValue ; } throw new DBFException ( "Unsupported type for Date at column:" + columnIndex + " " + fieldValue . getClass ( ) . getCanonic... | Reads the data as Date |
29,209 | public double getDouble ( int columnIndex ) { Object fieldValue = data [ columnIndex ] ; if ( fieldValue == null ) { return 0.0 ; } if ( fieldValue instanceof Number ) { return ( ( Number ) fieldValue ) . doubleValue ( ) ; } throw new DBFException ( "Unsupported type for Number at column:" + columnIndex + " " + fieldVa... | Reads the data as Double |
29,210 | 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 |
29,211 | 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 |
29,212 | 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 |
29,213 | 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 |
29,214 | 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 |
29,215 | 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 . |
29,216 | 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 . |
29,217 | 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 . |
29,218 | 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 . |
29,219 | 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 . |
29,220 | 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 . |
29,221 | 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 . |
29,222 | 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 . |
29,223 | 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 . |
29,224 | 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 . |
29,225 | 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 . |
29,226 | 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 . |
29,227 | 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 . |
29,228 | 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 . |
29,229 | 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 . |
29,230 | 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 . |
29,231 | 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 . |
29,232 | 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 . |
29,233 | 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 . |
29,234 | 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 . |
29,235 | 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 . |
29,236 | 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 . |
29,237 | 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 . |
29,238 | 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 . |
29,239 | 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 . |
29,240 | 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 . |
29,241 | 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 . |
29,242 | 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 . |
29,243 | 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 |
29,244 | 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 |
29,245 | 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 |
29,246 | 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 |
29,247 | 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 |
29,248 | 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 |
29,249 | 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 |
29,250 | public void setStatusBarTintEnabled ( boolean enabled ) { mStatusBarTintEnabled = enabled ; if ( mStatusBarAvailable ) { mStatusBarTintView . setVisibility ( enabled ? View . VISIBLE : View . GONE ) ; } } | Enable tinting of the system status bar . |
29,251 | public void setNavigationBarTintEnabled ( boolean enabled ) { mNavBarTintEnabled = enabled ; if ( mNavBarAvailable ) { mNavBarTintView . setVisibility ( enabled ? View . VISIBLE : View . GONE ) ; } } | Enable tinting of the system navigation bar . |
29,252 | @ 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 . |
29,253 | @ 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 . |
29,254 | 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 |
29,255 | 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 |
29,256 | 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 |
29,257 | 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 |
29,258 | 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 . |
29,259 | 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 . |
29,260 | 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 |
29,261 | 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 |
29,262 | 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 |
29,263 | 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 |
29,264 | 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 |
29,265 | public static int pxToDp ( Context context , int px ) { DisplayMetrics displayMetrics = context . getResources ( ) . getDisplayMetrics ( ) ; return ( int ) ( ( px / displayMetrics . density ) + 0.5 ) ; } | Converts pixel in dp |
29,266 | public static float pxToSp ( Context context , Float px ) { float scaledDensity = context . getResources ( ) . getDisplayMetrics ( ) . scaledDensity ; return px / scaledDensity ; } | Convertes pixels to sp |
29,267 | 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 |
29,268 | 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 |
29,269 | 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 |
29,270 | 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 |
29,271 | 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 |
29,272 | 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 |
29,273 | 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 |
29,274 | public Observable < List < Product > > loadProductsOfCategory ( String categoryName ) { return backendApi . getAllProductsOfCategory ( categoryName ) . delay ( 3 , TimeUnit . SECONDS ) ; } | Loads all items of a given category |
29,275 | 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 . |
29,276 | 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 |
29,277 | 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 |
29,278 | 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 . |
29,279 | 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 |
29,280 | 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 |
29,281 | 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 |
29,282 | 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 |
29,283 | 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 |
29,284 | 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 |
29,285 | 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 . |
29,286 | 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 . |
29,287 | 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 . |
29,288 | 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 . |
29,289 | 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 . |
29,290 | 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 . |
29,291 | 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 . |
29,292 | 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 . |
29,293 | 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 . |
29,294 | @ 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 . |
29,295 | 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 . |
29,296 | 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 . |
29,297 | 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 . |
29,298 | @ 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 . |
29,299 | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.