idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
40,100 | public static Locale getLocale ( ) { String tag = Configuration . get ( "locale" ) ; if ( tag == null ) { return Locale . ROOT ; } else { String [ ] splittedTag = tag . split ( "_" , MAX_LOCALE_ARGUMENTS ) ; if ( splittedTag . length == 1 ) { return new Locale ( splittedTag [ 0 ] ) ; } else if ( splittedTag . length ==... | Loads the locale from configuration . |
40,101 | public static Map < String , Level > getCustomLevels ( ) { Map < String , Level > levels = new HashMap < String , Level > ( ) ; for ( Entry < String , String > entry : Configuration . getSiblings ( "level@" ) . entrySet ( ) ) { String packageOrClass = entry . getKey ( ) . substring ( "level@" . length ( ) ) ; Level lev... | Loads custom severity levels for packages or classes from configuration . |
40,102 | public static List < String > getTags ( ) { List < String > tags = new ArrayList < String > ( ) ; for ( String writerProperty : Configuration . getSiblings ( "writer" ) . keySet ( ) ) { String tag = Configuration . get ( writerProperty + ".tag" ) ; if ( tag != null && ! tag . isEmpty ( ) && ! tag . equals ( "-" ) && ! ... | Loads all tags from writers in configuration . |
40,103 | private static void addWriter ( final Writer writer , final Collection < Writer > [ ] [ ] matrix , final int tagIndex , final Level level ) { for ( int levelIndex = level . ordinal ( ) ; levelIndex < Level . OFF . ordinal ( ) ; ++ levelIndex ) { Collection < Writer > collection = matrix [ tagIndex ] [ levelIndex ] ; if... | Adds a writer to a well - defined matrix . The given writer will be added only at the given tag index for severity levels equal or above the given severity level . |
40,104 | private static Level parse ( final String property , final Level defaultValue ) { if ( property == null ) { return defaultValue ; } else { try { return Level . valueOf ( property . toUpperCase ( Locale . ROOT ) ) ; } catch ( IllegalArgumentException ex ) { InternalLogger . log ( Level . ERROR , "Illegal severity level:... | Reads a severity level from configuration . |
40,105 | private static Level calculateMinimumLevel ( final Level globalLevel , final Map < String , Level > customLevels ) { Level minimumLevel = globalLevel ; for ( Level level : customLevels . values ( ) ) { if ( level . ordinal ( ) < minimumLevel . ordinal ( ) ) { minimumLevel = level ; } } return minimumLevel ; } | Calculates the minimum severity level that can output any log entries . |
40,106 | @ SuppressWarnings ( "unchecked" ) private static Collection < LogEntryValue > [ ] [ ] calculateRequiredLogEntryValues ( final Collection < Writer > [ ] [ ] writers ) { Collection < LogEntryValue > [ ] [ ] logEntryValues = new Collection [ writers . length ] [ Level . values ( ) . length - 1 ] ; for ( int tagIndex = 0 ... | Creates a matrix with all required log entry values for each tag and severity level . |
40,107 | private static BitSet calculateFullStackTraceRequirements ( final Collection < LogEntryValue > [ ] [ ] logEntryValues ) { BitSet result = new BitSet ( logEntryValues . length ) ; for ( int i = 0 ; i < logEntryValues . length ; ++ i ) { Collection < LogEntryValue > values = logEntryValues [ i ] [ Level . ERROR . ordinal... | Calculates for which tag a full stack trace element with method name file name and line number is required . |
40,108 | private static WritingThread createWritingThread ( final Collection < Writer > [ ] [ ] matrix ) { Collection < Writer > writers = getAllWriters ( matrix ) ; WritingThread thread = new WritingThread ( writers ) ; thread . start ( ) ; return thread ; } | Creates a writing thread for a matrix of writers . |
40,109 | private static Collection < Writer > getAllWriters ( final Collection < Writer > [ ] [ ] matrix ) { Collection < Writer > writers = Collections . newSetFromMap ( new IdentityHashMap < Writer , Boolean > ( ) ) ; for ( int i = 0 ; i < matrix . length ; ++ i ) { for ( int j = 0 ; j < matrix [ i ] . length ; ++ j ) { write... | Collects all writer instances from a matrix of writers . |
40,110 | private int getTagIndex ( final String tag ) { if ( tag == null ) { return 0 ; } else { int index = knownTags . indexOf ( tag ) ; return index == - 1 ? knownTags . size ( ) + 1 : index + 1 ; } } | Gets the index of a tag . |
40,111 | private void output ( final LogEntry logEntry , final Iterable < Writer > writers ) { if ( writingThread == null ) { for ( Writer writer : writers ) { try { writer . write ( logEntry ) ; } catch ( Exception ex ) { InternalLogger . log ( Level . ERROR , ex , "Failed to write log entry '" + logEntry . getMessage ( ) + "'... | Outputs a log entry to all passed writers . |
40,112 | public List < File > getAllFiles ( ) { List < File > files = new ArrayList < File > ( ) ; collectFiles ( folder , files ) ; Collections . sort ( files , LastModifiedFileComparator . INSTANCE ) ; return files ; } | Gets all files that are compatible with the dynamic path . The returned files are sorted by the last modification date . The most recently modified files are at the top the oldest at the bottom of the list . |
40,113 | private void collectFiles ( final File folder , final List < File > found ) { File [ ] files = folder . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { if ( file . isDirectory ( ) ) { collectFiles ( file , found ) ; } else if ( file . isFile ( ) && file . getPath ( ) . endsWith ( suffix ) ) { int ind... | Collects files from a folder and all nested sub folders . |
40,114 | private boolean isValid ( final String path , final int pathPosition , final int segmentIndex ) { Segment segment = segments . get ( segmentIndex ) ; String expectedValue = segment . getStaticText ( ) ; if ( expectedValue == null ) { if ( segmentIndex == segments . size ( ) - 1 ) { return segment . validateToken ( path... | Checks if a partial path to a file is compatible with this dynamic path . |
40,115 | private static Segment parseSegment ( final String path , final String token ) { int separator = token . indexOf ( ':' ) ; String name ; String parameter ; if ( separator == - 1 ) { name = token . trim ( ) ; parameter = null ; } else { name = token . substring ( 0 , separator ) . trim ( ) ; parameter = token . substrin... | Parses a token from a pattern as a segment . |
40,116 | public void run ( ) { Collection < Writer > writers = new ArrayList < Writer > ( 1 ) ; while ( true ) { for ( Task task : receiveTasks ( ) ) { if ( task == Task . POISON ) { close ( ) ; return ; } else { write ( writers , task ) ; } } flush ( writers ) ; writers . clear ( ) ; try { sleep ( MILLISECONDS_TO_SLEEP ) ; } c... | Fetches log entries and writes them until receiving a poison task . |
40,117 | void add ( final Writer writer , final LogEntry logEntry ) { Task task = new Task ( writer , logEntry ) ; synchronized ( mutex ) { tasks . add ( task ) ; } } | Adds a log entry for writing . |
40,118 | private List < Task > receiveTasks ( ) { synchronized ( mutex ) { if ( tasks . isEmpty ( ) ) { return Collections . emptyList ( ) ; } else { List < Task > currentTasks = tasks ; tasks = new ArrayList < Task > ( ) ; return currentTasks ; } } } | Receives all added log entries . |
40,119 | private void write ( final Collection < Writer > writers , final Task task ) { try { Writer writer = task . writer ; writer . write ( task . logEntry ) ; if ( ! writers . contains ( writer ) ) { writers . add ( writer ) ; } } catch ( Exception ex ) { InternalLogger . log ( Level . ERROR , ex , "Failed to write log entr... | Writes a log entry . |
40,120 | private void flush ( final Collection < Writer > writers ) { for ( Writer writer : writers ) { try { writer . flush ( ) ; } catch ( Exception ex ) { InternalLogger . log ( Level . ERROR , ex , "Failed to flush writer" ) ; } } } | Flushes a collection of writers . |
40,121 | private void close ( ) { for ( Writer writer : writers ) { try { writer . close ( ) ; } catch ( Exception ex ) { InternalLogger . log ( Level . ERROR , ex , "Failed to close writer" ) ; } } } | Closes all writers . |
40,122 | public void output ( final Map < String , Map < String , List < BigDecimal > > > benchmarks ) { for ( Entry < String , Map < String , List < BigDecimal > > > benchmark : benchmarks . entrySet ( ) ) { BigDecimal max = benchmark . getValue ( ) . values ( ) . stream ( ) . flatMap ( list -> list . stream ( ) ) . max ( Comp... | Creates and outputs HTML diagrams . |
40,123 | @ SuppressWarnings ( "rawtypes" ) public static Enumeration getCurrentLoggers ( ) { ArrayList < Logger > copy ; synchronized ( mutex ) { copy = new ArrayList < Logger > ( loggers . values ( ) ) ; } copy . remove ( root ) ; return Collections . enumeration ( copy ) ; } | Retrieves all existing loggers . |
40,124 | private static Logger getOrCreateLogger ( final String name ) { if ( name == null || name . length ( ) == 0 ) { return root ; } else { Logger logger = loggers . get ( name ) ; if ( logger == null ) { Logger parent = getOrCreateLogger ( reduce ( name ) ) ; logger = new Logger ( parent , name ) ; loggers . put ( name , l... | Retrieves a logger by name . |
40,125 | private static String reduce ( final String name ) { int index = name . lastIndexOf ( '.' ) ; return index == - 1 ? null : name . substring ( 0 , index ) ; } | Gets the parent s logger name for a given logger name . |
40,126 | public boolean isTraceEnabled ( ) { return MINIMUM_LEVEL_COVERS_TRACE && provider . isEnabled ( STACKTRACE_DEPTH , null , org . tinylog . Level . TRACE ) ; } | Check whether this category is enabled for the TRACE Level . |
40,127 | public T create ( final String name , final Object ... arguments ) { if ( name . indexOf ( '.' ) == - 1 ) { String expectingClassName = toSimpleClassName ( name ) ; for ( String className : classes ) { int split = className . lastIndexOf ( '.' ) ; String simpleClassName = split == - 1 ? className : className . substrin... | Creates a defined service implementation . The name can be either the fully - qualified class name or the simplified acronym . The acronym is the class name without package and service suffix . |
40,128 | public Collection < T > createAll ( final Object ... arguments ) { Collection < T > instances = new ArrayList < T > ( classes . size ( ) ) ; for ( String className : classes ) { T instance = createInstance ( className , arguments ) ; if ( instance != null ) { instances . add ( instance ) ; } } return instances ; } | Creates all registered service implementations . |
40,129 | private static < T > Collection < String > loadClasses ( final ClassLoader classLoader , final Class < ? extends T > service ) { String name = SERVICE_PREFIX + service . getName ( ) ; Enumeration < URL > urls ; try { urls = classLoader . getResources ( name ) ; } catch ( IOException ex ) { InternalLogger . log ( Level ... | Loads all registered service class names . |
40,130 | private String toSimpleClassName ( final String name ) { StringBuilder builder = new StringBuilder ( name . length ( ) ) ; for ( String token : SPLIT_PATTERN . split ( name ) ) { if ( ! token . isEmpty ( ) ) { builder . append ( Character . toUpperCase ( token . charAt ( 0 ) ) ) ; builder . append ( token . substring (... | Generates the simple class name from an acronym . A simple class name is the class name without package . |
40,131 | @ SuppressWarnings ( "unchecked" ) private T createInstance ( final String className , final Object ... arguments ) { try { Class < ? > implementation = Class . forName ( className , false , classLoader ) ; if ( service . isAssignableFrom ( implementation ) ) { return ( T ) implementation . getDeclaredConstructor ( arg... | Creates a new instance of a class . |
40,132 | private static String getVersion ( final Class < ? > clazz ) { CodeSource source = clazz . getProtectionDomain ( ) . getCodeSource ( ) ; URL location = source . getLocation ( ) ; try { Path path = Paths . get ( location . toURI ( ) ) ; return Files . isRegularFile ( path ) ? getVersionFromJar ( path ) : getVersionFromP... | Gets the version for a class . |
40,133 | private static String getVersionFromJar ( final Path path ) { Matcher matcher = JAR_VERSION . matcher ( path . toString ( ) ) ; if ( matcher . matches ( ) ) { return matcher . group ( 1 ) ; } else { Logger . error ( "JAR file \"{}\" does not contain a version" , path ) ; return null ; } } | Gets the version for a JAR file . |
40,134 | private static String getVersionFromPom ( final Path path ) { Path folder = path ; Path file ; while ( true ) { file = folder . resolve ( "pom.xml" ) ; if ( Files . exists ( file ) ) { break ; } folder = folder . getParent ( ) ; if ( folder == null ) { Logger . error ( "pom.xml is missing for \"{}\"" , path ) ; return ... | Gets the version for a folder by searching for a pom . xml in the folder and its folders . |
40,135 | private static StackTraceElement findStackTraceElement ( final String loggerClassName , final StackTraceElement [ ] trace ) { int index = 0 ; while ( index < trace . length && ! loggerClassName . equals ( trace [ index ] . getClassName ( ) ) ) { index = index + 1 ; } while ( index < trace . length && loggerClassName . ... | Gets the stack trace element that appears before the passed logger class name . |
40,136 | private StackTraceElement [ ] extractCallerStackTraceElements ( final int count ) { if ( stackTraceElementsFiller != null ) { try { StackTraceElement [ ] trace = new StackTraceElement [ count + 1 ] ; stackTraceElementsFiller . invoke ( null , Thread . currentThread ( ) , trace ) ; return trace ; } catch ( IllegalAccess... | Extracts a defined number of elements from stack trace . |
40,137 | public static TaggedLogger tag ( final String tag ) { if ( tag == null || tag . isEmpty ( ) ) { return instance ; } else { TaggedLogger logger = loggers . get ( tag ) ; if ( logger == null ) { logger = new TaggedLogger ( tag ) ; TaggedLogger existing = loggers . putIfAbsent ( tag , logger ) ; return existing == null ? ... | Gets a tagged logger instance . Tags are case - sensitive . |
40,138 | private static ProcessHandle getCurrentProcess ( ) { try { return ( ProcessHandle ) ProcessHandle . class . getDeclaredMethod ( "current" ) . invoke ( null ) ; } catch ( ReflectiveOperationException ex ) { InternalLogger . log ( Level . ERROR , ex , "Failed to receive the handle of the current process" ) ; return null ... | Gets the process handle of the current process . |
40,139 | private static void render ( final Throwable throwable , final StringBuilder builder ) { builder . append ( throwable . getClass ( ) . getName ( ) ) ; String message = throwable . getMessage ( ) ; if ( message != null ) { builder . append ( ": " ) ; builder . append ( message ) ; } StackTraceElement [ ] stackTrace = th... | Renders a throwable including stack trace and cause throwables . |
40,140 | public static void main ( final String [ ] args ) { BenchmarkOutputParser parser = new BenchmarkOutputParser ( FRAMEWORKS . keySet ( ) ) ; HtmlDiagramRenderer renderer = new HtmlDiagramRenderer ( FRAMEWORKS ) ; renderer . output ( parser . parse ( OUTPUT_FILE ) ) ; } | Main method for executing the converter . |
40,141 | protected static String getFileName ( final Map < String , String > properties ) { String fileName = properties . get ( "file" ) ; if ( fileName == null ) { throw new IllegalArgumentException ( "File name is missing for file writer" ) ; } else { return fileName ; } } | Extracts the log file name from configuration . |
40,142 | protected static Charset getCharset ( final Map < String , String > properties ) { String charsetName = properties . get ( "charset" ) ; try { return charsetName == null ? Charset . defaultCharset ( ) : Charset . forName ( charsetName ) ; } catch ( IllegalArgumentException ex ) { InternalLogger . log ( Level . ERROR , ... | Extracts the charset from configuration . The default charset will be returned if no charset is defined or the defined charset doesn t exist . |
40,143 | protected final String render ( final LogEntry logEntry ) { if ( builder == null ) { StringBuilder builder = new StringBuilder ( BUILDER_CAPACITY ) ; token . render ( logEntry , builder ) ; return builder . toString ( ) ; } else { builder . setLength ( 0 ) ; token . render ( logEntry , builder ) ; return builder . toSt... | Renders a log entry as string . |
40,144 | private void internalWrite ( final byte [ ] data ) throws IOException { if ( ! canBeContinued ( data , policies ) ) { writer . close ( ) ; String fileName = path . resolve ( ) ; deleteBackups ( path . getAllFiles ( ) , backups ) ; writer = createByteArrayWriter ( fileName , false , buffered , false , false ) ; for ( Po... | Outputs a passed byte array unsynchronized . |
40,145 | private static List < Policy > createPolicies ( final String property ) { if ( property == null || property . isEmpty ( ) ) { return Collections . < Policy > singletonList ( new StartupPolicy ( null ) ) ; } else { ServiceLoader < Policy > loader = new ServiceLoader < Policy > ( Policy . class , String . class ) ; List ... | Creates policies from a nullable string . |
40,146 | private static boolean canBeContinued ( final String fileName , final List < Policy > policies ) { boolean result = true ; for ( Policy policy : policies ) { result &= policy . continueExistingFile ( fileName ) ; } return result ; } | Checks if an already existing log file can be continued . |
40,147 | private static boolean canBeContinued ( final byte [ ] data , final List < Policy > policies ) { boolean result = true ; for ( Policy policy : policies ) { result &= policy . continueCurrentFile ( data ) ; } return result ; } | Checks if a new log entry can be still written to the current log file . |
40,148 | private static void deleteBackups ( final List < File > files , final int count ) { if ( count >= 0 ) { for ( int i = files . size ( ) - Math . max ( 0 , files . size ( ) - count ) ; i < files . size ( ) ; ++ i ) { if ( ! files . get ( i ) . delete ( ) ) { InternalLogger . log ( Level . WARN , "Failed to delete log fil... | Deletes old log files . |
40,149 | private static long parse ( final String argument ) throws NumberFormatException { if ( argument . endsWith ( "gb" ) ) { return Long . parseLong ( argument . substring ( 0 , argument . length ( ) - "gb" . length ( ) ) . trim ( ) ) * GB ; } else if ( argument . endsWith ( "mb" ) ) { return Long . parseLong ( argument . ... | Parses file size from a string . The units GB MB KB and bytes are supported . |
40,150 | public static void push ( final String message ) { InternalLogger . log ( org . tinylog . Level . WARN , "tinylog does not support NDC, \"" + message + "\" will be discarded" ) ; } | Push new diagnostic context information for the current thread . |
40,151 | private String format ( final String pattern , final Object argument ) { try { return getFormatter ( pattern , argument ) . format ( argument ) ; } catch ( IllegalArgumentException ex ) { InternalLogger . log ( Level . WARN , "Illegal argument '" + String . valueOf ( argument ) + "' for pattern '" + pattern + "'" ) ; r... | Formats a pattern of a placeholder . |
40,152 | private static String getSimpleClassName ( final String fullyQualifiedClassName ) { int dotIndex = fullyQualifiedClassName . lastIndexOf ( '.' ) ; if ( dotIndex < 0 ) { return fullyQualifiedClassName ; } else { return fullyQualifiedClassName . substring ( dotIndex + 1 ) ; } } | Gets the simple class name from a fully qualified class name . |
40,153 | private static org . tinylog . Level translateLevel ( final Level level ) { switch ( level ) { case TRACE : return org . tinylog . Level . TRACE ; case DEBUG : return org . tinylog . Level . DEBUG ; case INFO : return org . tinylog . Level . INFO ; case WARN : return org . tinylog . Level . WARN ; case ERROR : case FAT... | Translate JBoss Logging severity levels . |
40,154 | public static Map < String , String > getSiblings ( final String prefix ) { Map < String , String > map = new HashMap < String , String > ( ) ; for ( Enumeration < Object > enumeration = properties . keys ( ) ; enumeration . hasMoreElements ( ) ; ) { String key = ( String ) enumeration . nextElement ( ) ; if ( key . st... | Gets all siblings with a defined prefix . Child properties will be not returned . |
40,155 | public static Map < String , String > getChildren ( final String key ) { String prefix = key + "." ; Map < String , String > map = new HashMap < String , String > ( ) ; for ( Enumeration < Object > enumeration = properties . keys ( ) ; enumeration . hasMoreElements ( ) ; ) { String property = ( String ) enumeration . n... | Gets all child properties for a parent property . The parent property itself will be not returned . Children keys will be returned without parent key prefix . |
40,156 | public static void replace ( final Map < String , String > configuration ) { synchronized ( properties ) { properties . clear ( ) ; properties . putAll ( configuration ) ; } } | Replaces the current configuration by a new one . Already existing properties will be dropped . |
40,157 | private static Properties load ( ) { Properties properties = new Properties ( ) ; String file = System . getProperty ( CONFIGURATION_PROPERTY ) ; try { if ( file != null ) { InputStream stream ; if ( URL_DETECTION_PATTERN . matcher ( file ) . matches ( ) ) { stream = new URL ( file ) . openStream ( ) ; } else { stream ... | Loads all configuration properties . |
40,158 | private static void load ( final Properties properties , final InputStream stream ) throws IOException { try { properties . load ( stream ) ; } finally { stream . close ( ) ; } } | Puts all properties from a stream to an existing properties object . Already existing properties will be overridden . |
40,159 | private static String resolve ( final String value , final Resolver resolver ) { StringBuilder builder = new StringBuilder ( ) ; int position = 0 ; String prefix = resolver . getPrefix ( ) + "{" ; String postfix = "}" ; for ( int index = value . indexOf ( prefix ) ; index != - 1 ; index = value . indexOf ( prefix , pos... | Resolves placeholders with passed resolver . |
40,160 | void activate ( ) { LogManager . getLogManager ( ) . reset ( ) ; Logger logger = Logger . getLogger ( "" ) ; logger . setLevel ( translateLevel ( provider . getMinimumLevel ( null ) ) ) ; logger . addHandler ( this ) ; } | Activates this handler . |
40,161 | public static void log ( final Level level , final String message ) { System . err . println ( "LOGGER " + level + ": " + message ) ; } | Logs a plain text message . |
40,162 | public static void log ( final Level level , final Throwable exception ) { String nameOfException = exception . getClass ( ) . getName ( ) ; String messageOfException = exception . getMessage ( ) ; if ( messageOfException == null || messageOfException . isEmpty ( ) ) { System . err . println ( "LOGGER " + level + ": " ... | Logs a caught exception . |
40,163 | public static void log ( final Level level , final Throwable exception , final String message ) { String nameOfException = exception . getClass ( ) . getName ( ) ; String messageOfException = exception . getMessage ( ) ; StringBuilder builder = new StringBuilder ( BUFFER_SIZE ) ; builder . append ( level ) ; builder . ... | Logs a caught exception with a custom text message . |
40,164 | private void doWrite ( final LogEntry logEntry ) throws SQLException { if ( checkConnection ( ) ) { if ( batch ) { batchCount += 1 ; } try { for ( int i = 0 ; i < tokens . size ( ) ; ++ i ) { tokens . get ( i ) . apply ( logEntry , statement , i + 1 ) ; } } catch ( SQLException ex ) { resetConnection ( ) ; throw ex ; }... | Unsynchronized method for inserting a log entry . |
40,165 | private void doFlush ( ) throws SQLException { if ( batchCount > 0 ) { try { statement . executeBatch ( ) ; batchCount = 0 ; } catch ( SQLException ex ) { resetConnection ( ) ; throw ex ; } } } | Unsynchronized method for flushing all cached batch insert statements . |
40,166 | private void doClose ( ) throws SQLException { try { if ( batch ) { doFlush ( ) ; } } finally { if ( lostCount > 0 ) { InternalLogger . log ( Level . ERROR , "Lost log entries due to broken database connection: " + lostCount ) ; } if ( connection != null ) { connection . close ( ) ; } } } | Unsynchronized method for closing database connection . |
40,167 | private boolean checkConnection ( ) { if ( connection == null ) { if ( System . currentTimeMillis ( ) >= reconnectTimestamp ) { long start = System . currentTimeMillis ( ) ; try { connection = connect ( url , user , password ) ; statement = connection . prepareStatement ( sql ) ; InternalLogger . log ( Level . ERROR , ... | Checks if database connection is opened . Regular attempts are made to reestablish a broken database connection . |
40,168 | private void resetConnection ( ) { if ( reconnect ) { closeConnectionSilently ( ) ; statement = null ; lostCount = batch ? batchCount : 1 ; batchCount = 0 ; reconnectTimestamp = 0 ; } } | Resets the database connection after an error if automatic reconnection is enabled . |
40,169 | private static Connection connect ( final String url , final String user , final String password ) throws NamingException , SQLException { if ( url . toLowerCase ( Locale . ROOT ) . startsWith ( "java:" ) ) { DataSource source = ( DataSource ) new InitialContext ( ) . lookup ( url ) ; if ( user == null ) { return sourc... | Establishes the connection to the database . |
40,170 | private static String getUrl ( final Map < String , String > properties ) { String url = properties . get ( "url" ) ; if ( url == null ) { throw new IllegalArgumentException ( "URL is missing for JDBC writer" ) ; } else { return url ; } } | Extracts the URL to database or data source from configuration . |
40,171 | private static String getTable ( final Map < String , String > properties ) { String table = properties . get ( "table" ) ; if ( table == null ) { throw new IllegalArgumentException ( "Name of database table is missing for JDBC writer" ) ; } else { return table ; } } | Extracts the database table name from configuration . |
40,172 | private static String renderSql ( final Map < String , String > properties , final String quote ) throws SQLException { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "INSERT INTO " ) ; append ( builder , getTable ( properties ) , quote ) ; builder . append ( " (" ) ; int count = 0 ; for ( Entry < S... | Generates an insert SQL statement for the configured table and its fields . |
40,173 | private static void append ( final StringBuilder builder , final String identifier , final String quote ) throws SQLException { if ( identifier . indexOf ( '\n' ) >= 0 || identifier . indexOf ( '\r' ) >= 0 ) { throw new SQLException ( "Identifier contains line breaks: " + identifier ) ; } else if ( " " . equals ( quote... | Appends a database identifier securely to a builder that is building a SQL statement . |
40,174 | private static List < Token > createTokens ( final Map < String , String > properties ) { List < Token > tokens = new ArrayList < Token > ( ) ; for ( Entry < String , String > entry : properties . entrySet ( ) ) { if ( entry . getKey ( ) . toLowerCase ( Locale . ROOT ) . startsWith ( FIELD_PREFIX ) ) { tokens . add ( F... | Creates tokens for all configured fields . |
40,175 | protected static boolean isCoveredByMinimumLevel ( final org . tinylog . Level level ) { return provider . getMinimumLevel ( null ) . ordinal ( ) <= level . ordinal ( ) ; } | Checks if a given severity level is covered by the logging provider s minimum level . |
40,176 | private static org . tinylog . Level translatePriority ( final Priority priority ) { if ( priority . isGreaterOrEqual ( Level . ERROR ) ) { return org . tinylog . Level . ERROR ; } else if ( priority . isGreaterOrEqual ( Level . WARN ) ) { return org . tinylog . Level . WARN ; } else if ( priority . isGreaterOrEqual ( ... | Translates an Apache Log4j 1 . 2 priority into a tinylog 2 severity level . |
40,177 | private static Level translateLevel ( final org . tinylog . Level level ) { switch ( level ) { case TRACE : return Level . TRACE ; case DEBUG : return Level . DEBUG ; case INFO : return Level . INFO ; case WARN : return Level . WARN ; case ERROR : return Level . ERROR ; case OFF : return Level . OFF ; default : throw n... | Translates a tinylog 2 severity level into an Apache Log4j 1 . 2 level . |
40,178 | private static ContextProvider createContextProvider ( final Collection < LoggingProvider > loggingProviders ) { Collection < ContextProvider > contextProviders = new ArrayList < ContextProvider > ( loggingProviders . size ( ) ) ; for ( LoggingProvider loggingProvider : loggingProviders ) { contextProviders . add ( log... | Gets all context providers from given logging providers and combine them into a new one . |
40,179 | public static Token parse ( final String pattern ) { List < Token > tokens = new ArrayList < Token > ( ) ; int start = 0 ; int count = 0 ; for ( int i = 0 ; i < pattern . length ( ) ; ++ i ) { char character = pattern . charAt ( i ) ; if ( character == '{' ) { if ( count == 0 ) { if ( start < i ) { tokens . add ( new P... | Parses a format pattern and produces a generic token from it . This token can be used by writers for rendering log entries . |
40,180 | private static Token createPlainToken ( final String placeholder ) { int splitIndex = placeholder . indexOf ( ':' ) ; Token token ; if ( splitIndex == - 1 ) { token = createPlainToken ( placeholder . trim ( ) , null ) ; } else { String name = placeholder . substring ( 0 , splitIndex ) . trim ( ) ; String configuration ... | Creates a new token for a given placeholder . |
40,181 | private static Token createPlainToken ( final String name , final String configuration ) { if ( name . equals ( "date" ) ) { return createDateToken ( configuration ) ; } else if ( "pid" . equals ( name ) ) { return new ProcessIdToken ( ) ; } else if ( "thread" . equals ( name ) ) { return new ThreadNameToken ( ) ; } el... | Creates a new token for a name and configuration . |
40,182 | private static Token styleToken ( final Token token , final String [ ] options ) { Token styledToken = token ; for ( String option : options ) { int splitIndex = option . indexOf ( '=' ) ; if ( splitIndex == - 1 ) { InternalLogger . log ( Level . ERROR , "No value set for '" + option . trim ( ) + "'" ) ; } else { Strin... | Creates style decorators for a token . |
40,183 | private static LoggingProvider loadLoggingProvider ( ) { ServiceLoader < LoggingProvider > loader = new ServiceLoader < LoggingProvider > ( LoggingProvider . class ) ; String name = Configuration . get ( PROVIDER_PROPERTY ) ; if ( name == null ) { Collection < LoggingProvider > providers = loader . createAll ( ) ; swit... | Loads the actual logging provider . |
40,184 | @ BenchmarkMode ( Mode . Throughput ) public StackFrame stackWalkerWithLambda ( ) { return StackWalker . getInstance ( ) . walk ( stream -> stream . skip ( 1 ) . findFirst ( ) . get ( ) ) ; } | Benchmarks extracting a stack frame from stack walker by using a lambda expression . |
40,185 | @ BenchmarkMode ( Mode . Throughput ) public StackFrame stackWalkerWithAnonymousClass ( ) { return StackWalker . getInstance ( ) . walk ( new Function < Stream < StackFrame > , StackFrame > ( ) { public StackFrame apply ( final Stream < StackFrame > stream ) { return stream . skip ( 1 ) . findFirst ( ) . get ( ) ; } } ... | Benchmarks extracting a stack frame from stack walker by using an anonymous inner class . |
40,186 | @ BenchmarkMode ( Mode . Throughput ) public StackFrame stackWalkerWithInnerClass ( ) { return StackWalker . getInstance ( ) . walk ( new StackFrameExtractor ( 1 ) ) ; } | Benchmarks extracting a stack frame from stack walker by using a static inner class . |
40,187 | @ BenchmarkMode ( Mode . Throughput ) @ SuppressWarnings ( "removal" ) public Class < ? > sunReflection ( ) { return sun . reflect . Reflection . getCallerClass ( 1 ) ; } | Benchmarks extracting a class via Sun reflection . |
40,188 | private static String getPackage ( final String fullyQualifiedClassName ) { int dotIndex = fullyQualifiedClassName . lastIndexOf ( '.' ) ; if ( dotIndex == - 1 ) { return null ; } else { return fullyQualifiedClassName . substring ( 0 , dotIndex ) ; } } | Gets the package name from a fully qualified class name . |
40,189 | private static Long parseDigits ( final String text , final int start ) { for ( int i = start ; i < text . length ( ) ; ++ i ) { char character = text . charAt ( i ) ; if ( character < '0' || character > '9' ) { return parseLong ( text . substring ( start , i ) ) ; } } return parseLong ( text . substring ( start ) ) ; ... | Parses digits from a defined position in a text . Following non - numeric characters will be ignored . |
40,190 | private static Long parseLong ( final String text ) { if ( text . length ( ) == 0 ) { return null ; } else { try { return Long . parseLong ( text ) ; } catch ( NumberFormatException ex ) { return null ; } } } | Converts a text into a number . |
40,191 | private static Level translateLevel ( final int level ) { if ( level <= TRACE_INT ) { return Level . TRACE ; } else if ( level <= DEBUG_INT ) { return Level . DEBUG ; } else if ( level <= INFO_INT ) { return Level . INFO ; } else if ( level <= WARN_INT ) { return Level . WARN ; } else { return Level . ERROR ; } } | Translate SLF4J severity level codes . |
40,192 | private static Throwable extractThrowable ( final Object [ ] arguments ) { return arguments . length == 0 ? null : extractThrowable ( arguments [ arguments . length - 1 ] ) ; } | Returns a throwable if the last argument is one . |
40,193 | private static void validateLength ( byte [ ] data , String dataName , int expectedLength ) throws IllegalArgumentException { if ( data . length != expectedLength ) { throw new IllegalArgumentException ( String . format ( "Invalid %s length. Expected %d bytes but found %d." , dataName , expectedLength , data . length )... | Checks the length of a byte array . |
40,194 | byte [ ] getRawData ( ) { byte [ ] header = new byte [ ] { ( byte ) getVersionNumber ( ) , 0 } ; if ( isPasswordBased ) { header [ 1 ] |= FLAG_PASSWORD ; } final int dataSize ; if ( isPasswordBased ) { dataSize = header . length + encryptionSalt . length + hmacSalt . length + iv . length + ciphertext . length + hmac . ... | Returns the ciphertext packaged as a byte array . |
40,195 | static void isCorrectLength ( byte [ ] object , int length , String name ) { Validate . notNull ( object , "%s cannot be null." , name ) ; Validate . isTrue ( object . length == length , "%s should be %d bytes, found %d bytes." , name , length , object . length ) ; } | Tests object is not null and is of correct length . |
40,196 | private void createStreams ( SecretKey encryptionKey , SecretKey hmacKey , byte [ ] iv , OutputStream out ) throws CryptorException { this . iv = iv ; try { Cipher cipher = Cipher . getInstance ( AES256JNCryptor . AES_CIPHER_ALGORITHM ) ; cipher . init ( Cipher . ENCRYPT_MODE , encryptionKey , new IvParameterSpec ( iv ... | Creates the cipher and MAC streams required |
40,197 | private void writeHeader ( ) throws IOException { if ( passwordBased ) { macOutputStream . write ( AES256JNCryptor . VERSION ) ; macOutputStream . write ( AES256Ciphertext . FLAG_PASSWORD ) ; macOutputStream . write ( encryptionSalt ) ; macOutputStream . write ( hmacSalt ) ; macOutputStream . write ( iv ) ; } else { ma... | Writes the header data to the output stream . |
40,198 | public void write ( int b ) throws IOException { if ( ! writtenHeader ) { writeHeader ( ) ; writtenHeader = true ; } cipherStream . write ( b ) ; } | Writes one byte to the encrypted output stream . |
40,199 | private void fillTrailerBuffer ( ) throws IOException { trailerBuffer = new byte [ trailerSize ] ; if ( trailerSize == 0 ) { return ; } int bytesRead = StreamUtils . readAllBytes ( in , trailerBuffer ) ; if ( bytesRead != trailerBuffer . length ) { throw new EOFException ( String . format ( "Trailer size was %d bytes b... | Populates the trailer buffer with data from the stream . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.