idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
14,400
public void dropIndex ( final ODatabaseObject db ) { final String name = index . getName ( ) ; logger . info ( "Dropping existing index '{}' (class '{}'), because of definition mismatch" , name , index . getDefinition ( ) . getClassName ( ) ) ; SchemeUtils . dropIndex ( db , name ) ; }
Drops index .
14,401
@ SuppressWarnings ( "PMD.LinguisticNaming" ) public IndexMatchVerifier isIndexSigns ( final Object ... signs ) { final List < Object > idxsigns = Lists . newArrayList ( ) ; idxsigns . add ( index . getType ( ) ) ; idxsigns . addAll ( Arrays . asList ( signs ) ) ; return new IndexMatchVerifier ( idxsigns ) ; }
Compares current index configuration with new signature . Used to decide if index should be dropped and re - created or its completely equal to new signature .
14,402
public static Class < ? extends CobolContext > getInputKeyCobolContext ( Configuration conf ) { return conf . getClass ( CONF_INPUT_KEY_COBOL_CONTEXT , null , CobolContext . class ) ; }
Gets the job input key mainframe COBOL parameters .
14,403
public static void setInputKeyRecordType ( Job job , Class < ? extends CobolComplexType > cobolType ) { job . getConfiguration ( ) . setClass ( CONF_INPUT_KEY_RECORD_TYPE , cobolType , CobolComplexType . class ) ; }
Sets the job input key mainframe record type .
14,404
public static Class < ? extends CobolComplexType > getInputKeyRecordType ( Configuration conf ) { return conf . getClass ( CONF_INPUT_KEY_RECORD_TYPE , null , CobolComplexType . class ) ; }
Gets the job input key mainframe record type .
14,405
public static void setInputRecordMatcher ( Job job , Class < ? extends CobolTypeFinder > matcherClass ) { job . getConfiguration ( ) . setClass ( CONF_INPUT_RECORD_MATCHER_CLASS , matcherClass , CobolTypeFinder . class ) ; }
Sets the job input record matcher class .
14,406
public static Class < ? extends CobolTypeFinder > getInputRecordMatcher ( Configuration conf ) { return conf . getClass ( CONF_INPUT_RECORD_MATCHER_CLASS , null , CobolTypeFinder . class ) ; }
Gets the job input record matcher class .
14,407
public static void setInputChoiceStrategy ( Job job , Class < ? extends FromCobolChoiceStrategy > choiceStrategyClass ) { job . getConfiguration ( ) . setClass ( CONF_INPUT_RECORD_CHOICE_STRATEGY_CLASS , choiceStrategyClass , FromCobolChoiceStrategy . class ) ; }
Sets the job input record choice strategy class .
14,408
public static Class < ? extends FromCobolChoiceStrategy > getInputChoiceStrategy ( Configuration conf ) { return conf . getClass ( CONF_INPUT_RECORD_CHOICE_STRATEGY_CLASS , null , FromCobolChoiceStrategy . class ) ; }
Gets the job input record choice strategy class .
14,409
public int readFully ( byte b [ ] , int off , int len ) throws IOException { IOUtils . readFully ( inStream , b , off , len ) ; return len ; }
Read a number of bytes from the input stream blocking until all requested bytes are read or end of file is reached .
14,410
public int read ( byte b [ ] , int off , int len ) throws IOException { return IOUtils . read ( inStream , b , off , len ) ; }
Same as above but does not throw an exception at end of file just returns the actual data read .
14,411
public void addNamedParam ( final String name , final ParamInfo paramInfo ) { check ( ! named . containsKey ( name ) , "Duplicate parameter %s declaration at position %s" , name , paramInfo . position ) ; named . put ( name , paramInfo ) ; }
Register parameter as named .
14,412
public void addStaticElVarValue ( final String name , final String value ) { check ( ! staticElValues . containsKey ( name ) , "Duplicate el variable %s value declaration: %s (original: %s)" , name , value , staticElValues . get ( name ) ) ; check ( ! dynamicElValues . contains ( name ) , "El variable %s can't be registered as static, because dynamic declaration already defined" , name ) ; staticElValues . put ( name , value ) ; }
Register static query el variable value .
14,413
public void addDynamicElVarValue ( final String name ) { check ( ! dynamicElValues . contains ( name ) , "Duplicate dynamic el variable %s declaration" , name ) ; check ( ! staticElValues . containsKey ( name ) , "El variable %s can't be registered as dynamic, because static declaration already defined" , name ) ; dynamicElValues . add ( name ) ; }
Register dynamic query el variable value . Variable will be completely handled by extension . Registration is required to validated not handled variables .
14,414
private String generateXmlSchema ( Reader cobolReader , String targetNamespace , String targetXmlSchemaName , final String xsltFileName ) { log . debug ( "XML schema {} generation started" , targetXmlSchemaName + XSD_FILE_EXTENSION ) ; String xmlSchemaSource = cob2xsd . translate ( cobolReader , NamespaceUtils . toNamespace ( targetNamespace ) , xsltFileName ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Generated Cobol-annotated XML Schema: " ) ; log . debug ( xmlSchemaSource ) ; } log . debug ( "XML schema {} generation ended" , targetXmlSchemaName + XSD_FILE_EXTENSION ) ; return xmlSchemaSource ; }
Translate the COBOL copybook to XML Schema .
14,415
private Map < String , String > generateConverterClasses ( String xmlSchemaSource , String targetPackageName ) { log . debug ( "Converter support classes generation started" ) ; Map < String , String > codeMap = xsd2CobolTypes . generate ( new StringReader ( xmlSchemaSource ) , targetPackageName ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Generated converter support classes: " ) ; for ( String code : codeMap . values ( ) ) { log . debug ( code ) ; log . debug ( "\n" ) ; } } log . debug ( "Converter support classes generation ended" ) ; return codeMap ; }
Produce the LegStar converter support classes .
14,416
private String generateAvroSchema ( String xmlSchemaSource , String targetPackageName , String targetAvroSchemaName ) throws IOException { log . debug ( "Avro schema {} generation started" , targetAvroSchemaName + AVSC_FILE_EXTENSION ) ; String avroSchemaSource = cob2AvroTranslator . translate ( new StringReader ( xmlSchemaSource ) , targetPackageName , targetAvroSchemaName ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Generated Avro Schema: " ) ; log . debug ( avroSchemaSource ) ; } log . debug ( "Avro schema {} generation ended" , targetAvroSchemaName + AVSC_FILE_EXTENSION ) ; return avroSchemaSource ; }
Produce the avro schema .
14,417
private void avroCompile ( String avroSchemaSource , File avroSchemaFile , File javaTargetFolder ) throws IOException { log . debug ( "Avro compiler started for: {}" , avroSchemaFile ) ; Schema . Parser parser = new Schema . Parser ( ) ; Schema schema = parser . parse ( avroSchemaSource ) ; SpecificCompiler compiler = new CustomSpecificCompiler ( schema ) ; compiler . setStringType ( StringType . CharSequence ) ; compiler . compileToDestination ( avroSchemaFile , javaTargetFolder ) ; log . debug ( "Avro compiler ended for: {}" , avroSchemaFile ) ; }
Given an Avro schema produce java specific classes .
14,418
public static TxConfig buildConfig ( final Class < ? > type , final Method method , final boolean useDefaults ) { final Transactional transactional = findAnnotation ( type , method , Transactional . class , useDefaults ) ; TxConfig res = null ; if ( transactional != null ) { final TxType txType = findAnnotation ( type , method , TxType . class , true ) ; res = new TxConfig ( wrapExceptions ( transactional . rollbackOn ( ) ) , wrapExceptions ( transactional . ignore ( ) ) , txType . value ( ) ) ; } return res ; }
Build transaction config for type .
14,419
private static List < Class < ? extends Exception > > wrapExceptions ( final Class < ? extends Exception > ... list ) { return list . length == 0 ? null : Arrays . asList ( list ) ; }
Avoid creation of empty list .
14,420
public void setTitleGaps ( int gapBetweenIconAndTitle , int gapBetweenTitleAndComponents , int gapBetweenComponents ) { gapBetweenIconAndTitle = Math . max ( gapBetweenIconAndTitle , 0 ) ; gapBetweenTitleAndComponents = Math . max ( gapBetweenTitleAndComponents , 0 ) ; gapBetweenComponents = Math . max ( gapBetweenComponents , 0 ) ; rebuild ( ) ; }
Defines the title gaps
14,421
public static void checkExec ( final boolean condition , final String message , final Object ... args ) { if ( ! condition ) { throw new MethodExecutionException ( String . format ( message , args ) ) ; } }
Shortcut to check and throw execution exception .
14,422
public static List < String > findVars ( final String str ) { final List < String > vars = new ArrayList < String > ( ) ; final char [ ] strArray = str . toCharArray ( ) ; int i = 0 ; while ( i < strArray . length - 1 ) { if ( strArray [ i ] == VAR_START && strArray [ i + 1 ] == VAR_LEFT_BOUND ) { i = i + 2 ; final int begin = i ; while ( strArray [ i ] != VAR_RIGHT_BOUND ) { ++ i ; } final String var = str . substring ( begin , i ++ ) ; if ( ! vars . contains ( var ) ) { vars . add ( var ) ; } } else { ++ i ; } } return vars ; }
Analyze string for variables .
14,423
public static String replace ( final String str , final Map < String , String > params ) { final StringBuilder sb = new StringBuilder ( str . length ( ) ) ; final char [ ] strArray = str . toCharArray ( ) ; int i = 0 ; while ( i < strArray . length - 1 ) { if ( strArray [ i ] == VAR_START && strArray [ i + 1 ] == VAR_LEFT_BOUND ) { i = i + 2 ; final int begin = i ; while ( strArray [ i ] != VAR_RIGHT_BOUND ) { ++ i ; } final String var = str . substring ( begin , i ++ ) ; Preconditions . checkState ( params . containsKey ( var ) , "No value provided for variable '%s' " + "in string '%s'" , var , str ) ; final String value = params . get ( var ) . trim ( ) ; sb . append ( value ) ; } else { sb . append ( strArray [ i ] ) ; ++ i ; } } if ( i < strArray . length ) { sb . append ( strArray [ i ] ) ; } return sb . toString ( ) ; }
Replace placeholders in string .
14,424
public static void validate ( final String string , final List < String > params ) { final List < String > vars = findVars ( string ) ; for ( String param : params ) { Preconditions . checkState ( vars . contains ( param ) , "Variable '%s' not found in target string '%s'" , param , string ) ; } vars . removeAll ( params ) ; Preconditions . checkState ( vars . isEmpty ( ) , "No parameter binding defined for variables '%s' from string '%s'" , Joiner . on ( ',' ) . join ( vars ) , string ) ; }
Validate string variables and declared values for correctness .
14,425
private void expand ( boolean immediately ) { if ( locked == false && inAction == false && collapsed ) { inAction = true ; CollapsiblePanelListener [ ] array = listeners . getListeners ( CollapsiblePanelListener . class ) ; for ( CollapsiblePanelListener cpl : array ) { cpl . panelWillExpand ( new CollapsiblePanelEvent ( this ) ) ; } pixels = incremental ; if ( isAnimationEnabled ( ) && immediately == false ) { calculatedHeight = getSize ( ) . height ; if ( isFillMode ( ) ) { setEndHeights ( ) ; } else { endHeight = getPreferredSize ( false ) . height ; } getExpandTimer ( ) . start ( ) ; } else { changeStatus ( ) ; } } }
Expand the panel .
14,426
public void setReverseLayout ( boolean reverseLayout ) { if ( mPendingSavedState != null && mPendingSavedState . mReverseLayout != reverseLayout ) { mPendingSavedState . mReverseLayout = reverseLayout ; } if ( reverseLayout == mReverseLayout ) { return ; } mReverseLayout = reverseLayout ; requestLayout ( ) ; }
Used to reverse item traversal and layout order . This behaves similar to the layout change for RTL views . When set to true first item is rendered at the end of the UI second item is render before it etc .
14,427
public static void command ( final ODatabaseObject db , final String command , final Object ... args ) { db . command ( new OCommandSQL ( String . format ( command , args ) ) ) . execute ( ) ; }
Calls schema change sql command .
14,428
@ SuppressFBWarnings ( "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" ) public static void dropIndex ( final ODatabaseObject db , final String indexName ) { db . getMetadata ( ) . getIndexManager ( ) . dropIndex ( indexName ) ; }
Drops named index . Safe to call even if index not exist .
14,429
private void configureCustomTypes ( ) { final Multibinder < OObjectSerializer > typesBinder = Multibinder . newSetBinder ( binder ( ) , OObjectSerializer . class ) ; if ( ! customTypes . isEmpty ( ) ) { for ( Class < ? extends OObjectSerializer > type : customTypes ) { bind ( type ) . in ( Singleton . class ) ; typesBinder . addBinding ( ) . to ( type ) ; } } }
Binds registered custom types as guice singletons and register them with multibinder .
14,430
protected void loadOptionalPool ( final String poolBinder ) { try { final Method bindPool = OrientModule . class . getDeclaredMethod ( "bindPool" , Class . class , Class . class ) ; bindPool . setAccessible ( true ) ; try { Class . forName ( poolBinder ) . getConstructor ( OrientModule . class , Method . class , Binder . class ) . newInstance ( this , bindPool , binder ( ) ) ; } finally { bindPool . setAccessible ( false ) ; } } catch ( Exception ignored ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Failed to process pool loader " + poolBinder , ignored ) ; } } }
Allows to load pool only if required jars are in classpath . For example no need for graph dependencies if only object db is used .
14,431
@ SuppressWarnings ( "unchecked" ) private static boolean isParametersCompatible ( final List < Class < ? > > params , final List < ParamInfo > ordinalParamInfos ) { boolean resolution = params . size ( ) == ordinalParamInfos . size ( ) ; if ( resolution && ! params . isEmpty ( ) ) { final Iterator < Class < ? > > paramsIt = params . iterator ( ) ; final Iterator < ParamInfo > targetIt = ordinalParamInfos . iterator ( ) ; while ( paramsIt . hasNext ( ) ) { final Class < ? > type = paramsIt . next ( ) ; final ParamInfo paramInfo = targetIt . next ( ) ; if ( ! paramInfo . type . isAssignableFrom ( type ) ) { resolution = false ; break ; } } } return resolution ; }
Checking method parameters compatibility .
14,432
public static ElDescriptor analyzeQuery ( final GenericsContext genericsContext , final String query ) { final List < String > vars = ElUtils . findVars ( query ) ; ElDescriptor descriptor = null ; if ( ! vars . isEmpty ( ) ) { descriptor = new ElDescriptor ( vars ) ; checkGenericVars ( descriptor , genericsContext ) ; } return descriptor ; }
Analyze query string for variables .
14,433
public static void check ( final boolean condition , final String message , final Object ... args ) { if ( ! condition ) { throw new MethodDefinitionException ( String . format ( message , args ) ) ; } }
Shortcut to check and throw definition exception .
14,434
private static Object jdk8 ( final Class < ? > type , final Object object ) { try { if ( jdk8OptionalFactory == null ) { lookupOptionalFactoryMethod ( type ) ; } return jdk8OptionalFactory . invoke ( null , object ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Failed to instantiate jdk Optional" , e ) ; } }
Only this will cause optional class loading and fail for earlier jdk .
14,435
public void setEngineConfigMap ( Map < String , Object > engineConfigMap ) { if ( engineConfigMap != null ) { this . engineConfig . putAll ( engineConfigMap ) ; } }
Set Rythm properties as Map to allow for non - String values like ds . resource . loader . instance .
14,436
public RythmEngine createRythmEngine ( ) throws IOException , RythmException { Map < String , Object > p = new HashMap < String , Object > ( ) ; p . put ( RythmConfigurationKey . ENGINE_PLUGIN_VERSION . getKey ( ) , Version . VALUE ) ; if ( this . configLocation != null ) { logger . info ( "Loading Rythm config from [%s]" , this . configLocation ) ; CollectionUtils . mergePropertiesIntoMap ( PropertiesLoaderUtils . loadProperties ( this . configLocation ) , p ) ; } if ( ! this . engineConfig . isEmpty ( ) ) { p . putAll ( this . engineConfig ) ; } if ( null == devMode ) { String k = RythmConfigurationKey . ENGINE_MODE . getKey ( ) ; if ( p . containsKey ( k ) ) { String s = p . get ( k ) . toString ( ) ; devMode = Rythm . Mode . dev . name ( ) . equalsIgnoreCase ( s ) ; } else { devMode = getDevModeFromDevModeSensor ( ) ; } } Rythm . Mode mode = devMode ? Rythm . Mode . dev : Rythm . Mode . prod ; p . put ( RythmConfigurationKey . ENGINE_MODE . getKey ( ) , mode ) ; p . put ( RythmConfigurationKey . CACHE_ENABLED . getKey ( ) , enableCache ) ; List < ITemplateResourceLoader > loaders = null ; if ( this . resourceLoaderPath != null ) { loaders = new ArrayList < ITemplateResourceLoader > ( ) ; String [ ] paths = StringUtils . commaDelimitedListToStringArray ( resourceLoaderPath ) ; for ( String path : paths ) { loaders . add ( new SpringResourceLoader ( path , resourceLoader ) ) ; } p . put ( RythmConfigurationKey . RESOURCE_LOADER_IMPLS . getKey ( ) , loaders ) ; p . put ( RythmConfigurationKey . RESOURCE_DEF_LOADER_ENABLED . getKey ( ) , false ) ; } ApplicationContext ctx = getApplicationContext ( ) ; if ( null != ctx ) { SpringI18nMessageResolver i18n = new SpringI18nMessageResolver ( ) ; i18n . setApplicationContext ( getApplicationContext ( ) ) ; p . put ( RythmConfigurationKey . I18N_MESSAGE_RESOLVER . getKey ( ) , i18n ) ; } configRythm ( p ) ; RythmEngine engine = newRythmEngine ( p ) ; if ( null != loaders ) { for ( ITemplateResourceLoader loader : loaders ) { loader . setEngine ( engine ) ; } } postProcessRythmEngine ( engine ) ; return engine ; }
Prepare the RythmEngine instance and return it .
14,437
private static int getRecordLen ( byte [ ] hostData , int start , int length ) { int len = getRawRdw ( hostData , start , length ) ; if ( len < RDW_LEN || len > hostData . length ) { throw new IllegalArgumentException ( "Record does not start with a Record Descriptor Word" ) ; } return len - RDW_LEN ; }
RDW is a 4 bytes numeric stored in Big Endian as a binary 2 s complement .
14,438
public String translate ( XmlSchema xmlSchema , String avroNamespace , String avroSchemaName ) throws Xsd2AvroTranslatorException { log . debug ( "XML Schema to Avro Schema translator started" ) ; final Map < QName , XmlSchemaElement > items = xmlSchema . getElements ( ) ; ObjectNode rootAvroSchema = null ; final ArrayNode avroFields = MAPPER . createArrayNode ( ) ; if ( items . size ( ) > 1 ) { for ( Entry < QName , XmlSchemaElement > entry : items . entrySet ( ) ) { visit ( xmlSchema , entry . getValue ( ) , 1 , avroFields ) ; } rootAvroSchema = buildAvroRecordType ( avroSchemaName , avroFields ) ; } else if ( items . size ( ) == 1 ) { XmlSchemaElement xsdElement = ( XmlSchemaElement ) items . values ( ) . iterator ( ) . next ( ) ; if ( xsdElement . getSchemaType ( ) instanceof XmlSchemaComplexType ) { XmlSchemaComplexType xsdType = ( XmlSchemaComplexType ) xsdElement . getSchemaType ( ) ; visit ( xmlSchema , xsdType , 1 , avroFields ) ; rootAvroSchema = buildAvroRecordType ( getAvroTypeName ( xsdType ) , avroFields ) ; } else { throw new Xsd2AvroTranslatorException ( "XML schema does contain a root element but it is not a complex type" ) ; } } else { throw new Xsd2AvroTranslatorException ( "XML schema does not contain a root element" ) ; } rootAvroSchema . put ( "namespace" , avroNamespace == null ? "" : avroNamespace ) ; log . debug ( "XML Schema to Avro Schema translator ended" ) ; return rootAvroSchema . toString ( ) ; }
Translate the input XML Schema .
14,439
private void visit ( XmlSchema xmlSchema , final XmlSchemaElement xsdElement , final int level , final ArrayNode avroFields ) throws Xsd2AvroTranslatorException { if ( xsdElement . getRef ( ) . getTarget ( ) != null ) { return ; } log . debug ( "process started for element = " + xsdElement . getName ( ) ) ; if ( xsdElement . getSchemaType ( ) instanceof XmlSchemaComplexType ) { XmlSchemaComplexType xsdType = ( XmlSchemaComplexType ) xsdElement . getSchemaType ( ) ; int nextLevel = level + 1 ; final ArrayNode avroChildrenFields = MAPPER . createArrayNode ( ) ; visit ( xmlSchema , xsdType , nextLevel , avroChildrenFields ) ; ContainerNode avroRecordType = buildAvroCompositeType ( getAvroTypeName ( xsdType ) , avroChildrenFields , xsdElement . getMaxOccurs ( ) > 1 , xsdElement . getMinOccurs ( ) == 0 && xsdElement . getMaxOccurs ( ) == 1 ) ; ObjectNode avroRecordElement = MAPPER . createObjectNode ( ) ; avroRecordElement . put ( "type" , avroRecordType ) ; avroRecordElement . put ( "name" , getAvroFieldName ( xsdElement ) ) ; avroFields . add ( avroRecordElement ) ; } else if ( xsdElement . getSchemaType ( ) instanceof XmlSchemaSimpleType ) { visit ( ( XmlSchemaSimpleType ) xsdElement . getSchemaType ( ) , level , getAvroFieldName ( xsdElement ) , xsdElement . getMinOccurs ( ) , xsdElement . getMaxOccurs ( ) , avroFields ) ; } log . debug ( "process ended for element = " + xsdElement . getName ( ) ) ; }
Process a regular XML schema element .
14,440
private void visit ( XmlSchema xmlSchema , XmlSchemaComplexType xsdType , final int level , final ArrayNode avroFields ) { visit ( xmlSchema , xsdType . getParticle ( ) , level , avroFields ) ; }
Create an avro complex type field using an XML schema type .
14,441
private void visit ( XmlSchemaSimpleType xsdType , final int level , final String avroFieldName , long minOccurs , long maxOccurs , ArrayNode avroFields ) throws Xsd2AvroTranslatorException { Object avroType = getAvroPrimitiveType ( avroFieldName , xsdType , maxOccurs > 1 , minOccurs == 0 && maxOccurs == 1 ) ; ObjectNode avroField = MAPPER . createObjectNode ( ) ; avroField . put ( "name" , avroFieldName ) ; if ( avroType != null ) { if ( avroType instanceof String ) { avroField . put ( "type" , ( String ) avroType ) ; } else if ( avroType instanceof JsonNode ) { avroField . put ( "type" , ( JsonNode ) avroType ) ; } } avroFields . add ( avroField ) ; }
Create an avro primitive type field using an XML schema type .
14,442
public static boolean isBigDecimal ( Schema schema ) { if ( Type . BYTES == schema . getType ( ) ) { JsonNode logicalTypeNode = schema . getJsonProp ( "logicalType" ) ; if ( logicalTypeNode != null && "decimal" . equals ( logicalTypeNode . asText ( ) ) ) { return true ; } } return false ; }
Tests whether a field is to be externalized as a BigDecimal
14,443
protected void configureAop ( ) { final RepositoryMethodInterceptor proxy = new RepositoryMethodInterceptor ( ) ; requestInjection ( proxy ) ; bindInterceptor ( Matchers . any ( ) , new AbstractMatcher < Method > ( ) { public boolean matches ( final Method method ) { try { return ExtUtils . findMethodAnnotation ( method ) != null ; } catch ( Exception ex ) { throw new MethodDefinitionException ( String . format ( "Error declaration on method %s" , RepositoryUtils . methodToString ( method ) ) , ex ) ; } } } , proxy ) ; }
Configures repository annotations interceptor .
14,444
protected void bindExecutor ( final Class < ? extends RepositoryExecutor > executor ) { bind ( executor ) . in ( Singleton . class ) ; executorsMultibinder . addBinding ( ) . to ( executor ) ; }
Register executor for specific connection type .
14,445
protected void loadOptionalExecutor ( final String executorBinder ) { try { final Method bindExecutor = RepositoryModule . class . getDeclaredMethod ( "bindExecutor" , Class . class ) ; bindExecutor . setAccessible ( true ) ; try { Class . forName ( executorBinder ) . getConstructor ( RepositoryModule . class , Method . class ) . newInstance ( this , bindExecutor ) ; } finally { bindExecutor . setAccessible ( false ) ; } } catch ( Exception ignore ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Failed to process executor loader " + executorBinder , ignore ) ; } } }
Allows to load executor only if required jars are in classpath . For example no need for graph dependencies if only object db is used .
14,446
public void setAdapter ( Adapter adapter ) { if ( mAdapter != null ) { mAdapter . unregisterAdapterDataObserver ( mObserver ) ; } if ( mItemAnimator != null ) { mItemAnimator . endAnimations ( ) ; } if ( mLayout != null ) { mLayout . removeAndRecycleAllViews ( mRecycler ) ; mLayout . removeAndRecycleScrapInt ( mRecycler , true ) ; } final Adapter oldAdapter = mAdapter ; mAdapter = adapter ; if ( adapter != null ) { adapter . registerAdapterDataObserver ( mObserver ) ; } if ( mLayout != null ) { mLayout . onAdapterChanged ( oldAdapter , mAdapter ) ; } mRecycler . onAdapterChanged ( oldAdapter , mAdapter ) ; mState . mStructureChanged = true ; markKnownViewsInvalid ( ) ; requestLayout ( ) ; }
Set a new adapter to provide child views on demand .
14,447
private void addAnimatingView ( View view ) { boolean alreadyAdded = false ; if ( mNumAnimatingViews > 0 ) { for ( int i = mAnimatingViewIndex ; i < getChildCount ( ) ; ++ i ) { if ( getChildAt ( i ) == view ) { alreadyAdded = true ; break ; } } } if ( ! alreadyAdded ) { if ( mNumAnimatingViews == 0 ) { mAnimatingViewIndex = getChildCount ( ) ; } ++ mNumAnimatingViews ; addView ( view ) ; } mRecycler . unscrapView ( getChildViewHolder ( view ) ) ; }
Adds a view to the animatingViews list . mAnimatingViews holds the child views that are currently being kept around purely for the purpose of being animated out of view . They are drawn as a regular part of the child list of the RecyclerView but they are invisible to the LayoutManager as they are managed separately from the regular child views .
14,448
private void removeAnimatingView ( View view ) { if ( mNumAnimatingViews > 0 ) { for ( int i = mAnimatingViewIndex ; i < getChildCount ( ) ; ++ i ) { if ( getChildAt ( i ) == view ) { removeViewAt ( i ) ; -- mNumAnimatingViews ; if ( mNumAnimatingViews == 0 ) { mAnimatingViewIndex = - 1 ; } mRecycler . recycleView ( view ) ; return ; } } } }
Removes a view from the animatingViews list .
14,449
void scrollByInternal ( int x , int y ) { int overscrollX = 0 , overscrollY = 0 ; consumePendingUpdateOperations ( ) ; if ( mAdapter != null ) { eatRequestLayout ( ) ; if ( x != 0 ) { final int hresult = mLayout . scrollHorizontallyBy ( x , mRecycler , mState ) ; overscrollX = x - hresult ; } if ( y != 0 ) { final int vresult = mLayout . scrollVerticallyBy ( y , mRecycler , mState ) ; overscrollY = y - vresult ; } resumeRequestLayout ( false ) ; } if ( ! mItemDecorations . isEmpty ( ) ) { invalidate ( ) ; } if ( ViewCompat . getOverScrollMode ( this ) != ViewCompat . OVER_SCROLL_NEVER ) { pullGlows ( overscrollX , overscrollY ) ; } if ( mScrollListener != null && ( x != 0 || y != 0 ) ) { mScrollListener . onScrolled ( x , y ) ; } if ( ! awakenScrollBars ( ) ) { invalidate ( ) ; } }
Does not perform bounds checking . Used by internal methods that have already validated input .
14,450
public boolean fling ( int velocityX , int velocityY ) { if ( Math . abs ( velocityX ) < mMinFlingVelocity ) { velocityX = 0 ; } if ( Math . abs ( velocityY ) < mMinFlingVelocity ) { velocityY = 0 ; } velocityX = Math . max ( - mMaxFlingVelocity , Math . min ( velocityX , mMaxFlingVelocity ) ) ; velocityY = Math . max ( - mMaxFlingVelocity , Math . min ( velocityY , mMaxFlingVelocity ) ) ; if ( velocityX != 0 || velocityY != 0 ) { mViewFlinger . fling ( velocityX , velocityY ) ; return true ; } return false ; }
Begin a standard fling with an initial velocity along each axis in pixels per second . If the velocity given is below the system - defined minimum this method will return false and no fling will occur .
14,451
private void pullGlows ( int overscrollX , int overscrollY ) { if ( overscrollX < 0 ) { if ( mLeftGlow == null ) { mLeftGlow = new EdgeEffectCompat ( getContext ( ) ) ; mLeftGlow . setSize ( getMeasuredHeight ( ) - getPaddingTop ( ) - getPaddingBottom ( ) , getMeasuredWidth ( ) - getPaddingLeft ( ) - getPaddingRight ( ) ) ; } mLeftGlow . onPull ( - overscrollX / ( float ) getWidth ( ) ) ; } else if ( overscrollX > 0 ) { if ( mRightGlow == null ) { mRightGlow = new EdgeEffectCompat ( getContext ( ) ) ; mRightGlow . setSize ( getMeasuredHeight ( ) - getPaddingTop ( ) - getPaddingBottom ( ) , getMeasuredWidth ( ) - getPaddingLeft ( ) - getPaddingRight ( ) ) ; } mRightGlow . onPull ( overscrollX / ( float ) getWidth ( ) ) ; } if ( overscrollY < 0 ) { if ( mTopGlow == null ) { mTopGlow = new EdgeEffectCompat ( getContext ( ) ) ; mTopGlow . setSize ( getMeasuredWidth ( ) - getPaddingLeft ( ) - getPaddingRight ( ) , getMeasuredHeight ( ) - getPaddingTop ( ) - getPaddingBottom ( ) ) ; } mTopGlow . onPull ( - overscrollY / ( float ) getHeight ( ) ) ; } else if ( overscrollY > 0 ) { if ( mBottomGlow == null ) { mBottomGlow = new EdgeEffectCompat ( getContext ( ) ) ; mBottomGlow . setSize ( getMeasuredWidth ( ) - getPaddingLeft ( ) - getPaddingRight ( ) , getMeasuredHeight ( ) - getPaddingTop ( ) - getPaddingBottom ( ) ) ; } mBottomGlow . onPull ( overscrollY / ( float ) getHeight ( ) ) ; } if ( overscrollX != 0 || overscrollY != 0 ) { ViewCompat . postInvalidateOnAnimation ( this ) ; } }
Apply a pull to relevant overscroll glow effects
14,452
void viewRangeUpdate ( int positionStart , int itemCount ) { final int childCount = getChildCount ( ) ; final int positionEnd = positionStart + itemCount ; for ( int i = 0 ; i < childCount ; i ++ ) { final ViewHolder holder = getChildViewHolderInt ( getChildAt ( i ) ) ; if ( holder == null ) { continue ; } final int position = holder . getPosition ( ) ; if ( position >= positionStart && position < positionEnd ) { holder . addFlags ( ViewHolder . FLAG_UPDATE ) ; mAdapter . bindViewHolder ( holder , holder . getPosition ( ) ) ; } } mRecycler . viewRangeUpdate ( positionStart , itemCount ) ; }
Rebind existing views for the given range or create as needed .
14,453
void markKnownViewsInvalid ( ) { final int childCount = getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { final ViewHolder holder = getChildViewHolderInt ( getChildAt ( i ) ) ; if ( holder != null ) { holder . addFlags ( ViewHolder . FLAG_UPDATE | ViewHolder . FLAG_INVALID ) ; } } mRecycler . markKnownViewsInvalid ( ) ; }
Mark all known views as invalid . Used in response to a the whole world might have changed data change event .
14,454
void postAdapterUpdate ( UpdateOp op ) { mPendingUpdates . add ( op ) ; if ( mPendingUpdates . size ( ) == 1 ) { if ( mPostUpdatesOnAnimation && mHasFixedSize && mIsAttached ) { ViewCompat . postOnAnimation ( this , mUpdateChildViewsRunnable ) ; } else { mAdapterUpdateDuringMeasure = true ; requestLayout ( ) ; } } }
Schedule an update of data from the adapter to occur on the next frame . On newer platform versions this happens via the postOnAnimation mechanism and RecyclerView attempts to avoid relayouts if possible . On older platform versions the RecyclerView requests a layout the same way ListView does .
14,455
public int getChildPosition ( View child ) { final ViewHolder holder = getChildViewHolderInt ( child ) ; return holder != null ? holder . getPosition ( ) : NO_POSITION ; }
Return the adapter position that the given child view corresponds to .
14,456
public long getChildItemId ( View child ) { if ( mAdapter == null || ! mAdapter . hasStableIds ( ) ) { return NO_ID ; } final ViewHolder holder = getChildViewHolderInt ( child ) ; return holder != null ? holder . getItemId ( ) : NO_ID ; }
Return the stable item id that the given child view corresponds to .
14,457
public View findChildViewUnder ( float x , float y ) { final int count = getChildCount ( ) ; for ( int i = count - 1 ; i >= 0 ; i -- ) { final View child = getChildAt ( i ) ; final float translationX = ViewCompat . getTranslationX ( child ) ; final float translationY = ViewCompat . getTranslationY ( child ) ; if ( x >= child . getLeft ( ) + translationX && x <= child . getRight ( ) + translationX && y >= child . getTop ( ) + translationY && y <= child . getBottom ( ) + translationY ) { return child ; } } return null ; }
Find the topmost view under the given point .
14,458
protected int getHorizontalSnapPreference ( ) { return mTargetVector == null || mTargetVector . x == 0 ? SNAP_TO_ANY : mTargetVector . x > 0 ? SNAP_TO_END : SNAP_TO_START ; }
When scrolling towards a child view this method defines whether we should align the left or the right edge of the child with the parent RecyclerView .
14,459
protected int getVerticalSnapPreference ( ) { return mTargetVector == null || mTargetVector . y == 0 ? SNAP_TO_ANY : mTargetVector . y > 0 ? SNAP_TO_END : SNAP_TO_START ; }
When scrolling towards a child view this method defines whether we should align the top or the bottom edge of the child with the parent RecyclerView .
14,460
protected void updateActionForInterimTarget ( Action action ) { PointF scrollVector = computeScrollVectorForPosition ( getTargetPosition ( ) ) ; if ( scrollVector == null || ( scrollVector . x == 0 && scrollVector . y == 0 ) ) { Log . e ( TAG , "To support smooth scrolling, you should override \n" + "LayoutManager#computeScrollVectorForPosition.\n" + "Falling back to instant scroll" ) ; final int target = getTargetPosition ( ) ; stop ( ) ; instantScrollToPosition ( target ) ; return ; } normalize ( scrollVector ) ; mTargetVector = scrollVector ; mInterimTargetDx = ( int ) ( TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector . x ) ; mInterimTargetDy = ( int ) ( TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector . y ) ; final int time = calculateTimeForScrolling ( TARGET_SEEK_SCROLL_DISTANCE_PX ) ; action . update ( ( int ) ( mInterimTargetDx * TARGET_SEEK_EXTRA_SCROLL_RATIO ) , ( int ) ( mInterimTargetDy * TARGET_SEEK_EXTRA_SCROLL_RATIO ) , ( int ) ( time * TARGET_SEEK_EXTRA_SCROLL_RATIO ) , mLinearInterpolator ) ; }
When the target scroll position is not a child of the RecyclerView this method calculates a direction vector towards that child and triggers a smooth scroll .
14,461
public int calculateDyToMakeVisible ( View view , int snapPreference ) { final RecyclerView . LayoutManager layoutManager = getLayoutManager ( ) ; if ( ! layoutManager . canScrollVertically ( ) ) { return 0 ; } final RecyclerView . LayoutParams params = ( RecyclerView . LayoutParams ) view . getLayoutParams ( ) ; final int top = layoutManager . getDecoratedTop ( view ) - params . topMargin ; final int bottom = layoutManager . getDecoratedBottom ( view ) + params . bottomMargin ; final int start = layoutManager . getPaddingTop ( ) ; final int end = layoutManager . getHeight ( ) - layoutManager . getPaddingBottom ( ) ; return calculateDtToFit ( top , bottom , start , end , snapPreference ) ; }
Calculates the vertical scroll amount necessary to make the given view fully visible inside the RecyclerView .
14,462
public int calculateDxToMakeVisible ( View view , int snapPreference ) { final RecyclerView . LayoutManager layoutManager = getLayoutManager ( ) ; if ( ! layoutManager . canScrollHorizontally ( ) ) { return 0 ; } final RecyclerView . LayoutParams params = ( RecyclerView . LayoutParams ) view . getLayoutParams ( ) ; final int left = layoutManager . getDecoratedLeft ( view ) - params . leftMargin ; final int right = layoutManager . getDecoratedRight ( view ) + params . rightMargin ; final int start = layoutManager . getPaddingLeft ( ) ; final int end = layoutManager . getWidth ( ) - layoutManager . getPaddingRight ( ) ; return calculateDtToFit ( left , right , start , end , snapPreference ) ; }
Calculates the horizontal scroll amount necessary to make the given view fully visible inside the RecyclerView .
14,463
private Class < ? > resolveTargetType ( final Class < ? > listenerType , final Class < ? > declaredTargetType ) { Class < ? > target = null ; if ( RequiresRecordConversion . class . isAssignableFrom ( listenerType ) ) { target = GenericsResolver . resolve ( listenerType ) . type ( RequiresRecordConversion . class ) . generic ( "T" ) ; if ( Object . class . equals ( target ) ) { target = declaredTargetType ; } } return target ; }
Resolve target conversion type either from listener instance or if its not possible from listener parameter declaration .
14,464
public static String methodToString ( final Class < ? > type , final Method method ) { final StringBuilder res = new StringBuilder ( ) ; res . append ( type . getSimpleName ( ) ) . append ( '#' ) . append ( method . getName ( ) ) . append ( '(' ) ; int i = 0 ; for ( Class < ? > param : method . getParameterTypes ( ) ) { if ( i > 0 ) { res . append ( ", " ) ; } final Type generic = method . getGenericParameterTypes ( ) [ i ] ; if ( generic instanceof TypeVariable ) { res . append ( '<' ) . append ( ( ( TypeVariable ) generic ) . getName ( ) ) . append ( '>' ) ; } else { res . append ( param . getSimpleName ( ) ) ; } i ++ ; } res . append ( ')' ) ; return res . toString ( ) ; }
Converts method signature to human readable string .
14,465
public static void checkParamExtensionCompatibility ( final Class < ? extends RepositoryMethodDescriptor > descriptorType , final Class < ? extends MethodParamExtension > paramExtType ) { check ( isCompatible ( paramExtType , MethodParamExtension . class , descriptorType ) , "Param extension %s is incompatible with descriptor %s" , paramExtType . getSimpleName ( ) , descriptorType . getSimpleName ( ) ) ; }
Checks that parameter extension is compatible with descriptor and throws error if extension incompatible .
14,466
public static void checkAmendExtensionsCompatibility ( final Class < ? extends RepositoryMethodDescriptor > descriptorType , final List < Annotation > extensions ) { final List < Class < ? extends AmendMethodExtension > > exts = Lists . transform ( extensions , new Function < Annotation , Class < ? extends AmendMethodExtension > > ( ) { public Class < ? extends AmendMethodExtension > apply ( final Annotation input ) { return input . annotationType ( ) . getAnnotation ( AmendMethod . class ) . value ( ) ; } } ) ; for ( Class < ? extends AmendMethodExtension > ext : exts ) { check ( isCompatible ( ext , AmendMethodExtension . class , descriptorType ) , "Amend extension %s is incompatible with descriptor %s" , ext . getSimpleName ( ) , descriptorType . getSimpleName ( ) ) ; } }
Checks that amend extensions strictly compatible with descriptor object . Used for amend annotations defined on method .
14,467
public static List < AmendExecutionExtension > filterCompatibleExtensions ( final List < AmendExecutionExtension > extensions , final Class < ? extends RepositoryMethodDescriptor > descriptorType ) { @ SuppressWarnings ( "unchecked" ) final Class < ? extends AmendExecutionExtension > supportedExtension = ( Class < ? extends AmendExecutionExtension > ) GenericsResolver . resolve ( descriptorType ) . type ( RepositoryMethodDescriptor . class ) . generic ( "E" ) ; return Lists . newArrayList ( Iterables . filter ( extensions , new Predicate < AmendExecutionExtension > ( ) { public boolean apply ( final AmendExecutionExtension ext ) { final Class < ? > rawExtType = RepositoryUtils . resolveRepositoryClass ( ext ) ; final boolean compatible = supportedExtension . isAssignableFrom ( rawExtType ) ; if ( ! compatible ) { LOGGER . debug ( "Extension {} ignored, because it doesn't implement required extension " + "interface {}" , rawExtType . getSimpleName ( ) , supportedExtension . getSimpleName ( ) ) ; } return compatible ; } } ) ) ; }
Checks resolved amend extensions compatibility with method specific extension type . Extension may be universal and support some methods and doesn t support other .
14,468
public void disposeTooltip ( ) { if ( popup != null ) { timer . stop ( ) ; popup . setVisible ( false ) ; popup = null ; } }
Dispose the tooltip
14,469
private void showTooltip ( ) { Wrap tooltipLabel = new Wrap ( toolTipWrapWidth ) ; tooltipLabel . setForeground ( getForeground ( ) ) ; tooltipLabel . setFont ( ToolTipButton . this . getFont ( ) ) ; tooltipLabel . setText ( text ) ; JPanel panel = new JPanel ( ) ; panel . setBackground ( toolTipBackground ) ; panel . setLayout ( new BorderLayout ( ) ) ; panel . add ( tooltipLabel , BorderLayout . CENTER ) ; if ( extraComponent != null && extraComponentAnchor != null ) { if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . SOUTH ) ) { panel . add ( extraComponent , BorderLayout . SOUTH ) ; } else if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . NORTH ) ) { panel . add ( extraComponent , BorderLayout . NORTH ) ; } else if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . EAST ) ) { panel . add ( extraComponent , BorderLayout . EAST ) ; } else if ( extraComponentAnchor . equals ( ToolTipButtonAnchor . WEST ) ) { panel . add ( extraComponent , BorderLayout . WEST ) ; } } Border out = BorderFactory . createLineBorder ( borderColor , borderThickness ) ; Border in = BorderFactory . createEmptyBorder ( margin . top , margin . left , margin . bottom , margin . right ) ; Border border = BorderFactory . createCompoundBorder ( out , in ) ; panel . setBorder ( border ) ; popup = new JPopupMenu ( ) ; popup . setBorder ( BorderFactory . createEmptyBorder ( ) ) ; popup . add ( panel ) ; popup . addMouseListener ( new MouseAdapter ( ) { public void mouseExited ( MouseEvent e ) { tryDisposeTooltip ( ) ; } } ) ; popup . pack ( ) ; popup . show ( ToolTipButton . this , 0 , getHeight ( ) ) ; Point point = popup . getLocationOnScreen ( ) ; Dimension dim = popup . getSize ( ) ; popupBounds = new Rectangle2D . Double ( point . getX ( ) , point . getY ( ) , dim . getWidth ( ) , dim . getHeight ( ) ) ; }
Show the tooltip .
14,470
public static Collection < MatchedMethod > filterByClosestParams ( final Collection < MatchedMethod > possibilities , final int paramsCount ) { Collection < MatchedMethod > res = null ; for ( int i = 0 ; i < paramsCount ; i ++ ) { final Collection < MatchedMethod > filtered = filterByParam ( possibilities , i ) ; if ( res != null ) { if ( filtered . size ( ) < res . size ( ) ) { res = filtered ; } } else { res = filtered ; } } return res ; }
Looks for most specific type for each parameter .
14,471
private ODatabaseDocument checkAndAcquireConnection ( ) { final ODatabaseDocument res ; if ( userManager . isSpecificUser ( ) ) { res = orientDB . get ( ) . open ( database , userManager . getUser ( ) , userManager . getPassword ( ) ) ; } else { res = pool . acquire ( ) ; } if ( res . isClosed ( ) ) { final String message = String . format ( "Pool %s return closed connection something is terribly wrong" , getType ( ) ) ; logger . error ( message ) ; throw new IllegalStateException ( message ) ; } return res ; }
Its definitely not normal that pool returns closed connections but possible if used improperly .
14,472
public static void trackIdChange ( final ODocument document , final Object pojo ) { if ( document . getIdentity ( ) . isNew ( ) ) { ORecordInternal . addIdentityChangeListener ( document , new OIdentityChangeListener ( ) { public void onBeforeIdentityChange ( final ORecord record ) { } public void onAfterIdentityChange ( final ORecord record ) { OObjectSerializerHelper . setObjectID ( record . getIdentity ( ) , pojo ) ; OObjectSerializerHelper . setObjectVersion ( record . getVersion ( ) , pojo ) ; } } ) ; } }
When just created object is detached to pure pojo it gets temporary id . Real id is assigned only after transaction commit . This method tracks original document intercepts its id change and sets correct id and version into pojo . So it become safe to use such pojo id outside of transaction .
14,473
private static Field findIdField ( final Object value ) { Field res = null ; final Class < ? > type = value . getClass ( ) ; if ( ODatabaseRecordThreadLocal . instance ( ) . isDefined ( ) ) { res = OObjectEntitySerializer . getIdField ( type ) ; } else { final String idField = OObjectSerializerHelper . getObjectIDFieldName ( value ) ; if ( idField != null ) { try { res = type . getDeclaredField ( idField ) ; } catch ( NoSuchFieldException e ) { LOGGER . warn ( String . format ( "Id field '%s' not found in class '%s'." , idField , type . getSimpleName ( ) ) , e ) ; } } } return res ; }
Core orient field resolve method relies on bound connection but it may be required to resolve id outside of transaction . So we use orient method under transaction and do manual scan outside of transaction .
14,474
private static Component getCurrentModal_ ( RootPaneContainer rootPane ) { synchronized ( modals ) { Modal modal = modals . get ( rootPane ) ; if ( modal != null ) { if ( modal . getSize ( ) > 0 ) { return modal . components . get ( modal . components . size ( ) - 1 ) ; } } return null ; } }
Get the current modal component of a specific RootPaneContainer .
14,475
private static void closeCurrentModal_ ( RootPaneContainer rootPane ) { synchronized ( modals ) { Modal modal = modals . get ( rootPane ) ; if ( modal != null ) { modal . closeCurrent ( ) ; if ( modal . getSize ( ) == 0 ) { modals . remove ( rootPane ) ; } } } }
Close the current modal component of a specific RootPaneContainer .
14,476
public static void closeModal ( Component component ) { synchronized ( modals ) { RootPaneContainer frame = null ; Modal modal = null ; Iterator < Entry < RootPaneContainer , Modal > > it = modals . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Entry < RootPaneContainer , Modal > entry = it . next ( ) ; modal = entry . getValue ( ) ; frame = entry . getKey ( ) ; if ( frame != null && modal != null && modal . components . contains ( component ) ) { break ; } else { frame = null ; modal = null ; } } if ( frame != null && modal != null ) { modal . close ( component ) ; if ( modal . getSize ( ) == 0 ) { modals . remove ( frame ) ; } } } }
Close a specific modal component .
14,477
private static void closeAllModals_ ( RootPaneContainer rootPane ) { synchronized ( modals ) { Modal modal = modals . get ( rootPane ) ; if ( modal != null ) { modal . closeAll ( ) ; modals . remove ( rootPane ) ; } } }
Close all modals of a specific RootPaneContainer .
14,478
private static boolean hasModal_ ( RootPaneContainer rootPane ) { synchronized ( modals ) { Modal modal = modals . get ( rootPane ) ; if ( modal != null && modal . getSize ( ) > 0 ) { return true ; } return false ; } }
Indicates whether the RootPaneContainer has a modal .
14,479
private static Modal getModal ( RootPaneContainer rootPane ) { synchronized ( modals ) { Modal modal = modals . get ( rootPane ) ; if ( modal == null ) { modal = new Modal ( rootPane ) ; modals . put ( rootPane , modal ) ; } return modal ; } }
Get the modal of a specific frame
14,480
public static boolean isModal ( Component component ) { synchronized ( modals ) { Iterator < Entry < RootPaneContainer , Modal > > it = modals . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Entry < RootPaneContainer , Modal > entry = it . next ( ) ; if ( entry . getValue ( ) . components . contains ( component ) ) { return true ; } } return false ; } }
Indicates whether the component is a modal component .
14,481
public static void addModal ( JInternalFrame frame , Component component , ModalListener listener ) { addModal_ ( frame , component , listener , defaultModalDepth ) ; }
Add a modal component in the internal frame .
14,482
public static void addModal ( JFrame frame , Component component , ModalListener listener , Integer modalDepth ) { addModal_ ( frame , component , listener , modalDepth ) ; }
Add a modal component in the frame .
14,483
private static void addModal_ ( RootPaneContainer rootPane , Component component , ModalListener listener , Integer modalDepth ) { synchronized ( modals ) { if ( isModal ( component ) == false ) { getModal ( rootPane ) . addModal ( component , listener , modalDepth ) ; } } }
Add a modal component in the RootPaneContainer .
14,484
private static int getModalCount_ ( RootPaneContainer rootPane ) { synchronized ( modals ) { Modal modal = modals . get ( rootPane ) ; if ( modal != null ) { return modal . getSize ( ) ; } return 0 ; } }
Get the modal count of a specific RootPaneContainer .
14,485
private void closeCurrent ( ) { if ( components . size ( ) > 0 ) { Component component = components . remove ( components . size ( ) - 1 ) ; getModalPanel ( ) . removeAll ( ) ; fireCloseActionListener ( listeners . get ( component ) ) ; listeners . remove ( component ) ; if ( components . size ( ) > 0 ) { showNextComponent ( ) ; } else { restoreRootPane ( ) ; } } }
Close the current modal .
14,486
private void close ( Component component ) { if ( components . size ( ) > 0 ) { if ( components . contains ( component ) == false ) { return ; } components . remove ( component ) ; depths . remove ( component ) ; getModalPanel ( ) . removeAll ( ) ; fireCloseActionListener ( listeners . get ( component ) ) ; listeners . remove ( component ) ; if ( components . size ( ) > 0 ) { showNextComponent ( ) ; } else { restoreRootPane ( ) ; } } }
Close a modal
14,487
private void closeAll ( ) { getModalPanel ( ) . removeAll ( ) ; components . clear ( ) ; depths . clear ( ) ; listeners . clear ( ) ; restoreRootPane ( ) ; }
Close all modals .
14,488
private void addModal ( Component component , ModalListener listener , Integer modalDepth ) { if ( modalDepth == null ) { modalDepth = defaultModalDepth ; } if ( components . contains ( component ) == false ) { rootPane . getLayeredPane ( ) . remove ( getModalPanel ( ) ) ; rootPane . getLayeredPane ( ) . add ( getModalPanel ( ) , modalDepth ) ; KeyboardFocusManager focusManager = KeyboardFocusManager . getCurrentKeyboardFocusManager ( ) ; focusManager . clearGlobalFocusOwner ( ) ; getModalPanel ( ) . removeAll ( ) ; getModalPanel ( ) . add ( "" , component ) ; resizeModalPanel ( ) ; getModalPanel ( ) . repaint ( ) ; components . add ( component ) ; depths . put ( component , modalDepth ) ; addListener ( component , listener ) ; } }
Add a modal component
14,489
private ModalPanel getModalPanel ( ) { if ( modalPanel == null ) { modalPanel = new ModalPanel ( ) ; modalPanel . setLayout ( new ModalLayout ( ) ) ; } return modalPanel ; }
Get the transparent modal panel
14,490
public static RootPaneContainer getRootPaneContainer ( Component component ) { if ( component instanceof RootPaneContainer ) { return ( RootPaneContainer ) component ; } for ( Container p = component . getParent ( ) ; p != null ; p = p . getParent ( ) ) { if ( p instanceof RootPaneContainer ) { return ( RootPaneContainer ) p ; } } return null ; }
Get the RootPaneContainer of the specific component .
14,491
public static ResultDescriptor analyzeReturnType ( final DescriptorContext context , final Class < ? extends Collection > returnCollectionType ) { final Method method = context . method ; final MethodGenericsContext generics = context . generics . method ( method ) ; final Class < ? > returnClass = generics . resolveReturnClass ( ) ; final ResultDescriptor descriptor = new ResultDescriptor ( ) ; descriptor . expectType = resolveExpectedType ( returnClass , returnCollectionType ) ; final ResultType type ; final Class < ? > entityClass ; if ( isCollection ( returnClass ) ) { type = COLLECTION ; entityClass = resolveGenericType ( method , generics ) ; } else if ( returnClass . isArray ( ) ) { type = ARRAY ; entityClass = returnClass . getComponentType ( ) ; } else if ( VOID_TYPES . contains ( returnClass ) ) { type = VOID ; entityClass = Void . class ; } else { type = PLAIN ; entityClass = Optionals . isOptional ( returnClass ) ? resolveGenericType ( method , generics ) : returnClass ; } descriptor . returnType = type ; descriptor . entityType = entityClass ; return descriptor ; }
Analyze return type .
14,492
protected void recycleByRenderState ( RecyclerView . Recycler recycler , RenderState renderState ) { if ( renderState . mLayoutDirection == RenderState . LAYOUT_START ) { recycleViewsFromEnd ( recycler , renderState . mScrollingOffset ) ; } else { recycleViewsFromStart ( recycler , renderState . mScrollingOffset ) ; } }
Helper method to call appropriate recycle method depending on current render layout direction
14,493
public static void check ( final Object result , final Class < ? > targetType ) { if ( result != null && ! targetType . isAssignableFrom ( result . getClass ( ) ) ) { throw new ResultConversionException ( String . format ( "Failed to convert %s to %s" , toStringType ( result ) , targetType . getSimpleName ( ) ) ) ; } }
Check converted result compatibility with required type .
14,494
@ SuppressWarnings ( "unchecked" ) public static Object convertToCollection ( final Object result , final Class collectionType , final Class targetEntity , final boolean projection ) { final Object converted ; if ( collectionType . equals ( Iterator . class ) ) { converted = toIterator ( result , targetEntity , projection ) ; } else if ( collectionType . isAssignableFrom ( List . class ) ) { converted = Lists . newArrayList ( toIterator ( result , targetEntity , projection ) ) ; } else if ( collectionType . isAssignableFrom ( Set . class ) ) { converted = Sets . newHashSet ( toIterator ( result , targetEntity , projection ) ) ; } else if ( ! collectionType . isInterface ( ) ) { converted = convertToCollectionImpl ( result , collectionType , targetEntity , projection ) ; } else { throw new ResultConversionException ( String . format ( "Incompatible result type requested %s for conversion from actual result %s" , collectionType , result . getClass ( ) ) ) ; } return converted ; }
Convert result object to collection . In some cases this could be do nothing case because orient already returns collection . If projection is required or when collection type is different from requested type result will be re - packaged into the new collection .
14,495
@ SuppressWarnings ( "PMD.LooseCoupling" ) public static Object convertToArray ( final Object result , final Class entityType , final boolean projection ) { final Collection res = result instanceof Collection ? ( Collection ) result : convertToCollectionImpl ( result , ArrayList . class , entityType , false ) ; final Object array = Array . newInstance ( entityType , res . size ( ) ) ; int i = 0 ; for ( Object obj : res ) { Array . set ( array , i ++ , projection ? applyProjection ( obj , entityType ) : obj ) ; } return array ; }
Convert result object to array .
14,496
public static void check ( final boolean condition , final String message , final Object ... args ) { if ( ! condition ) { throw new SchemeInitializationException ( String . format ( message , args ) ) ; } }
Shortcut to check and throw scheme exception .
14,497
public < T > T doInTransaction ( final TxConfig config , final TxAction < T > action ) { return txTemplate . doInTransaction ( config , action ) ; }
Execute action within transaction .
14,498
public boolean collapsePanel ( ) { if ( mFirstLayout ) { mSlideState = SlideState . COLLAPSED ; return true ; } else { if ( mSlideState == SlideState . HIDDEN || mSlideState == SlideState . COLLAPSED ) return false ; return collapsePanel ( mSlideableView , 0 ) ; } }
Collapse the sliding pane if it is currently slideable . If first layout has already completed this will animate .
14,499
public boolean expandPanel ( float mSlideOffset ) { if ( mSlideableView == null || mSlideState == SlideState . EXPANDED ) return false ; mSlideableView . setVisibility ( View . VISIBLE ) ; return expandPanel ( mSlideableView , 0 , mSlideOffset ) ; }
Partially expand the sliding panel up to a specific offset