idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
23,800 | public M put ( Map < String , Object > map ) { attrs . putAll ( map ) ; return ( M ) this ; } | Put map to the model without check attribute name . |
23,801 | public < T > T get ( String attr , Object defaultValue ) { Object result = attrs . get ( attr ) ; return ( T ) ( result != null ? result : defaultValue ) ; } | Get attribute of any mysql type . Returns defaultValue if null . |
23,802 | public boolean save ( ) { filter ( FILTER_BY_SAVE ) ; Config config = _getConfig ( ) ; Table table = _getTable ( ) ; StringBuilder sql = new StringBuilder ( ) ; List < Object > paras = new ArrayList < Object > ( ) ; config . dialect . forModelSave ( table , attrs , sql , paras ) ; Connection conn = null ; PreparedState... | Save model . |
23,803 | public boolean deleteByIds ( Object ... idValues ) { Table table = _getTable ( ) ; if ( idValues == null || idValues . length != table . getPrimaryKey ( ) . length ) throw new IllegalArgumentException ( "Primary key nubmer must equals id value number and can not be null" ) ; return deleteById ( table , idValues ) ; } | Delete model by composite id values . |
23,804 | public boolean update ( ) { filter ( FILTER_BY_UPDATE ) ; if ( _getModifyFlag ( ) . isEmpty ( ) ) { return false ; } Table table = _getTable ( ) ; String [ ] pKeys = table . getPrimaryKey ( ) ; for ( String pKey : pKeys ) { Object id = attrs . get ( pKey ) ; if ( id == null ) throw new ActiveRecordException ( "You can'... | Update model . |
23,805 | public M remove ( String attr ) { attrs . remove ( attr ) ; _getModifyFlag ( ) . remove ( attr ) ; return ( M ) this ; } | Remove attribute of this model . |
23,806 | public M remove ( String ... attrs ) { if ( attrs != null ) for ( String a : attrs ) { this . attrs . remove ( a ) ; this . _getModifyFlag ( ) . remove ( a ) ; } return ( M ) this ; } | Remove attributes of this model . |
23,807 | public M removeNullValueAttrs ( ) { for ( Iterator < Entry < String , Object > > it = attrs . entrySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Entry < String , Object > e = it . next ( ) ; if ( e . getValue ( ) == null ) { it . remove ( ) ; _getModifyFlag ( ) . remove ( e . getKey ( ) ) ; } } return ( M ) this ; } | Remove attributes if it is null . |
23,808 | public M keep ( String ... attrs ) { if ( attrs != null && attrs . length > 0 ) { Config config = _getConfig ( ) ; if ( config == null ) { config = DbKit . brokenConfig ; } Map < String , Object > newAttrs = config . containerFactory . getAttrsMap ( ) ; Set < String > newModifyFlag = config . containerFactory . getModi... | Keep attributes of this model and remove other attributes . |
23,809 | public M keep ( String attr ) { if ( attrs . containsKey ( attr ) ) { Object keepIt = attrs . get ( attr ) ; boolean keepFlag = _getModifyFlag ( ) . contains ( attr ) ; attrs . clear ( ) ; _getModifyFlag ( ) . clear ( ) ; attrs . put ( attr , keepIt ) ; if ( keepFlag ) _getModifyFlag ( ) . add ( attr ) ; } else { attrs... | Keep attribute of this model and remove other attributes . |
23,810 | public List < M > findByCache ( String cacheName , Object key , String sql , Object ... paras ) { Config config = _getConfig ( ) ; ICache cache = config . getCache ( ) ; List < M > result = cache . get ( cacheName , key ) ; if ( result == null ) { result = find ( config , sql , paras ) ; cache . put ( cacheName , key ,... | Find model by cache . |
23,811 | public M findFirstByCache ( String cacheName , Object key , String sql , Object ... paras ) { ICache cache = _getConfig ( ) . getCache ( ) ; M result = cache . get ( cacheName , key ) ; if ( result == null ) { result = findFirst ( sql , paras ) ; cache . put ( cacheName , key , result ) ; } return result ; } | Find first model by cache . I recommend add limit 1 in your sql . |
23,812 | public static Res use ( String baseName , String locale ) { String resKey = baseName + locale ; Res res = resMap . get ( resKey ) ; if ( res == null ) { res = new Res ( baseName , locale ) ; resMap . put ( resKey , res ) ; } return res ; } | Using the base name and locale to get the Res object which is used to get i18n message value from the resource file . |
23,813 | public static String generateSalt ( int saltLength ) { StringBuilder salt = new StringBuilder ( saltLength ) ; for ( int i = 0 ; i < saltLength ; i ++ ) { salt . append ( CHAR_ARRAY [ random . nextInt ( CHAR_ARRAY . length ) ] ) ; } return salt . toString ( ) ; } | md5 128bit 16bytes sha1 160bit 20bytes sha256 256bit 32bytes sha384 384bit 48bytes sha512 512bit 64bytes |
23,814 | public void startAutoCycle ( long delay , long duration , boolean autoRecover ) { if ( mCycleTimer != null ) mCycleTimer . cancel ( ) ; if ( mCycleTask != null ) mCycleTask . cancel ( ) ; if ( mResumingTask != null ) mResumingTask . cancel ( ) ; if ( mResumingTimer != null ) mResumingTimer . cancel ( ) ; mSliderDuratio... | start auto cycle . |
23,815 | private void pauseAutoCycle ( ) { if ( mCycling ) { mCycleTimer . cancel ( ) ; mCycleTask . cancel ( ) ; mCycling = false ; } else { if ( mResumingTimer != null && mResumingTask != null ) { recoverCycle ( ) ; } } } | pause auto cycle . |
23,816 | public void stopAutoCycle ( ) { if ( mCycleTask != null ) { mCycleTask . cancel ( ) ; } if ( mCycleTimer != null ) { mCycleTimer . cancel ( ) ; } if ( mResumingTimer != null ) { mResumingTimer . cancel ( ) ; } if ( mResumingTask != null ) { mResumingTask . cancel ( ) ; } mAutoCycle = false ; mCycling = false ; } | stop the auto circle |
23,817 | private void recoverCycle ( ) { if ( ! mAutoRecover || ! mAutoCycle ) { return ; } if ( ! mCycling ) { if ( mResumingTask != null && mResumingTimer != null ) { mResumingTimer . cancel ( ) ; mResumingTask . cancel ( ) ; } mResumingTimer = new Timer ( ) ; mResumingTask = new TimerTask ( ) { public void run ( ) { startAut... | when paused cycle this method can weak it up . |
23,818 | public void setPagerTransformer ( boolean reverseDrawingOrder , BaseTransformer transformer ) { mViewPagerTransformer = transformer ; mViewPagerTransformer . setCustomAnimationInterface ( mCustomAnimation ) ; mViewPager . setPageTransformer ( reverseDrawingOrder , mViewPagerTransformer ) ; } | set ViewPager transformer . |
23,819 | public void setSliderTransformDuration ( int period , Interpolator interpolator ) { try { Field mScroller = ViewPagerEx . class . getDeclaredField ( "mScroller" ) ; mScroller . setAccessible ( true ) ; FixedSpeedScroller scroller = new FixedSpeedScroller ( mViewPager . getContext ( ) , interpolator , period ) ; mScroll... | set the duration between two slider changes . |
23,820 | public void setPresetTransformer ( int transformerId ) { for ( Transformer t : Transformer . values ( ) ) { if ( t . ordinal ( ) == transformerId ) { setPresetTransformer ( t ) ; break ; } } } | set a preset viewpager transformer by id . |
23,821 | public void setPresetTransformer ( String transformerName ) { for ( Transformer t : Transformer . values ( ) ) { if ( t . equals ( transformerName ) ) { setPresetTransformer ( t ) ; return ; } } } | set preset PagerTransformer via the name of transforemer . |
23,822 | public BaseSliderView getCurrentSlider ( ) { if ( getRealAdapter ( ) == null ) throw new IllegalStateException ( "You did not set a slider adapter" ) ; int count = getRealAdapter ( ) . getCount ( ) ; int realCount = mViewPager . getCurrentItem ( ) % count ; return getRealAdapter ( ) . getSliderView ( realCount ) ; } | get current slider . |
23,823 | public void setCurrentPosition ( int position , boolean smooth ) { if ( getRealAdapter ( ) == null ) throw new IllegalStateException ( "You did not set a slider adapter" ) ; if ( position >= getRealAdapter ( ) . getCount ( ) ) { throw new IllegalStateException ( "Item position is not exist" ) ; } int p = mViewPager . g... | set current slider |
23,824 | public void movePrevPosition ( boolean smooth ) { if ( getRealAdapter ( ) == null ) throw new IllegalStateException ( "You did not set a slider adapter" ) ; mViewPager . setCurrentItem ( mViewPager . getCurrentItem ( ) - 1 , smooth ) ; } | move to prev slide . |
23,825 | public void moveNextPosition ( boolean smooth ) { if ( getRealAdapter ( ) == null ) throw new IllegalStateException ( "You did not set a slider adapter" ) ; mViewPager . setCurrentItem ( mViewPager . getCurrentItem ( ) + 1 , smooth ) ; } | move to next slide . |
23,826 | public void setOffscreenPageLimit ( int limit ) { if ( limit < DEFAULT_OFFSCREEN_PAGES ) { Log . w ( TAG , "Requested offscreen page limit " + limit + " too small; defaulting to " + DEFAULT_OFFSCREEN_PAGES ) ; limit = DEFAULT_OFFSCREEN_PAGES ; } if ( limit != mOffscreenPageLimit ) { mOffscreenPageLimit = limit ; popula... | Set the number of pages that should be retained to either side of the current page in the view hierarchy in an idle state . Pages beyond this limit will be recreated from the adapter when needed . |
23,827 | public void setPageMarginDrawable ( Drawable d ) { mMarginDrawable = d ; if ( d != null ) refreshDrawableState ( ) ; setWillNotDraw ( d == null ) ; invalidate ( ) ; } | Set a drawable that will be used to fill the margin between pages . |
23,828 | public void addTouchables ( ArrayList < View > views ) { for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { final View child = getChildAt ( i ) ; if ( child . getVisibility ( ) == VISIBLE ) { ItemInfo ii = infoForChild ( child ) ; if ( ii != null && ii . position == mCurItem ) { child . addTouchables ( views ) ; } } } ... | We only want the current page that is being shown to be touchable . |
23,829 | public void onEnd ( boolean result , BaseSliderView target ) { if ( target . isErrorDisappear ( ) == false || result == true ) { return ; } for ( BaseSliderView slider : mImageContents ) { if ( slider . equals ( target ) ) { removeSlider ( target ) ; break ; } } } | When image download error then remove . |
23,830 | public void onPrepareNextItemShowInScreen ( View next ) { View descriptionLayout = next . findViewById ( R . id . description_layout ) ; if ( descriptionLayout != null ) { next . findViewById ( R . id . description_layout ) . setVisibility ( View . INVISIBLE ) ; } } | When next item is coming to show let s hide the description layout . |
23,831 | public void onNextItemAppear ( View view ) { View descriptionLayout = view . findViewById ( R . id . description_layout ) ; if ( descriptionLayout != null ) { float layoutY = ViewHelper . getY ( descriptionLayout ) ; view . findViewById ( R . id . description_layout ) . setVisibility ( View . VISIBLE ) ; ValueAnimator ... | When next item show in ViewPagerEx let s make an animation to show the description layout . |
23,832 | public void setDefaultIndicatorShape ( Shape shape ) { if ( mUserSetSelectedIndicatorResId == 0 ) { if ( shape == Shape . Oval ) { mSelectedGradientDrawable . setShape ( GradientDrawable . OVAL ) ; } else { mSelectedGradientDrawable . setShape ( GradientDrawable . RECTANGLE ) ; } } if ( mUserSetUnSelectedIndicatorResId... | if you are using the default indicator this method will help you to set the shape of indicator there are two kind of shapes you can set oval and rect . |
23,833 | public void setIndicatorStyleResource ( int selected , int unselected ) { mUserSetSelectedIndicatorResId = selected ; mUserSetUnSelectedIndicatorResId = unselected ; if ( selected == 0 ) { mSelectedDrawable = mSelectedLayerDrawable ; } else { mSelectedDrawable = mContext . getResources ( ) . getDrawable ( mUserSetSelec... | Set Indicator style . |
23,834 | public void setDefaultIndicatorColor ( int selectedColor , int unselectedColor ) { if ( mUserSetSelectedIndicatorResId == 0 ) { mSelectedGradientDrawable . setColor ( selectedColor ) ; } if ( mUserSetUnSelectedIndicatorResId == 0 ) { mUnSelectedGradientDrawable . setColor ( unselectedColor ) ; } resetDrawable ( ) ; } | if you are using the default indicator this method will help you to set the selected status and the unselected status color . |
23,835 | public void setIndicatorVisibility ( IndicatorVisibility visibility ) { if ( visibility == IndicatorVisibility . Visible ) { setVisibility ( View . VISIBLE ) ; } else { setVisibility ( View . INVISIBLE ) ; } resetDrawable ( ) ; } | set the visibility of indicator . |
23,836 | public void setViewPager ( ViewPagerEx pager ) { if ( pager . getAdapter ( ) == null ) { throw new IllegalStateException ( "Viewpager does not have adapter instance" ) ; } mPager = pager ; mPager . addOnPageChangeListener ( this ) ; ( ( InfinitePagerAdapter ) mPager . getAdapter ( ) ) . getRealAdapter ( ) . registerDat... | bind indicator with viewpagerEx . |
23,837 | public void redraw ( ) { mItemCount = getShouldDrawCount ( ) ; mPreviousSelectedIndicator = null ; for ( View i : mIndicators ) { removeView ( i ) ; } for ( int i = 0 ; i < mItemCount ; i ++ ) { ImageView indicator = new ImageView ( mContext ) ; indicator . setImageDrawable ( mUnselectedDrawable ) ; indicator . setPadd... | redraw the indicators . |
23,838 | private int getShouldDrawCount ( ) { if ( mPager . getAdapter ( ) instanceof InfinitePagerAdapter ) { return ( ( InfinitePagerAdapter ) mPager . getAdapter ( ) ) . getRealCount ( ) ; } else { return mPager . getAdapter ( ) . getCount ( ) ; } } | since we used a adapter wrapper so we can t getCount directly from wrapper . |
23,839 | public BaseSliderView image ( String url ) { if ( mFile != null || mRes != 0 ) { throw new IllegalStateException ( "Call multi image function," + "you only have permission to call it once" ) ; } mUrl = url ; return this ; } | set a url as a image that preparing to load |
23,840 | public BaseSliderView image ( File file ) { if ( mUrl != null || mRes != 0 ) { throw new IllegalStateException ( "Call multi image function," + "you only have permission to call it once" ) ; } mFile = file ; return this ; } | set a file as a image that will to load |
23,841 | public Object remove ( Object key ) { Object underlying = this . underlyingObjectGetter . getUnderlyingObject ( key ) ; return removeUsingUnderlying ( underlying ) ; } | Removes and returns the entry associated with the specified key in the HashMap . Returns null if the HashMap contains no mapping for this key . |
23,842 | public static final int hash ( double d , boolean isNull ) { if ( isNull ) return NULL_HASH ; long longVal = Double . doubleToLongBits ( d ) ; return ( int ) ( longVal ^ ( longVal >>> 32 ) ) ; } | need to mix the value but have to keep it compatible with Double . hashcode !! |
23,843 | public void shutdown ( ) { while ( true ) { long cur = combinedState . get ( ) ; long newValue = cur | 0x8000000000000000L ; if ( combinedState . compareAndSet ( cur , newValue ) ) { break ; } } } | Initiates an orderly shutdown in which previously submitted tasks are executed but no new tasks will be accepted . Invocation has no additional effect if already shut down . |
23,844 | public void shutdownAndWaitUntilDone ( ) { shutdown ( ) ; while ( true ) { synchronized ( endSignal ) { try { if ( ( combinedState . get ( ) & 0x7FFFFFFFFFFFFFFFL ) == 0 ) break ; endSignal . wait ( 100 ) ; } catch ( InterruptedException e ) { } } } } | Shuts down the executor and blocks until all tasks have completed execution |
23,845 | public synchronized void checkAndWaitForSyslogSynchronized ( Object sourceAttribute , String schema , MithraDatabaseObject databaseObject ) { long now = System . currentTimeMillis ( ) ; if ( now > nextTimeToCheck ) { this . checkAndWaitForSyslog ( sourceAttribute , schema , databaseObject ) ; } } | synchronized so it does one check for all involved threads . |
23,846 | private ReladomoTxIdInterface initializeTransactionXidRange ( String flowId , int xidId ) { ReladomoTxIdInterface transactionXid = null ; MithraTransactionalList list = null ; try { DeserializationClassMetaData deserializationClassMetaData = new DeserializationClassMetaData ( this . txIdFinder ) ; transactionXid = ( Re... | real records . |
23,847 | protected boolean matchesWithoutDeleteCheck ( Object o , Extractor extractor ) { String s = ( ( StringExtractor ) extractor ) . stringValueOf ( o ) ; return s != null && s . indexOf ( this . getParameter ( ) ) < 0 ; } | null must not match anything exactly as in SQL |
23,848 | private boolean linkFirst ( Node < E > node ) { if ( count >= capacity ) return false ; Node < E > f = first ; node . next = f ; first = node ; if ( last == null ) last = node ; else f . prev = node ; ++ count ; notEmpty . signal ( ) ; return true ; } | Links node as first element or returns false if full . |
23,849 | private boolean linkLast ( Node < E > node ) { if ( count >= capacity ) return false ; Node < E > l = last ; node . prev = l ; last = node ; if ( first == null ) first = node ; else l . next = node ; ++ count ; notEmpty . signal ( ) ; return true ; } | Links node as last element or returns false if full . |
23,850 | void unlink ( Node < E > x ) { Node < E > p = x . prev ; Node < E > n = x . next ; if ( p == null ) { unlinkFirst ( ) ; } else if ( n == null ) { unlinkLast ( ) ; } else { p . next = n ; n . prev = p ; x . item = null ; -- count ; notFull . signal ( ) ; } } | Unlinks x . |
23,851 | private Object getEntryAfterMiss ( TransactionLocal key , int i , Entry e ) { Entry [ ] tab = table ; int len = tab . length ; while ( e != null ) { if ( e . key == key ) return e . value ; i = nextIndex ( i , len ) ; e = tab [ i ] ; } return null ; } | Version of getEntry method for use when key is not found in its direct hash slot . |
23,852 | public void put ( TransactionLocal key , Object value ) { Entry [ ] tab = table ; int len = tab . length ; int i = key . hashCode & ( len - 1 ) ; for ( Entry e = tab [ i ] ; e != null ; e = tab [ i = nextIndex ( i , len ) ] ) { if ( e . key == key ) { e . value = value ; return ; } } tab [ i ] = new Entry ( key , value... | Set the value associated with key . |
23,853 | public void remove ( TransactionLocal key ) { Entry [ ] tab = table ; int len = tab . length ; int i = key . hashCode & ( len - 1 ) ; for ( Entry e = tab [ i ] ; e != null ; e = tab [ i = nextIndex ( i , len ) ] ) { if ( e . key == key ) { expungeStaleEntry ( i ) ; return ; } } } | Remove the entry for key . |
23,854 | private int expungeStaleEntry ( int staleSlot ) { Entry [ ] tab = table ; int len = tab . length ; tab [ staleSlot ] . value = null ; tab [ staleSlot ] = null ; size -- ; Entry e ; int i ; for ( i = nextIndex ( staleSlot , len ) ; ( e = tab [ i ] ) != null ; i = nextIndex ( i , len ) ) { int h = e . key . hashCode & ( ... | Expunge a stale entry by rehashing any possibly colliding entries lying between staleSlot and the next null slot . This also expunges any other stale entries encountered before the trailing null . See Knuth Section 6 . 4 |
23,855 | private void resize ( ) { Entry [ ] oldTab = table ; int oldLen = oldTab . length ; int newLen = oldLen * 2 ; Entry [ ] newTab = new Entry [ newLen ] ; int count = 0 ; for ( int j = 0 ; j < oldLen ; ++ j ) { Entry e = oldTab [ j ] ; if ( e != null ) { int h = e . key . hashCode & ( newLen - 1 ) ; while ( newTab [ h ] !... | Double the capacity of the table . |
23,856 | private List applyOperationAndCheck ( Operation op , MithraTransaction tx ) { boolean oldEvaluationMode = tx . zIsInOperationEvaluationMode ( ) ; List resultList = null ; try { tx . zSetOperationEvaluationMode ( true ) ; if ( this . isPureHome ( ) || ( ! this . isOperationPartiallyCached ( op ) && ! this . txParticipat... | the transaction is getting 100% correct data |
23,857 | private static boolean timestampToAsofAttributeRelationiship ( Map . Entry < Attribute , Attribute > each ) { return ( each . getValue ( ) != null && each . getValue ( ) . isAsOfAttribute ( ) ) && ! each . getKey ( ) . isAsOfAttribute ( ) ; } | unsupported combination of businessDate timestamp - > businessDate asOf mapping . requires custom index |
23,858 | public int ifRetriableWaitElseThrow ( String msg , int retriesLeft , Logger logger ) { if ( this . isRetriable ( ) && -- retriesLeft > 0 ) { logger . warn ( msg + " " + this . getMessage ( ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "find failed with retriable error. retrying." , this ) ; } cleanupAndRe... | must not be called from within a transaction unless the work is being done async in a non - tx thread . |
23,859 | public void prepareTables ( ) throws Exception { Path ddlPath = Paths . get ( ClassLoader . getSystemResource ( "sql" ) . toURI ( ) ) ; try ( Connection conn = xaConnectionManager . getConnection ( ) ; ) { Files . walk ( ddlPath , 1 ) . filter ( path -> ! Files . isDirectory ( path ) && ( path . toString ( ) . endsWith... | This is not typically done in production app . |
23,860 | public MergeOptions < E > doNotUpdate ( Attribute ... attributes ) { if ( this . doNotUpdate == null ) { this . doNotUpdate = attributes ; } else { List < Attribute > all = FastList . newListWith ( this . doNotUpdate ) ; for ( Attribute a : attributes ) all . add ( a ) ; this . doNotUpdate = new Attribute [ all . size ... | Do not update these attributes |
23,861 | private void extractMithraInterfaces ( Map < String , MithraInterfaceType > mithraInterfaces , List < String > errors ) { for ( String mithraInterfaceType : this . getWrapped ( ) . getMithraInterfaces ( ) ) { MithraInterfaceType mithraInterfaceObject = mithraInterfaces . get ( mithraInterfaceType ) ; if ( mithraInterfa... | For each finder interface validate the |
23,862 | public void addRelationshipFilter ( RelatedFinder relatedFinder , Operation filter ) { Operation existing = this . filters . get ( relatedFinder ) ; this . filters . put ( relatedFinder , existing == null ? filter : existing . or ( filter ) ) ; } | Add a filter to be applied to the result of a traversed relationship . |
23,863 | public void extract ( ) { ExecutorService executor = Executors . newFixedThreadPool ( this . extractorConfig . getThreadPoolSize ( ) ) ; try { Map < Pair < RelatedFinder , Object > , List < MithraDataObject > > extract = extractData ( executor ) ; writeToFiles ( executor , extract ) ; } finally { executor . shutdown ( ... | Extract data and related data from the root operations added and write extracted data to text files as defined by OutputStrategy . |
23,864 | public Object getFromSemiUnique ( Object dataHolder , List extractors ) { Object result = null ; TransactionLocalStorage txStorage = ( TransactionLocalStorage ) perTransactionStorage . get ( MithraManagerProvider . getMithraManager ( ) . zGetCurrentTransactionWithNoCheck ( ) ) ; FullSemiUniqueDatedIndex perThreadAdded ... | new to differentiate |
23,865 | public int execute ( ) throws IOException { Runtime runtime = Runtime . getRuntime ( ) ; int exitCode = - 1 ; TerminateProcessThread terminateProcess = null ; Process process = null ; try { String [ ] command = ( String [ ] ) this . command . toArray ( new String [ this . command . size ( ) ] ) ; if ( this . workingDir... | Executes the process . |
23,866 | protected long scanPagesToSend ( long maxClientReplicatedPageVersion , FastUnsafeOffHeapIntList pagesToSend ) { long maxPageVersion = 0 ; boolean upgraded = false ; for ( int i = 0 ; i < this . pageVersionList . size ( ) ; i ++ ) { if ( pageVersionList . get ( i ) == 0 && ! upgraded ) { boolean originalLockWasReleased ... | Method is protected for testing purposes only |
23,867 | private synchronized void expungeStaleEntries ( ) { if ( size == 0 ) return ; Object r ; while ( ( r = queue . poll ( ) ) != null ) { Entry e = ( Entry ) r ; unlink ( e ) ; int h = e . hash ; int i = indexFor ( h , table . length ) ; Entry prev = table [ i ] ; Entry p = prev ; while ( p != null ) { Entry next = p . nex... | Expunge stale entries from the table . |
23,868 | public String getReverseRelationshipName ( ) { String ret = "" ; if ( tableAB == null ) { if ( multipleRelationsBetweenTables ) { ret = concatenateColumnNames ( this ) ; ret = ret . substring ( 1 ) + "_" ; } ret += StringUtility . firstLetterToLower ( tableA . getClassName ( ) ) ; } else { ForeignKey [ ] fks = tableAB ... | TableA as property name in TableB |
23,869 | public String getRelationshipName ( ) { String ret ; if ( tableAB == null ) { ret = concatenateColumnNames ( this ) ; ret = ret . substring ( 1 ) ; } else { ForeignKey [ ] fks = tableAB . getForeignKeys ( ) . values ( ) . toArray ( new ForeignKey [ 2 ] ) ; ret = ForeignKey . concatenateColumnNames ( fks [ 1 ] ) . subst... | TableB as property name in TableA |
23,870 | public String getTableAMultiplicity ( ) { String ret = "many" ; List < ColumnInfo > tableAPKs = tableA . getPkList ( ) ; if ( tableAPKs . size ( ) == 0 || tableA . getTableName ( ) . equals ( tableB . getTableName ( ) ) ) { return ret ; } if ( tableAB == null ) { List < ColumnInfo > fkColumns = this . getColumns ( ) ; ... | Otherwise it is a 1 - 1 relationship . |
23,871 | public MutableIntSet asSet ( List < T > list , MutableIntSet setToAppend ) { asSet ( list , this , setToAppend ) ; return setToAppend ; } | extracts the int values represented by this attribute from the list and adds them to the setToAppend . If the int attribute is null it s ignored . |
23,872 | public < R > R executeTransactionalCommandInSeparateThread ( final TransactionalCommand < R > command ) throws MithraBusinessException { return this . executeTransactionalCommandInSeparateThread ( command , this . defaultTransactionStyle ) ; } | Use this method very carefully . It can easily lead to a deadlock . executes the transactional command in a separate thread . Using a separate thread creates a brand new transactional context and therefore this transaction will not join the context of any outer transactions . For example if the outer transaction rolls ... |
23,873 | public < R > R executeTransactionalCommand ( final TransactionalCommand < R > command , final int retryCount ) throws MithraBusinessException { return this . executeTransactionalCommand ( command , new TransactionStyle ( this . transactionTimeout , retryCount ) ) ; } | executes the given transactional command with the custom number of retries |
23,874 | public < R > R executeTransactionalCommand ( final TransactionalCommand < R > command , final TransactionStyle style ) throws MithraBusinessException { String commandName = command . getClass ( ) . getName ( ) ; MithraTransaction tx = this . getCurrentTransaction ( ) ; if ( tx != null ) { try { return command . execute... | executes the given transactional command with the custom transaction style . |
23,875 | public void zLazyInitObjectsWithCallback ( MithraRuntimeType mithraRuntimeType , MithraConfigurationManager . PostInitializeHook hook ) { configManager . lazyInitObjectsWithCallback ( mithraRuntimeType , hook ) ; } | only used for MithraTestResource . Do not use . use readConfiguration instead . |
23,876 | public synchronized void clear ( ) { pool . forEachUntil ( new DoUntilProcedure < E > ( ) { public boolean execute ( E object ) { destroyObject ( object ) ; return false ; } } ) ; pool . clear ( ) ; numActive = 0 ; notifyAll ( ) ; } | Clears any objects sitting idle in the pool . |
23,877 | public void evict ( ) throws Exception { assertOpen ( ) ; boolean isEmpty ; synchronized ( this ) { isEmpty = pool . isEmpty ( ) ; } if ( ! isEmpty ) { if ( softMinEvictableIdleTimeMillis > 0 ) { int numToEvict = getNumIdle ( ) - getMinIdle ( ) ; evict ( System . currentTimeMillis ( ) - softMinEvictableIdleTimeMillis ,... | Make one pass of the idle object evictor . |
23,878 | protected List convertToBusinessObjectAndWrapInList ( Object o , Extractor [ ] extractors , Timestamp [ ] asOfDates , boolean weak , boolean isLocked ) { if ( ! ( o instanceof List ) ) { if ( o == null ) { return ListFactory . EMPTY_LIST ; } MithraDataObject data = ( MithraDataObject ) o ; this . extractTimestampsFromD... | if o is a list we do the conversion in place |
23,879 | public Timestamp getOrAddToCache ( Timestamp newValue , boolean hard ) { if ( newValue == null || newValue instanceof CachedImmutableTimestamp || newValue == NullDataTimestamp . getInstance ( ) ) { return newValue ; } return ( Timestamp ) weakPool . getIfAbsentPut ( newValue , hard ) ; } | return the pooled value |
23,880 | public void clear ( ) { emptyReferenceQueue ( ) ; for ( int i = 0 ; i < table . length ; i ++ ) { Entry e = table [ i ] ; Entry first = null ; Entry prev = null ; while ( e != null ) { Object candidate = e . get ( ) ; if ( candidate != null ) { Entry dirty = e . makeDirtyAndWeak ( queue ) ; if ( first == null ) { first... | we don t actually clear anything just make things weak and dirty |
23,881 | public void addMithraNotificationEventForUpdate ( String databaseIdentifier , String classname , byte databaseOperation , MithraDataObject mithraDataObject , List updateWrappers , Object sourceAttribute ) { MithraDataObject [ ] dataObjects = new MithraDataObject [ 1 ] ; dataObjects [ 0 ] = mithraDataObject ; createAndA... | This is called from single insert update or delete . |
23,882 | private RegistrationEntryList getRegistrationEntryList ( String subject , RelatedFinder finder ) { RegistrationEntryList registrationEntryList ; RegistrationKey key = new RegistrationKey ( subject , finder . getFinderClassName ( ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "**************Adding applicati... | Must only be called from the thread which is used for registration |
23,883 | public Connection makeObject ( ObjectPoolWithThreadAffinity < Connection > pool ) throws Exception { Connection conn = connectionFactory . createConnection ( ) ; return new PooledConnection ( conn , pool , this . statementsToPool ) ; } | overriding to remove synchronized . We never mutate any state that affects this method |
23,884 | public void initialisePool ( ) { Properties loginProperties = createLoginProperties ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "about to create pool with user-id : " + this . getJdbcUser ( ) ) ; } ConnectionFactory connectionFactory = createConnectionFactory ( loginProperties ) ; PoolableObjectFactory ... | This method must be called after all the connection pool properties have been set . |
23,885 | public void setDriverClassName ( String driver ) { try { this . driver = ( Driver ) Class . forName ( driver ) . newInstance ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "Unable to load driver: " + driver , e ) ; } } | sets the driver class name . This is used in conjunction with the JDBC connection string |
23,886 | public void setMaxRetriesBeforeRequeue ( int maxRetriesBeforeRequeue ) { this . maxRetriesBeforeRequeue = maxRetriesBeforeRequeue ; this . transactionStyle = new TransactionStyle ( MithraManagerProvider . getMithraManager ( ) . getTransactionTimeout ( ) , maxRetriesBeforeRequeue , this . retryOnTimeout ) ; } | default value is 3 . |
23,887 | private void validateOrderByAttribute ( String attributeName ) { if ( ( ! nameToAggregateAttributeMap . containsKey ( attributeName ) ) && ( ! nameToGroupByAttributeMap . containsKey ( attributeName ) ) ) { throw new MithraBusinessException ( "Aggregate list cannot be order by attribute with name: " + attributeName + ... | The attribute to group by should be either a aggregate attribute or a group by attribute . |
23,888 | public MithraRuntimeType parseConfiguration ( InputStream mithraFileIs ) { if ( mithraFileIs == null ) { throw new MithraBusinessException ( "Could not parse Mithra configuration, because the input stream is null." ) ; } try { MithraRuntimeUnmarshaller unmarshaller = new MithraRuntimeUnmarshaller ( ) ; unmarshaller . s... | Parses the configuration file . Should only be called by MithraTestResource . Use readConfiguration to parse and initialize the configuration . |
23,889 | private synchronized boolean expungeStaleEntries ( ) { if ( this . size == 0 ) return false ; Object r ; boolean result = false ; while ( ( r = queue . poll ( ) ) != null ) { result = true ; SingleEntry e = ( SingleEntry ) r ; this . size -= e . cleanupPkTable ( this . table ) ; this . nonDatedEntryCount -= e . cleanup... | Expunge stale entries from the nonDatedTable . |
23,890 | private void resizeSemiUnique ( int newCapacity ) { SemiUniqueEntry [ ] oldTable = getNonDatedTable ( ) ; int oldCapacity = oldTable . length ; if ( oldCapacity == MAXIMUM_CAPACITY ) { semiUniqueThreshold = Integer . MAX_VALUE ; return ; } SemiUniqueEntry [ ] newTable = new SemiUniqueEntry [ newCapacity ] ; transferSem... | Rehashes the contents of this map into a new array with a larger capacity . This method is called automatically when the number of keys in this map reaches its semiUniqueThreshold . |
23,891 | private void resize ( Object [ ] oldTable , int newSize ) { int oldCapacity = oldTable . length ; int end = oldCapacity - 1 ; Object last = arrayAt ( oldTable , end ) ; if ( this . size ( ) < ( ( end * 3 ) >> 2 ) && last == RESIZE_SENTINEL ) { return ; } if ( oldCapacity >= MAXIMUM_CAPACITY ) { throw new RuntimeExcepti... | newSize must be a power of 2 + 1 |
23,892 | public void forAllInParallel ( final ParallelProcedure procedure ) { MithraCpuBoundThreadPool pool = MithraCpuBoundThreadPool . getInstance ( ) ; final Object [ ] set = this . table ; ThreadChunkSize threadChunkSize = new ThreadChunkSize ( pool . getThreads ( ) , set . length - 2 , 1 ) ; final ArrayBasedQueue queue = n... | does not allow concurrent iteration with additions to the index |
23,893 | public DependentKeyIndex createDependentKeyIndex ( CacheLoaderEngine cacheLoaderEngine , Extractor [ ] keyExtractors , Operation ownerObjectFilter ) { DependentKeyIndex dependentKeyIndex = null ; for ( DependentKeyIndex each : this . dependentKeyIndexes ) { if ( Arrays . equals ( each . getKeyExtractors ( ) , keyExtrac... | executed from a single thread during the cacheloader startup . |
23,894 | public Operation createMappedOperationForDeepFetch ( Mapper mapper ) { Operation rootOperation = this . getRootOperation ( ) ; if ( rootOperation == null ) return null ; return mapper . createMappedOperationForDeepFetch ( rootOperation ) ; } | mapper is not necessarily this . relatedFinder . mapper . chained mapper and linked mapper s callbacks . |
23,895 | public Operation getSimplifiedJoinOp ( Mapper mapper , List parentList ) { int maxSimplifiedIn = DeepRelationshipUtility . MAX_SIMPLIFIED_IN ; boolean differentPersisterThanParent = differentPersisterIdThanParent ( mapper ) ; if ( differentPersisterThanParent ) { maxSimplifiedIn = Integer . MAX_VALUE ; } return mapper ... | mapper is not necessarily this . relatedFinder . mapper . chained mapper |
23,896 | protected void zSetData ( MithraDataObject data ) { this . currentData = data ; this . persistenceState = PersistenceState . PERSISTED ; MithraTransaction currentTransaction = MithraManagerProvider . getMithraManager ( ) . getCurrentTransaction ( ) ; if ( currentTransaction != null && zGetPortal ( ) . getTxParticipatio... | also called after constructing a new object for remote insert non - persistent copy and detached copy |
23,897 | public static int calculateQuotientScale ( int precision1 , int scale1 , int precision2 , int scale2 ) { return Math . max ( scale1 + precision2 - scale2 + 1 , 6 ) ; } | From the Sybase Transact - SQL user guide |
23,898 | protected void onSizeChanged ( int w , int h , int oldw , int oldh ) { super . onSizeChanged ( w , h , oldw , oldh ) ; mAreDimensionsInvalid = true ; } | fix rotation changes |
23,899 | private Calendar getTimeFromPoint ( float x , float y ) { int leftDaysWithGaps = ( int ) - ( Math . ceil ( mCurrentOrigin . x / ( mWidthPerDay + mColumnGap ) ) ) ; float startPixel = mCurrentOrigin . x + ( mWidthPerDay + mColumnGap ) * leftDaysWithGaps + mHeaderColumnWidth ; for ( int dayNumber = leftDaysWithGaps + 1 ;... | Get the time and date where the user clicked on . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.