idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
12,300 | public static final KeyPressHandler getNumericAndUpperAsciiKeyPressHandler ( ) { if ( HandlerFactory . numericAndUpperAsciiKeyPressHandler == null ) { synchronized ( NumericAndUpperAsciiKeyPressHandler . class ) { if ( HandlerFactory . numericAndUpperAsciiKeyPressHandler == null ) { HandlerFactory . numericAndUpperAsciiKeyPressHandler = new NumericAndUpperAsciiKeyPressHandler ( ) ; } } } return HandlerFactory . numericAndUpperAsciiKeyPressHandler ; } | get a numeric and upper case key press handler . |
12,301 | public static final KeyPressHandler getNumericKeyPressHandler ( ) { if ( HandlerFactory . numericKeyPressHandler == null ) { synchronized ( NumericKeyPressHandler . class ) { if ( HandlerFactory . numericKeyPressHandler == null ) { HandlerFactory . numericKeyPressHandler = new NumericKeyPressHandler ( ) ; } } } return HandlerFactory . numericKeyPressHandler ; } | get a numeric key press handler . |
12,302 | public static final KeyPressHandler getNumericWithSeparatorsKeyPressHandler ( ) { if ( HandlerFactory . numericWsKeyPressHandler == null ) { synchronized ( NumericWithSeparatorsKeyPressHandler . class ) { if ( HandlerFactory . numericWsKeyPressHandler == null ) { HandlerFactory . numericWsKeyPressHandler = new NumericWithSeparatorsKeyPressHandler ( ) ; } } } return HandlerFactory . numericWsKeyPressHandler ; } | get a numeric with separators key press handler . |
12,303 | public static final KeyPressHandler getCurrencyKeyPressHandler ( ) { if ( HandlerFactory . currencyKeyPressHandler == null ) { synchronized ( CurrencyKeyPressHandler . class ) { if ( HandlerFactory . currencyKeyPressHandler == null ) { HandlerFactory . currencyKeyPressHandler = new CurrencyKeyPressHandler ( ) ; } } } return HandlerFactory . currencyKeyPressHandler ; } | get a currency key press handler . |
12,304 | public static final KeyPressHandler getPercentKeyPressHandler ( ) { if ( HandlerFactory . percentKeyPressHandler == null ) { synchronized ( PercentKeyPressHandler . class ) { if ( HandlerFactory . percentKeyPressHandler == null ) { HandlerFactory . percentKeyPressHandler = new PercentKeyPressHandler ( ) ; } } } return HandlerFactory . percentKeyPressHandler ; } | get a percent key press handler . |
12,305 | public static final KeyPressHandler getPhoneNumberKeyPressHandler ( ) { if ( HandlerFactory . phoneNumberKeyPressHandler == null ) { synchronized ( PhoneNumberKeyPressHandler . class ) { if ( HandlerFactory . phoneNumberKeyPressHandler == null ) { HandlerFactory . phoneNumberKeyPressHandler = new PhoneNumberKeyPressHandler ( ) ; } } } return HandlerFactory . phoneNumberKeyPressHandler ; } | get a phone number key press handler . |
12,306 | public static final KeyPressHandler getDecimalKeyPressHandler ( ) { if ( HandlerFactory . decimalKeyPressHandler == null ) { synchronized ( DecimalKeyPressHandler . class ) { if ( HandlerFactory . decimalKeyPressHandler == null ) { HandlerFactory . decimalKeyPressHandler = new DecimalKeyPressHandler ( ) ; } } } return HandlerFactory . decimalKeyPressHandler ; } | get a decimal key press handler . |
12,307 | public static final KeyPressHandler getRegExKeyPressHandler ( final String pregEx ) { if ( StringUtils . isEmpty ( pregEx ) ) { return null ; } RegExKeyPressHandler result = HandlerFactory . REG_EX_KEY_PRESS_HANDLER_MAP . get ( pregEx ) ; if ( result == null ) { result = new RegExKeyPressHandler ( pregEx ) ; } return result ; } | get a key press handler which allows all characters which could match a reg ex . |
12,308 | public static final KeyPressHandler getFilterReplAndFormatStrKeyPressHandler ( ) { if ( HandlerFactory . filReplFormStrKeyPrH == null ) { synchronized ( DecimalKeyPressHandler . class ) { if ( HandlerFactory . filReplFormStrKeyPrH == null ) { HandlerFactory . filReplFormStrKeyPrH = new FilterReplaceAndFormatKeyPressHandler < > ( ) ; } } } return HandlerFactory . filReplFormStrKeyPrH ; } | get a filter replace and format String key press handler . |
12,309 | public static final KeyUpHandler getFormatStrKeyUpHandler ( ) { if ( HandlerFactory . formatStrKeyUpHandler == null ) { synchronized ( DecimalKeyPressHandler . class ) { if ( HandlerFactory . formatStrKeyUpHandler == null ) { HandlerFactory . formatStrKeyUpHandler = new FormatKeyUpHandler < > ( ) ; } } } return HandlerFactory . formatStrKeyUpHandler ; } | get a format key up handler . |
12,310 | public String asString ( ) { final StringBuilder builder = new StringBuilder ( ) ; boolean first = true ; for ( int i = 1 ; i < this . nodeList . size ( ) ; i ++ ) { final NodeImpl nodeImpl = ( NodeImpl ) this . nodeList . get ( i ) ; final String name = nodeImpl . asString ( ) ; if ( name . isEmpty ( ) ) { continue ; } if ( ! first ) { builder . append ( PROPERTY_PATH_SEPARATOR ) ; } builder . append ( nodeImpl . asString ( ) ) ; first = false ; } return builder . toString ( ) ; } | serialize as string . |
12,311 | public < T extends BaseProxy > T create ( final Class < T > clazz ) { this . checkLocked ( ) ; final SimpleProxyId < T > id = this . state . requestFactory . allocateId ( clazz ) ; final AutoBean < T > created = this . createProxy ( clazz , id , false ) ; return this . takeOwnership ( created ) ; } | Create a new object with an ephemeral id . |
12,312 | public < T extends BaseProxy > T editProxy ( final T object ) { AutoBean < T > bean = this . checkStreamsNotCrossed ( object ) ; this . checkLocked ( ) ; @ SuppressWarnings ( "unchecked" ) final AutoBean < T > previouslySeen = ( AutoBean < T > ) this . state . editedProxies . get ( BaseProxyCategory . stableId ( bean ) ) ; if ( previouslySeen != null && ! previouslySeen . isFrozen ( ) ) { return previouslySeen . as ( ) ; } final AutoBean < T > parent = bean ; bean = this . cloneBeanAndCollections ( bean ) ; bean . setTag ( Constants . PARENT_OBJECT , parent ) ; return bean . as ( ) ; } | Take ownership of a proxy instance and make it editable . |
12,313 | public void fire ( ) { boolean needsReceiver = true ; for ( final AbstractRequest < ? , ? > request : this . state . invocations ) { if ( request . hasReceiver ( ) ) { needsReceiver = false ; break ; } } if ( needsReceiver ) { this . doFire ( new Receiver < Void > ( ) { public void onSuccess ( final Void response ) { } } ) ; } else { this . doFire ( null ) ; } } | Make sure there s a default receiver so errors don t get dropped . This behavior should be revisited when chaining is supported depending on whether or not chained invocations can fail independently . |
12,314 | protected < T extends BaseProxy > AutoBean < T > createProxy ( final Class < T > clazz , final SimpleProxyId < T > id , final boolean useAppendedContexts ) { AutoBean < T > created = null ; if ( useAppendedContexts ) { for ( final AbstractRequestContext ctx : this . state . appendedContexts ) { created = ctx . getAutoBeanFactory ( ) . create ( clazz ) ; if ( created != null ) { break ; } } } else { created = this . getAutoBeanFactory ( ) . create ( clazz ) ; } if ( created != null ) { created . setTag ( STABLE_ID , id ) ; return created ; } throw new IllegalArgumentException ( "Unknown proxy type " + clazz . getName ( ) ) ; } | Creates a new proxy with an assigned ID . |
12,315 | SimpleProxyId < BaseProxy > getId ( final IdMessage op ) { if ( Strength . SYNTHETIC . equals ( op . getStrength ( ) ) ) { return this . allocateSyntheticId ( op . getTypeToken ( ) , op . getSyntheticId ( ) ) ; } return this . state . requestFactory . getId ( op . getTypeToken ( ) , op . getServerId ( ) , op . getClientId ( ) ) ; } | Resolves an IdMessage into an SimpleProxyId . |
12,316 | < Q extends BaseProxy > AutoBean < Q > getProxyForReturnPayloadGraph ( final SimpleProxyId < Q > id ) { @ SuppressWarnings ( "unchecked" ) AutoBean < Q > bean = ( AutoBean < Q > ) this . state . returnedProxies . get ( id ) ; if ( bean == null ) { final Class < Q > proxyClass = id . getProxyClass ( ) ; bean = this . createProxy ( proxyClass , id , true ) ; this . state . returnedProxies . put ( id , bean ) ; } return bean ; } | Creates or retrieves a new canonical AutoBean to represent the given id in the returned payload . |
12,317 | AutoBean < OperationMessage > makeOperationMessage ( final SimpleProxyId < BaseProxy > stableId , final AutoBean < ? > proxyBean , final boolean useDelta ) { final AutoBean < OperationMessage > toReturn = MessageFactoryHolder . FACTORY . operation ( ) ; final OperationMessage operation = toReturn . as ( ) ; operation . setTypeToken ( this . state . requestFactory . getTypeToken ( stableId . getProxyClass ( ) ) ) ; AutoBean < ? > parent ; if ( stableId . isEphemeral ( ) ) { parent = this . createProxy ( stableId . getProxyClass ( ) , stableId , true ) ; operation . setOperation ( WriteOperation . PERSIST ) ; operation . setClientId ( stableId . getClientId ( ) ) ; operation . setStrength ( Strength . EPHEMERAL ) ; } else if ( stableId . isSynthetic ( ) ) { parent = this . createProxy ( stableId . getProxyClass ( ) , stableId , true ) ; operation . setOperation ( WriteOperation . PERSIST ) ; operation . setSyntheticId ( stableId . getSyntheticId ( ) ) ; operation . setStrength ( Strength . SYNTHETIC ) ; } else { parent = proxyBean . getTag ( Constants . PARENT_OBJECT ) ; operation . setServerId ( stableId . getServerId ( ) ) ; operation . setOperation ( WriteOperation . UPDATE ) ; } assert ! useDelta || parent != null ; final String version = proxyBean . getTag ( Constants . VERSION_PROPERTY_B64 ) ; if ( version != null ) { operation . setVersion ( version ) ; } Map < String , Object > diff = Collections . emptyMap ( ) ; if ( this . isEntityType ( stableId . getProxyClass ( ) ) ) { diff = useDelta ? AutoBeanUtils . diff ( parent , proxyBean ) : AutoBeanUtils . getAllProperties ( proxyBean ) ; } else if ( this . isValueType ( stableId . getProxyClass ( ) ) ) { diff = AutoBeanUtils . getAllProperties ( proxyBean ) ; } if ( ! diff . isEmpty ( ) ) { final Map < String , Splittable > propertyMap = new HashMap < > ( ) ; for ( final Map . Entry < String , Object > entry : diff . entrySet ( ) ) { propertyMap . put ( entry . getKey ( ) , EntityCodex . encode ( this , entry . getValue ( ) ) ) ; } operation . setPropertyMap ( propertyMap ) ; } return toReturn ; } | Create a single OperationMessage that encapsulates the state of a proxy AutoBean . |
12,318 | < Q extends BaseProxy > Q processReturnOperation ( final SimpleProxyId < Q > id , final OperationMessage op , final WriteOperation ... operations ) { final AutoBean < Q > toMutate = this . getProxyForReturnPayloadGraph ( id ) ; toMutate . setTag ( Constants . VERSION_PROPERTY_B64 , op . getVersion ( ) ) ; final Map < String , Splittable > properties = op . getPropertyMap ( ) ; if ( properties != null ) { toMutate . accept ( new AutoBeanVisitor ( ) { public boolean visitReferenceProperty ( final String propertyName , final AutoBean < ? > value , final PropertyContext ctx ) { if ( ctx . canSet ( ) ) { if ( properties . containsKey ( propertyName ) ) { final Splittable raw = properties . get ( propertyName ) ; Object decoded = null ; if ( ctx . getType ( ) == Map . class ) { final MapPropertyContext mapCtx = ( MapPropertyContext ) ctx ; final Class < ? > keyType = mapCtx . getKeyType ( ) ; final Class < ? > valueType = mapCtx . getValueType ( ) ; decoded = EntityCodex . decode ( AbstractRequestContext . this , mapCtx . getType ( ) , keyType , valueType , raw ) ; } else { final Class < ? > elementType = ctx instanceof CollectionPropertyContext ? ( ( CollectionPropertyContext ) ctx ) . getElementType ( ) : null ; decoded = EntityCodex . decode ( AbstractRequestContext . this , ctx . getType ( ) , elementType , raw ) ; } ctx . set ( decoded ) ; } } return false ; } public boolean visitValueProperty ( final String propertyName , final Object value , final PropertyContext ctx ) { if ( ctx . canSet ( ) ) { if ( properties . containsKey ( propertyName ) ) { final Splittable raw = properties . get ( propertyName ) ; Object decoded = ValueCodex . decode ( ctx . getType ( ) , raw ) ; if ( decoded != null && Date . class . equals ( ctx . getType ( ) ) ) { decoded = new DatePoser ( ( Date ) decoded ) ; } ctx . set ( decoded ) ; } } return false ; } } ) ; } this . makeImmutable ( toMutate ) ; final Q proxy = toMutate . as ( ) ; if ( operations != null && this . state . requestFactory . isEntityType ( id . getProxyClass ( ) ) ) { for ( final WriteOperation writeOperation : operations ) { if ( writeOperation . equals ( WriteOperation . UPDATE ) && ! this . state . requestFactory . hasVersionChanged ( id , op . getVersion ( ) ) ) { continue ; } this . state . requestFactory . getEventBus ( ) . fireEventFromSource ( new EntityProxyChange < > ( ( EntityProxy ) proxy , writeOperation ) , id . getProxyClass ( ) ) ; } } return proxy ; } | Create a new EntityProxy from a snapshot in the return payload . |
12,319 | private < Q extends BaseProxy > SimpleProxyId < Q > allocateSyntheticId ( final String typeToken , final int syntheticId ) { @ SuppressWarnings ( "unchecked" ) SimpleProxyId < Q > toReturn = ( SimpleProxyId < Q > ) this . state . syntheticIds . get ( syntheticId ) ; if ( toReturn == null ) { toReturn = this . state . requestFactory . allocateId ( this . state . requestFactory . < Q > getTypeFromToken ( typeToken ) ) ; this . state . syntheticIds . put ( syntheticId , toReturn ) ; } return toReturn ; } | Get - or - create method for synthetic ids . |
12,320 | private < T > AutoBean < T > checkStreamsNotCrossed ( final T object ) { final AutoBean < T > bean = AutoBeanUtils . getAutoBean ( object ) ; if ( bean == null ) { throw new IllegalArgumentException ( object . getClass ( ) . getName ( ) ) ; } final State otherState = bean . getTag ( REQUEST_CONTEXT_STATE ) ; if ( ! bean . isFrozen ( ) && otherState != this . state ) { assert otherState != null : "Unfrozen bean with null RequestContext" ; throw new IllegalArgumentException ( "Attempting to edit an EntityProxy" + " previously edited by another RequestContext" ) ; } return bean ; } | This method checks that a proxy object is either immutable or already edited by this context . |
12,321 | private void freezeEntities ( final boolean frozen ) { for ( final AutoBean < ? > bean : this . state . editedProxies . values ( ) ) { bean . setFrozen ( frozen ) ; } } | Set the frozen status of all EntityProxies owned by this context . |
12,322 | private void makeImmutable ( final AutoBean < ? extends BaseProxy > toMutate ) { toMutate . setTag ( Constants . PARENT_OBJECT , toMutate ) ; toMutate . setTag ( REQUEST_CONTEXT_STATE , null ) ; toMutate . setFrozen ( true ) ; } | Make an EntityProxy immutable . |
12,323 | private List < InvocationMessage > makePayloadInvocations ( ) { final MessageFactory f = MessageFactoryHolder . FACTORY ; final List < InvocationMessage > invocationMessages = new ArrayList < > ( ) ; for ( final AbstractRequest < ? , ? > invocation : this . state . invocations ) { final RequestData data = invocation . getRequestData ( ) ; final InvocationMessage message = f . invocation ( ) . as ( ) ; message . setOperation ( data . getOperation ( ) ) ; final Set < String > refsToSend = data . getPropertyRefs ( ) ; if ( ! refsToSend . isEmpty ( ) ) { message . setPropertyRefs ( refsToSend ) ; } final List < Splittable > parameters = new ArrayList < > ( data . getOrderedParameters ( ) . length ) ; for ( final Object param : data . getOrderedParameters ( ) ) { parameters . add ( EntityCodex . encode ( this , param ) ) ; } if ( ! parameters . isEmpty ( ) ) { message . setParameters ( parameters ) ; } invocationMessages . add ( message ) ; } return invocationMessages ; } | Create an InvocationMessage for each remote method call being made by the context . |
12,324 | private void processReturnOperations ( final ResponseMessage response ) { final List < OperationMessage > ops = response . getOperations ( ) ; if ( ops == null ) { return ; } for ( final OperationMessage op : ops ) { final SimpleProxyId < ? > id = this . getId ( op ) ; WriteOperation [ ] toPropagate = null ; final WriteOperation effect = op . getOperation ( ) ; if ( effect != null ) { switch ( effect ) { case DELETE : toPropagate = DELETE_ONLY ; break ; case PERSIST : toPropagate = PERSIST_AND_UPDATE ; break ; case UPDATE : toPropagate = UPDATE_ONLY ; break ; default : throw new RuntimeException ( effect . toString ( ) ) ; } } this . processReturnOperation ( id , op , toPropagate ) ; } assert this . state . returnedProxies . size ( ) == ops . size ( ) ; } | Process an array of OperationMessages . |
12,325 | private void retainArg ( final Object arg ) { if ( arg instanceof Iterable < ? > ) { for ( final Object o : ( Iterable < ? > ) arg ) { this . retainArg ( o ) ; } } else if ( arg instanceof BaseProxy ) { this . edit ( ( BaseProxy ) arg ) ; } } | Ensures that any method arguments are retained in the context s sphere of influence . |
12,326 | private < T extends BaseProxy > T takeOwnership ( final AutoBean < T > bean ) { this . state . editedProxies . put ( stableId ( bean ) , bean ) ; bean . setTag ( REQUEST_CONTEXT_STATE , this . state ) ; return bean . as ( ) ; } | Make the EnityProxy bean edited and owned by this RequestContext . |
12,327 | public void showErrors ( final Set < String > messages ) { final InputElement inputElement = this . getInputElement ( ) ; if ( messages . isEmpty ( ) ) { if ( FeatureCheck . supportCustomValidity ( inputElement ) ) { inputElement . setCustomValidity ( StringUtils . EMPTY ) ; } if ( this . validationMessageElement == null ) { inputElement . setTitle ( StringUtils . EMPTY ) ; } else { this . validationMessageElement . getElement ( ) . removeAllChildren ( ) ; } } else { final String messagesAsString = ErrorMessageFormater . messagesToString ( messages ) ; if ( FeatureCheck . supportCustomValidity ( inputElement ) ) { inputElement . setCustomValidity ( messagesAsString ) ; } if ( this . validationMessageElement == null ) { inputElement . setTitle ( messagesAsString ) ; } else { this . validationMessageElement . getElement ( ) . setInnerSafeHtml ( ErrorMessageFormater . messagesToList ( messages ) ) ; } } } | show error messages . |
12,328 | public void readSessionData ( ) { this . dispatcher . execute ( this . userService . isCurrentUserLoggedIn ( ) , new AbstractSimpleRestCallback < GwtpSpringSession < T > , Boolean , HttpMessages > ( this , this ) { public void onSuccess ( final Boolean presult ) { if ( BooleanUtils . isTrue ( presult ) ) { GwtpSpringSession . this . dispatcher . execute ( GwtpSpringSession . this . userService . getCurrentUser ( ) , new AbstractSimpleRestCallback < GwtpSpringSession < T > , T , HttpMessages > ( GwtpSpringSession . this , GwtpSpringSession . this ) { public void onSuccess ( final T presult ) { GwtpSpringSession . this . setUser ( presult ) ; } } ) ; } else { GwtpSpringSession . this . setUser ( null ) ; } } } ) ; } | read session data . |
12,329 | @ GwtIncompatible ( "incompatible method" ) @ SuppressWarnings ( "unchecked" ) public static < T > T findValueOfType ( final Collection < ? > collection , final Class < T > type ) { if ( CollectionUtils . isEmpty ( collection ) ) { return null ; } T value = null ; for ( final Object element : collection ) { if ( type == null || type . isInstance ( element ) ) { if ( value != null ) { return null ; } value = ( T ) element ; } } return value ; } | Find a single value of the given type in the given Collection . |
12,330 | public static < T > T lastElement ( final List < T > list ) { if ( CollectionUtils . isEmpty ( list ) ) { return null ; } return list . get ( list . size ( ) - 1 ) ; } | Retrieve the last element of the given List accessing the highest index . |
12,331 | @ SuppressWarnings ( "unchecked" ) public static < K , V > MultiValueMap < K , V > unmodifiableMultiValueMap ( final MultiValueMap < ? extends K , ? extends V > map ) { Assert . notNull ( map , "'map' must not be null" ) ; final Map < K , List < V > > result = new LinkedHashMap < > ( map . size ( ) ) ; map . forEach ( ( key , value ) -> { final List < ? extends V > values = Collections . unmodifiableList ( value ) ; result . put ( key , ( List < V > ) values ) ; } ) ; final Map < K , List < V > > unmodifiableMap = Collections . unmodifiableMap ( result ) ; return CollectionUtils . toMultiValueMap ( unmodifiableMap ) ; } | Return an unmodifiable view of the specified multi - value map . |
12,332 | BeanHelper createHelper ( final JClassType pjtype , final TreeLogger plogger , final GeneratorContext pcontext ) throws UnableToCompleteException { final JClassType erasedType = pjtype . getErasedType ( ) ; try { final Class < ? > clazz = Class . forName ( erasedType . getQualifiedBinaryName ( ) ) ; return doCreateHelper ( clazz , erasedType , plogger , pcontext ) ; } catch ( final ClassNotFoundException e ) { plogger . log ( TreeLogger . ERROR , "Unable to create BeanHelper for " + erasedType , e ) ; throw new UnableToCompleteException ( ) ; } } | Creates a BeanHelper and writes an interface containing its instance . Also recursively creates any BeanHelpers on its constrained properties . |
12,333 | private void doCreateHelperForProp ( final PropertyDescriptor propertyDescriptor , final BeanHelper parent , final TreeLogger logger , final GeneratorContext context ) throws UnableToCompleteException { final Class < ? > elementClass = propertyDescriptor . getElementClass ( ) ; if ( GwtSpecificValidatorCreator . isIterableOrMap ( elementClass ) ) { if ( parent . hasField ( propertyDescriptor ) ) { final JClassType type = parent . getAssociationType ( propertyDescriptor , true ) ; this . createHelper ( type . getErasedType ( ) , logger , context ) ; } if ( parent . hasGetter ( propertyDescriptor ) ) { final JClassType type = parent . getAssociationType ( propertyDescriptor , false ) ; this . createHelper ( type . getErasedType ( ) , logger , context ) ; } } else { if ( serverSideValidator . getConstraintsForClass ( elementClass ) . isBeanConstrained ( ) ) { this . createHelper ( elementClass , logger , context ) ; } } } | Creates the appropriate BeanHelper for a property on a bean . |
12,334 | private void generateMapRecursive ( final List < NavigationEntryInterface > pnavigationEntries ) { for ( final NavigationEntryInterface entryToAdd : pnavigationEntries ) { String token = entryToAdd . getToken ( ) ; if ( entryToAdd . getMenuValue ( ) != null && token != null ) { if ( token . endsWith ( "/" + StringUtils . removeStart ( loginToken , "/" ) ) ) { token = loginToken ; } if ( ! placeMap . containsKey ( token ) ) { placeMap . put ( token , entryToAdd ) ; } } if ( entryToAdd instanceof NavigationEntryFolder ) { generateMapRecursive ( ( ( NavigationEntryFolder ) entryToAdd ) . getSubEntries ( ) ) ; } } } | create map out of the navigation list . |
12,335 | private List < NavigationEntryInterface > recursiveGetEntries ( final List < NavigationEntryInterface > pnavigationEntries ) { if ( pnavigationEntries == null ) { return Collections . emptyList ( ) ; } return pnavigationEntries . stream ( ) . filter ( entry -> entry . canReveal ( ) ) . map ( entry -> { if ( entry instanceof NavigationEntryFolder ) { return new NavigationEntryFolder ( entry . getMenuValue ( ) , entry . isOpenOnStartup ( ) , recursiveGetEntries ( ( ( NavigationEntryFolder ) entry ) . getSubEntries ( ) ) ) ; } else { return entry ; } } ) . collect ( Collectors . toList ( ) ) ; } | get all navigation entries that can be displayed by a given user . |
12,336 | public static < T > ConstraintViolation < T > forReturnValueValidation ( final String messageTemplate , final Map < String , Object > messageParameters , final Map < String , Object > expressionVariables , final String interpolatedMessage , final Class < T > rootBeanClass , final T rootBean , final Object leafBeanInstance , final Object value , final Path propertyPath , final ConstraintDescriptor < ? > constraintDescriptor , final ElementType elementType , final Object executableReturnValue , final Object dynamicPayload ) { return new ConstraintViolationImpl < > ( messageTemplate , messageParameters , expressionVariables , interpolatedMessage , rootBeanClass , rootBean , leafBeanInstance , value , propertyPath , constraintDescriptor , elementType , null , executableReturnValue , dynamicPayload ) ; } | create ConstraintViolation for return value validation . |
12,337 | private int createHashCode ( ) { return Objects . hash ( this . interpolatedMessage , this . propertyPath , this . rootBean , this . leafBeanInstance , this . value , this . constraintDescriptor , this . messageTemplate , this . elementType ) ; } | create hash code . |
12,338 | private void initFromAttributes ( Context context , AttributeSet attrs , int defStyleAttr , int defStyleRes ) { TypedArray a = context . obtainStyledAttributes ( attrs , R . styleable . JCropImageView , defStyleAttr , defStyleRes ) ; mCropType = a . getInt ( R . styleable . JCropImageView_cropType , mCropType ) ; mCropAlign = a . getInt ( R . styleable . JCropImageView_cropAlign , mCropAlign ) ; a . recycle ( ) ; setCropType ( mCropType ) ; } | Initialize the attributes for JCropImageView |
12,339 | public void await ( long timeout , TimeUnit unit ) throws InterruptedException , TimeoutException { if ( ! latch . await ( timeout , unit ) ) { throw new TimeoutException ( ) ; } } | Waits for the CallFuture to complete without returning the result . |
12,340 | public static < T > HashSet < T > newHashSet ( final Iterable < ? extends T > iterable ) { final HashSet < T > set = newHashSet ( ) ; for ( final T t : iterable ) { set . add ( t ) ; } return set ; } | new has set from iterable . |
12,341 | public static < T > ArrayList < T > newArrayList ( final Iterable < T > ... iterables ) { final ArrayList < T > resultList = newArrayList ( ) ; for ( final Iterable < T > oneIterable : iterables ) { for ( final T oneElement : oneIterable ) { resultList . add ( oneElement ) ; } } return resultList ; } | new array list from iterable . |
12,342 | public static < T > List < T > toImmutableList ( final List < ? extends T > list ) { switch ( list . size ( ) ) { case 0 : return Collections . emptyList ( ) ; case 1 : return Collections . singletonList ( list . get ( 0 ) ) ; default : return Collections . unmodifiableList ( list ) ; } } | list to imuteable list . |
12,343 | public static < T > Set < T > toImmutableSet ( final Set < ? extends T > set ) { switch ( set . size ( ) ) { case 0 : return Collections . emptySet ( ) ; case 1 : return Collections . singleton ( set . iterator ( ) . next ( ) ) ; default : return Collections . unmodifiableSet ( set ) ; } } | list to imuteable set . |
12,344 | public static < K , V > Map < K , V > toImmutableMap ( final Map < K , V > map ) { switch ( map . size ( ) ) { case 0 : return Collections . emptyMap ( ) ; case 1 : final Entry < K , V > entry = map . entrySet ( ) . iterator ( ) . next ( ) ; return Collections . singletonMap ( entry . getKey ( ) , entry . getValue ( ) ) ; default : return Collections . unmodifiableMap ( map ) ; } } | list to imuteable map . |
12,345 | protected static PhoneCountryConstantsImpl createPhoneCountryConstants ( final Locale plocale ) { final Map < String , String > phoneCountryNames = CreatePhoneCountryConstantsClass . readPhoneCountryNames ( plocale ) ; final Map < String , String > phoneCountryCodes = CreatePhoneCountryConstantsClass . readPhoneCountryCodes ( plocale ) ; final Set < PhoneCountryCodeData > countryCodeData = readPhoneCountryProperties ( plocale , phoneCountryNames , phoneCountryCodes ) ; return new PhoneCountryConstantsImpl ( countryCodeData , createMapFromPhoneCountry ( plocale , countryCodeData , phoneCountryNames , phoneCountryCodes ) ) ; } | NOPMD can t include abstract static methods |
12,346 | public static String RToSqlUdf ( List < String > RExps , List < String > selectedColumns , List < Column > existingColumns ) { List < String > udfs = Lists . newArrayList ( ) ; Map < String , String > newColToDef = new HashMap < String , String > ( ) ; boolean updateOnConflict = ( selectedColumns == null || selectedColumns . isEmpty ( ) ) ; String dupColExp = "%s duplicates another column name" ; if ( updateOnConflict ) { if ( existingColumns != null && ! existingColumns . isEmpty ( ) ) { for ( Column c : existingColumns ) { udfs . add ( c . getName ( ) ) ; } } } else { for ( String c : selectedColumns ) { udfs . add ( c ) ; } } Set < String > newColsInRExp = new HashSet < String > ( ) ; for ( String str : RExps ) { int index = str . indexOf ( "=" ) > str . indexOf ( "~" ) ? str . indexOf ( "=" ) : str . indexOf ( "~" ) ; String [ ] udf = new String [ 2 ] ; if ( index == - 1 ) { udf [ 0 ] = str ; } else { udf [ 0 ] = str . substring ( 0 , index ) ; udf [ 1 ] = str . substring ( index + 1 ) ; } String newCol = ( index != - 1 ) ? udf [ 0 ] . trim ( ) . replaceAll ( "\\W" , "" ) : udf [ 0 ] . trim ( ) ; if ( newColsInRExp . contains ( newCol ) ) { throw new RuntimeException ( String . format ( dupColExp , newCol ) ) ; } String newDef = ( index != - 1 ) ? udf [ 1 ] . trim ( ) : null ; if ( ! udfs . contains ( newCol ) ) { udfs . add ( newCol ) ; } else if ( ! updateOnConflict ) { throw new RuntimeException ( String . format ( dupColExp , newCol ) ) ; } if ( newDef != null && ! newDef . isEmpty ( ) ) { newColToDef . put ( newCol . replaceAll ( "\\W" , "" ) , newDef ) ; } newColsInRExp . add ( newCol ) ; } String selectStr = "" ; for ( String udf : udfs ) { String exp = newColToDef . containsKey ( udf ) ? String . format ( "%s as %s" , newColToDef . get ( udf ) , udf ) : String . format ( "%s" , udf ) ; selectStr += ( exp + "," ) ; } return selectStr . substring ( 0 , selectStr . length ( ) - 1 ) ; } | Parse R transform expression to Hive equivalent |
12,347 | public static List < String > getCurrentRevisionIDs ( Document doc ) throws ForestException { List < String > currentRevIDs = new ArrayList < String > ( ) ; do { currentRevIDs . add ( doc . getSelectedRevID ( ) ) ; } while ( doc . selectNextLeaf ( false , false ) ) ; return currentRevIDs ; } | Not include deleted leaf node |
12,348 | public final void addSubEntries ( final Collection < NavigationEntryInterface > psubEntries ) { if ( ! CollectionUtils . isEmpty ( psubEntries ) ) { subEntries . addAll ( psubEntries ) ; subEntries . forEach ( subEntry -> subEntry . setParentEntry ( this ) ) ; } } | add a menu sub entries . |
12,349 | public static Locale convertLanguageToLocale ( final String planguage ) { final Locale locale ; if ( planguage == null ) { locale = null ; } else { final String localeStringUp = planguage . toUpperCase ( ) . replace ( '-' , '_' ) ; if ( LocaleUtil . DEFAULT_MAP . containsKey ( localeStringUp ) ) { locale = LocaleUtil . DEFAULT_MAP . get ( localeStringUp ) ; } else if ( localeStringUp . contains ( "_" ) ) { final String [ ] lcoaleSplitted = localeStringUp . split ( "_" ) ; if ( lcoaleSplitted . length > 2 ) { locale = new Locale ( lcoaleSplitted [ 0 ] . toLowerCase ( ) , lcoaleSplitted [ 1 ] , lcoaleSplitted [ 2 ] ) ; } else { locale = new Locale ( lcoaleSplitted [ 0 ] . toLowerCase ( ) , lcoaleSplitted [ 1 ] ) ; } } else { locale = new Locale ( planguage ) ; } } return locale ; } | convert language string to Locale . |
12,350 | public static String locateDirectory ( String dirName ) throws IOException { if ( Utils . dirExists ( dirName ) ) return dirName ; String path = null ; String curDir = new File ( "." ) . getCanonicalPath ( ) ; for ( int i = 0 ; i < 10 ; i ++ ) { path = String . format ( "%s/%s" , curDir , dirName ) ; if ( Utils . dirExists ( path ) ) break ; curDir = String . format ( "%s/.." , curDir ) ; } if ( path != null ) { File file = new File ( path ) ; path = file . getCanonicalPath ( ) ; if ( ! Utils . dirExists ( path ) ) path = null ; } return path ; } | Locates the given dirName as a full path in the current directory or in successively higher parent directory above . |
12,351 | public static String getBankNumberOfIban ( final String pstring ) { final String compressedIban = ibanCompress ( pstring ) ; final String country = StringUtils . substring ( compressedIban , 0 , 2 ) ; final IbanLengthDefinition length = IBAN_LENGTH_MAP . ibanLengths ( ) . get ( country ) ; return length == null ? null : StringUtils . substring ( compressedIban , length . getBankNumberStart ( ) , length . getBankNumberEnd ( ) ) ; } | get bank number of iban . |
12,352 | public static String getAccountNumberOfIban ( final String pstring ) { final String compressedIban = ibanCompress ( pstring ) ; final String country = StringUtils . substring ( compressedIban , 0 , 2 ) ; final IbanLengthDefinition length = IBAN_LENGTH_MAP . ibanLengths ( ) . get ( country ) ; return length == null ? null : StringUtils . substring ( compressedIban , length . getAccountNumberStart ( ) , length . getAccountNumberEnd ( ) ) ; } | get account number of iban . |
12,353 | public static String getBicOfIban ( final String pstring ) { final String country = StringUtils . substring ( pstring , 0 , 2 ) ; final String bankNumber = getBankNumberOfIban ( pstring ) ; return BANK_ACCOINT_BIC_MAP . bankAccounts ( ) . get ( new CountryBankAccountData ( country , bankNumber ) ) ; } | get bic of iban . |
12,354 | protected void addURL ( final URL url ) { final URL [ ] newUrls = new URL [ this . urls . length + 1 ] ; System . arraycopy ( url , 0 , newUrls , 0 , this . urls . length ) ; newUrls [ this . urls . length ] = url ; this . urls = newUrls ; } | Included here so attempts at reflection succeed |
12,355 | public static String asLiteral ( final Object value ) throws IllegalArgumentException { final Class < ? > clazz = value . getClass ( ) ; if ( clazz . isArray ( ) ) { final StringBuilder sb = new StringBuilder ( ) ; final Object [ ] array = ( Object [ ] ) value ; sb . append ( "new " + clazz . getComponentType ( ) . getCanonicalName ( ) + "[] {" ) ; boolean first = true ; for ( final Object object : array ) { if ( first ) { first = false ; } else { sb . append ( ',' ) ; } sb . append ( asLiteral ( object ) ) ; } sb . append ( '}' ) ; return sb . toString ( ) ; } if ( value instanceof Boolean ) { return JBooleanLiteral . get ( ( ( Boolean ) value ) . booleanValue ( ) ) . toSource ( ) ; } else if ( value instanceof Byte ) { return JIntLiteral . get ( ( ( Byte ) value ) . byteValue ( ) ) . toSource ( ) ; } else if ( value instanceof Character ) { return JCharLiteral . get ( ( ( Character ) value ) . charValue ( ) ) . toSource ( ) ; } else if ( value instanceof Class < ? > ) { return ( ( Class < ? > ) ( Class < ? > ) value ) . getCanonicalName ( ) + ".class" ; } else if ( value instanceof Double ) { return JDoubleLiteral . get ( ( ( Double ) value ) . doubleValue ( ) ) . toSource ( ) ; } else if ( value instanceof Enum ) { return value . getClass ( ) . getCanonicalName ( ) + "." + ( ( Enum < ? > ) value ) . name ( ) ; } else if ( value instanceof Float ) { return JFloatLiteral . get ( ( ( Float ) value ) . floatValue ( ) ) . toSource ( ) ; } else if ( value instanceof Integer ) { return JIntLiteral . get ( ( ( Integer ) value ) . intValue ( ) ) . toSource ( ) ; } else if ( value instanceof Long ) { return JLongLiteral . get ( ( ( Long ) value ) . longValue ( ) ) . toSource ( ) ; } else if ( value instanceof String ) { return '"' + Generator . escape ( ( String ) value ) + '"' ; } else { throw new IllegalArgumentException ( value . getClass ( ) + " can not be represented as a Java Literal." ) ; } } | Returns the literal value of an object that is suitable for inclusion in Java Source code . |
12,356 | public static boolean isIterableOrMap ( final Class < ? > elementClass ) { return elementClass . isArray ( ) || Iterable . class . isAssignableFrom ( elementClass ) || Map . class . isAssignableFrom ( elementClass ) ; } | check if elementClass is iterable . |
12,357 | static < T extends Annotation > Class < ? > getTypeOfConstraintValidator ( final Class < ? extends ConstraintValidator < T , ? > > constraintClass ) { int candidateCount = 0 ; Class < ? > result = null ; for ( final Method method : constraintClass . getMethods ( ) ) { if ( method . getName ( ) . equals ( "isValid" ) && method . getParameterTypes ( ) . length == 2 && method . getReturnType ( ) . isAssignableFrom ( Boolean . TYPE ) ) { final Class < ? > firstArgType = method . getParameterTypes ( ) [ 0 ] ; if ( result == null || result . isAssignableFrom ( firstArgType ) ) { result = firstArgType ; } candidateCount ++ ; } } if ( candidateCount == 0 ) { throw new IllegalStateException ( "ConstraintValidators must have a isValid method" ) ; } else if ( candidateCount > 2 ) { throw new IllegalStateException ( "ConstraintValidators must have no more than two isValid methods" ) ; } return result ; } | Finds the type that a constraint validator will check . |
12,358 | private void writeValidatorCall ( final SourceWriter sw , final Class < ? > type , final Stage stage , final PropertyDescriptor ppropertyDescription , final boolean expandDefaultGroupSequence , final String groupsVarName ) throws UnableToCompleteException { if ( cache . isClassConstrained ( type ) && ! isIterableOrMap ( type ) ) { final BeanHelper helper = this . createBeanHelper ( type ) ; beansToValidate . add ( helper ) ; switch ( stage ) { case OBJECT : sw . print ( helper . getValidatorInstanceName ( ) ) ; if ( expandDefaultGroupSequence ) { sw . println ( ".expandDefaultAndValidateClassGroups(context, object, violations, " + groupsVarName + ");" ) ; } else { sw . println ( ".validateClassGroups(context, object, violations, " + groupsVarName + ");" ) ; } break ; case PROPERTY : if ( this . isPropertyConstrained ( helper , ppropertyDescription ) ) { sw . print ( helper . getValidatorInstanceName ( ) ) ; sw . print ( ".validatePropertyGroups(context, object," ) ; sw . println ( " propertyName, violations, " + groupsVarName + ");" ) ; } break ; case VALUE : if ( this . isPropertyConstrained ( helper , ppropertyDescription ) ) { sw . print ( helper . getValidatorInstanceName ( ) ) ; sw . print ( ".validateValueGroups(context, " ) ; sw . print ( helper . getTypeCanonicalName ( ) ) ; sw . println ( ".class, propertyName, value, violations, " + groupsVarName + ");" ) ; } break ; default : throw new IllegalStateException ( ) ; } } } | write validator call . |
12,359 | public static boolean containsElement ( final Object [ ] array , final Object element ) { if ( array == null ) { return false ; } for ( final Object arrayEle : array ) { if ( ObjectUtils . nullSafeEquals ( arrayEle , element ) ) { return true ; } } return false ; } | Check whether the given array contains the given element . |
12,360 | public static boolean containsConstant ( final Enum < ? > [ ] enumValues , final String constant ) { return ObjectUtils . containsConstant ( enumValues , constant , false ) ; } | Check whether the given array of enum constants contains a constant with the given name ignoring case when determining a match . |
12,361 | public static boolean containsConstant ( final Enum < ? > [ ] enumValues , final String constant , final boolean caseSensitive ) { for ( final Enum < ? > candidate : enumValues ) { if ( caseSensitive ? candidate . toString ( ) . equals ( constant ) : candidate . toString ( ) . equalsIgnoreCase ( constant ) ) { return true ; } } return false ; } | Check whether the given array of enum constants contains a constant with the given name . |
12,362 | public boolean removeColumn ( String name ) { if ( getColumnIndex ( name ) < 0 ) return false ; this . mColumns . remove ( getColumnIndex ( name ) ) ; return true ; } | Remove a column by its name |
12,363 | public boolean removeColumn ( int i ) { if ( getColumn ( i ) == null ) return false ; this . mColumns . remove ( i ) ; return true ; } | Remove a column by its index |
12,364 | @ UiChild ( limit = 1 , tagname = "label" ) public void setChildLabel ( final Widget plabel ) { label = plabel ; getLayout ( ) . add ( label ) ; } | Set the label of widget . |
12,365 | public static < T , E extends Editor < ? super T > > ListValidationEditor < T , E > of ( final EditorSource < E > source ) { return new ListValidationEditor < > ( source ) ; } | Create a ListEditor backed by an EditorSource . |
12,366 | public static < T > Collection < T > getAllBeansOfType ( WeldContainer weldContainer , Class < T > type ) { Collection < T > beans = Lists . newArrayList ( ) ; Set < Bean < ? > > cdiBeans = weldContainer . getBeanManager ( ) . getBeans ( type , AnyLiteral . INSTANCE ) ; for ( Bean < ? > b : cdiBeans ) { @ SuppressWarnings ( "unchecked" ) Bean < T > b2 = ( Bean < T > ) b ; CreationalContext < T > creationalContext = weldContainer . getBeanManager ( ) . createCreationalContext ( b2 ) ; T bean = b2 . create ( creationalContext ) ; beans . add ( bean ) ; } return beans ; } | Searches the container for all beans of a certain type without respecting qualifiers . |
12,367 | public static PathImpl instantiate ( final SerializationStreamReader streamReader ) throws SerializationException { final String propertyPath = streamReader . readString ( ) ; return PathImpl . createPathFromString ( propertyPath ) ; } | instantiate a path implementation . |
12,368 | public static String delete ( final String inString , final String pattern ) { return StringUtils . replace ( inString , pattern , "" ) ; } | Delete all occurrences of the given substring . |
12,369 | public void setFor ( final IsWidget target ) { if ( init ) { return ; } init = true ; final InputElement input = getInputElement ( target . asWidget ( ) ) ; if ( input != null ) { if ( ! input . hasAttribute ( "id" ) ) { input . setId ( DOM . createUniqueId ( ) ) ; } getElement ( ) . setAttribute ( "for" , input . getId ( ) ) ; } } | set widget to reference to . |
12,370 | public PMMLPlanner setRetainOnlyActiveFields ( ) { Evaluator evaluator = getEvaluator ( ) ; Fields incomingFields = new Fields ( ) . append ( FieldsUtil . getActiveFields ( evaluator ) ) . append ( FieldsUtil . getGroupFields ( evaluator ) ) ; return setRetainedFields ( incomingFields ) ; } | Orders the retention of only those incoming fields that represent PMML function argument fields . |
12,371 | public Set < MessageAndPath > getMessageAndPaths ( ) { if ( ! this . disableDefault ) { this . messages . add ( new MessageAndPath ( this . basePath , this . getDefaultConstraintMessageTemplate ( ) ) ) ; } return this . messages ; } | getter for message and path . |
12,372 | Map < String , String > parseQueryString ( final String queryString , final Map < String , String > into ) { final Map < String , String > result = ( into == null ) ? new HashMap < > ( ) : into ; if ( StringUtils . isNotEmpty ( queryString ) ) { for ( final String keyValuePair : queryString . split ( "&" ) ) { final String [ ] keyValue = keyValuePair . split ( "=" , 2 ) ; if ( keyValue . length > 1 ) { result . put ( keyValue [ 0 ] , urlUtils . decodeQueryString ( keyValue [ 1 ] ) ) ; } else { result . put ( keyValue [ 0 ] , StringUtils . EMPTY ) ; } } } return result ; } | Parse the given query - string and store all parameters into a map . |
12,373 | protected final String parseAndFormatDate ( final String pversionDate ) { Date date ; if ( StringUtils . isEmpty ( pversionDate ) ) { date = new Date ( ) ; } else { try { date = versionDateFormat . parse ( pversionDate ) ; } catch ( final IllegalArgumentException e ) { date = new Date ( ) ; } } return dateFormatDisplay . format ( date ) ; } | parse and format a date string . |
12,374 | public T get ( ) throws IllegalStateException { switch ( this . state ) { case INCOMPLETE : throw new IllegalStateException ( "The server response did not yet recieved." ) ; case FAILED : throw new IllegalStateException ( this . error ) ; case SUCCEEDED : return this . value ; default : throw new IllegalStateException ( "Something very unclear" ) ; } } | get result of the call . |
12,375 | public TextBoxBase getTextBox ( ) { if ( getTakesValues ( ) instanceof SuggestBox ) { return ( TextBoxBase ) ( ( SuggestBox ) getTakesValues ( ) ) . getValueBox ( ) ; } return null ; } | get text box . |
12,376 | public ValueBoxBase < String > getValueBox ( ) { if ( getTakesValues ( ) instanceof SuggestBox ) { return ( ( SuggestBox ) getTakesValues ( ) ) . getValueBox ( ) ; } return null ; } | get value box base . |
12,377 | public static String [ ] getArgsTypeNameArray ( Class < ? > [ ] argsTypes ) { String [ ] argsTypeArray = null ; if ( argsTypes != null ) { argsTypeArray = new String [ argsTypes . length ] ; for ( int i = 0 ; i < argsTypes . length ; i ++ ) { argsTypeArray [ i ] = argsTypes [ i ] . getName ( ) ; } } return argsTypeArray ; } | Get parameter type name array from a method |
12,378 | public static String getArgsTypeName ( String [ ] argTypes ) { if ( argTypes != null ) { return StringUtil . join ( argTypes , ',' ) ; } return StringUtil . EMPTY ; } | Get parameter type name string from a arg types string array |
12,379 | @ SuppressWarnings ( "unchecked" ) public Iterable < ConstraintViolation < ? > > convert ( final ValidationResultInterface psource , final E pbean ) { if ( psource == null ) { return null ; } return psource . getValidationErrorSet ( ) . stream ( ) . map ( violation -> ConstraintViolationImpl . forBeanValidation ( null , Collections . emptyMap ( ) , Collections . emptyMap ( ) , violation . getMessage ( ) , ( Class < E > ) ( pbean == null ? null : pbean . getClass ( ) ) , pbean , null , null , PathImpl . createPathFromString ( violation . getPropertyPath ( ) ) , null , null , null ) ) . collect ( Collectors . toList ( ) ) ; } | convert ValidationResultData from server to a ArrayList< ; ConstraintViolation< ; ?> ; > ; which can be handled by gwt . |
12,380 | public static String escapeMessageParameter ( final String messageParameter ) { if ( messageParameter == null ) { return null ; } return ESCAPE_MESSAGE_PARAMETER_PATTERN . replace ( messageParameter , String . valueOf ( ESCAPE_CHARACTER ) + "$1" ) ; } | escape message parameter . |
12,381 | public static String syncRestCall ( final String purl ) { try { return CACHE . get ( purl ) ; } catch ( final ExecutionException e ) { GWT . log ( e . getMessage ( ) , e ) ; return null ; } } | start get rest call with given url . |
12,382 | private static String syncRestNativeCall ( final String purl ) { final XMLHttpRequest xmlHttp = Browser . getWindow ( ) . newXMLHttpRequest ( ) ; xmlHttp . open ( "GET" , purl , false ) ; xmlHttp . send ( ) ; return xmlHttp . getResponseText ( ) ; } | simple synchronous rest get call |
12,383 | public IModel train ( String trainMethodName , Object ... paramArgs ) throws DDFException { if ( paramArgs == null ) paramArgs = new Object [ 0 ] ; String mappedName = Config . getValueWithGlobalDefault ( this . getEngine ( ) , trainMethodName ) ; if ( ! Strings . isNullOrEmpty ( mappedName ) ) trainMethodName = mappedName ; TrainMethod trainMethod = new TrainMethod ( trainMethodName , MLClassMethods . DEFAULT_TRAIN_METHOD_NAME , paramArgs ) ; if ( trainMethod . getMethod ( ) == null ) { throw new DDFException ( String . format ( "Cannot locate method specified by %s" , trainMethodName ) ) ; } Object [ ] allArgs = this . buildArgsForMethod ( trainMethod . getMethod ( ) , paramArgs ) ; Object rawModel = trainMethod . classInvoke ( allArgs ) ; List < Schema . Column > columns = this . getDDF ( ) . getSchemaHandler ( ) . getColumns ( ) ; String [ ] trainedColumns = new String [ columns . size ( ) ] ; for ( int i = 0 ; i < columns . size ( ) ; i ++ ) { trainedColumns [ i ] = columns . get ( i ) . getName ( ) ; } for ( String col : trainedColumns ) { mLog . info ( ">>>>>> trainedCol = " + col ) ; } IModel model = this . newModel ( rawModel ) ; model . setTrainedColumns ( trainedColumns ) ; mLog . info ( ">>>> modelID = " + model . getName ( ) ) ; this . getManager ( ) . addModel ( model ) ; return model ; } | Runs a training algorithm on the entire DDF dataset . |
12,384 | @ SuppressWarnings ( "unchecked" ) protected ValueBoxBase < E > getTextBoxFromEvent ( final GwtEvent < ? > pevent ) { final ValueBoxBase < E > ptextBox ; if ( pevent . getSource ( ) instanceof SuggestBox ) { ptextBox = ( ValueBoxBase < E > ) ( ( SuggestBox ) pevent . getSource ( ) ) . getValueBox ( ) ; } else if ( pevent . getSource ( ) instanceof ValueBoxBase < ? > ) { ptextBox = ( ValueBoxBase < E > ) pevent . getSource ( ) ; } else { throw new RuntimeException ( "Widget type not supported!" ) ; } return ptextBox ; } | get ValueBoxBase which produced the event . |
12,385 | public User getLoggedInUser ( ) { User user = null ; final Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authentication != null ) { final Object principal = authentication . getPrincipal ( ) ; if ( principal instanceof UserDetails ) { user = userDetailsConverter . convert ( ( UserDetails ) principal ) ; } } return user ; } | get logged in user . |
12,386 | public Configuration loadConfig ( ) throws ConfigurationException , IOException { Configuration resultConfig = new Configuration ( ) ; if ( ! Utils . localFileExists ( this . getConfigFileName ( ) ) ) { File file = new File ( this . locateConfigFileName ( this . getConfigDir ( ) , this . getConfigFileName ( ) ) ) ; mConfigDir = file . getParentFile ( ) . getName ( ) ; mConfigFileName = file . getCanonicalPath ( ) ; } if ( ! Utils . localFileExists ( this . getConfigFileName ( ) ) ) return null ; HierarchicalINIConfiguration config = new HierarchicalINIConfiguration ( this . getConfigFileName ( ) ) ; @ SuppressWarnings ( "unchecked" ) Set < String > sectionNames = config . getSections ( ) ; for ( String sectionName : sectionNames ) { SubnodeConfiguration section = config . getSection ( sectionName ) ; if ( section != null ) { Configuration . Section resultSection = resultConfig . getSection ( sectionName ) ; @ SuppressWarnings ( "unchecked" ) Iterator < String > keys = section . getKeys ( ) ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; String value = section . getString ( key ) ; if ( value != null ) { resultSection . set ( key , value ) ; } } } } mConfig = resultConfig ; return mConfig ; } | Load configuration from ddf . ini or the file name specified by the environment variable DDF_INI . |
12,387 | private String locateConfigFileName ( String configDir , String configFileName ) throws IOException { String curDir = new File ( "." ) . getCanonicalPath ( ) ; String path = null ; for ( int i = 0 ; i < 10 ; i ++ ) { path = String . format ( "%s/%s" , curDir , configFileName ) ; if ( Utils . localFileExists ( path ) ) break ; String dir = String . format ( "%s/%s" , curDir , configDir ) ; if ( Utils . dirExists ( dir ) ) { path = String . format ( "%s/%s" , dir , configFileName ) ; if ( Utils . localFileExists ( path ) ) break ; } curDir = String . format ( "%s/.." , curDir ) ; } mSource = path ; if ( Strings . isNullOrEmpty ( path ) ) throw new IOException ( String . format ( "Cannot locate DDF configuration file %s" , configFileName ) ) ; mLog . debug ( String . format ( "Using config file found at %s\n" , path ) ) ; return path ; } | Search in current dir and working up looking for the config file |
12,388 | public Set < Class < ? > > findAllExtendedGroups ( final Collection < Class < ? > > baseGroups ) throws IllegalArgumentException { final Set < Class < ? > > found = new HashSet < > ( ) ; final Stack < Class < ? > > remaining = new Stack < > ( ) ; baseGroups . forEach ( group -> { if ( ! inheritanceMapping . containsKey ( group ) ) { throw new IllegalArgumentException ( "The collection of groups contains a group which" + " was not added to the map. Be sure to call addGroup() for all groups first." ) ; } remaining . push ( group ) ; } ) ; while ( ! remaining . isEmpty ( ) ) { final Class < ? > current = remaining . pop ( ) ; found . add ( current ) ; inheritanceMapping . get ( current ) . forEach ( parent -> { if ( ! found . contains ( parent ) ) { remaining . push ( parent ) ; } } ) ; } return found ; } | Finds all of the validation groups extended by an intial set of groups . |
12,389 | private void updateServiceLocalCache ( ) { try { LOG . info ( "Update local cache now..." ) ; zkClient . getChildren ( NaviCommonConstant . ZOOKEEPER_BASE_PATH ) ; LOG . info ( "Zookeeper global root path is " + NaviCommonConstant . ZOOKEEPER_BASE_PATH ) ; ServiceLocalCache . prepare ( ) ; if ( ArrayUtil . isEmpty ( RpcClientConf . ZK_WATCH_NAMESPACE_PATHS ) ) { LOG . info ( "Zookeeper watched name space is empty" ) ; return ; } LOG . info ( "Zookeeper watched name spaces are " + Arrays . toString ( RpcClientConf . ZK_WATCH_NAMESPACE_PATHS ) ) ; for ( String watchedNameSpacePath : RpcClientConf . ZK_WATCH_NAMESPACE_PATHS ) { try { List < String > serviceChildren = zkClient . getChildren ( ZkPathUtil . buildPath ( NaviCommonConstant . ZOOKEEPER_BASE_PATH , watchedNameSpacePath ) ) ; LOG . info ( "======>Find " + serviceChildren . size ( ) + " interfaces under service path - " + ZkPathUtil . buildPath ( NaviCommonConstant . ZOOKEEPER_BASE_PATH , watchedNameSpacePath ) ) ; if ( CollectionUtil . isNotEmpty ( serviceChildren ) ) { for ( String service : serviceChildren ) { String servicePath = ZkPathUtil . buildPath ( NaviCommonConstant . ZOOKEEPER_BASE_PATH , watchedNameSpacePath , service ) ; List < String > serverList = zkClient . getChildren ( servicePath ) ; LOG . info ( serverList . size ( ) + " servers available for " + servicePath + ", server list = " + Arrays . toString ( serverList . toArray ( new String [ ] { } ) ) ) ; if ( CollectionUtil . isNotEmpty ( serverList ) ) { Collections . sort ( serverList ) ; ServiceLocalCache . set ( servicePath , serverList ) ; } } } else { LOG . warn ( "No services registered" ) ; } } catch ( NoAuthException e ) { LOG . error ( "[FATAL ERROR]No auth error! Please check zookeeper digest auth code!!! " + e . getMessage ( ) , e ) ; } catch ( NoNodeException e ) { LOG . error ( "Node not found, " + e . getMessage ( ) ) ; } } ServiceLocalCache . switchCache ( ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e ) ; } finally { try { ServiceLocalCache . done ( ) ; } catch ( Exception e2 ) { LOG . error ( e2 . getMessage ( ) , e2 ) ; } } } | Refresh all service info in local cache |
12,390 | private void doConnect ( ) { try { LOG . info ( "Connecting to zookeeper server - " + RpcClientConf . ZK_SERVER_LIST ) ; zkClient = new SimpleZooKeeperClient ( RpcClientConf . ZK_SERVER_LIST , RpcClientConf . ZK_DIGEST_AUTH , new ServiceWatcher ( ) ) ; updateServiceLocalCache ( ) ; } catch ( Exception e ) { LOG . error ( "Zookeeper client initialization failed, " + e . getMessage ( ) , e ) ; } } | Connect to zookeeper server |
12,391 | private boolean isInZkWathcedNamespacePaths ( String path ) { if ( StringUtil . isEmpty ( path ) ) { return false ; } for ( String watchNamespacePath : RpcClientConf . ZK_WATCH_NAMESPACE_PATHS ) { if ( StringUtil . isEmpty ( watchNamespacePath ) ) { continue ; } if ( path . contains ( watchNamespacePath ) ) { return true ; } } return false ; } | Check if the changed path is in the watched paths that the client should care |
12,392 | private boolean checkDeTaxNumber ( final String ptaxNumber ) { final int fa = Integer . parseInt ( StringUtils . substring ( ptaxNumber , 2 , 4 ) ) ; final int sb = Integer . parseInt ( StringUtils . substring ( ptaxNumber , 5 , 8 ) ) ; final int checkSum = ptaxNumber . charAt ( 12 ) - '0' ; if ( StringUtils . startsWith ( ptaxNumber , "11" ) ) { final int calculatedCheckSum ; if ( fa >= 27 && fa <= 30 || fa < 31 && ( sb < 201 || sb > 693 ) || fa == 19 && ( sb < 200 || sb > 639 && sb < 680 || sb > 680 && sb < 684 || sb > 684 ) || fa == 37 ) { calculatedCheckSum = ( ( ptaxNumber . charAt ( 5 ) - '0' ) * 7 + ( ptaxNumber . charAt ( 6 ) - '0' ) * 6 + ( ptaxNumber . charAt ( 7 ) - '0' ) * 5 + ( ptaxNumber . charAt ( 8 ) - '0' ) * 8 + ( ptaxNumber . charAt ( 9 ) - '0' ) * 4 + ( ptaxNumber . charAt ( 10 ) - '0' ) * 3 + ( ptaxNumber . charAt ( 11 ) - '0' ) * 2 ) % MODULO_11 ; } else { calculatedCheckSum = ( ( ptaxNumber . charAt ( 2 ) - '0' ) * 3 + ( ptaxNumber . charAt ( 3 ) - '0' ) * 2 + ( ptaxNumber . charAt ( 4 ) - '0' ) * 9 + ( ptaxNumber . charAt ( 5 ) - '0' ) * 8 + ( ptaxNumber . charAt ( 6 ) - '0' ) * 7 + ( ptaxNumber . charAt ( 7 ) - '0' ) * 6 + ( ptaxNumber . charAt ( 8 ) - '0' ) * 5 + ( ptaxNumber . charAt ( 9 ) - '0' ) * 4 + ( ptaxNumber . charAt ( 10 ) - '0' ) * 3 + ( ptaxNumber . charAt ( 11 ) - '0' ) * 2 ) % MODULO_11 ; } return checkSum == calculatedCheckSum ; } return true ; } | check the Tax Identification Number number country version for Germany . |
12,393 | public static Map < String , Object > parse ( String fileContent ) { MapFormatter f = new MapFormatter ( ) ; Parser p = new Parser ( f ) ; p . parse ( fileContent , "feature" , 0 ) ; return f . getFeature ( ) ; } | Parse the content of a feature file . |
12,394 | public static Map < String , String > readPhoneCountryNames ( final Locale plocale ) { final PhoneCountryNameConstants phoneCountryNames = GWT . create ( PhoneCountryNameConstants . class ) ; return phoneCountryNames . phoneCountryNames ( ) ; } | read phone country names . |
12,395 | public static Map < String , String > readPhoneCountryCodes ( final Locale plocale ) { final PhoneCountryCodeConstants phoneCountryCodes = GWT . create ( PhoneCountryCodeConstants . class ) ; return phoneCountryCodes . phoneCountryCodes ( ) ; } | read phone country codes and country iso codes . |
12,396 | public static Map < String , String > readPhoneTrunkAndExitCodes ( final Locale plocale ) { final PhoneCountryTrunkAndExitCodesConstants phoneTrunkAndExitCodes = GWT . create ( PhoneCountryTrunkAndExitCodesConstants . class ) ; return phoneTrunkAndExitCodes . phoneTrunkAndExitCodes ( ) ; } | read phone trunk an exit code map from property file . |
12,397 | public static NodeImpl createContainerElementNode ( final String name , final NodeImpl parent ) { return new NodeImpl ( name , parent , false , null , null , ElementKind . CONTAINER_ELEMENT , EMPTY_CLASS_ARRAY , null , null , null , null ) ; } | create container element node . |
12,398 | public static NodeImpl createParameterNode ( final String name , final NodeImpl parent , final int parameterIndex ) { return new NodeImpl ( name , parent , false , null , null , ElementKind . PARAMETER , EMPTY_CLASS_ARRAY , parameterIndex , null , null , null ) ; } | create parameter node . |
12,399 | public static NodeImpl createCrossParameterNode ( final NodeImpl parent ) { return new NodeImpl ( CROSS_PARAMETER_NODE_NAME , parent , false , null , null , ElementKind . CROSS_PARAMETER , EMPTY_CLASS_ARRAY , null , null , null , null ) ; } | create cross parameter node node . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.