idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
36,800 | public String [ ] split ( String text , String splitValue , String [ ] HTMLBalanceTags ) { String restOfText = text ; int nextBreakIndex = 0 ; List < String > list = new ArrayList < String > ( ) ; int splitValueLength = splitValue . length ( ) ; while ( restOfText . length ( ) > 0 ) { nextBreakIndex = restOfText . indexOf ( splitValue ) ; if ( nextBreakIndex < 0 ) { list . add ( restOfText ) ; break ; } list . add ( restOfText . substring ( 0 , nextBreakIndex + splitValueLength ) ) ; restOfText = restOfText . substring ( nextBreakIndex + splitValueLength ) ; } if ( HTMLBalanceTags . length > 0 ) { List < String > balancedList = new ArrayList < String > ( ) ; for ( int t = 0 ; t < HTMLBalanceTags . length ; t ++ ) { if ( t < 1 ) { balancedList = getBalancedList ( HTMLBalanceTags [ t ] , list ) ; } else if ( balancedList . size ( ) > 1 ) { balancedList = getBalancedList ( HTMLBalanceTags [ t ] , balancedList ) ; } } return balancedList . toArray ( new String [ balancedList . size ( ) ] ) ; } else { return list . toArray ( new String [ list . size ( ) ] ) ; } } | Split the given string around the given split value . This will also ensure any of the given HTML tags are properly closed . |
36,801 | public Annotation [ ] [ ] getAnnotations ( ) { Annotation [ ] [ ] copy = new Annotation [ mParameterAnnotations . size ( ) ] [ ] ; for ( int i = copy . length ; -- i >= 0 ; ) { Vector < Annotation > annotations = mParameterAnnotations . get ( i ) ; if ( annotations == null ) { copy [ i ] = new Annotation [ 0 ] ; } else { copy [ i ] = annotations . toArray ( new Annotation [ annotations . size ( ) ] ) ; } } return copy ; } | First array index is zero - based parameter number . |
36,802 | public void launchAuto ( boolean active ) { killAuto ( ) ; if ( mSock != null ) { try { mAuto = new AutomaticClusterManagementThread ( this , mCluster . getClusterName ( ) , active ) ; } catch ( Exception e ) { mAuto = new AutomaticClusterManagementThread ( this , active ) ; } if ( mAuto != null ) { mAuto . start ( ) ; } } } | Allows the management thread to passively take part in the cluster operations . Other cluster members will not be made aware of this instance . |
36,803 | public void launchAuto ( AutomaticClusterManagementThread auto ) { killAuto ( ) ; if ( mSock != null ) { mAuto = auto ; if ( mAuto != null ) { mAuto . start ( ) ; } } } | permits the AutomaticClusterManagementThread to be subclassed and used into the ClusterManager . |
36,804 | public long convertIPBytes ( byte [ ] ipBytes ) { if ( ipBytes . length == 4 ) { long ipLong = ( ( ( long ) ipBytes [ 0 ] ) << 24 ) ; ipLong |= ( ( ( long ) ipBytes [ 1 ] ) << 16 ) ; ipLong |= ( ( ( long ) ipBytes [ 2 ] ) << 8 ) ; ipLong |= ( long ) ipBytes [ 3 ] ; return ipLong ; } return - 1 ; } | converts an array of four bytes to a long . |
36,805 | public long convertIPString ( String ip ) throws NumberFormatException , IllegalArgumentException { StringTokenizer st = new StringTokenizer ( ip , "." ) ; if ( st . countTokens ( ) == 4 ) { long ipLong = ( Long . parseLong ( st . nextToken ( ) ) << 24 ) ; ipLong += ( Long . parseLong ( st . nextToken ( ) ) << 16 ) ; ipLong += ( Long . parseLong ( st . nextToken ( ) ) << 8 ) ; ipLong += Long . parseLong ( st . nextToken ( ) ) ; return ipLong ; } else { throw new IllegalArgumentException ( "Invalid IP string" ) ; } } | turns a dot delimited IP address string into a long . |
36,806 | public String convertIPBackToString ( long ip ) { StringBuffer sb = new StringBuffer ( 16 ) ; sb . append ( Long . toString ( ( ip >> 24 ) & 0xFF ) ) ; sb . append ( '.' ) ; sb . append ( Long . toString ( ( ip >> 16 ) & 0xFF ) ) ; sb . append ( '.' ) ; sb . append ( Long . toString ( ( ip >> 8 ) & 0xFF ) ) ; sb . append ( '.' ) ; sb . append ( Long . toString ( ip & 0xFF ) ) ; return sb . toString ( ) ; } | converts a long to a dot delimited IP address string . |
36,807 | public Class < ? > loadClass ( String name ) throws ClassNotFoundException { while ( true ) { try { if ( mClassLoader == null ) { return Class . forName ( name ) ; } else { return mClassLoader . loadClass ( name ) ; } } catch ( ClassNotFoundException e ) { int index = name . lastIndexOf ( '.' ) ; if ( index < 0 ) { throw e ; } name = name . substring ( 0 , index ) + '$' + name . substring ( index + 1 ) ; } } } | Loads and returns a class by the fully qualified name given . If a ClassLoader is specified it is used to load the class . Otherwise the class is loaded via Class . forName . |
36,808 | public void preserveParseTree ( String name ) { if ( mPreserveTree == null ) { mPreserveTree = new HashSet < String > ( ) ; } mPreserveTree . add ( name ) ; } | After a template is compiled all but the root node of its parse tree is clipped in order to save memory . Applications that wish to traverse CompilationUnit parse trees should call this method to preserve them . This method must be called prior to compilation and prior to requesting a parse tree from a CompilationUnit . |
36,809 | public String [ ] compile ( String [ ] names ) throws IOException { if ( ! TemplateRepository . isInitialized ( ) ) { return compile0 ( names ) ; } String [ ] compNames = compile0 ( names ) ; ArrayList < String > compList = new ArrayList < String > ( Arrays . asList ( compNames ) ) ; TemplateRepository rep = TemplateRepository . getInstance ( ) ; String [ ] callers = rep . getCallersNeedingRecompile ( compNames , this ) ; if ( callers . length > 0 ) compList . addAll ( Arrays . asList ( compile0 ( callers ) ) ) ; String [ ] compiled = compList . toArray ( new String [ compList . size ( ) ] ) ; try { rep . update ( compiled ) ; } catch ( Exception e ) { System . err . println ( "Unable to update repository" ) ; e . printStackTrace ( System . err ) ; } return compiled ; } | Compile a list of compilation units . This method can be called multiple times but it will not compile compilation units that have already been compiled . |
36,810 | public CompilationUnit getCompilationUnit ( String name , CompilationUnit from ) { String fqName = determineQualifiedName ( name , from ) ; boolean compiled = false ; if ( fqName == null && ( compiled = CompiledTemplate . exists ( this , name , from ) ) ) { fqName = CompiledTemplate . getFullyQualifiedName ( name ) ; } if ( fqName == null ) return null ; CompilationUnit unit = mCompilationUnitMap . get ( fqName ) ; if ( unit == null ) { if ( ! compiled ) { unit = createCompilationUnit ( fqName ) ; if ( unit != null ) mCompilationUnitMap . put ( fqName , unit ) ; } else { unit = new CompiledTemplate ( name , this , from ) ; if ( ( ( CompiledTemplate ) unit ) . isValid ( ) ) { mCompilationUnitMap . put ( fqName , unit ) ; } else { unit = null ; } } } return unit ; } | Returns a compilation unit associated with the given name or null if not found . |
36,811 | public void addImportedPackages ( String [ ] imports ) { if ( imports == null ) { return ; } for ( String imported : imports ) { this . mImports . add ( imported ) ; } } | Add all imported packages that all templates will have . |
36,812 | public final Method [ ] getStringConverterMethods ( ) { if ( mStringConverters == null ) { String name = getRuntimeStringConverter ( ) ; Vector < Method > methods = new Vector < Method > ( ) ; if ( name != null ) { Method [ ] contextMethods = getRuntimeContextMethods ( ) ; for ( int i = 0 ; i < contextMethods . length ; i ++ ) { Method m = contextMethods [ i ] ; if ( m . getName ( ) . equals ( name ) && m . getReturnType ( ) == String . class && m . getParameterTypes ( ) . length == 1 ) { methods . addElement ( m ) ; } } } int customSize = methods . size ( ) ; Method [ ] stringMethods = String . class . getMethods ( ) ; for ( int i = 0 ; i < stringMethods . length ; i ++ ) { Method m = stringMethods [ i ] ; if ( m . getName ( ) . equals ( "valueOf" ) && m . getReturnType ( ) == String . class && m . getParameterTypes ( ) . length == 1 && Modifier . isStatic ( m . getModifiers ( ) ) ) { Class < ? > type = m . getParameterTypes ( ) [ 0 ] ; int j ; for ( j = 0 ; j < customSize ; j ++ ) { Method cm = methods . elementAt ( j ) ; if ( cm . getParameterTypes ( ) [ 0 ] == type ) { break ; } } if ( j == customSize ) { methods . addElement ( m ) ; } } } mStringConverters = new Method [ methods . size ( ) ] ; methods . copyInto ( mStringConverters ) ; } return mStringConverters . clone ( ) ; } | Returns the set of methods that are used to perform conversion to strings . The compiler will bind to the closest matching method based on its parameter type . |
36,813 | private String determineQualifiedName ( String name , CompilationUnit from ) { if ( from != null ) { String fromName = from . getName ( ) ; int index = fromName . lastIndexOf ( '.' ) ; if ( index >= 0 ) { String qual = fromName . substring ( 0 , index + 1 ) + name ; if ( sourceExists ( qual ) ) { return qual ; } } } if ( sourceExists ( name ) ) { return name ; } return null ; } | Given a name as requested by the given CompilationUnit return a fully qualified name or null if the name could not be found . |
36,814 | public Result getMatch ( String lookup ) { int strLen = lookup . length ( ) ; char [ ] chars = new char [ strLen + 1 ] ; lookup . getChars ( 0 , strLen , chars , 0 ) ; chars [ strLen ] = '\uffff' ; TinyList resultList = new TinyList ( ) ; fillMatchResults ( chars , 1 , resultList ) ; return ( Result ) resultList . mElement ; } | Returns null if no match . |
36,815 | protected static boolean addMatchResult ( int limit , List results , String pattern , Object value , int [ ] positions , int len ) { int size = results . size ( ) ; if ( size < limit ) { if ( positions == null || len == 0 ) { positions = NO_POSITIONS ; } else { int [ ] original = positions ; positions = new int [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { positions [ i ] = original [ i ] ; } } results . add ( new Result ( pattern , value , positions ) ) ; return size + 1 < limit ; } else { return false ; } } | Returns false if no more results should be added . |
36,816 | public boolean endsWith ( String str , String suffix ) { return ( str == null || suffix == null ) ? ( str == suffix ) : str . endsWith ( suffix ) ; } | Tests if the given string ends with the given suffix . Returns true if the given string ends with the given suffix . |
36,817 | public int [ ] find ( String str , String search , int fromIndex ) { if ( str == null || search == null ) { return new int [ 0 ] ; } int [ ] indices = new int [ 10 ] ; int size = 0 ; int index = fromIndex ; while ( ( index = str . indexOf ( search , index ) ) >= 0 ) { if ( size >= indices . length ) { int [ ] newArray = new int [ indices . length * 2 ] ; System . arraycopy ( indices , 0 , newArray , 0 , indices . length ) ; indices = newArray ; } indices [ size ++ ] = index ; index += search . length ( ) ; } if ( size < indices . length ) { int [ ] newArray = new int [ size ] ; System . arraycopy ( indices , 0 , newArray , 0 , size ) ; indices = newArray ; } return indices ; } | Finds the indices for each occurrence of the given search string in the source string starting from the given index . |
36,818 | public int findFirst ( String str , String search ) { return ( str == null || search == null ) ? - 1 : str . indexOf ( search ) ; } | Finds the index of the first occurrence of the given search string in the source string or - 1 if not found . |
36,819 | public String substring ( String str , int startIndex , int endIndex ) { return ( str == null ) ? null : str . substring ( startIndex , endIndex ) ; } | Returns a sub - portion of the given string for the characters that are at or after the starting index and are before the end index . |
36,820 | public String trimLeading ( String str ) { if ( str == null ) { return null ; } int length = str . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { if ( str . charAt ( i ) > ' ' ) { return str . substring ( i ) ; } } return "" ; } | Trims all leading whitespace characters from the given string . |
36,821 | public String trimTrailing ( String str ) { if ( str == null ) { return null ; } int length = str . length ( ) ; for ( int i = length - 1 ; i >= 0 ; i -- ) { if ( str . charAt ( i ) > ' ' ) { return str . substring ( 0 , i + 1 ) ; } } return "" ; } | Trims all trailing whitespace characters from the given string . |
36,822 | public String [ ] split ( String str , String regex , int limit ) { return str . split ( regex , limit ) ; } | Split the given string with the given regular expression returning the array of strings after splitting . |
36,823 | public String [ ] splitString ( String text , int maxChars ) { String [ ] splitVals = { " " } ; return splitString ( text , maxChars , splitVals ) ; } | Split the given string on spaces ensuring the maximum number of characters in each token . |
36,824 | public String [ ] splitString ( String text , int maxChars , String [ ] splitValues ) { String restOfText = text ; List < String > list = new ArrayList < String > ( ) ; while ( restOfText . length ( ) > maxChars ) { String thisLine = restOfText . substring ( 0 , maxChars ) ; int lineEnd = 0 ; for ( int i = 0 ; i < splitValues . length ; i ++ ) { int lastIndex = thisLine . lastIndexOf ( splitValues [ i ] ) ; if ( lastIndex > lineEnd ) { lineEnd = lastIndex ; } } if ( lineEnd == 0 ) { list . add ( thisLine ) ; restOfText = restOfText . substring ( maxChars ) ; } else { list . add ( thisLine . substring ( 0 , lineEnd ) ) ; restOfText = restOfText . substring ( lineEnd ) ; } } list . add ( restOfText ) ; return list . toArray ( new String [ list . size ( ) ] ) ; } | Split the given string on the given split values ensuring the maximum number of characters in each token . |
36,825 | public String [ ] tokenize ( String string , String token ) { String [ ] result ; try { StringTokenizer st = new StringTokenizer ( string , token ) ; List < String > list = new ArrayList < String > ( ) ; while ( st . hasMoreTokens ( ) ) { list . add ( st . nextToken ( ) ) ; } result = list . toArray ( new String [ list . size ( ) ] ) ; } catch ( Exception e ) { result = null ; } return result ; } | Tokenize the given string with the given token . This will return an array of strings containing each token delimited by the given value . |
36,826 | public String [ ] addToStringArray ( String [ ] strArray , String str ) { String [ ] result = null ; if ( strArray != null ) { result = new String [ strArray . length + 1 ] ; System . arraycopy ( strArray , 0 , result , 0 , strArray . length ) ; result [ strArray . length ] = str ; } return result ; } | Add the given string to the string array . This will create a new array expanded by one element copy the existing array add the given value and return the resulting array . |
36,827 | public String [ ] removeFromStringArray ( String [ ] strArray , String str ) { String [ ] result = null ; if ( strArray != null && strArray . length > 0 ) { List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < strArray . length ; i ++ ) { if ( ! strArray [ i ] . equals ( str ) ) { list . add ( strArray [ i ] ) ; } } int size = list . size ( ) ; if ( size > 0 ) { result = list . toArray ( new String [ size ] ) ; } } return result ; } | Remove all occurrences of the given string from the given array . This will create a new array containing all elements of the given array except for those matching the given value . |
36,828 | public String [ ] removeFromStringArray ( String [ ] strArray , int index ) { String [ ] result = null ; if ( strArray != null && index > 0 && index < strArray . length ) { result = new String [ strArray . length - 1 ] ; for ( int i = 0 , j = 0 ; i < strArray . length ; i ++ ) { if ( i != index ) { result [ j ++ ] = strArray [ i ] ; } } } return result ; } | Remove the string at the given index from the given array . This will return a new array containing the given array excluding the element at the given index . |
36,829 | public boolean setInStringArray ( String [ ] strArray , int index , String str ) { boolean result = false ; if ( strArray != null && index >= 0 && index < strArray . length ) { strArray [ index ] = str ; result = true ; } return result ; } | Set the given string in the given array at the given index . This will overwrite the existing value at the given index . |
36,830 | public String convertToEncoding ( String subject , String encoding ) throws UnsupportedEncodingException { return new String ( subject . getBytes ( encoding ) , encoding ) ; } | Convert the given string to the given encoding . |
36,831 | public String replaceFirstRegex ( String subject , String regex , String replacement ) { return subject . replaceFirst ( regex , replacement ) ; } | Replace the given regular expression pattern with the given replacement . Only the first match will be replaced . |
36,832 | public String replaceAllRegex ( String subject , String regex , String replacement ) { return subject . replaceAll ( regex , replacement ) ; } | Replace the given regular expression pattern with the given replacement . This will replace all matches in the given string . |
36,833 | public void append ( StringBuilder buffer , Object value ) { if ( buffer == null ) { throw new NullPointerException ( "buffer" ) ; } buffer . append ( value ) ; } | A function to append a value to an existing buffer . |
36,834 | public void prepend ( StringBuilder buffer , Object value ) { if ( buffer == null ) { throw new NullPointerException ( "buffer" ) ; } buffer . insert ( 0 , value ) ; } | A function to prepend a value to an existing buffer . |
36,835 | public void insert ( StringBuilder buffer , Object value , int index ) { if ( buffer == null ) { throw new NullPointerException ( "buffer" ) ; } buffer . insert ( index , value ) ; } | A function to insert a value into an existing buffer . |
36,836 | public void setPriority ( int priority ) throws IllegalArgumentException { if ( priority < Thread . MIN_PRIORITY || priority > Thread . MAX_PRIORITY ) { throw new IllegalArgumentException ( "Priority out of range: " + priority ) ; } synchronized ( mPool ) { mPriority = priority ; } } | Sets the priority given to each thread in the pool . |
36,837 | public void close ( long timeout ) throws InterruptedException { synchronized ( mPool ) { mClosed = true ; mPool . notifyAll ( ) ; if ( timeout != 0 ) { if ( timeout < 0 ) { while ( mActive > 0 ) { mPool . wait ( 0 ) ; } } else { long expireTime = System . currentTimeMillis ( ) + timeout ; while ( mActive > 0 ) { mPool . wait ( timeout ) ; if ( System . currentTimeMillis ( ) > expireTime ) { break ; } } } } } interrupt ( ) ; } | Will close down all the threads in the pool as they become available . If all the threads cannot become available within the specified timeout any active threads not yet returned to the thread pool are interrupted . |
36,838 | protected Expression visitExpression ( Expression expr ) { if ( expr == null ) { return null ; } Expression newExpr = ( Expression ) expr . accept ( this ) ; if ( expr != newExpr ) { Type newType = newExpr . getType ( ) ; if ( newType == null || ! newType . equals ( expr . getType ( ) ) ) { Iterator < Expression . Conversion > it = expr . getConversionChain ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Expression . Conversion conv = it . next ( ) ; newExpr . convertTo ( conv . getToType ( ) , conv . isCastPreferred ( ) ) ; } } } return newExpr ; } | All expressions pass through this method to ensure the expression s type is preserved . |
36,839 | protected Block visitBlock ( Block block ) { if ( block == null ) { return null ; } Statement stmt = ( Statement ) block . accept ( this ) ; if ( stmt instanceof Block ) { return ( Block ) stmt ; } else if ( stmt != null ) { return new Block ( stmt ) ; } else { return new Block ( block . getSourceInfo ( ) ) ; } } | Visit a Block to ensure that new Statement is a Block . |
36,840 | public void init ( ApplicationConfig config ) throws ServletException { mConfig = config ; mLog = config . getLog ( ) ; } | Initialize this application with the provided application configuration . |
36,841 | static ConstantDoubleInfo make ( ConstantPool cp , double value ) { ConstantInfo ci = new ConstantDoubleInfo ( value ) ; return ( ConstantDoubleInfo ) cp . addConstant ( ci ) ; } | Will return either a new ConstantDoubleInfo object or one already in the constant pool . If it is a new ConstantDoubleInfo it will be inserted into the pool . |
36,842 | public boolean isDeprecated ( Class < ? > clazz ) { if ( clazz . getAnnotation ( Deprecated . class ) != null ) { return true ; } Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null ) { return isDeprecated ( superClass ) ; } for ( Class < ? > iface : clazz . getInterfaces ( ) ) { return isDeprecated ( iface ) ; } return false ; } | Returns whether the given class or any super class or interface is deprecated . |
36,843 | protected boolean isDeprecated ( Class < ? > clazz , String methodName , Class < ? > ... paramTypes ) { if ( isDeprecated ( clazz ) ) { return true ; } try { Method method = clazz . getDeclaredMethod ( methodName , paramTypes ) ; if ( method . getAnnotation ( Deprecated . class ) != null ) { return true ; } } catch ( NoSuchMethodException nsme ) { } Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null ) { return isDeprecated ( superClass , methodName , paramTypes ) ; } for ( Class < ? > iface : clazz . getInterfaces ( ) ) { return isDeprecated ( iface , methodName , paramTypes ) ; } return false ; } | Returns whether the given method or any super method or interface declaration is deprecated . |
36,844 | public Date createDate ( int month , int day , int year , int hour , int minute , int second , int millisecond ) { GregorianCalendar gc = new GregorianCalendar ( ) ; gc . clear ( ) ; gc . set ( Calendar . MONTH , month - 1 ) ; gc . set ( Calendar . DAY_OF_MONTH , day ) ; gc . set ( Calendar . YEAR , year ) ; gc . set ( Calendar . HOUR_OF_DAY , hour ) ; gc . set ( Calendar . MINUTE , minute ) ; gc . set ( Calendar . SECOND , second ) ; gc . set ( Calendar . MILLISECOND , millisecond ) ; return gc . getTime ( ) ; } | Create a date from the given data . |
36,845 | public Date changeDate ( Date date , int delta ) { return adjustDate ( date , Calendar . DATE , delta ) ; } | Roll a date forward or back a given number of days . Only the days are modified in the associated date . If the delta is positive then the date is rolled forward the given number of days . If the delta is negative then the date is rolled backward the given number of days . |
36,846 | public int calculateAge ( Date birthday ) { int result = - 1 ; if ( birthday != null ) { GregorianCalendar todayCal = new GregorianCalendar ( ) ; todayCal . setTime ( new Date ( ) ) ; int dayOfYear = todayCal . get ( Calendar . DAY_OF_YEAR ) ; int year = todayCal . get ( Calendar . YEAR ) ; GregorianCalendar birthdayCal = new GregorianCalendar ( ) ; birthdayCal . setTime ( birthday ) ; int birthDayOfYear = birthdayCal . get ( Calendar . DAY_OF_YEAR ) ; int birthYear = birthdayCal . get ( Calendar . YEAR ) ; birthDayOfYear = processLeapYear ( todayCal , birthdayCal , birthDayOfYear ) ; result = year - birthYear ; if ( dayOfYear < birthDayOfYear ) { result -- ; } } return result ; } | Calcualte the age in years from today given a birthday . |
36,847 | public void parse ( Reader reader ) throws IOException { mScanner = new Scanner ( reader ) ; mScanner . addErrorListener ( new ErrorListener ( ) { public void parseError ( ErrorEvent e ) { dispatchParseError ( e ) ; } } ) ; try { parseProperties ( ) ; } finally { mScanner . close ( ) ; } } | Parses properties from the given reader and stores them in the Map . To capture any parsing errors call addErrorListener prior to parsing . |
36,848 | private void parseBlock ( String keyPrefix ) throws IOException { parsePropertyList ( keyPrefix ) ; Token token ; if ( ( token = peek ( ) ) . getId ( ) == Token . RBRACE ) { read ( ) ; } else { error ( "Right brace expected" , token ) ; } } | When this is called the LBRACE token has already been read . |
36,849 | public void close ( ) throws IOException { if ( mPositionReader != null ) { mPositionReader . close ( ) ; } mPositionReader = null ; mPositionReaderUnit = null ; } | Closes all open resources . |
36,850 | protected String createPrepend ( LogEvent e ) { StringBuffer pre = new StringBuffer ( 80 ) ; String code = "??" ; switch ( e . getType ( ) ) { case LogEvent . DEBUG_TYPE : code = " D" ; break ; case LogEvent . INFO_TYPE : code = " I" ; break ; case LogEvent . WARN_TYPE : code = "*W" ; break ; case LogEvent . ERROR_TYPE : code = "*E" ; break ; } pre . append ( code ) ; pre . append ( ',' ) ; if ( mFastFormat != null ) { pre . append ( mFastFormat . format ( e . getTimestamp ( ) ) ) ; } else { synchronized ( mSlowFormat ) { pre . append ( mSlowFormat . format ( e . getTimestamp ( ) ) ) ; } } if ( isShowThreadEnabled ( ) ) { pre . append ( ',' ) ; pre . append ( e . getThreadName ( ) ) ; } if ( isShowSourceEnabled ( ) ) { Log source = e . getLogSource ( ) ; if ( source != null ) { String sourceName = source . getName ( ) ; if ( sourceName != null ) { pre . append ( ',' ) ; pre . append ( sourceName ) ; } } } pre . append ( '>' ) ; pre . append ( ' ' ) ; return pre . toString ( ) ; } | Creates the default line prepend for a message . |
36,851 | public double max ( double ... values ) { double max = Double . MIN_VALUE ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( i == 0 || values [ i ] > max ) { max = values [ i ] ; } } return max ; } | Get the greatest of the set of double values . |
36,852 | public float max ( float ... values ) { float max = Float . MIN_VALUE ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( i == 0 || values [ i ] > max ) { max = values [ i ] ; } } return max ; } | Get the greatest of the set of float values . |
36,853 | public double min ( double ... values ) { double min = Double . MAX_VALUE ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( i == 0 || values [ i ] < min ) { min = values [ i ] ; } } return min ; } | Get the smallest of the set of double values . |
36,854 | public float min ( float ... values ) { float min = Float . MAX_VALUE ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( i == 0 || values [ i ] < min ) { min = values [ i ] ; } } return min ; } | Get the smallest of the set of float values . |
36,855 | public long min ( long ... values ) { long min = Long . MAX_VALUE ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( i == 0 || values [ i ] < min ) { min = values [ i ] ; } } return min ; } | Get the smallest of the set of long values . |
36,856 | public void applyProperties ( PropertyMap properties ) { if ( properties != null ) { mRawWindowSize = properties . getInt ( "rawWindowSize" , DEFAULT_RAW_WINDOW_SIZE ) ; mAggregateWindowSize = properties . getInt ( "aggregateWindowSize" , DEFAULT_AGGREGATE_WINDOW_SIZE ) ; reset ( ) ; } } | This method applies properties from a stats block in the tea servlet config . |
36,857 | public TemplateStats getStats ( String fullTemplateName ) { TemplateStats stats = ( TemplateStats ) mStatsMap . get ( fullTemplateName ) ; if ( stats == null ) { stats = new TemplateStats ( fullTemplateName , mRawWindowSize , mAggregateWindowSize ) ; mStatsMap . put ( fullTemplateName , stats ) ; } return stats ; } | Returns the template stats for a given template name . |
36,858 | public TemplateStats [ ] getTemplateStats ( ) { Collection < TemplateStats > collection = mStatsMap . values ( ) ; TemplateStats [ ] result = null ; if ( collection . size ( ) > 0 ) { result = collection . toArray ( new TemplateStats [ collection . size ( ) ] ) ; } return result ; } | Returns an array of template stats . |
36,859 | public void log ( String fullTemplateName , long startTime , long stopTime , long contentLength , Object [ ] params ) { TemplateStats stats = ( TemplateStats ) mStatsMap . get ( fullTemplateName ) ; if ( stats == null ) { stats = new TemplateStats ( fullTemplateName , mRawWindowSize , mAggregateWindowSize ) ; mStatsMap . put ( fullTemplateName , stats ) ; } stats . log ( startTime , stopTime , contentLength , params ) ; } | Logs an invokation of an http template invocation . |
36,860 | protected void moveToIntervalStart ( Calendar cal ) { int year = cal . get ( Calendar . YEAR ) ; int month = cal . get ( Calendar . MONTH ) ; int day = cal . get ( Calendar . DAY_OF_MONTH ) ; cal . clear ( ) ; cal . set ( year , month , day ) ; } | Moves calendar to beginning of day . |
36,861 | public void readFrom ( InputStream in , byte [ ] buffer ) throws IOException { String header ; while ( ( header = HttpUtils . readLine ( in , buffer , MAX_HEADER_LENGTH ) ) != null ) { if ( header . length ( ) == 0 ) { break ; } processHeaderLine ( header ) ; } } | Read and parse headers from the given InputStream until a blank line is reached . Except for Cookies all other headers that contain multiple fields delimited by commas are parsed into multiple headers . |
36,862 | public Object get ( Object key ) { Object value = mMap . get ( key ) ; if ( value instanceof List ) { return ( ( List ) value ) . get ( 0 ) ; } else { return value ; } } | Returns the first value associated with the given key . |
36,863 | public List getAll ( Object key ) { Object value = mMap . get ( key ) ; if ( value instanceof List ) { return ( ( List ) value ) ; } else { List list = new ArrayList ( ) ; if ( value != null || mMap . containsKey ( key ) ) { list . add ( value ) ; } mMap . put ( key , list ) ; return list ; } } | Returns all the values associated with the given key . Changes to the returned list will be reflected in this map . |
36,864 | public Object put ( Object key , Object value ) { if ( value instanceof List ) { return mMap . put ( key , new ArrayList ( ( List ) value ) ) ; } else { return mMap . put ( key , value ) ; } } | May return a list if the key previously mapped to multiple values . |
36,865 | public void add ( Object key , Object value ) { Object existing = mMap . get ( key ) ; if ( existing instanceof List ) { if ( value instanceof List ) { ( ( List ) existing ) . addAll ( ( List ) value ) ; } else { ( ( List ) existing ) . add ( value ) ; } } else if ( existing == null && ! mMap . containsKey ( key ) ) { if ( value instanceof List ) { mMap . put ( key , new ArrayList ( ( List ) value ) ) ; } else { mMap . put ( key , value ) ; } } else { List list = new ArrayList ( ) ; list . add ( existing ) ; if ( value instanceof List ) { list . addAll ( ( List ) value ) ; } else { list . add ( value ) ; } mMap . put ( key , list ) ; } } | Add more than one value associated with the given key . |
36,866 | public void set ( Object object , String attributeName , Object attributeValue ) throws IllegalAccessException , InvocationTargetException , BeanContextException { Class < ? > objectClass = object . getClass ( ) ; String methodName = "set" + attributeName . substring ( 0 , 1 ) . toUpperCase ( ) + attributeName . substring ( 1 ) ; String methodKey = objectClass . getName ( ) + "." + methodName ; MethodTypePair pair = mMethodTypePairMap . get ( methodKey ) ; if ( pair == null ) { pair = getMethodTypePair ( objectClass , methodName , attributeValue ) ; mMethodTypePairMap . put ( methodKey , pair ) ; } if ( pair != null ) { Object [ ] params = { convertObjectType ( attributeValue , pair . type ) } ; pair . method . invoke ( object , params ) ; } else { throw new BeanContextException ( methodName + "(" + ( attributeValue == null ? "null" : attributeValue . getClass ( ) ) + ") could not be found." ) ; } } | Method to set attributes of an object . This method may be called to set the values of an object by passing in the object the attribute name to set and the attribute value . To get a listing of attribute values that can be set for a given object see the createObject method for the object . |
36,867 | public void truncate ( long size ) throws IOException { super . truncate ( size ) ; if ( size == 0 ) { synchronized ( this ) { mTranCount = 0 ; mBitlist . clear ( mBitlistPos ) ; } } } | Truncating the file to zero restores it to a clean state . |
36,868 | private static List < ConfigFile > createStandaloneConfigFiles ( FeaturePack featurePack , ConfigOverride configOverride ) { final List < org . wildfly . build . common . model . ConfigFile > configFiles = featurePack . getDescription ( ) . getConfig ( ) . getStandaloneConfigFiles ( ) ; final Map < String , ConfigFileOverride > configFileOverrides = configOverride != null ? configOverride . getStandaloneConfigFiles ( ) : null ; return createConfigFiles ( featurePack . getFeaturePackFile ( ) , configFiles , configOverride , configFileOverrides ) ; } | Creates the provisioning standalone config files . |
36,869 | public Map < String , Map < String , SubsystemConfig > > getSubsystemConfigs ( File featurePackFile ) throws IOException , XMLStreamException { Map < String , Map < String , SubsystemConfig > > subsystems = new HashMap < > ( ) ; try ( ZipFile zip = new ZipFile ( featurePackFile ) ) { ZipEntry zipEntry = zip . getEntry ( getSubsystems ( ) ) ; if ( zipEntry == null ) { throw new RuntimeException ( "Feature pack " + featurePackFile + " subsystems file " + getSubsystems ( ) + " not found" ) ; } InputStreamSource inputStreamSource = new ZipEntryInputStreamSource ( featurePackFile , zipEntry ) ; SubsystemsParser . parse ( inputStreamSource , getProperties ( ) , subsystems ) ; } return subsystems ; } | Retrieves the subsystems configs . |
36,870 | public void addSubsystemFileSource ( String subsystemFileName , File zipFile , ZipEntry zipEntry ) { inputStreamSourceMap . put ( subsystemFileName , new ZipEntryInputStreamSource ( zipFile , zipEntry ) ) ; } | Creates a zip entry inputstream source and maps it to the specified filename . |
36,871 | public void addAllSubsystemFileSources ( ZipFileSubsystemInputStreamSources other ) { for ( Map . Entry < String , ZipEntryInputStreamSource > entry : other . inputStreamSourceMap . entrySet ( ) ) { if ( ! this . inputStreamSourceMap . containsKey ( entry . getKey ( ) ) ) { this . inputStreamSourceMap . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } } } | Adds all subsystem input stream sources from the specified factory . Note that only absent sources will be added . |
36,872 | public void addAllSubsystemFileSourcesFromZipFile ( File file ) throws IOException { try ( ZipFile zip = new ZipFile ( file ) ) { if ( zip . getEntry ( "subsystem-templates" ) != null ) { Enumeration < ? extends ZipEntry > entries = zip . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry entry = entries . nextElement ( ) ; if ( ! entry . isDirectory ( ) ) { String entryName = entry . getName ( ) ; if ( entryName . startsWith ( "subsystem-templates/" ) ) { addSubsystemFileSource ( entryName . substring ( "subsystem-templates/" . length ( ) ) , file , entry ) ; } } } } } } | Adds all file sources in the specified zip file . |
36,873 | public boolean addSubsystemFileSourceFromZipFile ( String subsystem , File file ) throws IOException { try ( ZipFile zip = new ZipFile ( file ) ) { String entryName = "subsystem-templates/" + subsystem ; ZipEntry entry = zip . getEntry ( entryName ) ; if ( entry != null ) { addSubsystemFileSource ( subsystem , file , entry ) ; return true ; } } return false ; } | Adds the file source for the specified subsystem from the specified zip file . |
36,874 | public void addAllSubsystemFileSourcesFromModule ( FeaturePack . Module module , ArtifactFileResolver artifactFileResolver , boolean transitive ) throws IOException { for ( ModuleParseResult . ArtifactName artifactName : module . getModuleParseResult ( ) . getArtifacts ( ) ) { Artifact artifact = module . getFeaturePack ( ) . getArtifactResolver ( ) . getArtifact ( artifactName . getArtifact ( ) ) ; if ( artifact == null ) { throw new RuntimeException ( "Could not resolve module resource artifact " + artifactName . getArtifactCoords ( ) + " for feature pack " + module . getFeaturePack ( ) . getFeaturePackFile ( ) ) ; } File artifactFile = artifactFileResolver . getArtifactFile ( artifact ) ; addAllSubsystemFileSourcesFromZipFile ( artifactFile ) ; } if ( transitive ) { for ( FeaturePack . Module dependency : module . getDependencies ( ) . values ( ) ) { addAllSubsystemFileSourcesFromModule ( dependency , artifactFileResolver , false ) ; } } } | Adds all file sources in the specified module s artifacts . |
36,875 | public boolean addSubsystemFileSourceFromModule ( String subsystem , FeaturePack . Module module , ArtifactFileResolver artifactFileResolver ) throws IOException { for ( ModuleParseResult . ArtifactName artifactName : module . getModuleParseResult ( ) . getArtifacts ( ) ) { Artifact artifact = module . getFeaturePack ( ) . getArtifactResolver ( ) . getArtifact ( artifactName . getArtifact ( ) ) ; if ( artifact == null ) { throw new RuntimeException ( "Could not resolve module resource artifact " + artifactName . getArtifactCoords ( ) + " for feature pack " + module . getFeaturePack ( ) . getFeaturePackFile ( ) ) ; } File artifactFile = artifactFileResolver . getArtifactFile ( artifact ) ; if ( addSubsystemFileSourceFromZipFile ( subsystem , artifactFile ) ) { return true ; } } return false ; } | Adds the file source for the specified subsystem from the specified module s artifacts . |
36,876 | public Set < String > getSubsystems ( ) throws IOException , XMLStreamException { final Set < String > result = new HashSet < > ( ) ; for ( ConfigFile configFile : description . getConfig ( ) . getDomainConfigFiles ( ) ) { for ( Map < String , SubsystemConfig > subsystems : configFile . getSubsystemConfigs ( featurePackFile ) . values ( ) ) { result . addAll ( subsystems . keySet ( ) ) ; } } for ( ConfigFile configFile : description . getConfig ( ) . getStandaloneConfigFiles ( ) ) { for ( Map < String , SubsystemConfig > subsystems : configFile . getSubsystemConfigs ( featurePackFile ) . values ( ) ) { result . addAll ( subsystems . keySet ( ) ) ; } } for ( ConfigFile configFile : description . getConfig ( ) . getHostConfigFiles ( ) ) { for ( Map < String , SubsystemConfig > subsystems : configFile . getSubsystemConfigs ( featurePackFile ) . values ( ) ) { result . addAll ( subsystems . keySet ( ) ) ; } } return result ; } | Retrieves all subsystems included in the feature pack config files . |
36,877 | public static List < RemoteRepository > getStandardRemoteRepositories ( ) { final List < RemoteRepository > remoteRepositories = new ArrayList < > ( ) ; remoteRepositories . add ( new RemoteRepository . Builder ( "central" , "default" , "https://central.maven.org/maven2/" ) . build ( ) ) ; remoteRepositories . add ( new RemoteRepository . Builder ( "jboss-community-repository" , "default" , "https://repository.jboss.org/nexus/content/groups/public/" ) . build ( ) ) ; return remoteRepositories ; } | Retrieves the standard remote repositories i . e . maven central and jboss . org |
36,878 | public static ResourceReference getJQueryResourceReference ( ) { ResourceReference reference ; if ( Application . exists ( ) ) { reference = Application . get ( ) . getJavaScriptLibrarySettings ( ) . getJQueryReference ( ) ; } else { reference = JQueryResourceReference . get ( ) ; } return reference ; } | Looks for the jQuery resource reference . First we see if the application knows where it is in case the user has overriden it . If that fails we use the default resource reference . |
36,879 | public CharSequence render ( ) { if ( statement == null ) { statement = new StringBuilder ( ) ; statement . append ( "function(" ) ; statement . append ( scopeContext . scopeDeclaration ( ) ) ; statement . append ( ") {\n" ) ; execute ( scopeContext ) ; statement . append ( scopeContext . render ( ) ) ; closeScope ( ) ; } return statement . toString ( ) ; } | Renders the scope . |
36,880 | public Accordion setIcons ( UiIcon header , UiIcon headerSelected ) { setIcons ( new AccordionIcon ( header , headerSelected ) ) ; return this ; } | Icons to use for headers . |
36,881 | public void hide ( AjaxRequestTarget ajaxRequestTarget , short speed ) { ajaxRequestTarget . appendJavaScript ( this . hide ( speed ) . render ( ) . toString ( ) ) ; } | Method to hide the datepicker within the ajax request |
36,882 | public void setDate ( AjaxRequestTarget ajaxRequestTarget , DateOption dateOption ) { ajaxRequestTarget . appendJavaScript ( this . setDate ( dateOption ) . render ( ) . toString ( ) ) ; } | Method to set the date of the datepicker within the ajax request |
36,883 | public void search ( AjaxRequestTarget ajaxRequestTarget , String value ) { ajaxRequestTarget . appendJavaScript ( this . search ( value ) . render ( ) . toString ( ) ) ; } | Method to search the autocomplete within the ajax request |
36,884 | public void setArrayParam ( Integer x1 , Integer y1 , Integer x2 , Integer y2 ) { ArrayItemOptions < IntegerItemOptions > tempArrayParam = new ArrayItemOptions < IntegerItemOptions > ( ) ; tempArrayParam . add ( new IntegerItemOptions ( x1 ) ) ; tempArrayParam . add ( new IntegerItemOptions ( y1 ) ) ; tempArrayParam . add ( new IntegerItemOptions ( x2 ) ) ; tempArrayParam . add ( new IntegerItemOptions ( y2 ) ) ; setParam ( tempArrayParam , containmentEnumParam , null , null ) ; } | Set s the array parameter |
36,885 | private int parseInteger ( String value , int defaultValue ) { try { return Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { return defaultValue ; } } | Parses an integer . |
36,886 | public Tabs setAjaxBeforeLoadEvent ( ITabsAjaxEvent beforeLoadEvent ) { this . ajaxEvents . put ( TabEvent . beforeLoad , beforeLoadEvent ) ; setBeforeLoadEvent ( new TabsAjaxJsScopeUiEvent ( this , TabEvent . beforeLoad ) ) ; return this ; } | Sets the call - back for the AJAX beforeLoad event . |
36,887 | public Tabs setAjaxLoadEvent ( ITabsAjaxEvent loadEvent ) { this . ajaxEvents . put ( TabEvent . load , loadEvent ) ; setLoadEvent ( new TabsAjaxJsScopeUiEvent ( this , TabEvent . load ) ) ; return this ; } | Sets the call - back for the AJAX Load event . |
36,888 | public Tabs setAjaxBeforeActivateEvent ( ITabsAjaxEvent beforeActivateEvent ) { this . ajaxEvents . put ( TabEvent . beforeActivate , beforeActivateEvent ) ; setBeforeActivateEvent ( new TabsAjaxBeforeActivateJsScopeUiEvent ( this , TabEvent . beforeActivate , false ) ) ; return this ; } | Sets the call - back for the AJAX beforeActivate event . |
36,889 | public Tabs setAjaxActivateEvent ( ITabsAjaxEvent activateEvent ) { this . ajaxEvents . put ( TabEvent . activate , activateEvent ) ; setActivateEvent ( new TabsAjaxJsScopeUiEvent ( this , TabEvent . activate ) ) ; return this ; } | Sets the call - back for the AJAX activate event . |
36,890 | public void disable ( AjaxRequestTarget ajaxRequestTarget , int index ) { ajaxRequestTarget . appendJavaScript ( this . disable ( index ) . render ( ) . toString ( ) ) ; } | Method to disable a tab within the ajax request |
36,891 | public void enable ( AjaxRequestTarget ajaxRequestTarget , int index ) { ajaxRequestTarget . appendJavaScript ( this . enable ( index ) . render ( ) . toString ( ) ) ; } | Method to enable a tab within the ajax request |
36,892 | public void load ( AjaxRequestTarget ajaxRequestTarget , int index ) { ajaxRequestTarget . appendJavaScript ( this . load ( index ) . render ( ) . toString ( ) ) ; } | Method to reload the content of an Ajax tab programmatically within the ajax request |
36,893 | public DatePickerNumberOfMonths getNumberOfMonths ( ) { IComplexOption numberOfMonths = getComplexOption ( "numberOfMonths" ) ; if ( numberOfMonths != null && numberOfMonths instanceof DatePickerNumberOfMonths ) { return ( DatePickerNumberOfMonths ) numberOfMonths ; } return new DatePickerNumberOfMonths ( new Short ( "1" ) ) ; } | Returns the number of months displayed on the date picker . |
36,894 | public DatePickerShortYearCutOff getShortYearCutoff ( ) { IComplexOption shortYearCutoff = getComplexOption ( "shortYearCutoff" ) ; if ( shortYearCutoff != null && shortYearCutoff instanceof DatePickerShortYearCutOff ) { return ( DatePickerShortYearCutOff ) shortYearCutoff ; } return new DatePickerShortYearCutOff ( "+10" ) ; } | Returns the shortYearCutoff option value . |
36,895 | public static void hover ( Component component , AjaxRequestTarget ajaxRequestTarget ) { ajaxRequestTarget . appendJavaScript ( hover ( component ) . render ( ) . toString ( ) ) ; } | Method to insert the the hover style into the Ajax transaction |
36,896 | public CharSequence getJavaScriptOptions ( ) { StringBuilder sb = new StringBuilder ( ) ; this . optionsRenderer . renderBefore ( sb ) ; int count = 0 ; for ( Entry < String , Object > entry : options . entrySet ( ) ) { String key = entry . getKey ( ) ; Object value = entry . getValue ( ) ; if ( value instanceof IModelOption < ? > ) value = ( ( IModelOption < ? > ) value ) . wrapOnAssignment ( owner ) ; boolean isLast = ! ( count < options . size ( ) - 1 ) ; if ( value instanceof JsScope ) { sb . append ( this . optionsRenderer . renderOption ( key , ( ( JsScope ) value ) . render ( ) , isLast ) ) ; } else if ( value instanceof ICollectionItemOptions ) { sb . append ( this . optionsRenderer . renderOption ( key , ( ( ICollectionItemOptions ) value ) . getJavascriptOption ( ) , isLast ) ) ; } else if ( value instanceof IComplexOption ) { sb . append ( this . optionsRenderer . renderOption ( key , ( ( IComplexOption ) value ) . getJavascriptOption ( ) , isLast ) ) ; } else if ( value instanceof ITypedOption < ? > ) { sb . append ( this . optionsRenderer . renderOption ( key , ( ( ITypedOption < ? > ) value ) . getJavascriptOption ( ) , isLast ) ) ; } else { sb . append ( this . optionsRenderer . renderOption ( key , value , isLast ) ) ; } count ++ ; } this . optionsRenderer . renderAfter ( sb ) ; return sb ; } | Returns the JavaScript statement corresponding to options . |
36,897 | public Slider setAnimate ( AnimateEnum animate ) { if ( animate . equals ( AnimateEnum . FAST ) ) this . options . put ( "animate" , SliderAnimate . FAST ) ; else if ( animate . equals ( AnimateEnum . NORMAL ) ) this . options . put ( "animate" , SliderAnimate . NORMAL ) ; else if ( animate . equals ( AnimateEnum . SLOW ) ) this . options . put ( "animate" , SliderAnimate . SLOW ) ; else unsetAnimate ( ) ; return this ; } | Whether to slide handle smoothly when user click outside handle on the bar . Sets the animate using enum constants . |
36,898 | public Slider setAnimate ( Number number ) { if ( number != null && number . doubleValue ( ) > 0 ) this . options . put ( "animate" , new SliderAnimate ( number ) ) ; return this ; } | Whether to slide handle smoothly when user click outside handle on the bar . |
36,899 | public Slider setValues ( Integer value1 , Integer value2 ) { if ( value1 != null && value2 != null ) { ArrayItemOptions < IntegerItemOptions > options = new ArrayItemOptions < IntegerItemOptions > ( ) ; options . add ( new IntegerItemOptions ( value1 ) ) ; options . add ( new IntegerItemOptions ( value2 ) ) ; this . options . put ( "values" , options ) ; } return this ; } | This option can be used to specify multiple handles . If range is set to true the length of values should be 2 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.