idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
13,100 | public RequestHeader withUri ( URI uri ) { return new RequestHeader ( method , uri , protocol , acceptedResponseProtocols , principal , headers , lowercaseHeaders ) ; } | Return a copy of this request header with the given uri set . |
13,101 | public RequestHeader withAcceptedResponseProtocols ( PSequence < MessageProtocol > acceptedResponseProtocols ) { return new RequestHeader ( method , uri , protocol , acceptedResponseProtocols , principal , headers , lowercaseHeaders ) ; } | Return a copy of this request header with the given accepted response protocols set . |
13,102 | public RequestHeader withPrincipal ( Principal principal ) { return new RequestHeader ( method , uri , protocol , acceptedResponseProtocols , Optional . ofNullable ( principal ) , headers , lowercaseHeaders ) ; } | Return a copy of this request header with the principal set . |
13,103 | public RequestHeader clearPrincipal ( ) { return new RequestHeader ( method , uri , protocol , acceptedResponseProtocols , Optional . empty ( ) , headers , lowercaseHeaders ) ; } | Return a copy of this request header with the principal cleared . |
13,104 | public Optional < String > getHeader ( String name ) { PSequence < String > values = lowercaseHeaders . get ( name . toLowerCase ( Locale . ENGLISH ) ) ; if ( values == null || values . isEmpty ( ) ) { return Optional . empty ( ) ; } else { return Optional . of ( values . get ( 0 ) ) ; } } | Get the header with the given name . |
13,105 | @ SuppressWarnings ( "unchecked" ) public < Metadata > Optional < Metadata > get ( MetadataKey < Metadata > key ) { return Optional . ofNullable ( ( Metadata ) metadataMap . get ( key ) ) ; } | Get the metadata for the given metadata key . |
13,106 | public < Metadata > Message < Payload > add ( MetadataKey < Metadata > key , Metadata metadata ) { return new Message < > ( payload , metadataMap . plus ( key , metadata ) ) ; } | Add a metadata key and value to this message . |
13,107 | public static < Payload > Message < Payload > create ( Payload payload ) { return new Message < > ( payload , HashTreePMap . empty ( ) ) ; } | Create a message with the given payload . |
13,108 | public static Binder binder ( Object module ) { if ( module instanceof AbstractModule ) { try { Method method = AbstractModule . class . getDeclaredMethod ( "binder" ) ; if ( ! method . isAccessible ( ) ) { method . setAccessible ( true ) ; } return ( Binder ) method . invoke ( module ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } else { throw new IllegalArgumentException ( "Module must be an instance of AbstractModule" ) ; } } | Get the binder from an AbstractModule . |
13,109 | public Descriptor withCalls ( Call < ? , ? > ... calls ) { return replaceAllCalls ( this . calls . plusAll ( Arrays . asList ( calls ) ) ) ; } | Add the given service calls to this service . |
13,110 | public Descriptor replaceAllCalls ( PSequence < Call < ? , ? > > calls ) { return new Descriptor ( name , calls , pathParamSerializers , messageSerializers , serializerFactory , exceptionSerializer , autoAcl , acls , headerFilter , locatableService , circuitBreaker , topicCalls ) ; } | Replace all the service calls provided by this descriptor with the the given service calls . |
13,111 | public Descriptor replaceAllPathParamSerializers ( PMap < Type , PathParamSerializer < ? > > pathParamSerializers ) { return new Descriptor ( name , calls , pathParamSerializers , messageSerializers , serializerFactory , exceptionSerializer , autoAcl , acls , headerFilter , locatableService , circuitBreaker , topicCalls ) ; } | Replace all the path param serializers registered with this descriptor with the the given path param serializers . |
13,112 | public Descriptor replaceAllMessageSerializers ( PMap < Type , MessageSerializer < ? , ? > > messageSerializers ) { return new Descriptor ( name , calls , pathParamSerializers , messageSerializers , serializerFactory , exceptionSerializer , autoAcl , acls , headerFilter , locatableService , circuitBreaker , topicCalls ) ; } | Replace all the message serializers registered with this descriptor with the the given message serializers . |
13,113 | public Descriptor replaceAllTopicCalls ( PSequence < TopicCall < ? > > topicCalls ) { return new Descriptor ( name , calls , pathParamSerializers , messageSerializers , serializerFactory , exceptionSerializer , autoAcl , acls , headerFilter , locatableService , circuitBreaker , topicCalls ) ; } | Replace all the topic calls provided by this descriptor with the the given topic calls . |
13,114 | public Descriptor withExceptionSerializer ( ExceptionSerializer exceptionSerializer ) { return new Descriptor ( name , calls , pathParamSerializers , messageSerializers , serializerFactory , exceptionSerializer , autoAcl , acls , headerFilter , locatableService , circuitBreaker , topicCalls ) ; } | Use the given exception serializer to serialize and deserialized exceptions handled by this service . |
13,115 | public Descriptor withServiceAcls ( ServiceAcl ... acls ) { return replaceAllAcls ( this . acls . plusAll ( Arrays . asList ( acls ) ) ) ; } | Add the given manual ACLs . |
13,116 | public Descriptor replaceAllAcls ( PSequence < ServiceAcl > acls ) { return new Descriptor ( name , calls , pathParamSerializers , messageSerializers , serializerFactory , exceptionSerializer , autoAcl , acls , headerFilter , locatableService , circuitBreaker , topicCalls ) ; } | Replace all the ACLs with the given ACL sequence . |
13,117 | public Descriptor withTopics ( TopicCall < ? > ... topicCalls ) { return new Descriptor ( name , calls , pathParamSerializers , messageSerializers , serializerFactory , exceptionSerializer , autoAcl , acls , headerFilter , locatableService , circuitBreaker , this . topicCalls . plusAll ( Arrays . asList ( topicCalls ) ) ) ; } | Add the given topic calls to this service . |
13,118 | public static < Message > Topic < Message > singleStreamWithOffset ( Function < Offset , Source < Pair < Message , Offset > , ? > > eventStream ) { return taggedStreamWithOffset ( SINGLETON_TAG , ( tag , offset ) -> eventStream . apply ( offset ) ) ; } | Publish a single stream . |
13,119 | public static < Message , Event extends AggregateEvent < Event > > Topic < Message > taggedStreamWithOffset ( PSequence < AggregateEventTag < Event > > tags , BiFunction < AggregateEventTag < Event > , Offset , Source < Pair < Message , Offset > , ? > > eventStream ) { return new TaggedOffsetTopicProducer < > ( tags , eventStream ) ; } | Publish a stream that is sharded across many tags . |
13,120 | public static < Message , Event extends AggregateEvent < Event > > Topic < Message > taggedStreamWithOffset ( AggregateEventShards < Event > shards , BiFunction < AggregateEventTag < Event > , Offset , Source < Pair < Message , Offset > , ? > > eventStream ) { return new TaggedOffsetTopicProducer < > ( shards . allTags ( ) , eventStream ) ; } | Publish all tags of a stream that is sharded across many tags . |
13,121 | public static TransportErrorCode fromHttp ( int code ) { TransportErrorCode builtIn = HTTP_ERROR_CODE_MAP . get ( code ) ; if ( builtIn == null ) { if ( code > 599 || code < 100 ) { throw new IllegalArgumentException ( "Invalid http status code: " + code ) ; } else if ( code < 400 ) { throw new IllegalArgumentException ( "Invalid http error code: " + code ) ; } else { return new TransportErrorCode ( code , 4000 + code , "Unknown error code" ) ; } } else { return builtIn ; } } | Get a transport error code from the given HTTP error code . |
13,122 | public static TransportErrorCode fromWebSocket ( int code ) { TransportErrorCode builtIn = WEBSOCKET_ERROR_CODE_MAP . get ( code ) ; if ( builtIn == null ) { if ( code < 0 || code > 65535 ) { throw new IllegalArgumentException ( "Invalid WebSocket status code: " + code ) ; } else if ( code >= 4400 && code <= 4599 ) { return new TransportErrorCode ( code - 4000 , code , "Unknown error code" ) ; } else { return new TransportErrorCode ( 404 , code , "Unknown error code" ) ; } } else { return builtIn ; } } | Get a transport error code from the given WebSocket close code . |
13,123 | private Behavior becomePostAdded ( BlogState newState ) { BehaviorBuilder b = newBehaviorBuilder ( newState ) ; b . setCommandHandler ( ChangeBody . class , ( cmd , ctx ) -> ctx . thenPersist ( new BodyChanged ( entityId ( ) , cmd . getBody ( ) ) , evt -> ctx . reply ( Done . getInstance ( ) ) ) ) ; b . setEventHandler ( BodyChanged . class , evt -> state ( ) . withBody ( evt . getBody ( ) ) ) ; b . setCommandHandler ( Publish . class , ( cmd , ctx ) -> ctx . thenPersist ( new PostPublished ( entityId ( ) ) , evt -> { ctx . reply ( Done . getInstance ( ) ) ; publishedTopic . publish ( evt ) ; } ) ) ; b . setEventHandler ( PostPublished . class , evt -> new BlogState ( state ( ) . getContent ( ) , true ) ) ; return b . build ( ) ; } | Behavior can be changed in the event handlers . |
13,124 | public static GoogleLogger forEnclosingClass ( ) { String loggingClass = Platform . getCallerFinder ( ) . findLoggingClass ( GoogleLogger . class ) ; return new GoogleLogger ( Platform . getBackend ( loggingClass ) ) ; } | Returns a new Google specific logger instance using printf style message formatting . |
13,125 | public static GoogleLogger forInjectedClassName ( String className ) { checkArgument ( ! className . isEmpty ( ) , "injected class name is empty" ) ; return new GoogleLogger ( Platform . getBackend ( className . replace ( '/' , '.' ) ) ) ; } | Returns a new Google specific logger instance for the given class using printf style message formatting . |
13,126 | public Tags merge ( Tags other ) { if ( other . isEmpty ( ) ) { return this ; } if ( this . isEmpty ( ) ) { return other ; } SortedMap < String , SortedSet < Object > > merged = new TreeMap < String , SortedSet < Object > > ( ) ; for ( Map . Entry < String , SortedSet < Object > > e : map . entrySet ( ) ) { SortedSet < Object > otherValues = other . map . get ( e . getKey ( ) ) ; if ( otherValues == null || e . getValue ( ) . containsAll ( otherValues ) ) { merged . put ( e . getKey ( ) , e . getValue ( ) ) ; } else if ( otherValues . containsAll ( e . getValue ( ) ) ) { merged . put ( e . getKey ( ) , otherValues ) ; } else { SortedSet < Object > mergedValues = new TreeSet < Object > ( e . getValue ( ) ) ; mergedValues . addAll ( otherValues ) ; merged . put ( e . getKey ( ) , Collections . unmodifiableSortedSet ( mergedValues ) ) ; } } for ( Map . Entry < String , SortedSet < Object > > e : other . map . entrySet ( ) ) { if ( ! map . containsKey ( e . getKey ( ) ) ) { merged . put ( e . getKey ( ) , e . getValue ( ) ) ; } } return new Tags ( Collections . unmodifiableSortedMap ( merged ) ) ; } | Merges two tags instances combining values for any name contained in both . |
13,127 | private static < T > T resolveAttribute ( String attributeName , Class < T > type ) { String getter = readProperty ( attributeName ) ; if ( getter == null ) { return null ; } int idx = getter . indexOf ( '#' ) ; if ( idx <= 0 || idx == getter . length ( ) - 1 ) { error ( "invalid getter (expected <class>#<method>): %s\n" , getter ) ; return null ; } return callStaticMethod ( getter . substring ( 0 , idx ) , getter . substring ( idx + 1 ) , type ) ; } | Helper to call a static no - arg getter to obtain an instance of a specified type . This is used for platform aspects which are optional but are expected to have a singleton available . |
13,128 | private static Parameter wrapHexParameter ( final FormatOptions options , int index ) { return new Parameter ( options , index ) { protected void accept ( ParameterVisitor visitor , Object value ) { visitor . visit ( value . hashCode ( ) , FormatChar . HEX , getFormatOptions ( ) ) ; } public String getFormat ( ) { return options . shouldUpperCase ( ) ? "%H" : "%h" ; } } ; } | Static method so the anonymous synthetic parameter is static rather than an inner class . |
13,129 | void log ( LogRecord record , boolean wasForced ) { if ( ! wasForced || logger . isLoggable ( record . getLevel ( ) ) ) { logger . log ( record ) ; } else { Filter filter = logger . getFilter ( ) ; if ( filter != null ) { filter . isLoggable ( record ) ; } if ( logger . getClass ( ) == Logger . class || cannotUseForcingLogger ) { publish ( logger , record ) ; } else { forceLoggingViaChildLogger ( record ) ; } } } | loggability check . |
13,130 | private static void publish ( Logger logger , LogRecord record ) { for ( Handler handler : logger . getHandlers ( ) ) { handler . publish ( record ) ; } if ( logger . getUseParentHandlers ( ) ) { logger = logger . getParent ( ) ; if ( logger != null ) { publish ( logger , record ) ; } } } | rate limiting . Thus we don t have to care about using iterative methods vs recursion here . |
13,131 | void forceLoggingViaChildLogger ( LogRecord record ) { Logger forcingLogger = getForcingLogger ( logger ) ; try { forcingLogger . setLevel ( Level . ALL ) ; } catch ( SecurityException e ) { cannotUseForcingLogger = true ; Logger . getLogger ( "" ) . log ( Level . SEVERE , "Forcing log statements with Flogger has been partially disabled.\n" + "The Flogger library cannot modify logger log levels, which is necessary to force" + " log statements. This is likely due to an installed SecurityManager.\n" + "Forced log statements will still be published directly to log handlers, but will" + " not be visible to the 'log(LogRecord)' method of Logger sub-classes.\n" ) ; publish ( logger , record ) ; return ; } forcingLogger . log ( record ) ; } | subclasses of Logger to be used . |
13,132 | public static String checkMetadataIdentifier ( String s ) { if ( s . isEmpty ( ) ) { throw new IllegalArgumentException ( "identifier must not be empty" ) ; } if ( ! isLetter ( s . charAt ( 0 ) ) ) { throw new IllegalArgumentException ( "identifier must start with an ASCII letter: " + s ) ; } for ( int n = 1 ; n < s . length ( ) ; n ++ ) { char c = s . charAt ( n ) ; if ( ! isLetter ( c ) && ( c < '0' || c > '9' ) && c != '_' ) { throw new IllegalArgumentException ( "identifier must contain only ASCII letters, digits or underscore: " + s ) ; } } return s ; } | Checks if the given string is a valid metadata identifier . |
13,133 | public static StackTraceElement findCallerOf ( Class < ? > target , Throwable throwable , int skip ) { checkNotNull ( target , "target" ) ; checkNotNull ( throwable , "throwable" ) ; if ( skip < 0 ) { throw new IllegalArgumentException ( "skip count cannot be negative: " + skip ) ; } StackTraceElement [ ] stack = ( stackGetter != null ) ? null : throwable . getStackTrace ( ) ; boolean foundCaller = false ; try { for ( int index = skip ; ; index ++ ) { StackTraceElement element = ( stackGetter != null ) ? stackGetter . getStackTraceElement ( throwable , index ) : stack [ index ] ; if ( target . getName ( ) . equals ( element . getClassName ( ) ) ) { foundCaller = true ; } else if ( foundCaller ) { return element ; } } } catch ( Exception e ) { return null ; } } | Returns the stack trace element of the immediate caller of the specified class . |
13,134 | public static StackTraceElement [ ] getStackForCallerOf ( Class < ? > target , Throwable throwable , int maxDepth ) { checkNotNull ( target , "target" ) ; checkNotNull ( throwable , "throwable" ) ; if ( maxDepth <= 0 && maxDepth != - 1 ) { throw new IllegalArgumentException ( "invalid maximum depth: " + maxDepth ) ; } StackTraceElement [ ] stack ; int depth ; if ( stackGetter != null ) { stack = null ; depth = stackGetter . getStackTraceDepth ( throwable ) ; } else { stack = throwable . getStackTrace ( ) ; depth = stack . length ; } boolean foundCaller = false ; for ( int index = 0 ; index < depth ; index ++ ) { StackTraceElement element = ( stackGetter != null ) ? stackGetter . getStackTraceElement ( throwable , index ) : stack [ index ] ; if ( target . getName ( ) . equals ( element . getClassName ( ) ) ) { foundCaller = true ; } else if ( foundCaller ) { int elementsToAdd = depth - index ; if ( maxDepth > 0 && maxDepth < elementsToAdd ) { elementsToAdd = maxDepth ; } StackTraceElement [ ] syntheticStack = new StackTraceElement [ elementsToAdd ] ; syntheticStack [ 0 ] = element ; for ( int n = 1 ; n < elementsToAdd ; n ++ ) { syntheticStack [ n ] = ( stackGetter != null ) ? stackGetter . getStackTraceElement ( throwable , index + n ) : stack [ index + n ] ; } return syntheticStack ; } } return new StackTraceElement [ 0 ] ; } | Returns a synthetic stack trace starting at the immediate caller of the specified target . |
13,135 | public final T build ( ) { getParser ( ) . parseImpl ( this ) ; if ( ( pmask & ( pmask + 1 ) ) != 0 || ( maxIndex > 31 && pmask != - 1 ) ) { int firstMissing = Integer . numberOfTrailingZeros ( ~ pmask ) ; throw ParseException . generic ( String . format ( "unreferenced arguments [first missing index=%d]" , firstMissing ) , getMessage ( ) ) ; } return buildImpl ( ) ; } | Builds a log message using the current message context . |
13,136 | public static FluentLogger forEnclosingClass ( ) { String loggingClass = Platform . getCallerFinder ( ) . findLoggingClass ( FluentLogger . class ) ; return new FluentLogger ( Platform . getBackend ( loggingClass ) ) ; } | Returns a new logger instance which parses log messages using printf format for the enclosing class using the system default logging backend . |
13,137 | @ SuppressWarnings ( "ReferenceEquality" ) private void logImpl ( String message , Object ... args ) { this . args = args ; for ( int n = 0 ; n < args . length ; n ++ ) { if ( args [ n ] instanceof LazyArg ) { args [ n ] = ( ( LazyArg < ? > ) args [ n ] ) . evaluate ( ) ; } } if ( message != LITERAL_VALUE_MESSAGE ) { this . templateContext = new TemplateContext ( getMessageParser ( ) , message ) ; } getLogger ( ) . write ( this ) ; } | Make the backend logging call . This is the point at which we have paid the price of creating a varargs array and doing any necessary auto - boxing . |
13,138 | private static SimpleParameter [ ] createParameterArray ( FormatChar formatChar ) { SimpleParameter [ ] parameters = new SimpleParameter [ MAX_CACHED_PARAMETERS ] ; for ( int index = 0 ; index < MAX_CACHED_PARAMETERS ; index ++ ) { parameters [ index ] = new SimpleParameter ( index , formatChar , FormatOptions . getDefault ( ) ) ; } return parameters ; } | Helper to make reusable default parameter instances for the commonest indices . |
13,139 | public static LoggerConfig getConfig ( String name ) { LoggerConfig config = strongRefMap . get ( checkNotNull ( name , "logger name" ) ) ; if ( config == null ) { config = new LoggerConfig ( name ) ; strongRefMap . put ( name , config ) ; } return config ; } | Returns a configuration instance suitable for configuring a logger with the same name . |
13,140 | final void write ( LogData data ) { checkNotNull ( data , "data" ) ; try { backend . log ( data ) ; } catch ( RuntimeException error ) { try { backend . handleError ( error , data ) ; } catch ( LoggingException allowed ) { throw allowed ; } catch ( RuntimeException wtf ) { System . err . println ( "logging error: " + wtf . getMessage ( ) ) ; wtf . printStackTrace ( System . err ) ; } } } | Invokes the logging backend to write a log statement . |
13,141 | private static void safeFormatTo ( Formattable value , StringBuilder out , FormatOptions options ) { int formatFlags = options . getFlags ( ) & ( FLAG_LEFT_ALIGN | FLAG_UPPER_CASE | FLAG_SHOW_ALT_FORM ) ; if ( formatFlags != 0 ) { formatFlags = ( ( formatFlags & FLAG_LEFT_ALIGN ) != 0 ? FormattableFlags . LEFT_JUSTIFY : 0 ) | ( ( formatFlags & FLAG_UPPER_CASE ) != 0 ? FormattableFlags . UPPERCASE : 0 ) | ( ( formatFlags & FLAG_SHOW_ALT_FORM ) != 0 ? FormattableFlags . ALTERNATE : 0 ) ; } int originalLength = out . length ( ) ; Formatter formatter = new Formatter ( out , FORMAT_LOCALE ) ; try { value . formatTo ( formatter , formatFlags , options . getWidth ( ) , options . getPrecision ( ) ) ; } catch ( RuntimeException e ) { out . setLength ( originalLength ) ; try { formatter . out ( ) . append ( getErrorString ( value , e ) ) ; } catch ( IOException impossible ) { } } } | Returns a string representation of the user supplied formattable accounting for any possible runtime exceptions . |
13,142 | static org . apache . log4j . Level toLog4jLevel ( java . util . logging . Level level ) { if ( level . intValue ( ) >= java . util . logging . Level . SEVERE . intValue ( ) ) { return org . apache . log4j . Level . ERROR ; } else if ( level . intValue ( ) >= java . util . logging . Level . WARNING . intValue ( ) ) { return org . apache . log4j . Level . WARN ; } else if ( level . intValue ( ) >= java . util . logging . Level . INFO . intValue ( ) ) { return org . apache . log4j . Level . INFO ; } else if ( level . intValue ( ) >= java . util . logging . Level . FINE . intValue ( ) ) { return org . apache . log4j . Level . DEBUG ; } return org . apache . log4j . Level . TRACE ; } | Converts java . util . logging . Level to org . apache . log4j . Level . |
13,143 | public static ParseException withBounds ( String errorMessage , String logMessage , int start , int end ) { return new ParseException ( msg ( errorMessage , logMessage , start , end ) , logMessage ) ; } | Creates a new parse exception for situations in which both the start and end positions of the error are known . |
13,144 | public static ParseException atPosition ( String errorMessage , String logMessage , int position ) { return new ParseException ( msg ( errorMessage , logMessage , position , position + 1 ) , logMessage ) ; } | Creates a new parse exception for situations in which the position of the error is known . |
13,145 | public static ParseException withStartPosition ( String errorMessage , String logMessage , int start ) { return new ParseException ( msg ( errorMessage , logMessage , start , - 1 ) , logMessage ) ; } | Creates a new parse exception for situations in which only the start position of the error is known . |
13,146 | private static String msg ( String errorMessage , String logMessage , int errorStart , int errorEnd ) { if ( errorEnd < 0 ) { errorEnd = logMessage . length ( ) ; } StringBuilder out = new StringBuilder ( errorMessage ) . append ( ": " ) ; if ( errorStart > SNIPPET_LENGTH + ELLIPSIS . length ( ) ) { out . append ( ELLIPSIS ) . append ( logMessage , errorStart - SNIPPET_LENGTH , errorStart ) ; } else { out . append ( logMessage , 0 , errorStart ) ; } out . append ( '[' ) . append ( logMessage . substring ( errorStart , errorEnd ) ) . append ( ']' ) ; if ( logMessage . length ( ) - errorEnd > SNIPPET_LENGTH + ELLIPSIS . length ( ) ) { out . append ( logMessage , errorEnd , errorEnd + SNIPPET_LENGTH ) . append ( ELLIPSIS ) ; } else { out . append ( logMessage , errorEnd , logMessage . length ( ) ) ; } return out . toString ( ) ; } | Helper to format a human readable error message for this exception . |
13,147 | static void formatBadLogData ( RuntimeException error , LogData badLogData , SimpleLogHandler receiver ) { StringBuilder errorMsg = new StringBuilder ( "LOGGING ERROR: " ) . append ( error . getMessage ( ) ) . append ( '\n' ) ; int length = errorMsg . length ( ) ; try { appendLogData ( badLogData , errorMsg ) ; } catch ( RuntimeException e ) { errorMsg . setLength ( length ) ; errorMsg . append ( "Cannot append LogData: " ) . append ( e ) ; } Level level = badLogData . getLevel ( ) . intValue ( ) < WARNING . intValue ( ) ? WARNING : badLogData . getLevel ( ) ; receiver . handleFormattedLogMessage ( level , errorMsg . toString ( ) , error ) ; } | Formats the log message in response to an exception during a previous logging attempt . A synthetic error message is generated from the original log data and the given exception is set as the cause . The level of this record is the maximum of WARNING or the original level . |
13,148 | public static FormatOptions of ( int flags , int width , int precision ) { if ( ! checkFlagConsistency ( flags , width != UNSET ) ) { throw new IllegalArgumentException ( "invalid flags: 0x" + Integer . toHexString ( flags ) ) ; } if ( ( width < 1 || width > MAX_ALLOWED_WIDTH ) && width != UNSET ) { throw new IllegalArgumentException ( "invalid width: " + width ) ; } if ( ( precision < 0 || precision > MAX_ALLOWED_PRECISION ) && precision != UNSET ) { throw new IllegalArgumentException ( "invalid precision: " + precision ) ; } return new FormatOptions ( flags , width , precision ) ; } | Creates a options instance with the given values . |
13,149 | public static FormatOptions parse ( String message , int pos , int end , boolean isUpperCase ) throws ParseException { if ( pos == end && ! isUpperCase ) { return DEFAULT ; } int flags = isUpperCase ? FLAG_UPPER_CASE : 0 ; char c ; while ( true ) { if ( pos == end ) { return new FormatOptions ( flags , UNSET , UNSET ) ; } c = message . charAt ( pos ++ ) ; if ( c < MIN_FLAG_VALUE || c > MAX_FLAG_VALUE ) { break ; } int flagIdx = indexOfFlagCharacter ( c ) ; if ( flagIdx < 0 ) { if ( c == '.' ) { return new FormatOptions ( flags , UNSET , parsePrecision ( message , pos , end ) ) ; } throw ParseException . atPosition ( "invalid flag" , message , pos - 1 ) ; } int flagBit = 1 << flagIdx ; if ( ( flags & flagBit ) != 0 ) { throw ParseException . atPosition ( "repeated flag" , message , pos - 1 ) ; } flags |= flagBit ; } int widthStart = pos - 1 ; if ( c > '9' ) { throw ParseException . atPosition ( "invalid flag" , message , widthStart ) ; } int width = c - '0' ; while ( true ) { if ( pos == end ) { return new FormatOptions ( flags , width , UNSET ) ; } c = message . charAt ( pos ++ ) ; if ( c == '.' ) { return new FormatOptions ( flags , width , parsePrecision ( message , pos , end ) ) ; } int n = ( char ) ( c - '0' ) ; if ( n >= 10 ) { throw ParseException . atPosition ( "invalid width character" , message , pos - 1 ) ; } width = ( width * 10 ) + n ; if ( width > MAX_ALLOWED_WIDTH ) { throw ParseException . withBounds ( "width too large" , message , widthStart , end ) ; } } } | Parses a sub - sequence of a log message to extract and return its options . Note that callers cannot rely on this method producing new instances each time it is called as caching of common option values may occur . |
13,150 | static int parseValidFlags ( String flagChars , boolean hasUpperVariant ) { int flags = hasUpperVariant ? FLAG_UPPER_CASE : 0 ; for ( int i = 0 ; i < flagChars . length ( ) ; i ++ ) { int flagIdx = indexOfFlagCharacter ( flagChars . charAt ( i ) ) ; if ( flagIdx < 0 ) { throw new IllegalArgumentException ( "invalid flags: " + flagChars ) ; } flags |= 1 << flagIdx ; } return flags ; } | Internal helper method for creating a bit - mask from a string of valid flag characters . |
13,151 | public FormatOptions filter ( int allowedFlags , boolean allowWidth , boolean allowPrecision ) { if ( isDefault ( ) ) { return this ; } int newFlags = allowedFlags & flags ; int newWidth = allowWidth ? width : UNSET ; int newPrecision = allowPrecision ? precision : UNSET ; if ( newFlags == 0 && newWidth == UNSET && newPrecision == UNSET ) { return DEFAULT ; } if ( newFlags == flags && newWidth == width && newPrecision == precision ) { return this ; } return new FormatOptions ( newFlags , newWidth , newPrecision ) ; } | Returns a possibly new FormatOptions instance possibly containing a subset of the formatting information . This is useful if a backend implementation wishes to create formatting options that ignore some of the specified formatting information . |
13,152 | static boolean checkFlagConsistency ( int flags , boolean hasWidth ) { if ( ( flags & ( FLAG_PREFIX_PLUS_FOR_POSITIVE_VALUES | FLAG_PREFIX_SPACE_FOR_POSITIVE_VALUES ) ) == ( FLAG_PREFIX_PLUS_FOR_POSITIVE_VALUES | FLAG_PREFIX_SPACE_FOR_POSITIVE_VALUES ) ) { return false ; } if ( ( flags & ( FLAG_LEFT_ALIGN | FLAG_SHOW_LEADING_ZEROS ) ) == ( FLAG_LEFT_ALIGN | FLAG_SHOW_LEADING_ZEROS ) ) { return false ; } if ( ( flags & ( FLAG_LEFT_ALIGN | FLAG_SHOW_LEADING_ZEROS ) ) != 0 && ! hasWidth ) { return false ; } return true ; } | Helper to check for legal combinations of flags . |
13,153 | public Class resolveTypeVariable ( TypeVariable typeVariable ) { for ( int i = argumentsSize - 2 ; i >= 0 ; i -= 2 ) if ( arguments [ i ] == typeVariable ) return ( Class ) arguments [ i + 1 ] ; return null ; } | Returns the class for the specified type variable or null if it is not known . |
13,154 | static public Type resolveType ( Class fromClass , Class toClass , Type type ) { if ( type instanceof Class ) return ( Class ) type ; if ( type instanceof TypeVariable ) return resolveTypeVariable ( fromClass , toClass , type , true ) ; if ( type instanceof ParameterizedType ) return ( Class ) ( ( ParameterizedType ) type ) . getRawType ( ) ; if ( type instanceof GenericArrayType ) { int dimensions = 1 ; while ( true ) { type = ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ; if ( ! ( type instanceof GenericArrayType ) ) break ; dimensions ++ ; } Type componentType = resolveType ( fromClass , toClass , type ) ; if ( ! ( componentType instanceof Class ) ) return type ; if ( dimensions == 1 ) return Array . newInstance ( ( Class ) componentType , 0 ) . getClass ( ) ; return Array . newInstance ( ( Class ) componentType , new int [ dimensions ] ) . getClass ( ) ; } if ( type instanceof WildcardType ) { Type upperBound = ( ( WildcardType ) type ) . getUpperBounds ( ) [ 0 ] ; if ( upperBound != Object . class ) return resolveType ( fromClass , toClass , upperBound ) ; Type [ ] lowerBounds = ( ( WildcardType ) type ) . getLowerBounds ( ) ; if ( lowerBounds . length != 0 ) return resolveType ( fromClass , toClass , lowerBounds [ 0 ] ) ; return Object . class ; } throw new KryoException ( "Unable to resolve type: " + type ) ; } | Returns the class for the specified type after replacing any type variables using the class hierarchy between the specified classes . |
13,155 | static private Type resolveTypeVariable ( Class fromClass , Class current , Type type , boolean first ) { Type genericSuper = current . getGenericSuperclass ( ) ; if ( ! ( genericSuper instanceof ParameterizedType ) ) return type ; Class superClass = current . getSuperclass ( ) ; if ( superClass != fromClass ) { Type resolved = resolveTypeVariable ( fromClass , superClass , type , false ) ; if ( resolved instanceof Class ) return ( Class ) resolved ; type = resolved ; } String name = type . toString ( ) ; TypeVariable [ ] params = superClass . getTypeParameters ( ) ; for ( int i = 0 , n = params . length ; i < n ; i ++ ) { TypeVariable param = params [ i ] ; if ( param . getName ( ) . equals ( name ) ) { Type arg = ( ( ParameterizedType ) genericSuper ) . getActualTypeArguments ( ) [ i ] ; if ( arg instanceof Class ) return ( Class ) arg ; if ( arg instanceof ParameterizedType ) return resolveType ( fromClass , current , arg ) ; if ( arg instanceof TypeVariable ) { if ( first ) return type ; return arg ; } } } throw new KryoException ( "Unable to resolve type variable: " + type ) ; } | Returns the class for the specified type variable by finding the first class in the hierarchy between the specified classes which explicitly specifies the type variable s class . |
13,156 | static public Type [ ] resolveTypeParameters ( Class fromClass , Class toClass , Type type ) { if ( type instanceof ParameterizedType ) { Type [ ] actualArgs = ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) ; int n = actualArgs . length ; Type [ ] generics = new Type [ n ] ; for ( int i = 0 ; i < n ; i ++ ) generics [ i ] = resolveType ( fromClass , toClass , actualArgs [ i ] ) ; return generics ; } if ( type instanceof GenericArrayType ) { while ( true ) { type = ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ; if ( ! ( type instanceof GenericArrayType ) ) break ; } return resolveTypeParameters ( fromClass , toClass , type ) ; } return null ; } | Resolves type variables for the type parameters of the specified type by using the class hierarchy between the specified classes . |
13,157 | protected int require ( int required ) throws KryoException { int remaining = limit - position ; if ( remaining >= required ) return remaining ; if ( required > capacity ) throw new KryoException ( "Buffer too small: capacity: " + capacity + ", required: " + required ) ; int count ; if ( remaining > 0 ) { count = fill ( buffer , limit , capacity - limit ) ; if ( count == - 1 ) throw new KryoException ( "Buffer underflow." ) ; remaining += count ; if ( remaining >= required ) { limit += count ; return remaining ; } } System . arraycopy ( buffer , position , buffer , 0 , remaining ) ; total += position ; position = 0 ; while ( true ) { count = fill ( buffer , remaining , capacity - remaining ) ; if ( count == - 1 ) { if ( remaining >= required ) break ; throw new KryoException ( "Buffer underflow." ) ; } remaining += count ; if ( remaining >= required ) break ; } limit = remaining ; return remaining ; } | Fills the buffer with at least the number of bytes specified . |
13,158 | protected int optional ( int optional ) throws KryoException { int remaining = limit - position ; if ( remaining >= optional ) return optional ; optional = Math . min ( optional , capacity ) ; int count ; count = fill ( buffer , limit , capacity - limit ) ; if ( count == - 1 ) return remaining == 0 ? - 1 : Math . min ( remaining , optional ) ; remaining += count ; if ( remaining >= optional ) { limit += count ; return optional ; } System . arraycopy ( buffer , position , buffer , 0 , remaining ) ; total += position ; position = 0 ; while ( true ) { count = fill ( buffer , remaining , capacity - remaining ) ; if ( count == - 1 ) break ; remaining += count ; if ( remaining >= optional ) break ; } limit = remaining ; return remaining == 0 ? - 1 : Math . min ( remaining , optional ) ; } | Fills the buffer with at least the number of bytes specified if possible . |
13,159 | public int readInt ( ) throws KryoException { require ( 4 ) ; byte [ ] buffer = this . buffer ; int p = this . position ; this . position = p + 4 ; return buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( buffer [ p + 3 ] & 0xFF ) << 24 ; } | Reads a 4 byte int . |
13,160 | public int readVarInt ( boolean optimizePositive ) throws KryoException { if ( require ( 1 ) < 5 ) return readVarInt_slow ( optimizePositive ) ; int b = buffer [ position ++ ] ; int result = b & 0x7F ; if ( ( b & 0x80 ) != 0 ) { byte [ ] buffer = this . buffer ; int p = position ; b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 7 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 14 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 21 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 28 ; } } } position = p ; } return optimizePositive ? result : ( ( result >>> 1 ) ^ - ( result & 1 ) ) ; } | Reads a 1 - 5 byte int . |
13,161 | public long readLong ( ) throws KryoException { require ( 8 ) ; byte [ ] buffer = this . buffer ; int p = position ; position = p + 8 ; return buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( long ) ( buffer [ p + 3 ] & 0xFF ) << 24 | ( long ) ( buffer [ p + 4 ] & 0xFF ) << 32 | ( long ) ( buffer [ p + 5 ] & 0xFF ) << 40 | ( long ) ( buffer [ p + 6 ] & 0xFF ) << 48 | ( long ) buffer [ p + 7 ] << 56 ; } | Reads an 8 byte long . |
13,162 | public long readVarLong ( boolean optimizePositive ) throws KryoException { if ( require ( 1 ) < 9 ) return readVarLong_slow ( optimizePositive ) ; int p = position ; int b = buffer [ p ++ ] ; long result = b & 0x7F ; if ( ( b & 0x80 ) != 0 ) { byte [ ] buffer = this . buffer ; b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 7 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 14 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( b & 0x7F ) << 21 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( long ) ( b & 0x7F ) << 28 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( long ) ( b & 0x7F ) << 35 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( long ) ( b & 0x7F ) << 42 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( long ) ( b & 0x7F ) << 49 ; if ( ( b & 0x80 ) != 0 ) { b = buffer [ p ++ ] ; result |= ( long ) b << 56 ; } } } } } } } } position = p ; return optimizePositive ? result : ( ( result >>> 1 ) ^ - ( result & 1 ) ) ; } | Reads a 1 - 9 byte long . |
13,163 | public float readFloat ( ) throws KryoException { require ( 4 ) ; byte [ ] buffer = this . buffer ; int p = this . position ; this . position = p + 4 ; return Float . intBitsToFloat ( buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( buffer [ p + 3 ] & 0xFF ) << 24 ) ; } | Reads a 4 byte float . |
13,164 | public double readDouble ( ) throws KryoException { require ( 8 ) ; byte [ ] buffer = this . buffer ; int p = position ; position = p + 8 ; return Double . longBitsToDouble ( buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( long ) ( buffer [ p + 3 ] & 0xFF ) << 24 | ( long ) ( buffer [ p + 4 ] & 0xFF ) << 32 | ( long ) ( buffer [ p + 5 ] & 0xFF ) << 40 | ( long ) ( buffer [ p + 6 ] & 0xFF ) << 48 | ( long ) buffer [ p + 7 ] << 56 ) ; } | Reads an 8 byte double . |
13,165 | public short readShort ( ) throws KryoException { require ( 2 ) ; int p = position ; position = p + 2 ; return ( short ) ( ( buffer [ p ] & 0xFF ) | ( ( buffer [ p + 1 ] & 0xFF ) ) << 8 ) ; } | Reads a 2 byte short . |
13,166 | public int readShortUnsigned ( ) throws KryoException { require ( 2 ) ; int p = position ; position = p + 2 ; return ( buffer [ p ] & 0xFF ) | ( ( buffer [ p + 1 ] & 0xFF ) ) << 8 ; } | Reads a 2 byte short as an int from 0 to 65535 . |
13,167 | public char readChar ( ) throws KryoException { require ( 2 ) ; int p = position ; position = p + 2 ; return ( char ) ( ( buffer [ p ] & 0xFF ) | ( ( buffer [ p + 1 ] & 0xFF ) ) << 8 ) ; } | Reads a 2 byte char . |
13,168 | public int [ ] readInts ( int length ) throws KryoException { int [ ] array = new int [ length ] ; if ( optional ( length << 2 ) == length << 2 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 4 ) { array [ i ] = buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( buffer [ p + 3 ] & 0xFF ) << 24 ; } position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readInt ( ) ; } return array ; } | Reads an int array in bulk . This may be more efficient than reading them individually . |
13,169 | public long [ ] readLongs ( int length ) throws KryoException { long [ ] array = new long [ length ] ; if ( optional ( length << 3 ) == length << 3 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 8 ) { array [ i ] = buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( long ) ( buffer [ p + 3 ] & 0xFF ) << 24 | ( long ) ( buffer [ p + 4 ] & 0xFF ) << 32 | ( long ) ( buffer [ p + 5 ] & 0xFF ) << 40 | ( long ) ( buffer [ p + 6 ] & 0xFF ) << 48 | ( long ) buffer [ p + 7 ] << 56 ; } position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readLong ( ) ; } return array ; } | Reads a long array in bulk . This may be more efficient than reading them individually . |
13,170 | public float [ ] readFloats ( int length ) throws KryoException { float [ ] array = new float [ length ] ; if ( optional ( length << 2 ) == length << 2 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 4 ) { array [ i ] = Float . intBitsToFloat ( buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( buffer [ p + 3 ] & 0xFF ) << 24 ) ; } position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readFloat ( ) ; } return array ; } | Reads a float array in bulk . This may be more efficient than reading them individually . |
13,171 | public double [ ] readDoubles ( int length ) throws KryoException { double [ ] array = new double [ length ] ; if ( optional ( length << 3 ) == length << 3 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 8 ) { array [ i ] = Double . longBitsToDouble ( buffer [ p ] & 0xFF | ( buffer [ p + 1 ] & 0xFF ) << 8 | ( buffer [ p + 2 ] & 0xFF ) << 16 | ( long ) ( buffer [ p + 3 ] & 0xFF ) << 24 | ( long ) ( buffer [ p + 4 ] & 0xFF ) << 32 | ( long ) ( buffer [ p + 5 ] & 0xFF ) << 40 | ( long ) ( buffer [ p + 6 ] & 0xFF ) << 48 | ( long ) buffer [ p + 7 ] << 56 ) ; } position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readDouble ( ) ; } return array ; } | Reads a double array in bulk . This may be more efficient than reading them individually . |
13,172 | public short [ ] readShorts ( int length ) throws KryoException { short [ ] array = new short [ length ] ; if ( optional ( length << 1 ) == length << 1 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 2 ) array [ i ] = ( short ) ( ( buffer [ p ] & 0xFF ) | ( ( buffer [ p + 1 ] & 0xFF ) ) << 8 ) ; position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readShort ( ) ; } return array ; } | Reads a short array in bulk . This may be more efficient than reading them individually . |
13,173 | public char [ ] readChars ( int length ) throws KryoException { char [ ] array = new char [ length ] ; if ( optional ( length << 1 ) == length << 1 ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p += 2 ) array [ i ] = ( char ) ( ( buffer [ p ] & 0xFF ) | ( ( buffer [ p + 1 ] & 0xFF ) ) << 8 ) ; position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readChar ( ) ; } return array ; } | Reads a char array in bulk . This may be more efficient than reading them individually . |
13,174 | public boolean [ ] readBooleans ( int length ) throws KryoException { boolean [ ] array = new boolean [ length ] ; if ( optional ( length ) == length ) { byte [ ] buffer = this . buffer ; int p = this . position ; for ( int i = 0 ; i < length ; i ++ , p ++ ) array [ i ] = buffer [ p ] != 0 ; position = p ; } else { for ( int i = 0 ; i < length ; i ++ ) array [ i ] = readBoolean ( ) ; } return array ; } | Reads a boolean array in bulk . This may be more efficient than reading them individually . |
13,175 | public CachedField getField ( String fieldName ) { for ( CachedField cachedField : cachedFields . fields ) if ( cachedField . name . equals ( fieldName ) ) return cachedField ; throw new IllegalArgumentException ( "Field \"" + fieldName + "\" not found on class: " + type . getName ( ) ) ; } | Returns the field with the specified name allowing field specific settings to be configured . |
13,176 | static public ByteBuffer newDirectBuffer ( long address , int size ) { if ( directByteBufferConstructor == null ) throw new UnsupportedOperationException ( "No direct ByteBuffer constructor is available." ) ; try { return directByteBufferConstructor . newInstance ( address , size , null ) ; } catch ( Exception ex ) { throw new KryoException ( "Error creating a ByteBuffer at address: " + address , ex ) ; } } | Create a ByteBuffer that uses the specified off - heap memory address instead of allocating a new one . |
13,177 | static public void dispose ( ByteBuffer buffer ) { if ( ! ( buffer instanceof DirectBuffer ) ) return ; if ( cleanerMethod != null ) { try { cleanMethod . invoke ( cleanerMethod . invoke ( buffer ) ) ; } catch ( Throwable ignored ) { } } } | Release a direct buffer immediately rather than waiting for GC . |
13,178 | public void endChunk ( ) { flush ( ) ; if ( TRACE ) trace ( "kryo" , "End chunk." ) ; try { getOutputStream ( ) . write ( 0 ) ; } catch ( IOException ex ) { throw new KryoException ( ex ) ; } } | Marks the curent written data as the end of a chunk . This chunk can then be skipped when reading . |
13,179 | public V put ( K key , V value ) { if ( key == null ) throw new IllegalArgumentException ( "key cannot be null." ) ; K [ ] keyTable = this . keyTable ; int mask = this . mask ; int hashCode = key . hashCode ( ) ; int index1 = hashCode & mask ; K key1 = keyTable [ index1 ] ; if ( key . equals ( key1 ) ) { V oldValue = valueTable [ index1 ] ; valueTable [ index1 ] = value ; return oldValue ; } int index2 = hash2 ( hashCode ) ; K key2 = keyTable [ index2 ] ; if ( key . equals ( key2 ) ) { V oldValue = valueTable [ index2 ] ; valueTable [ index2 ] = value ; return oldValue ; } int index3 = hash3 ( hashCode ) ; K key3 = keyTable [ index3 ] ; if ( key . equals ( key3 ) ) { V oldValue = valueTable [ index3 ] ; valueTable [ index3 ] = value ; return oldValue ; } int index4 = - 1 ; K key4 = null ; if ( bigTable ) { index4 = hash4 ( hashCode ) ; key4 = keyTable [ index4 ] ; if ( key . equals ( key4 ) ) { V oldValue = valueTable [ index4 ] ; valueTable [ index4 ] = value ; return oldValue ; } } for ( int i = capacity , n = i + stashSize ; i < n ; i ++ ) { if ( key . equals ( keyTable [ i ] ) ) { V oldValue = valueTable [ i ] ; valueTable [ i ] = value ; return oldValue ; } } if ( key1 == null ) { keyTable [ index1 ] = key ; valueTable [ index1 ] = value ; if ( size ++ >= threshold ) resize ( capacity << 1 ) ; return null ; } if ( key2 == null ) { keyTable [ index2 ] = key ; valueTable [ index2 ] = value ; if ( size ++ >= threshold ) resize ( capacity << 1 ) ; return null ; } if ( key3 == null ) { keyTable [ index3 ] = key ; valueTable [ index3 ] = value ; if ( size ++ >= threshold ) resize ( capacity << 1 ) ; return null ; } if ( bigTable && key4 == null ) { keyTable [ index4 ] = key ; valueTable [ index4 ] = value ; if ( size ++ >= threshold ) resize ( capacity << 1 ) ; return null ; } push ( key , value , index1 , key1 , index2 , key2 , index3 , key3 , index4 , key4 ) ; return null ; } | Returns the old value associated with the specified key or null . |
13,180 | public V remove ( K key ) { int hashCode = key . hashCode ( ) ; int index = hashCode & mask ; if ( key . equals ( keyTable [ index ] ) ) { keyTable [ index ] = null ; V oldValue = valueTable [ index ] ; valueTable [ index ] = null ; size -- ; return oldValue ; } index = hash2 ( hashCode ) ; if ( key . equals ( keyTable [ index ] ) ) { keyTable [ index ] = null ; V oldValue = valueTable [ index ] ; valueTable [ index ] = null ; size -- ; return oldValue ; } index = hash3 ( hashCode ) ; if ( key . equals ( keyTable [ index ] ) ) { keyTable [ index ] = null ; V oldValue = valueTable [ index ] ; valueTable [ index ] = null ; size -- ; return oldValue ; } if ( bigTable ) { index = hash4 ( hashCode ) ; if ( key . equals ( keyTable [ index ] ) ) { keyTable [ index ] = null ; V oldValue = valueTable [ index ] ; valueTable [ index ] = null ; size -- ; return oldValue ; } } return removeStash ( key ) ; } | Returns the value associated with the key or null . |
13,181 | public void shrink ( int maximumCapacity ) { if ( maximumCapacity < 0 ) throw new IllegalArgumentException ( "maximumCapacity must be >= 0: " + maximumCapacity ) ; if ( size > maximumCapacity ) maximumCapacity = size ; if ( capacity <= maximumCapacity ) return ; maximumCapacity = nextPowerOfTwo ( maximumCapacity ) ; resize ( maximumCapacity ) ; } | Reduces the size of the backing arrays to be the specified capacity or less . If the capacity is already less nothing is done . If the map contains more items than the specified capacity the next highest power of two capacity is used instead . |
13,182 | public Serializer getDefaultSerializer ( Class type ) { if ( type == null ) throw new IllegalArgumentException ( "type cannot be null." ) ; Serializer serializerForAnnotation = getDefaultSerializerForAnnotatedType ( type ) ; if ( serializerForAnnotation != null ) return serializerForAnnotation ; for ( int i = 0 , n = defaultSerializers . size ( ) ; i < n ; i ++ ) { DefaultSerializerEntry entry = defaultSerializers . get ( i ) ; if ( entry . type . isAssignableFrom ( type ) && entry . serializerFactory . isSupported ( type ) ) return entry . serializerFactory . newSerializer ( this , type ) ; } return newDefaultSerializer ( type ) ; } | Returns the best matching serializer for a class . This method can be overridden to implement custom logic to choose a serializer . |
13,183 | public Registration writeClass ( Output output , Class type ) { if ( output == null ) throw new IllegalArgumentException ( "output cannot be null." ) ; try { return classResolver . writeClass ( output , type ) ; } finally { if ( depth == 0 && autoReset ) reset ( ) ; } } | Writes a class and returns its registration . |
13,184 | public void writeObject ( Output output , Object object ) { if ( output == null ) throw new IllegalArgumentException ( "output cannot be null." ) ; if ( object == null ) throw new IllegalArgumentException ( "object cannot be null." ) ; beginObject ( ) ; try { if ( references && writeReferenceOrNull ( output , object , false ) ) return ; if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Write" , object , output . position ( ) ) ; getRegistration ( object . getClass ( ) ) . getSerializer ( ) . write ( this , output , object ) ; } finally { if ( -- depth == 0 && autoReset ) reset ( ) ; } } | Writes an object using the registered serializer . |
13,185 | public void writeObject ( Output output , Object object , Serializer serializer ) { if ( output == null ) throw new IllegalArgumentException ( "output cannot be null." ) ; if ( object == null ) throw new IllegalArgumentException ( "object cannot be null." ) ; if ( serializer == null ) throw new IllegalArgumentException ( "serializer cannot be null." ) ; beginObject ( ) ; try { if ( references && writeReferenceOrNull ( output , object , false ) ) return ; if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Write" , object , output . position ( ) ) ; serializer . write ( this , output , object ) ; } finally { if ( -- depth == 0 && autoReset ) reset ( ) ; } } | Writes an object using the specified serializer . The registered serializer is ignored . |
13,186 | public void writeObjectOrNull ( Output output , Object object , Serializer serializer ) { if ( output == null ) throw new IllegalArgumentException ( "output cannot be null." ) ; if ( serializer == null ) throw new IllegalArgumentException ( "serializer cannot be null." ) ; beginObject ( ) ; try { if ( references ) { if ( writeReferenceOrNull ( output , object , true ) ) return ; } else if ( ! serializer . getAcceptsNull ( ) ) { if ( object == null ) { if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Write" , null , output . position ( ) ) ; output . writeByte ( NULL ) ; return ; } if ( TRACE ) trace ( "kryo" , "Write: <not null>" + pos ( output . position ( ) ) ) ; output . writeByte ( NOT_NULL ) ; } if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Write" , object , output . position ( ) ) ; serializer . write ( this , output , object ) ; } finally { if ( -- depth == 0 && autoReset ) reset ( ) ; } } | Writes an object or null using the specified serializer . The registered serializer is ignored . |
13,187 | public void writeClassAndObject ( Output output , Object object ) { if ( output == null ) throw new IllegalArgumentException ( "output cannot be null." ) ; beginObject ( ) ; try { if ( object == null ) { writeClass ( output , null ) ; return ; } Registration registration = writeClass ( output , object . getClass ( ) ) ; if ( references && writeReferenceOrNull ( output , object , false ) ) return ; if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Write" , object , output . position ( ) ) ; registration . getSerializer ( ) . write ( this , output , object ) ; } finally { if ( -- depth == 0 && autoReset ) reset ( ) ; } } | Writes the class and object or null using the registered serializer . |
13,188 | public Registration readClass ( Input input ) { if ( input == null ) throw new IllegalArgumentException ( "input cannot be null." ) ; try { return classResolver . readClass ( input ) ; } finally { if ( depth == 0 && autoReset ) reset ( ) ; } } | Reads a class and returns its registration . |
13,189 | public < T > T readObject ( Input input , Class < T > type ) { if ( input == null ) throw new IllegalArgumentException ( "input cannot be null." ) ; if ( type == null ) throw new IllegalArgumentException ( "type cannot be null." ) ; beginObject ( ) ; try { T object ; if ( references ) { int stackSize = readReferenceOrNull ( input , type , false ) ; if ( stackSize == REF ) return ( T ) readObject ; object = ( T ) getRegistration ( type ) . getSerializer ( ) . read ( this , input , type ) ; if ( stackSize == readReferenceIds . size ) reference ( object ) ; } else object = ( T ) getRegistration ( type ) . getSerializer ( ) . read ( this , input , type ) ; if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Read" , object , input . position ( ) ) ; return object ; } finally { if ( -- depth == 0 && autoReset ) reset ( ) ; } } | Reads an object using the registered serializer . |
13,190 | public Object readClassAndObject ( Input input ) { if ( input == null ) throw new IllegalArgumentException ( "input cannot be null." ) ; beginObject ( ) ; try { Registration registration = readClass ( input ) ; if ( registration == null ) return null ; Class type = registration . getType ( ) ; Object object ; if ( references ) { int stackSize = readReferenceOrNull ( input , type , false ) ; if ( stackSize == REF ) return readObject ; object = registration . getSerializer ( ) . read ( this , input , type ) ; if ( stackSize == readReferenceIds . size ) reference ( object ) ; } else object = registration . getSerializer ( ) . read ( this , input , type ) ; if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Read" , object , input . position ( ) ) ; return object ; } finally { if ( -- depth == 0 && autoReset ) reset ( ) ; } } | Reads the class and object or null using the registered serializer . |
13,191 | public void setReferenceResolver ( ReferenceResolver referenceResolver ) { if ( referenceResolver == null ) throw new IllegalArgumentException ( "referenceResolver cannot be null." ) ; this . references = true ; this . referenceResolver = referenceResolver ; if ( TRACE ) trace ( "kryo" , "Reference resolver: " + referenceResolver . getClass ( ) . getName ( ) ) ; } | Sets the reference resolver and enables references . |
13,192 | public void clear ( int maximumCapacity ) { if ( capacity <= maximumCapacity ) { clear ( ) ; return ; } zeroValue = null ; hasZeroValue = false ; size = 0 ; resize ( maximumCapacity ) ; } | Clears the map and reduces the size of the backing arrays to be the specified capacity if they are larger . |
13,193 | public void setPortProbeDetails ( java . util . Collection < PortProbeDetail > portProbeDetails ) { if ( portProbeDetails == null ) { this . portProbeDetails = null ; return ; } this . portProbeDetails = new java . util . ArrayList < PortProbeDetail > ( portProbeDetails ) ; } | A list of port probe details objects . |
13,194 | public EncryptionContext withContext ( String key , String value ) { this . context . put ( key , value ) ; return this ; } | Fluent API to add encryption context . |
13,195 | public void setEgressEndpoints ( java . util . Collection < ChannelEgressEndpoint > egressEndpoints ) { if ( egressEndpoints == null ) { this . egressEndpoints = null ; return ; } this . egressEndpoints = new java . util . ArrayList < ChannelEgressEndpoint > ( egressEndpoints ) ; } | The endpoints where outgoing connections initiate from |
13,196 | public void setInputAttachments ( java . util . Collection < InputAttachment > inputAttachments ) { if ( inputAttachments == null ) { this . inputAttachments = null ; return ; } this . inputAttachments = new java . util . ArrayList < InputAttachment > ( inputAttachments ) ; } | List of input attachments for channel . |
13,197 | public java . util . concurrent . Future < DescribeSeverityLevelsResult > describeSeverityLevelsAsync ( com . amazonaws . handlers . AsyncHandler < DescribeSeverityLevelsRequest , DescribeSeverityLevelsResult > asyncHandler ) { return describeSeverityLevelsAsync ( new DescribeSeverityLevelsRequest ( ) , asyncHandler ) ; } | Simplified method form for invoking the DescribeSeverityLevels operation with an AsyncHandler . |
13,198 | public void setState ( TransferState state ) { super . setState ( state ) ; switch ( state ) { case Waiting : fireProgressEvent ( ProgressEventType . TRANSFER_PREPARING_EVENT ) ; break ; case InProgress : if ( subTransferStarted . compareAndSet ( false , true ) ) { fireProgressEvent ( ProgressEventType . TRANSFER_STARTED_EVENT ) ; } break ; case Completed : fireProgressEvent ( ProgressEventType . TRANSFER_COMPLETED_EVENT ) ; break ; case Canceled : fireProgressEvent ( ProgressEventType . TRANSFER_CANCELED_EVENT ) ; break ; case Failed : fireProgressEvent ( ProgressEventType . TRANSFER_FAILED_EVENT ) ; break ; default : break ; } } | Override this method so that TransferState updates are also sent out to the progress listener chain in forms of ProgressEvent . |
13,199 | public void setAudioDescriptionNames ( java . util . Collection < String > audioDescriptionNames ) { if ( audioDescriptionNames == null ) { this . audioDescriptionNames = null ; return ; } this . audioDescriptionNames = new java . util . ArrayList < String > ( audioDescriptionNames ) ; } | The names of the AudioDescriptions used as audio sources for this output . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.