idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
17,800 | public void stop ( ) { if ( isStarted ) { synchronized ( this ) { if ( isStarted ) { if ( getRegistrationService ( ) instanceof Closable ) { ( ( Closable ) getRegistrationService ( ) ) . stop ( ) ; } isStarted = false ; } } } } | Stop the RegistrationManagerImpl |
17,801 | public List < String > getSectionNames ( ) { List < String > sections = new ArrayList < String > ( ) ; for ( Map . Entry < String , String > entry : this . entrySet ( ) ) { String key = entry . getKey ( ) ; int pos = key . indexOf ( '.' ) ; if ( pos > 0 ) key = key . substring ( 0 , pos ) ; boolean found = false ; for ( String section : sections ) { if ( section . equalsIgnoreCase ( key ) ) { found = true ; break ; } } if ( ! found ) sections . add ( key ) ; } return sections ; } | Gets a list with all 1st level section names . |
17,802 | public ConfigParams getSection ( String section ) { ConfigParams result = new ConfigParams ( ) ; String prefix = section + "." ; for ( Map . Entry < String , String > entry : this . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( key . length ( ) < prefix . length ( ) ) continue ; String keyPrefix = key . substring ( 0 , prefix . length ( ) ) ; if ( keyPrefix . equalsIgnoreCase ( prefix ) ) { key = key . substring ( prefix . length ( ) ) ; result . put ( key , entry . getValue ( ) ) ; } } return result ; } | Gets parameters from specific section stored in this ConfigMap . The section name is removed from parameter keys . |
17,803 | public void addSection ( String section , ConfigParams sectionParams ) { if ( section == null ) throw new NullPointerException ( "Section name cannot be null" ) ; if ( sectionParams != null ) { for ( Map . Entry < String , String > entry : sectionParams . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( key . length ( ) > 0 && section . length ( ) > 0 ) key = section + "." + key ; else if ( key . length ( ) == 0 ) key = section ; String value = entry . getValue ( ) ; put ( key , value ) ; } } } | Adds parameters into this ConfigParams under specified section . Keys for the new parameters are appended with section dot prefix . |
17,804 | public ConfigParams override ( ConfigParams configParams ) { StringValueMap map = StringValueMap . fromMaps ( this , configParams ) ; return new ConfigParams ( map ) ; } | Overrides parameters with new values from specified ConfigParams and returns a new ConfigParams object . |
17,805 | public ConfigParams setDefaults ( ConfigParams defaultConfigParams ) { StringValueMap map = StringValueMap . fromMaps ( defaultConfigParams , this ) ; return new ConfigParams ( map ) ; } | Set default values from specified ConfigParams and returns a new ConfigParams object . |
17,806 | public static ConfigParams fromValue ( Object value ) { Map < String , Object > map = RecursiveObjectReader . getProperties ( value ) ; return new ConfigParams ( map ) ; } | Creates a new ConfigParams object filled with key - value pairs from specified object . |
17,807 | public static ConfigParams fromTuples ( Object ... tuples ) { StringValueMap map = StringValueMap . fromTuplesArray ( tuples ) ; return new ConfigParams ( map ) ; } | Creates a new ConfigParams object filled with provided key - value pairs called tuples . Tuples parameters contain a sequence of key1 value1 key2 value2 ... pairs . |
17,808 | public static ConfigParams fromString ( String line ) { StringValueMap map = StringValueMap . fromString ( line ) ; return new ConfigParams ( map ) ; } | Creates a new ConfigParams object filled with key - value pairs serialized as a string . |
17,809 | public static ConfigParams mergeConfigs ( ConfigParams ... configs ) { StringValueMap map = StringValueMap . fromMaps ( configs ) ; return new ConfigParams ( map ) ; } | Merges two or more ConfigParams into one . The following ConfigParams override previously defined parameters . |
17,810 | private void registerCachedServiceInstance ( ProvidedServiceInstance instance , ServiceInstanceHealth registryHealth ) { try { write . lock ( ) ; ServiceInstanceId id = new ServiceInstanceId ( instance . getServiceName ( ) , instance . getProviderId ( ) ) ; CachedProviderServiceInstance cachedInstance = getCacheServiceInstances ( ) . get ( id ) ; if ( cachedInstance == null ) { cachedInstance = new CachedProviderServiceInstance ( instance ) ; getCacheServiceInstances ( ) . put ( id , cachedInstance ) ; } if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "add cached ProvidedServiceInstance: {}." , cachedInstance . toString ( ) ) ; } cachedInstance . setServiceInstanceHealth ( registryHealth ) ; } finally { write . unlock ( ) ; } } | Register a ProvidedServiceInstance to the Cache . |
17,811 | private void editCachedServiceInstance ( ProvidedServiceInstance instance ) { try { write . lock ( ) ; ServiceInstanceId id = new ServiceInstanceId ( instance . getServiceName ( ) , instance . getProviderId ( ) ) ; CachedProviderServiceInstance cachedInstance = getCacheServiceInstances ( ) . get ( id ) ; if ( cachedInstance != null ) { cachedInstance . setMonitorEnabled ( instance . isMonitorEnabled ( ) ) ; cachedInstance . setStatus ( instance . getStatus ( ) ) ; } LOGGER . debug ( "update cached ProvidedServiceInstance: {}." , cachedInstance . toString ( ) ) ; } finally { write . unlock ( ) ; } } | Edit the Cached ProvidedServiceInstance when updateService is called . |
17,812 | private CachedProviderServiceInstance getCachedServiceInstance ( String serviceName , String providerId ) { try { read . lock ( ) ; ServiceInstanceId id = new ServiceInstanceId ( serviceName , providerId ) ; return getCacheServiceInstances ( ) . get ( id ) ; } finally { read . unlock ( ) ; } } | Get the Cached ProvidedServiceInstance by serviceName and providerId . |
17,813 | private void unregisterCachedServiceInstance ( String serviceName , String providerId ) { try { write . lock ( ) ; ServiceInstanceId id = new ServiceInstanceId ( serviceName , providerId ) ; getCacheServiceInstances ( ) . remove ( id ) ; LOGGER . debug ( "delete cached ProvidedServiceInstance, serviceName={}, providerId={}." , serviceName , providerId ) ; } finally { write . unlock ( ) ; } } | Delete the Cached ProvidedServiceInstance by serviceName and providerId . |
17,814 | private void releaseServicesForChild ( BCSSChild bcssChild , boolean delegatedServices ) { if ( bcssChild . serviceRecords == null || bcssChild . serviceRecords . isEmpty ( ) ) { return ; } synchronized ( bcssChild . child ) { Object records [ ] = bcssChild . serviceRecords . toArray ( ) ; for ( int i = 0 ; i < records . length ; i ++ ) { ServiceRecord rec = ( ServiceRecord ) records [ i ] ; if ( delegatedServices ) { if ( rec . isDelegate ) { releaseServiceWithoutCheck ( rec . child , bcssChild , rec . requestor , rec . service , true ) ; } } else { releaseServiceWithoutCheck ( rec . child , bcssChild , rec . requestor , rec . service , false ) ; } } } } | Release all services requested by the given child . |
17,815 | public Object getService ( BeanContextChild child , Object requestor , Class serviceClass , Object serviceSelector , BeanContextServiceRevokedListener bcsrl ) throws TooManyListenersException { if ( child == null || requestor == null || serviceClass == null || bcsrl == null ) { throw new NullPointerException ( ) ; } BCSSChild bcssChild = null ; BeanContextServiceProvider provider = null ; Object service = null ; boolean isDelegate = false ; synchronized ( globalHierarchyLock ) { synchronized ( children ) { bcssChild = ( BCSSChild ) children . get ( child ) ; } if ( bcssChild == null ) { throw new IllegalArgumentException ( Messages . getString ( "beans.65" ) ) ; } provider = getLocalServiceProvider ( serviceClass ) ; if ( provider != null ) { service = provider . getService ( getBeanContextServicesPeer ( ) , requestor , serviceClass , serviceSelector ) ; } if ( service == null && proxy != null ) { provider = proxy ; service = proxy . getService ( getBeanContextServicesPeer ( ) , requestor , serviceClass , serviceSelector , bcsrl ) ; isDelegate = true ; } } if ( service != null ) { synchronized ( child ) { if ( bcssChild . serviceRecords == null ) { bcssChild . serviceRecords = new ArrayList < ServiceRecord > ( ) ; } bcssChild . serviceRecords . add ( new ServiceRecord ( provider , child , requestor , serviceClass , bcsrl , service , isDelegate ) ) ; } } return service ; } | Get a service instance on behalf of the specified child of this context by calling the registered service provider or by delegating to the parent context . |
17,816 | public boolean hasService ( Class serviceClass ) { if ( serviceClass == null ) { throw new NullPointerException ( ) ; } boolean has ; synchronized ( services ) { has = services . containsKey ( serviceClass ) ; } if ( ! has && getBeanContext ( ) instanceof BeanContextServices ) { has = ( ( BeanContextServices ) getBeanContext ( ) ) . hasService ( serviceClass ) ; } return has ; } | Checks whether a service is registed in this context or the parent context . |
17,817 | public void releaseService ( BeanContextChild child , Object requestor , Object service ) { if ( child == null || requestor == null || service == null ) { throw new NullPointerException ( ) ; } synchronized ( globalHierarchyLock ) { BCSSChild bcssChild ; synchronized ( children ) { bcssChild = ( BCSSChild ) children . get ( child ) ; } if ( bcssChild == null ) { throw new IllegalArgumentException ( Messages . getString ( "beans.65" ) ) ; } releaseServiceWithoutCheck ( child , bcssChild , requestor , service , false ) ; } } | Release a service which has been requested previously . |
17,818 | private void releaseServiceWithoutCheck ( BeanContextChild child , BCSSChild bcssChild , Object requestor , Object service , boolean callRevokedListener ) { if ( bcssChild . serviceRecords == null || bcssChild . serviceRecords . isEmpty ( ) ) { return ; } synchronized ( child ) { for ( Iterator iter = bcssChild . serviceRecords . iterator ( ) ; iter . hasNext ( ) ; ) { ServiceRecord rec = ( ServiceRecord ) iter . next ( ) ; if ( rec . requestor == requestor && rec . service == service ) { rec . provider . releaseService ( getBeanContextServicesPeer ( ) , requestor , service ) ; if ( callRevokedListener && rec . revokedListener != null ) { rec . revokedListener . serviceRevoked ( new BeanContextServiceRevokedEvent ( getBeanContextServicesPeer ( ) , rec . serviceClass , true ) ) ; } iter . remove ( ) ; break ; } } } } | Releases a service without checking the membership of the child . |
17,819 | private void notifyServiceRevokedToServiceUsers ( Class serviceClass , BeanContextServiceProvider serviceProvider , boolean revokeCurrentServicesNow ) { synchronized ( children ) { for ( Iterator iter = bcsChildren ( ) ; iter . hasNext ( ) ; ) { BCSSChild bcssChild = ( BCSSChild ) iter . next ( ) ; notifyServiceRevokedToServiceUsers ( serviceClass , serviceProvider , revokeCurrentServicesNow , bcssChild ) ; } } } | Notify all children that a service has been revoked . |
17,820 | private void notifyServiceRevokedToServiceUsers ( Class serviceClass , BeanContextServiceProvider serviceProvider , boolean revokeCurrentServicesNow , BCSSChild bcssChild ) { if ( bcssChild . serviceRecords == null || bcssChild . serviceRecords . isEmpty ( ) ) { return ; } synchronized ( bcssChild . child ) { for ( Iterator it = bcssChild . serviceRecords . iterator ( ) ; it . hasNext ( ) ; ) { ServiceRecord rec = ( ServiceRecord ) it . next ( ) ; if ( rec . serviceClass == serviceClass && rec . provider == serviceProvider && rec . revokedListener != null && ! rec . isDelegate ) { rec . revokedListener . serviceRevoked ( new BeanContextServiceRevokedEvent ( getBeanContextServicesPeer ( ) , serviceClass , revokeCurrentServicesNow ) ) ; rec . revokedListener = null ; } } } } | Notify the given child that a service has been revoked . |
17,821 | public static Predicate < Number > getGreater ( Number target ) { return number -> number . doubleValue ( ) > target . doubleValue ( ) ; } | Gets greater . |
17,822 | public static Predicate < Number > getGreaterOrEqual ( Number target ) { return number -> number . doubleValue ( ) >= target . doubleValue ( ) ; } | Gets greater or equal . |
17,823 | public static Predicate < Number > getLess ( Number target ) { return number -> number . doubleValue ( ) < target . doubleValue ( ) ; } | Gets less . |
17,824 | public static Predicate < Number > getLessOrEqual ( Number target ) { return number -> number . doubleValue ( ) <= target . doubleValue ( ) ; } | Gets less or equal . |
17,825 | public static < T > Predicate < T > peekToRun ( Runnable block ) { return target -> JMLambda . getTrueAfterRunning ( block ) ; } | Peek to run predicate . |
17,826 | public static < T > Predicate < T > peek ( Consumer < T > consumer ) { return target -> JMLambda . getTrueAfterRunning ( ( ) -> consumer . accept ( target ) ) ; } | Peek predicate . |
17,827 | public static < T > Predicate < T > peekSOPL ( ) { return target -> JMLambda . getTrueAfterRunning ( ( ) -> System . out . println ( target ) ) ; } | Peek sopl predicate . |
17,828 | public static < T > Predicate < T > getEquals ( T target2 ) { return target -> target . equals ( target2 ) ; } | Gets equals . |
17,829 | private static int validate ( byte [ ] decodabet , byte from ) { byte b = decodabet [ from & 0x7F ] ; if ( b < 0 ) { throw new IllegalArgumentException ( String . format ( "Bad Base64%s character '%s'" , ( decodabet == _URL_SAFE_DECODABET ? " url safe" : "" ) , escape ( from ) ) ) ; } return b ; } | Validate char byte and revalculate to data byte value or throw IllegalArgumentException . |
17,830 | @ SuppressWarnings ( "unchecked" ) public T tag ( final String tag ) { if ( this . tags == null ) { this . tags = new HashSet < > ( ) ; } this . tags . add ( tag ) ; return ( T ) this ; } | Specify an individual tag associated with the sound . |
17,831 | @ SuppressWarnings ( "unchecked" ) public T tags ( final Collection < String > tags ) { if ( this . tags == null ) { this . tags = new HashSet < > ( ) ; } this . tags . addAll ( tags ) ; return ( T ) this ; } | Specify the tags associated with the sound . |
17,832 | public static List < Path > getFileStorePathList ( ) { return getFileStoreList ( ) . stream ( ) . map ( Object :: toString ) . map ( toString -> toString . substring ( 0 , toString . indexOf ( JMString . SPACE ) ) ) . map ( JMPath :: getPath ) . collect ( toList ( ) ) ; } | Gets file store path list . |
17,833 | public static Optional < Path > getParentAsOpt ( Path path ) { return Optional . ofNullable ( path . getParent ( ) ) . filter ( ExistFilter ) ; } | Gets parent as opt . |
17,834 | public static Stream < Path > getChildDirectoryPathStream ( Path path , Predicate < Path > filter ) { return getChildrenPathStream ( path ) . filter ( DirectoryAndNotSymbolicLinkFilter . and ( filter ) ) ; } | Gets child directory path stream . |
17,835 | public static Stream < Path > getChildFilePathStream ( Path path , Predicate < Path > filter ) { return getChildrenPathStream ( path ) . filter ( RegularFileFilter . and ( filter ) ) ; } | Gets child file path stream . |
17,836 | public static List < Path > getAncestorPathList ( Path startPath ) { List < Path > ancestorPathList = new ArrayList < > ( ) ; buildPathListOfAncestorDirectory ( ancestorPathList , startPath ) ; Collections . reverse ( ancestorPathList ) ; return ancestorPathList ; } | Gets ancestor path list . |
17,837 | public static Optional < String > getFilePathExtensionAsOpt ( Path path ) { return JMOptional . getNullableAndFilteredOptional ( path , RegularFileFilter ) . map ( JMPath :: getLastName ) . map ( JMString :: getExtension ) . filter ( getIsEmpty ( ) . negate ( ) ) ; } | Gets file path extension as opt . |
17,838 | public static Path extractSubPath ( Path basePath , Path sourcePath ) { return sourcePath . subpath ( basePath . getNameCount ( ) - 1 , sourcePath . getNameCount ( ) ) ; } | Extract sub path path . |
17,839 | public static Path buildRelativeDestinationPath ( Path destinationDirPath , Path baseDirPath , Path sourcePath ) { Path extractSubPath = extractSubPath ( baseDirPath , sourcePath ) ; return destinationDirPath . resolve ( extractSubPath ) ; } | Build relative destination path path . |
17,840 | public static GroupAnalyzer createGroupAnalyzer ( AreaImpl root ) { return new org . fit . segm . grouping . op . GroupAnalyzerByStyles ( root , 1 , false ) ; } | Creates a group analyzer for an area using the selected implementation . |
17,841 | public static SeparatorSet createSeparators ( AreaImpl root ) { SeparatorSet sset ; sset = new SeparatorSetHVS ( root ) ; sset . applyFinalFilters ( ) ; return sset ; } | Creates the separators for an area using the selected algorithm |
17,842 | public static Stream < byte [ ] > binaryStream ( final String path , final String name , final int skip , final int recordSize ) throws IOException { final File file = new File ( path , name ) ; final byte [ ] fileData = IOUtils . toByteArray ( new BufferedInputStream ( new GZIPInputStream ( new BufferedInputStream ( new FileInputStream ( file ) ) ) ) ) ; final DataInputStream in = new DataInputStream ( new ByteArrayInputStream ( fileData ) ) ; in . skip ( skip ) ; return com . simiacryptus . util . Util . toIterator ( new BinaryChunkIterator ( in , recordSize ) ) ; } | Binary stream stream . |
17,843 | public static < F , T > Function < F , T > cache ( final Function < F , T > inner ) { final LoadingCache < F , T > cache = CacheBuilder . newBuilder ( ) . build ( new CacheLoader < F , T > ( ) { public T load ( final F key ) throws Exception { return inner . apply ( key ) ; } } ) ; return cache :: apply ; } | Cache function . |
17,844 | public static File cacheFile ( final String url , final String file ) throws IOException , NoSuchAlgorithmException , KeyStoreException , KeyManagementException { if ( ! new File ( file ) . exists ( ) ) { IOUtils . copy ( get ( url ) , new FileOutputStream ( file ) ) ; } return new File ( file ) ; } | Cache file file . |
17,845 | public static TemporalUnit cvt ( final TimeUnit units ) { switch ( units ) { case DAYS : return ChronoUnit . DAYS ; case HOURS : return ChronoUnit . HOURS ; case MINUTES : return ChronoUnit . MINUTES ; case SECONDS : return ChronoUnit . SECONDS ; case NANOSECONDS : return ChronoUnit . NANOS ; case MICROSECONDS : return ChronoUnit . MICROS ; case MILLISECONDS : return ChronoUnit . MILLIS ; default : throw new IllegalArgumentException ( units . toString ( ) ) ; } } | Cvt temporal unit . |
17,846 | public static String mkString ( final String separator , final String ... strs ) { return Arrays . asList ( strs ) . stream ( ) . collect ( Collectors . joining ( separator ) ) ; } | Mk string string . |
17,847 | public static String pathTo ( final File from , final File to ) { return from . toPath ( ) . relativize ( to . toPath ( ) ) . toString ( ) . replaceAll ( "\\\\" , "/" ) ; } | Path to string . |
17,848 | public static BufferedImage resize ( final BufferedImage image ) { if ( null == image ) return image ; final int width = Math . min ( image . getWidth ( ) , 800 ) ; if ( width == image . getWidth ( ) ) return image ; final int height = image . getHeight ( ) * width / image . getWidth ( ) ; final BufferedImage rerender = new BufferedImage ( width , height , BufferedImage . TYPE_INT_ARGB ) ; final Graphics gfx = rerender . getGraphics ( ) ; final RenderingHints hints = new RenderingHints ( RenderingHints . KEY_INTERPOLATION , RenderingHints . VALUE_INTERPOLATION_BICUBIC ) ; ( ( Graphics2D ) gfx ) . setRenderingHints ( hints ) ; gfx . drawImage ( image , 0 , 0 , rerender . getWidth ( ) , rerender . getHeight ( ) , null ) ; return rerender ; } | Resize buffered image . |
17,849 | public static BufferedImage toImage ( final Component component ) { try { com . simiacryptus . util . Util . layout ( component ) ; final BufferedImage img = new BufferedImage ( component . getWidth ( ) , component . getHeight ( ) , BufferedImage . TYPE_INT_ARGB_PRE ) ; final Graphics2D g = img . createGraphics ( ) ; g . setColor ( component . getForeground ( ) ) ; g . setFont ( component . getFont ( ) ) ; component . print ( g ) ; return img ; } catch ( final Exception e ) { return null ; } } | To image buffered image . |
17,850 | public static < T > Stream < T > toIterator ( final Iterator < T > iterator ) { return StreamSupport . stream ( Spliterators . spliterator ( iterator , 1 , Spliterator . ORDERED ) , false ) ; } | To iterator stream . |
17,851 | public String words ( int count ) { StringBuilder s = new StringBuilder ( ) ; while ( count -- > 0 ) s . append ( randomWord ( ) ) . append ( " " ) ; return s . toString ( ) . trim ( ) ; } | Get a string of words |
17,852 | private void deregisterServices ( ) { Iterator < ServiceRegistration < ? > > serviceIterator = serviceRegistrations . iterator ( ) ; while ( serviceIterator . hasNext ( ) ) { ServiceRegistration < ? > serviceReference = serviceIterator . next ( ) ; serviceReference . unregister ( ) ; serviceIterator . remove ( ) ; } } | This method de - registers all former registered services . |
17,853 | public final < T > ServiceRegistration < ? > registerService ( Class < T > iface , T instance ) { Hashtable < String , String > properties = new Hashtable < String , String > ( ) ; return registerService ( iface , instance , properties ) ; } | This method should be used to register services . Services registered with this method auto deregistered during bundle stop . |
17,854 | public final < T > ServiceRegistration < ? > registerService ( Class < T > iface , T instance , Dictionary < String , String > dictionary ) { logger . info ( "Register service '{}' for interface '{}' (context='" + context . getBundle ( ) . getSymbolicName ( ) + "')." , instance . getClass ( ) . getName ( ) , iface . getName ( ) ) ; ServiceRegistration < ? > serviceRegistration = context . registerService ( iface , instance , dictionary ) ; serviceRegistrations . add ( serviceRegistration ) ; return serviceRegistration ; } | This method should be used to register services . Services registered with this method auto de - registered during bundle stop . |
17,855 | protected BigInteger toBigInteger ( Number number ) { if ( number == null ) { return null ; } Class < ? > claz = number . getClass ( ) ; if ( claz == BigInteger . class ) { return ( BigInteger ) number ; } else if ( claz == BigDecimal . class ) { return ( ( BigDecimal ) number ) . toBigInteger ( ) ; } else if ( claz == Double . class ) { return new BigDecimal ( ( Double ) number ) . toBigInteger ( ) ; } else if ( claz == Float . class ) { return new BigDecimal ( ( Float ) number ) . toBigInteger ( ) ; } else { return BigInteger . valueOf ( number . longValue ( ) ) ; } } | Convert a number to a big integer and try the best to preserve precision |
17,856 | public AreaImpl findSuperArea ( AreaImpl sub , Vector < AreaImpl > selected ) { AreaImpl ret = new AreaImpl ( 0 , 0 , 0 , 0 ) ; ret . setPage ( sub . getPage ( ) ) ; AreaImpl sibl = ( AreaImpl ) sub . getNextSibling ( ) ; selected . removeAllElements ( ) ; selected . add ( sub ) ; if ( sibl != null ) { selected . add ( sibl ) ; } return ret ; } | Starts with a specified subarea and finds all the subareas that may be joined with the first one . Returns an empty area and the vector of the areas inside . The subareas are not automatically added to the new area because this would cause their removal from the parent area . |
17,857 | protected void doHead ( final HttpServletRequest request , final HttpServletResponse response ) throws IOException , ServletException { serveResource ( request , response , false ) ; } | Process a HEAD request for the specified resource . |
17,858 | protected boolean checkIfHeaders ( final HttpServletRequest request , final HttpServletResponse response , final Attributes resourceAttributes ) throws IOException { return checkIfMatch ( request , response , resourceAttributes ) && checkIfModifiedSince ( request , response , resourceAttributes ) && checkIfNoneMatch ( request , response , resourceAttributes ) && checkIfUnmodifiedSince ( request , response , resourceAttributes ) ; } | Check if the conditions specified in the optional If headers are satisfied . |
17,859 | protected boolean checkIfMatch ( final HttpServletRequest request , final HttpServletResponse response , final Attributes resourceAttributes ) throws IOException { final String eTag = resourceAttributes . getETag ( ) ; final String headerValue = request . getHeader ( "If-Match" ) ; if ( headerValue != null ) { if ( headerValue . indexOf ( '*' ) == - 1 ) { final StringTokenizer commaTokenizer = new StringTokenizer ( headerValue , "," ) ; boolean conditionSatisfied = false ; while ( ! conditionSatisfied && commaTokenizer . hasMoreTokens ( ) ) { final String currentToken = commaTokenizer . nextToken ( ) ; if ( currentToken . trim ( ) . equals ( eTag ) ) conditionSatisfied = true ; } if ( ! conditionSatisfied ) { response . sendError ( HttpServletResponse . SC_PRECONDITION_FAILED ) ; return false ; } } } return true ; } | Check if the if - match condition is satisfied . |
17,860 | protected boolean checkIfModifiedSince ( final HttpServletRequest request , final HttpServletResponse response , final Attributes resourceAttributes ) { try { final long headerValue = request . getDateHeader ( "If-Modified-Since" ) ; final long lastModified = resourceAttributes . getLastModified ( ) ; if ( headerValue != - 1 ) { if ( ( request . getHeader ( "If-None-Match" ) == null ) && ( lastModified < headerValue + 1000 ) ) { response . setStatus ( HttpServletResponse . SC_NOT_MODIFIED ) ; response . setHeader ( "ETag" , resourceAttributes . getETag ( ) ) ; return false ; } } } catch ( final IllegalArgumentException illegalArgument ) { return true ; } return true ; } | Check if the if - modified - since condition is satisfied . |
17,861 | protected boolean checkIfNoneMatch ( final HttpServletRequest request , final HttpServletResponse response , final Attributes resourceAttributes ) throws IOException { final String eTag = resourceAttributes . getETag ( ) ; final String headerValue = request . getHeader ( "If-None-Match" ) ; if ( headerValue != null ) { boolean conditionSatisfied = false ; if ( ! headerValue . equals ( "*" ) ) { final StringTokenizer commaTokenizer = new StringTokenizer ( headerValue , "," ) ; while ( ! conditionSatisfied && commaTokenizer . hasMoreTokens ( ) ) { final String currentToken = commaTokenizer . nextToken ( ) ; if ( currentToken . trim ( ) . equals ( eTag ) ) conditionSatisfied = true ; } } else { conditionSatisfied = true ; } if ( conditionSatisfied ) { if ( ( "GET" . equals ( request . getMethod ( ) ) ) || ( "HEAD" . equals ( request . getMethod ( ) ) ) ) { response . setStatus ( HttpServletResponse . SC_NOT_MODIFIED ) ; response . setHeader ( "ETag" , eTag ) ; return false ; } response . sendError ( HttpServletResponse . SC_PRECONDITION_FAILED ) ; return false ; } } return true ; } | Check if the if - none - match condition is satisfied . |
17,862 | protected boolean checkIfUnmodifiedSince ( final HttpServletRequest request , final HttpServletResponse response , final Attributes resourceAttributes ) throws IOException { try { final long lastModified = resourceAttributes . getLastModified ( ) ; final long headerValue = request . getDateHeader ( "If-Unmodified-Since" ) ; if ( headerValue != - 1 ) { if ( lastModified >= ( headerValue + 1000 ) ) { response . sendError ( HttpServletResponse . SC_PRECONDITION_FAILED ) ; return false ; } } } catch ( final IllegalArgumentException illegalArgument ) { return true ; } return true ; } | Check if the if - unmodified - since condition is satisfied . |
17,863 | public void close ( ) { synchronized ( startedTasks ) { if ( executor . isShutdown ( ) ) { return ; } executor . shutdown ( ) ; try { updater . get ( ) ; } catch ( InterruptedException | CancellationException | ExecutionException ignore ) { } for ( InternalTask task : startedTasks ) { task . cancel ( true ) ; } for ( InternalTask task : queuedTasks ) { task . close ( ) ; } try { executor . awaitTermination ( 100L , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException ignore ) { Thread . currentThread ( ) . interrupt ( ) ; } } } | Close the progress and all tasks associated with it . |
17,864 | public void waitAbortable ( ) throws IOException , InterruptedException { try { isWaiting . set ( true ) ; terminal . waitAbortable ( updater ) ; } finally { close ( ) ; updateLines ( ) ; terminal . finish ( ) ; } } | Wait for all scheduled tasks to finish allowing the user to abort all tasks with < ; ctrl> ; - C . |
17,865 | public ParseTreeNode getChild ( String name ) throws TreeException { ParseTreeNode result = null ; for ( ParseTreeNode child : children ) { if ( child . getName ( ) . equals ( name ) ) { if ( result != null ) { throw new TreeException ( "Child '" + name + "'is multiply defined!" ) ; } result = child ; } } return result ; } | This method returns the child with the given name from this node . |
17,866 | public boolean hasChild ( String name ) { for ( ParseTreeNode child : children ) { if ( child . getName ( ) . equals ( name ) ) { return true ; } } return false ; } | This method look for a child with a given name . |
17,867 | public static BiFunction < CharTrie , CharTrie , CharTrie > reducer ( BiFunction < TrieNode , TrieNode , TreeMap < Character , Long > > fn ) { return ( left , right ) -> left . reduce ( right , fn ) ; } | Reducer bi function . |
17,868 | synchronized void ensureParentIndexCapacity ( int start , int length , int parentId ) { int end = start + length ; if ( null == parentIndex ) { parentIndex = new int [ end ] ; Arrays . fill ( parentIndex , parentId ) ; } else { int newLength = parentIndex . length ; while ( newLength < end ) newLength *= 2 ; if ( newLength > parentIndex . length ) { parentIndex = Arrays . copyOfRange ( parentIndex , 0 , newLength ) ; Arrays . fill ( parentIndex , end , newLength , - 1 ) ; } Arrays . fill ( parentIndex , start , end , parentId ) ; } if ( null == godparentIndex ) { godparentIndex = new int [ end ] ; Arrays . fill ( godparentIndex , - 1 ) ; } else { int newLength = godparentIndex . length ; while ( newLength < end ) newLength *= 2 ; if ( newLength > godparentIndex . length ) { int prevLength = godparentIndex . length ; godparentIndex = Arrays . copyOfRange ( godparentIndex , 0 , newLength ) ; Arrays . fill ( godparentIndex , prevLength , newLength , - 1 ) ; } } } | Ensure parent index capacity . |
17,869 | public CharTrie reverse ( ) { CharTrie result = new CharTrieIndex ( ) ; TreeMap < Character , ? extends TrieNode > childrenMap = root ( ) . getChildrenMap ( ) ; reverseSubtree ( childrenMap , result . root ( ) ) ; return result . recomputeCursorDetails ( ) ; } | Reverse char trie . |
17,870 | public CharTrie rewrite ( BiFunction < TrieNode , Map < Character , TrieNode > , TreeMap < Character , Long > > fn ) { CharTrie result = new CharTrieIndex ( ) ; rewriteSubtree ( root ( ) , result . root ( ) , fn ) ; return result . recomputeCursorDetails ( ) ; } | Rewrite char trie . |
17,871 | public CharTrie add ( CharTrie z ) { return reduceSimple ( z , ( left , right ) -> ( null == left ? 0 : left ) + ( null == right ? 0 : right ) ) ; } | Add char trie . |
17,872 | public CharTrie product ( CharTrie z ) { return reduceSimple ( z , ( left , right ) -> ( null == left ? 0 : left ) * ( null == right ? 0 : right ) ) ; } | Product char trie . |
17,873 | public CharTrie divide ( CharTrie z , int factor ) { return reduceSimple ( z , ( left , right ) -> ( null == right ? 0 : ( ( null == left ? 0 : left ) * factor / right ) ) ) ; } | Divide char trie . |
17,874 | public CharTrie reduceSimple ( CharTrie z , BiFunction < Long , Long , Long > fn ) { return reduce ( z , ( left , right ) -> { TreeMap < Character , ? extends TrieNode > leftChildren = null == left ? new TreeMap < > ( ) : left . getChildrenMap ( ) ; TreeMap < Character , ? extends TrieNode > rightChildren = null == right ? new TreeMap < > ( ) : right . getChildrenMap ( ) ; Map < Character , Long > map = Stream . of ( rightChildren . keySet ( ) , leftChildren . keySet ( ) ) . flatMap ( x -> x . stream ( ) ) . distinct ( ) . collect ( Collectors . toMap ( c -> c , ( Character c ) -> { assert ( null != leftChildren ) ; assert ( null != rightChildren ) ; assert ( null != c ) ; TrieNode leftChild = leftChildren . get ( c ) ; Long l = null == leftChild ? null : leftChild . getCursorCount ( ) ; TrieNode rightChild = rightChildren . get ( c ) ; Long r = null == rightChild ? null : rightChild . getCursorCount ( ) ; return fn . apply ( l , r ) ; } ) ) ; return new TreeMap < > ( map ) ; } ) ; } | Reduce simple char trie . |
17,875 | public CharTrie reduce ( CharTrie right , BiFunction < TrieNode , TrieNode , TreeMap < Character , Long > > fn ) { CharTrie result = new CharTrieIndex ( ) ; reduceSubtree ( root ( ) , right . root ( ) , result . root ( ) , fn ) ; return result . recomputeCursorDetails ( ) ; } | Reduce char trie . |
17,876 | CharTrie recomputeCursorDetails ( ) { godparentIndex = new int [ getNodeCount ( ) ] ; parentIndex = new int [ getNodeCount ( ) ] ; Arrays . fill ( godparentIndex , 0 , godparentIndex . length , - 1 ) ; Arrays . fill ( parentIndex , 0 , parentIndex . length , - 1 ) ; System . gc ( ) ; recomputeCursorTotals ( root ( ) ) ; System . gc ( ) ; recomputeCursorPositions ( root ( ) , 0 ) ; System . gc ( ) ; return this ; } | Recompute cursor details char trie . |
17,877 | public TrieNode matchEnd ( String search ) { if ( search . isEmpty ( ) ) return root ( ) ; int min = 0 ; int max = search . length ( ) ; int i = Math . min ( max , 12 ) ; int winner = - 1 ; while ( max > min ) { String attempt = search . substring ( search . length ( ) - i ) ; TrieNode cursor = traverse ( attempt ) ; if ( cursor . getString ( ) . equals ( attempt ) ) { min = Math . max ( min , i + 1 ) ; winner = Math . max ( winner , i ) ; } else { max = Math . min ( max , i - 1 ) ; } i = ( 3 * max + min ) / 4 ; } if ( winner < 0 ) return root ( ) ; String matched = search . substring ( search . length ( ) - winner ) ; return traverse ( matched ) ; } | Match end trie node . |
17,878 | public TrieNode matchPredictor ( String search ) { TrieNode cursor = matchEnd ( search ) ; if ( cursor . getNumberOfChildren ( ) > 0 ) { return cursor ; } String string = cursor . getString ( ) ; if ( string . isEmpty ( ) ) return null ; return matchPredictor ( string . substring ( 1 ) ) ; } | Match predictor trie node . |
17,879 | public Set < Character > tokens ( ) { return root ( ) . getChildrenMap ( ) . keySet ( ) . stream ( ) . filter ( c -> c != END_OF_STRING && c != FALLBACK && c != ESCAPE ) . collect ( Collectors . toSet ( ) ) ; } | Tokens set . |
17,880 | public < T extends Comparable < T > > Stream < TrieNode > max ( Function < TrieNode , T > fn , int maxResults ) { return max ( fn , maxResults , root ( ) ) ; } | Max stream . |
17,881 | public static int parseDurationString ( String timeStr ) { int seconds = 0 ; Matcher matcher = timeStringPattern . matcher ( timeStr ) ; while ( matcher . find ( ) ) { String s = matcher . group ( ) ; String [ ] parts = s . split ( "(?<=[yMwdhms])(?=\\d)|(?<=\\d)(?=[yMwdhms])" ) ; int numb = Integer . parseInt ( parts [ 0 ] ) ; String type = parts [ 1 ] ; switch ( type ) { case "s" : seconds = seconds + ( numb ) ; break ; case "m" : seconds = seconds + ( numb * 60 ) ; break ; case "h" : seconds = seconds + ( numb * 60 * 60 ) ; break ; case "d" : seconds = seconds + ( numb * 60 * 60 * 24 ) ; break ; case "w" : seconds = seconds + ( numb * 60 * 60 * 24 * 7 ) ; break ; case "M" : seconds = seconds + ( numb * 60 * 60 * 24 * 30 ) ; break ; case "y" : seconds = seconds + ( numb * 60 * 60 * 24 * 365 ) ; break ; default : } } return seconds ; } | parseToSeconds duration string like nYnMnDnHnMnS to seconds |
17,882 | public void associateWithPackage ( org . drools . core . rule . Package pkg ) { factTemplate = pkg . getFactTemplate ( factTemplateName ) ; } | Associate this fact with a package which has a FactTemplate defined with the same FactTemplate name |
17,883 | private static String mkString ( TreeSet < Integer > values ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "\033[" ) ; boolean first = true ; for ( int i : values ) { if ( first ) { first = false ; } else { builder . append ( ';' ) ; } builder . append ( String . format ( "%d" , i ) ) ; } builder . append ( "m" ) ; return builder . toString ( ) ; } | Generate the color string . |
17,884 | private boolean headerEq ( HttpRequestBase request , String headerName , String headerValue ) { Header [ ] headers = request . getAllHeaders ( ) ; if ( headers != null ) { for ( Header h : headers ) { if ( headerName . equalsIgnoreCase ( h . getName ( ) ) && headerValue . equalsIgnoreCase ( h . getValue ( ) ) ) { return true ; } } } return false ; } | Check if request contains header with value |
17,885 | public static Object eval ( String script ) { try { return getScriptEngine ( ) . eval ( script ) ; } catch ( Exception e ) { return JMExceptionManager . handleExceptionAndReturnNull ( log , e , "eval" , script ) ; } } | Eval object . |
17,886 | public void setDirectoryServers ( List < String > servers ) { if ( servers == null || servers . size ( ) == 0 ) { return ; } directoryServers = new DirectoryServers ( servers ) ; connection . setDirectoryServers ( directoryServers . getNextDirectoryServer ( ) ) ; } | Set the Directory Server list . |
17,887 | public void setUser ( String userName , String password ) { if ( userName != null && ! userName . isEmpty ( ) ) { connection . setDirectoryUser ( userName , password ) ; } } | Set the user for the DirectoryServiceClient . |
17,888 | public void createUser ( User user , String password ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . CreateUser ) ; byte [ ] secret = null ; if ( password != null && ! password . isEmpty ( ) ) { secret = ObfuscatUtil . base64Encode ( password . getBytes ( ) ) ; } CreateUserProtocol p = new CreateUserProtocol ( user , secret ) ; connection . submitRequest ( header , p , null ) ; } | Create a User . |
17,889 | public void setUserPassword ( String userName , String password ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . SetUserPassword ) ; byte [ ] secret = null ; if ( password != null && ! password . isEmpty ( ) ) { secret = ObfuscatUtil . base64Encode ( password . getBytes ( ) ) ; } SetUserPasswordProtocol p = new SetUserPasswordProtocol ( userName , secret ) ; connection . submitRequest ( header , p , null ) ; } | Set user password . |
17,890 | public void deleteUser ( String userName ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . DeleteUser ) ; DeleteUserProtocol p = new DeleteUserProtocol ( userName ) ; connection . submitRequest ( header , p , null ) ; } | Delete user by name . |
17,891 | public List < User > getAllUser ( ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . GetAllUser ) ; Response resp = connection . submitRequest ( header , null , null ) ; return ( ( GetAllUserResponse ) resp ) . getUsers ( ) ; } | Get all Users . |
17,892 | public User getUser ( String name ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . GetUser ) ; GetUserProtocol p = new GetUserProtocol ( name ) ; Response resp = connection . submitRequest ( header , p , null ) ; return ( ( GetUserResponse ) resp ) . getUser ( ) ; } | Get user by name . |
17,893 | public void setACL ( ACL acl ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . SetACL ) ; SetACLProtocol p = new SetACLProtocol ( acl ) ; connection . submitRequest ( header , p , null ) ; } | Set ACL . |
17,894 | public ACL getACL ( AuthScheme scheme , String id ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . GetACL ) ; GetACLProtocol p = new GetACLProtocol ( scheme , id ) ; Response resp = connection . submitRequest ( header , p , null ) ; return ( ( GetACLResponse ) resp ) . getAcl ( ) ; } | Get the ACL . |
17,895 | public void registerServiceInstance ( ProvidedServiceInstance instance , final RegistrationCallback cb , Object context ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . RegisterServiceInstance ) ; RegisterServiceInstanceProtocol p = new RegisterServiceInstanceProtocol ( instance ) ; ProtocolCallback pcb = new ProtocolCallback ( ) { public void call ( boolean result , Response response , ErrorCode error , Object ctx ) { cb . call ( result , error , ctx ) ; } } ; connection . submitCallbackRequest ( header , p , pcb , context ) ; } | Register ServiceInstance with Callback . |
17,896 | public void updateServiceInstanceStatus ( String serviceName , String instanceId , OperationalStatus status ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . UpdateServiceInstanceStatus ) ; UpdateServiceInstanceStatusProtocol p = new UpdateServiceInstanceStatusProtocol ( serviceName , instanceId , status ) ; connection . submitRequest ( header , p , null ) ; } | Update ServiceInstance status . |
17,897 | public void updateServiceInstanceStatus ( String serviceName , String instanceId , OperationalStatus status , final RegistrationCallback cb , Object context ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . UpdateServiceInstanceStatus ) ; UpdateServiceInstanceStatusProtocol p = new UpdateServiceInstanceStatusProtocol ( serviceName , instanceId , status ) ; ProtocolCallback pcb = new ProtocolCallback ( ) { public void call ( boolean result , Response response , ErrorCode error , Object ctx ) { cb . call ( result , error , ctx ) ; } } ; connection . submitCallbackRequest ( header , p , pcb , context ) ; } | Update ServiceInstance status with Callback . |
17,898 | public void updateServiceInstanceInternalStatus ( String serviceName , String instanceId , OperationalStatus status ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . UpdateServiceInstanceInternalStatus ) ; UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol ( serviceName , instanceId , status ) ; connection . submitRequest ( header , protocol , null ) ; } | Update ServiceInstance internal status . |
17,899 | public void updateServiceInstanceInternalStatus ( String serviceName , String instanceId , OperationalStatus status , final RegistrationCallback cb , Object context ) { ProtocolHeader header = new ProtocolHeader ( ) ; header . setType ( ProtocolType . UpdateServiceInstanceInternalStatus ) ; UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol ( serviceName , instanceId , status ) ; ProtocolCallback pcb = new ProtocolCallback ( ) { public void call ( boolean result , Response response , ErrorCode error , Object ctx ) { cb . call ( result , error , ctx ) ; } } ; connection . submitCallbackRequest ( header , protocol , pcb , context ) ; } | Update ServiceInstance internal status with Callback . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.