idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
156,000
private static void buildYCCtoRGBtable ( ) { if ( ColorSpaces . DEBUG ) { System . err . println ( "Building YCC conversion table" ) ; } for ( int i = 0 , x = - CENTERJSAMPLE ; i <= MAXJSAMPLE ; i ++ , x ++ ) { // i is the actual input pixel value, in the range 0..MAXJSAMPLE // The Cb or Cr value we are thinking of is ...
Initializes tables for YCC - > RGB color space conversion .
369
13
156,001
private int getOparamCountFromRequest ( HttpServletRequest pRequest ) { // Use request.attribute for incrementing oparam counter Integer count = ( Integer ) pRequest . getAttribute ( COUNTER ) ; if ( count == null ) { count = new Integer ( 0 ) ; } else { count = new Integer ( count . intValue ( ) + 1 ) ; } // ... and s...
Gets the current oparam count for this request
106
10
156,002
private static int getFilterType ( RenderingHints pHints ) { if ( pHints == null ) { return FILTER_UNDEFINED ; } if ( pHints . containsKey ( KEY_RESAMPLE_INTERPOLATION ) ) { Object value = pHints . get ( KEY_RESAMPLE_INTERPOLATION ) ; // NOTE: Workaround for a bug in RenderingHints constructor (Bug id# 5084832) if ( ! ...
Gets the filter type specified by the given hints .
563
11
156,003
public String getColumn ( String pProperty ) { if ( mPropertiesMap == null || pProperty == null ) return null ; return ( String ) mPropertiesMap . get ( pProperty ) ; }
Gets the column for a given property .
43
9
156,004
public String getTable ( String pProperty ) { String table = getColumn ( pProperty ) ; if ( table != null ) { int dotIdx = 0 ; if ( ( dotIdx = table . lastIndexOf ( "." ) ) >= 0 ) table = table . substring ( 0 , dotIdx ) ; else return null ; } return table ; }
Gets the table name for a given property .
77
10
156,005
public String getProperty ( String pColumn ) { if ( mColumnMap == null || pColumn == null ) return null ; String property = ( String ) mColumnMap . get ( pColumn ) ; int dotIdx = 0 ; if ( property == null && ( dotIdx = pColumn . lastIndexOf ( "." ) ) >= 0 ) property = ( String ) mColumnMap . get ( pColumn . substring (...
Gets the property for a given database column . If the column incudes table qualifier the table qualifier is removed .
103
23
156,006
public synchronized Object [ ] mapObjects ( ResultSet pRSet ) throws SQLException { Vector result = new Vector ( ) ; ResultSetMetaData meta = pRSet . getMetaData ( ) ; int cols = meta . getColumnCount ( ) ; // Get colum names String [ ] colNames = new String [ cols ] ; for ( int i = 0 ; i < cols ; i ++ ) { colNames [ i...
Maps each row of the given result set to an object ot this OM s type .
469
17
156,007
String buildIdentitySQL ( String [ ] pKeys ) { mTables = new Hashtable ( ) ; mColumns = new Vector ( ) ; // Get columns to select mColumns . addElement ( getPrimaryKey ( ) ) ; // Get tables to select (and join) from and their joins tableJoins ( null , false ) ; for ( int i = 0 ; i < pKeys . length ; i ++ ) { tableJoins...
Creates a SQL query string to get the primary keys for this ObjectMapper .
147
17
156,008
public String buildSQL ( ) { mTables = new Hashtable ( ) ; mColumns = new Vector ( ) ; String key = null ; for ( Enumeration keys = mPropertiesMap . keys ( ) ; keys . hasMoreElements ( ) ; ) { key = ( String ) keys . nextElement ( ) ; // Get columns to select String column = ( String ) mPropertiesMap . get ( key ) ; mC...
Creates a SQL query string to get objects for this ObjectMapper .
143
15
156,009
private String buildSelectClause ( ) { StringBuilder sqlBuf = new StringBuilder ( ) ; sqlBuf . append ( "SELECT " ) ; String column = null ; for ( Enumeration select = mColumns . elements ( ) ; select . hasMoreElements ( ) ; ) { column = ( String ) select . nextElement ( ) ; /* String subColumn = column.substring(colum...
Builds a SQL SELECT clause from the columns Vector
213
10
156,010
private void tableJoins ( String pColumn , boolean pWhereJoin ) { String join = null ; String table = null ; if ( pColumn == null ) { // Identity join = getIdentityJoin ( ) ; table = getTable ( getProperty ( getPrimaryKey ( ) ) ) ; } else { // Normal int dotIndex = - 1 ; if ( ( dotIndex = pColumn . lastIndexOf ( "." ) ...
Finds tables used in mappings and joins and adds them to the tables Hashtable with the table name as key and the join as value .
408
29
156,011
public final void seek ( long pPosition ) throws IOException { checkOpen ( ) ; // TODO: This is correct according to javax.imageio (IndexOutOfBoundsException), // but it's inconsistent with reset that throws IOException... if ( pPosition < flushedPosition ) { throw new IndexOutOfBoundsException ( "position < flushedPos...
probably a good idea to extract a delegate .. ?
93
10
156,012
public static String getMIMEType ( final String pFileExt ) { List < String > types = sExtToMIME . get ( StringUtil . toLowerCase ( pFileExt ) ) ; return ( types == null || types . isEmpty ( ) ) ? null : types . get ( 0 ) ; }
Returns the default MIME type for the given file extension .
68
12
156,013
public static List < String > getMIMETypes ( final String pFileExt ) { List < String > types = sExtToMIME . get ( StringUtil . toLowerCase ( pFileExt ) ) ; return maskNull ( types ) ; }
Returns all MIME types for the given file extension .
55
11
156,014
private static List < String > getExtensionForWildcard ( final String pMIME ) { final String family = pMIME . substring ( 0 , pMIME . length ( ) - 1 ) ; Set < String > extensions = new LinkedHashSet < String > ( ) ; for ( Map . Entry < String , List < String > > mimeToExt : sMIMEToExt . entrySet ( ) ) { if ( "*/" . equ...
Gets all extensions for a wildcard MIME type
157
11
156,015
private static List < String > maskNull ( List < String > pTypes ) { return ( pTypes == null ) ? Collections . < String > emptyList ( ) : pTypes ; }
Returns the list or empty list if list is null
39
10
156,016
public int decode ( final InputStream stream , final ByteBuffer buffer ) throws IOException { while ( buffer . remaining ( ) >= 64 ) { int val = stream . read ( ) ; if ( val < 0 ) { break ; // EOF } if ( ( val & COMPRESSED_RUN_MASK ) == COMPRESSED_RUN_MASK ) { int count = val & ~ COMPRESSED_RUN_MASK ; int pixel = strea...
even if this will make the output larger .
165
9
156,017
private boolean buildRegexpParser ( ) { // Convert wildcard string mask to regular expression String regexp = convertWildcardExpressionToRegularExpression ( mStringMask ) ; if ( regexp == null ) { out . println ( DebugUtil . getPrefixErrorMessage ( this ) + "irregularity in regexp conversion - now not able to parse any...
Builds the regexp parser .
267
7
156,018
private boolean checkStringToBeParsed ( final String pStringToBeParsed ) { // Check for nullness if ( pStringToBeParsed == null ) { if ( mDebugging ) { out . println ( DebugUtil . getPrefixDebugMessage ( this ) + "string to be parsed is null - rejection!" ) ; } return false ; } // Check if valid character (element in a...
Simple check of the string to be parsed .
192
9
156,019
public static boolean isInAlphabet ( final char pCharToCheck ) { for ( int i = 0 ; i < ALPHABET . length ; i ++ ) { if ( pCharToCheck == ALPHABET [ i ] ) { return true ; } } return false ; }
Tests if a certain character is a valid character in the alphabet that is applying for this automaton .
61
21
156,020
public static Object mergeArrays ( Object pArray1 , Object pArray2 ) { return mergeArrays ( pArray1 , 0 , Array . getLength ( pArray1 ) , pArray2 , 0 , Array . getLength ( pArray2 ) ) ; }
Merges two arrays into a new array . Elements from array1 and array2 will be copied into a new array that has array1 . length + array2 . length elements .
57
36
156,021
@ SuppressWarnings ( { "SuspiciousSystemArraycopy" } ) public static Object mergeArrays ( Object pArray1 , int pOffset1 , int pLength1 , Object pArray2 , int pOffset2 , int pLength2 ) { Class class1 = pArray1 . getClass ( ) ; Class type = class1 . getComponentType ( ) ; // Create new array of the new length Object arra...
Merges two arrays into a new array . Elements from pArray1 and pArray2 will be copied into a new array that has pLength1 + pLength2 elements .
158
36
156,022
public static < E > void addAll ( Collection < E > pCollection , Iterator < ? extends E > pIterator ) { while ( pIterator . hasNext ( ) ) { pCollection . add ( pIterator . next ( ) ) ; } }
Adds all elements of the iterator to the collection .
53
10
156,023
< T > void registerSPIs ( final URL pResource , final Class < T > pCategory , final ClassLoader pLoader ) { Properties classNames = new Properties ( ) ; try { classNames . load ( pResource . openStream ( ) ) ; } catch ( IOException e ) { throw new ServiceConfigurationError ( e ) ; } if ( ! classNames . isEmpty ( ) ) { ...
Registers all SPIs listed in the given resource .
289
11
156,024
private < T > CategoryRegistry < T > getRegistry ( final Class < T > pCategory ) { @ SuppressWarnings ( { "unchecked" } ) CategoryRegistry < T > registry = categoryMap . get ( pCategory ) ; if ( registry == null ) { throw new IllegalArgumentException ( "No such category: " + pCategory . getName ( ) ) ; } return registr...
Gets the category registry for the given category .
89
10
156,025
public boolean register ( final Object pProvider ) { Iterator < Class < ? > > categories = compatibleCategories ( pProvider ) ; boolean registered = false ; while ( categories . hasNext ( ) ) { Class < ? > category = categories . next ( ) ; if ( registerImpl ( pProvider , category ) && ! registered ) { registered = tru...
Registers the given provider for all categories it matches .
80
11
156,026
public < T > boolean register ( final T pProvider , final Class < ? super T > pCategory ) { return registerImpl ( pProvider , pCategory ) ; }
Registers the given provider for the given category .
35
10
156,027
public boolean deregister ( final Object pProvider ) { Iterator < Class < ? > > categories = containingCategories ( pProvider ) ; boolean deregistered = false ; while ( categories . hasNext ( ) ) { Class < ? > category = categories . next ( ) ; if ( deregister ( pProvider , category ) && ! deregistered ) { deregistered...
De - registers the given provider from all categories it s currently registered in .
85
15
156,028
public static boolean isEmpty ( String [ ] pStringArray ) { // No elements to test if ( pStringArray == null ) { return true ; } // Test all the elements for ( String string : pStringArray ) { if ( ! isEmpty ( string ) ) { return false ; } } // All elements are empty return true ; }
Tests a string array to see if all items are null or an empty string .
71
17
156,029
public static boolean contains ( String pContainer , String pLookFor ) { return ( ( pContainer != null ) && ( pLookFor != null ) && ( pContainer . indexOf ( pLookFor ) >= 0 ) ) ; }
Tests if a string contains another string .
49
9
156,030
public static boolean containsIgnoreCase ( String pString , int pChar ) { return ( ( pString != null ) && ( ( pString . indexOf ( Character . toLowerCase ( ( char ) pChar ) ) >= 0 ) || ( pString . indexOf ( Character . toUpperCase ( ( char ) pChar ) ) >= 0 ) ) ) ; // NOTE: I don't convert the string to uppercase, but i...
Tests if a string contains a specific character ignoring case .
120
12
156,031
public static int indexOfIgnoreCase ( String pString , int pChar , int pPos ) { if ( ( pString == null ) ) { return - 1 ; } // Get first char char lower = Character . toLowerCase ( ( char ) pChar ) ; char upper = Character . toUpperCase ( ( char ) pChar ) ; int indexLower ; int indexUpper ; // Test for char indexLower ...
Returns the index within this string of the first occurrence of the specified character starting at the specified index .
203
20
156,032
public static int lastIndexOfIgnoreCase ( String pString , int pChar ) { return lastIndexOfIgnoreCase ( pString , pChar , pString != null ? pString . length ( ) : - 1 ) ; }
Returns the index within this string of the last occurrence of the specified character .
50
15
156,033
public static int lastIndexOfIgnoreCase ( String pString , int pChar , int pPos ) { if ( ( pString == null ) ) { return - 1 ; } // Get first char char lower = Character . toLowerCase ( ( char ) pChar ) ; char upper = Character . toUpperCase ( ( char ) pChar ) ; int indexLower ; int indexUpper ; // Test for char indexLo...
Returns the index within this string of the last occurrence of the specified character searching backward starting at the specified index .
206
22
156,034
public static String ltrim ( String pString ) { if ( ( pString == null ) || ( pString . length ( ) == 0 ) ) { return pString ; // Null or empty string } for ( int i = 0 ; i < pString . length ( ) ; i ++ ) { if ( ! Character . isWhitespace ( pString . charAt ( i ) ) ) { if ( i == 0 ) { return pString ; // First char is ...
Trims the argument string for whitespace on the left side only .
137
14
156,035
public static String replace ( String pSource , String pPattern , String pReplace ) { if ( pPattern . length ( ) == 0 ) { return pSource ; // Special case: No pattern to replace } int match ; int offset = 0 ; StringBuilder result = new StringBuilder ( ) ; // Loop string, until last occurence of pattern, and replace whi...
Replaces a substring of a string with another string . All matches are replaced .
178
17
156,036
public static String replaceIgnoreCase ( String pSource , String pPattern , String pReplace ) { if ( pPattern . length ( ) == 0 ) { return pSource ; // Special case: No pattern to replace } int match ; int offset = 0 ; StringBuilder result = new StringBuilder ( ) ; while ( ( match = indexOfIgnoreCase ( pSource , pPatte...
Replaces a substring of a string with another string ignoring case . All matches are replaced .
150
19
156,037
public static String capitalize ( String pString , int pIndex ) { if ( pIndex < 0 ) { throw new IndexOutOfBoundsException ( "Negative index not allowed: " + pIndex ) ; } if ( pString == null || pString . length ( ) <= pIndex ) { return pString ; } // This is the fastest method, according to my tests // Skip array dupli...
Makes the Nth letter of a String uppercase . If the index is outside the the length of the argument string the argument is simply returned .
260
31
156,038
public static String pad ( String pSource , int pRequiredLength , String pPadString , boolean pPrepend ) { if ( pPadString == null || pPadString . length ( ) == 0 ) { throw new IllegalArgumentException ( "Pad string: \"" + pPadString + "\"" ) ; } if ( pSource . length ( ) >= pRequiredLength ) { return pSource ; } // TO...
String length check with simple concatenation of selected pad - string . E . g . a zip number from 123 to the correct 0123 .
376
29
156,039
public static String [ ] toStringArray ( String pString , String pDelimiters ) { if ( isEmpty ( pString ) ) { return new String [ 0 ] ; } StringTokenIterator st = new StringTokenIterator ( pString , pDelimiters ) ; List < String > v = new ArrayList < String > ( ) ; while ( st . hasMoreElements ( ) ) { v . add ( st . ne...
Converts a delimiter separated String to an array of Strings .
117
14
156,040
public static int [ ] toIntArray ( String pString , String pDelimiters , int pBase ) { if ( isEmpty ( pString ) ) { return new int [ 0 ] ; } // Some room for improvement here... String [ ] temp = toStringArray ( pString , pDelimiters ) ; int [ ] array = new int [ temp . length ] ; for ( int i = 0 ; i < array . length ;...
Converts a comma - separated String to an array of ints .
123
14
156,041
public static long [ ] toLongArray ( String pString , String pDelimiters ) { if ( isEmpty ( pString ) ) { return new long [ 0 ] ; } // Some room for improvement here... String [ ] temp = toStringArray ( pString , pDelimiters ) ; long [ ] array = new long [ temp . length ] ; for ( int i = 0 ; i < array . length ; i ++ )...
Converts a comma - separated String to an array of longs .
116
14
156,042
public static double [ ] toDoubleArray ( String pString , String pDelimiters ) { if ( isEmpty ( pString ) ) { return new double [ 0 ] ; } // Some room for improvement here... String [ ] temp = toStringArray ( pString , pDelimiters ) ; double [ ] array = new double [ temp . length ] ; for ( int i = 0 ; i < array . lengt...
Converts a comma - separated String to an array of doubles .
127
13
156,043
public static String toCSVString ( Object [ ] pStringArray , String pDelimiterString ) { if ( pStringArray == null ) { return "" ; } if ( pDelimiterString == null ) { throw new IllegalArgumentException ( "delimiter == null" ) ; } StringBuilder buffer = new StringBuilder ( ) ; for ( int i = 0 ; i < pStringArray . length...
Converts a string array to a string separated by the given delimiter .
134
15
156,044
static void loadLibrary0 ( String pLibrary , String pResource , ClassLoader pLoader ) { if ( pLibrary == null ) { throw new IllegalArgumentException ( "library == null" ) ; } // Try loading normal way UnsatisfiedLinkError unsatisfied ; try { System . loadLibrary ( pLibrary ) ; return ; } catch ( UnsatisfiedLinkError er...
Loads a native library .
431
6
156,045
public Rational plus ( final Rational pOther ) { // special cases if ( equals ( ZERO ) ) { return pOther ; } if ( pOther . equals ( ZERO ) ) { return this ; } // Find gcd of numerators and denominators long f = gcd ( numerator , pOther . numerator ) ; long g = gcd ( denominator , pOther . denominator ) ; // add cross-p...
return a + b staving off overflow
155
8
156,046
public void service ( PageContext pContext ) throws ServletException , IOException { JspWriter writer = pContext . getOut ( ) ; writer . print ( value ) ; }
Services the page fragment . This version simply prints the value of this parameter to teh PageContext s out .
38
22
156,047
static void main ( String [ ] argv ) { Time time = null ; TimeFormat in = null ; TimeFormat out = null ; if ( argv . length >= 3 ) { System . out . println ( "Creating out TimeFormat: \"" + argv [ 2 ] + "\"" ) ; out = new TimeFormat ( argv [ 2 ] ) ; } if ( argv . length >= 2 ) { System . out . println ( "Creating in Ti...
Main method for testing ONLY
271
5
156,048
public String format ( Time pTime ) { StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < formatter . length ; i ++ ) { buf . append ( formatter [ i ] . format ( pTime ) ) ; } return buf . toString ( ) ; }
Formats the the given time using this format .
64
10
156,049
static long getDateHeader ( final String pHeaderValue ) { long date = - 1L ; if ( pHeaderValue != null ) { date = HTTPUtil . parseHTTPDate ( pHeaderValue ) ; } return date ; }
Utility to read a date header from a cached response .
52
12
156,050
public void service ( ServletRequest pRequest , ServletResponse pResponse ) throws IOException , ServletException { int red = 0 ; int green = 0 ; int blue = 0 ; // Get color parameter and parse color String rgb = pRequest . getParameter ( RGB_PARAME ) ; if ( rgb != null && rgb . length ( ) >= 6 && rgb . length ( ) <= 7...
Renders the 1 x 1 single color PNG to the response .
420
13
156,051
public static String getParameter ( final ServletRequest pReq , final String pName , final String pDefault ) { String str = pReq . getParameter ( pName ) ; return str != null ? str : pDefault ; }
Gets the value of the given parameter from the request or if the parameter is not set the default value .
50
22
156,052
static < T > T getParameter ( final ServletRequest pReq , final String pName , final Class < T > pType , final String pFormat , final T pDefault ) { // Test if pDefault is either null or instance of pType if ( pDefault != null && ! pType . isInstance ( pDefault ) ) { throw new IllegalArgumentException ( "default value ...
Gets the value of the given parameter from the request converted to an Object . If the parameter is not set or not parseable the default value is returned .
173
32
156,053
static String getScriptName ( final HttpServletRequest pRequest ) { String requestURI = pRequest . getRequestURI ( ) ; return StringUtil . getLastElement ( requestURI , "/" ) ; }
Gets the name of the servlet or the script that generated the servlet .
46
17
156,054
public static String getSessionId ( final HttpServletRequest pRequest ) { HttpSession session = pRequest . getSession ( ) ; return ( session != null ) ? session . getId ( ) : null ; }
Gets the unique identifier assigned to this session . The identifier is assigned by the servlet container and is implementation dependent .
47
24
156,055
protected static Object toUpper ( final Object pObject ) { if ( pObject instanceof String ) { return ( ( String ) pObject ) . toUpperCase ( ) ; } return pObject ; }
Converts the parameter to uppercase if it s a String .
44
14
156,056
private static long scanForSequence ( final ImageInputStream pStream , final byte [ ] pSequence ) throws IOException { long start = - 1l ; int index = 0 ; int nullBytes = 0 ; for ( int read ; ( read = pStream . read ( ) ) >= 0 ; ) { if ( pSequence [ index ] == ( byte ) read ) { // If this is the first byte in the seque...
Scans for a given ASCII sequence .
262
8
156,057
private static InputStream getResourceAsStream ( ClassLoader pClassLoader , String pName , boolean pGuessSuffix ) { InputStream is ; if ( ! pGuessSuffix ) { is = pClassLoader . getResourceAsStream ( pName ) ; // If XML, wrap stream if ( is != null && pName . endsWith ( XML_PROPERTIES ) ) { is = new XMLPropertiesInputSt...
Gets the named resource as a stream from the given Class Classoader . If the pGuessSuffix parameter is true the method will try to append typical properties file suffixes such as . properties or . xml .
191
46
156,058
private static InputStream getFileAsStream ( String pName , boolean pGuessSuffix ) { InputStream is = null ; File propertiesFile ; try { if ( ! pGuessSuffix ) { // Get file propertiesFile = new File ( pName ) ; if ( propertiesFile . exists ( ) ) { is = new FileInputStream ( propertiesFile ) ; // If XML, wrap stream if ...
Gets the named file as a stream from the current directory . If the pGuessSuffix parameter is true the method will try to append typical properties file suffixes such as . properties or . xml .
260
43
156,059
private static Properties loadProperties ( InputStream pInput ) throws IOException { if ( pInput == null ) { throw new IllegalArgumentException ( "InputStream == null!" ) ; } Properties mapping = new Properties ( ) ; /*if (pInput instanceof XMLPropertiesInputStream) { mapping = new XMLProperties(); } else { mapping = n...
Returns a Properties loaded from the given inputstream . If the given inputstream is null then an empty Properties object is returned .
95
25
156,060
private static char initMaxDelimiter ( char [ ] pDelimiters ) { if ( pDelimiters == null ) { return 0 ; } char max = 0 ; for ( char c : pDelimiters ) { if ( max < c ) { max = c ; } } return max ; }
Returns the highest char in the delimiter set .
68
10
156,061
private Rectangle getPICTFrame ( ) throws IOException { if ( frame == null ) { // Read in header information readPICTHeader ( imageInput ) ; if ( DEBUG ) { System . out . println ( "Done reading PICT header!" ) ; } } return frame ; }
Open and read the frame size of the PICT file .
62
12
156,062
private void readPICTHeader ( final ImageInputStream pStream ) throws IOException { pStream . seek ( 0l ) ; try { readPICTHeader0 ( pStream ) ; } catch ( IIOException e ) { // Rest and try again pStream . seek ( 0l ) ; // Skip first 512 bytes PICTImageReaderSpi . skipNullHeader ( pStream ) ; readPICTHeader0 ( pStream )...
Read the PICT header . The information read is shown on stdout if DEBUG is true .
100
19
156,063
private void readRectangle ( DataInput pStream , Rectangle pDestRect ) throws IOException { int y = pStream . readUnsignedShort ( ) ; int x = pStream . readUnsignedShort ( ) ; int h = pStream . readUnsignedShort ( ) ; int w = pStream . readUnsignedShort ( ) ; pDestRect . setLocation ( getXPtCoord ( x ) , getYPtCoord ( ...
Reads the rectangle location and size from an 8 - byte rectangle stream .
130
15
156,064
private Polygon readPoly ( DataInput pStream , Rectangle pBounds ) throws IOException { // Get polygon data size int size = pStream . readUnsignedShort ( ) ; // Get poly bounds readRectangle ( pStream , pBounds ) ; // Initialize the point array to the right size int points = ( size - 10 ) / 4 ; // Get the rest of the p...
Read in a polygon . The input stream should be positioned at the first byte of the polygon .
217
21
156,065
public void setMaxConcurrentThreadCount ( String pMaxConcurrentThreadCount ) { if ( ! StringUtil . isEmpty ( pMaxConcurrentThreadCount ) ) { try { maxConcurrentThreadCount = Integer . parseInt ( pMaxConcurrentThreadCount ) ; } catch ( NumberFormatException nfe ) { // Use default } } }
Sets the minimum free thread count .
74
8
156,066
private String getContentType ( HttpServletRequest pRequest ) { if ( responseMessageTypes != null ) { String accept = pRequest . getHeader ( "Accept" ) ; for ( String type : responseMessageTypes ) { // Note: This is not 100% correct way of doing content negotiation // But we just want a compatible result, quick, so thi...
Gets the content type for the response suitable for the requesting user agent .
111
15
156,067
private String getMessage ( String pContentType ) { String fileName = responseMessageNames . get ( pContentType ) ; // Get cached value CacheEntry entry = responseCache . get ( fileName ) ; if ( ( entry == null ) || entry . isExpired ( ) ) { // Create and add or replace cached value entry = new CacheEntry ( readMessage...
Gets the response message for the given content type .
134
11
156,068
private String readMessage ( String pFileName ) { try { // Read resource from web app InputStream is = getServletContext ( ) . getResourceAsStream ( pFileName ) ; if ( is != null ) { return new String ( FileUtil . read ( is ) ) ; } else { log ( "File not found: " + pFileName ) ; } } catch ( IOException ioe ) { log ( "E...
Reads the response message from a file in the current web app .
121
14
156,069
public void init ( ) throws ServletException { FilterConfig config = getFilterConfig ( ) ; // Default don't delete cache files on exit (persistent cache) boolean deleteCacheOnExit = "TRUE" . equalsIgnoreCase ( config . getInitParameter ( "deleteCacheOnExit" ) ) ; // Default expiry time 10 minutes int expiryTime = 10 * ...
Initializes the filter
512
4
156,070
protected Entry < K , V > removeEntry ( Entry < K , V > pEntry ) { if ( pEntry == null ) { return null ; } // Find candidate entry for this key Entry < K , V > candidate = getEntry ( pEntry . getKey ( ) ) ; if ( candidate == pEntry || ( candidate != null && candidate . equals ( pEntry ) ) ) { // Remove remove ( pEntry ...
Removes the given entry from the Map .
103
9
156,071
public void writeHtml ( JspWriter pOut , String pHtml ) throws IOException { StringTokenizer parser = new StringTokenizer ( pHtml , "<>&" , true ) ; while ( parser . hasMoreTokens ( ) ) { String token = parser . nextToken ( ) ; if ( token . equals ( "<" ) ) { pOut . print ( "&lt;" ) ; } else if ( token . equals ( ">" )...
writeHtml ensures that the text being outputted appears as it was entered . This prevents users from hacking the system by entering html or jsp code into an entry form where that value will be displayed later in the site .
147
45
156,072
public String getInitParameter ( String pName , int pScope ) { switch ( pScope ) { case PageContext . PAGE_SCOPE : return getServletConfig ( ) . getInitParameter ( pName ) ; case PageContext . APPLICATION_SCOPE : return getServletContext ( ) . getInitParameter ( pName ) ; default : throw new IllegalArgumentException ( ...
Returns the initialisation parameter from the scope specified with the name specified .
90
14
156,073
public Enumeration getInitParameterNames ( int pScope ) { switch ( pScope ) { case PageContext . PAGE_SCOPE : return getServletConfig ( ) . getInitParameterNames ( ) ; case PageContext . APPLICATION_SCOPE : return getServletContext ( ) . getInitParameterNames ( ) ; default : throw new IllegalArgumentException ( "Illega...
Returns an enumeration containing all the parameters defined in the scope specified by the parameter .
87
17
156,074
public InputStream getResourceAsStream ( String pPath ) { //throws MalformedURLException { String path = pPath ; if ( pPath != null && ! pPath . startsWith ( "/" ) ) { path = getContextPath ( ) + pPath ; } return pageContext . getServletContext ( ) . getResourceAsStream ( path ) ; }
Gets the resource associated with the given relative path for the current JSP page request . The path may be absolute or relative to the current context root .
80
31
156,075
public static boolean isCS_sRGB ( final ICC_Profile profile ) { Validate . notNull ( profile , "profile" ) ; return profile . getColorSpaceType ( ) == ColorSpace . TYPE_RGB && Arrays . equals ( getProfileHeaderWithProfileId ( profile ) , sRGB . header ) ; }
Tests whether an ICC color profile is equal to the default sRGB profile .
68
16
156,076
public Object toObject ( String pString , Class pType , String pFormat ) throws ConversionException { if ( StringUtil . isEmpty ( pString ) ) return null ; try { DateFormat format ; if ( pFormat == null ) { // Use system default format, using default locale format = DateFormat . getDateTimeInstance ( ) ; } else { // Ge...
Converts the string to a date using the given format for parsing .
226
14
156,077
private static int [ ] toRGBArray ( int pARGB , int [ ] pBuffer ) { pBuffer [ 0 ] = ( ( pARGB & 0x00ff0000 ) >> 16 ) ; pBuffer [ 1 ] = ( ( pARGB & 0x0000ff00 ) >> 8 ) ; pBuffer [ 2 ] = ( ( pARGB & 0x000000ff ) ) ; //pBuffer[3] = ((pARGB & 0xff000000) >> 24); // alpha return pBuffer ; }
Converts an int ARGB to int triplet .
110
11
156,078
protected RenderedImage doFilter ( BufferedImage pImage , ServletRequest pRequest , ImageServletResponse pResponse ) { // Get quality setting // SMOOTH | FAST | REPLICATE | DEFAULT | AREA_AVERAGING // See Image (mHints) int quality = getQuality ( pRequest . getParameter ( PARAM_SCALE_QUALITY ) ) ; // Get units, default...
Reads the image from the requested URL scales it and returns it in the Servlet stream . See above for details on parameters .
330
26
156,079
protected int getQuality ( String pQualityStr ) { if ( ! StringUtil . isEmpty ( pQualityStr ) ) { try { // Get quality constant from Image using reflection Class cl = Image . class ; Field field = cl . getField ( pQualityStr . toUpperCase ( ) ) ; return field . getInt ( null ) ; } catch ( IllegalAccessException ia ) { ...
Gets the quality constant for the scaling from the string argument .
130
13
156,080
protected int getUnits ( String pUnitStr ) { if ( StringUtil . isEmpty ( pUnitStr ) || pUnitStr . equalsIgnoreCase ( "PIXELS" ) ) { return UNITS_PIXELS ; } else if ( pUnitStr . equalsIgnoreCase ( "PERCENT" ) ) { return UNITS_PERCENT ; } else { return UNITS_UNKNOWN ; } }
Gets the units constant for the width and height arguments from the given string argument .
90
17
156,081
private int getHuffmanValue ( final int table [ ] , final int temp [ ] , final int index [ ] ) throws IOException { int code , input ; final int mask = 0xFFFF ; if ( index [ 0 ] < 8 ) { temp [ 0 ] <<= 8 ; input = this . input . readUnsignedByte ( ) ; if ( input == 0xFF ) { marker = this . input . readUnsignedByte ( ) ;...
will not be called
414
4
156,082
public void write ( final byte [ ] pBytes , final int pOffset , final int pLength ) throws IOException { if ( ! flushOnWrite && pLength < buffer . remaining ( ) ) { // Buffer data buffer . put ( pBytes , pOffset , pLength ) ; } else { // Encode data already in the buffer encodeBuffer ( ) ; // Encode rest without buffer...
tell the EncoderStream how large buffer it prefers ...
107
11
156,083
private static URL getURLAndSetAuthorization ( final String pURL , final Properties pProperties ) throws MalformedURLException { String url = pURL ; // Split user/password away from url String userPass = null ; String protocolPrefix = HTTP ; int httpIdx = url . indexOf ( HTTPS ) ; if ( httpIdx >= 0 ) { protocolPrefix =...
Registers the password from the URL string and returns the URL object .
285
14
156,084
public static HttpURLConnection createHttpURLConnection ( URL pURL , Properties pProperties , boolean pFollowRedirects , int pTimeout ) throws IOException { // Open the connection, and get the stream HttpURLConnection conn ; if ( pTimeout > 0 ) { // Supports timeout conn = new com . twelvemonkeys . net . HttpURLConnect...
Creates a HTTP connection to the given URL .
483
10
156,085
public static String encode ( byte [ ] pData ) { int offset = 0 ; int len ; StringBuilder buf = new StringBuilder ( ) ; while ( ( pData . length - offset ) > 0 ) { byte a , b , c ; if ( ( pData . length - offset ) > 2 ) { len = 3 ; } else { len = pData . length - offset ; } switch ( len ) { case 1 : a = pData [ offset ...
Encodes the input data using the standard base64 encoding scheme .
482
13
156,086
public void setSourceSubsampling ( int pXSub , int pYSub ) { // Re-fetch everything, if subsampling changed if ( xSub != pXSub || ySub != pYSub ) { dispose ( ) ; } if ( pXSub > 1 ) { xSub = pXSub ; } if ( pYSub > 1 ) { ySub = pYSub ; } }
Sets the source subsampling for the new image .
88
12
156,087
public void addProgressListener ( ProgressListener pListener ) { if ( pListener == null ) { return ; } if ( listeners == null ) { listeners = new CopyOnWriteArrayList < ProgressListener > ( ) ; } listeners . add ( pListener ) ; }
Adds a progress listener to this factory .
55
8
156,088
public void removeProgressListener ( ProgressListener pListener ) { if ( pListener == null ) { return ; } if ( listeners == null ) { return ; } listeners . remove ( pListener ) ; }
Removes a progress listener from this factory .
42
9
156,089
protected PasswordAuthentication getPasswordAuthentication ( ) { // Don't worry, this is just a hack to figure out if we were able // to set this Authenticator through the setDefault method. if ( ! sInitialized && MAGIC . equals ( getRequestingScheme ( ) ) && getRequestingPort ( ) == FOURTYTWO ) { return new PasswordAu...
Gets the PasswordAuthentication for the request . Called when password authorization is needed .
290
17
156,090
public PasswordAuthentication registerPasswordAuthentication ( URL pURL , PasswordAuthentication pPA ) { return registerPasswordAuthentication ( NetUtil . createInetAddressFromURL ( pURL ) , pURL . getPort ( ) , pURL . getProtocol ( ) , null , // Prompt/Realm BASIC , pPA ) ; }
Registers a PasswordAuthentication with a given URL address .
73
12
156,091
public PasswordAuthentication registerPasswordAuthentication ( InetAddress pAddress , int pPort , String pProtocol , String pPrompt , String pScheme , PasswordAuthentication pPA ) { /* System.err.println("registerPasswordAuthentication"); System.err.println(pAddress); System.err.println(pPort); System.err.println(pProt...
Registers a PasswordAuthentication with a given net address .
137
12
156,092
public PasswordAuthentication unregisterPasswordAuthentication ( URL pURL ) { return unregisterPasswordAuthentication ( NetUtil . createInetAddressFromURL ( pURL ) , pURL . getPort ( ) , pURL . getProtocol ( ) , null , BASIC ) ; }
Unregisters a PasswordAuthentication with a given URL address .
61
13
156,093
public PasswordAuthentication unregisterPasswordAuthentication ( InetAddress pAddress , int pPort , String pProtocol , String pPrompt , String pScheme ) { return passwordAuthentications . remove ( new AuthKey ( pAddress , pPort , pProtocol , pPrompt , pScheme ) ) ; }
Unregisters a PasswordAuthentication with a given net address .
68
13
156,094
@ InitParam ( name = "accept-mappings-file" ) public void setAcceptMappingsFile ( String pPropertiesFile ) throws ServletConfigException { // NOTE: Format is: // <agent-name>=<reg-exp> // <agent-name>.accept=<http-accept-header> Properties mappings = new Properties ( ) ; try { log ( "Reading Accept-mappings properties ...
Sets the accept - mappings for this filter
186
10
156,095
public int doEndTag ( ) throws JspException { // Trim String trimmed = truncateWS ( bodyContent . getString ( ) ) ; try { // Print trimmed content //pageContext.getOut().print("<!--TWS-->\n"); pageContext . getOut ( ) . print ( trimmed ) ; //pageContext.getOut().print("\n<!--/TWS-->"); } catch ( IOException ioe ) { thr...
doEndTag implementation truncates all whitespace .
115
10
156,096
private static String truncateWS ( String pStr ) { char [ ] chars = pStr . toCharArray ( ) ; int count = 0 ; boolean lastWasWS = true ; // Avoids leading WS for ( int i = 0 ; i < chars . length ; i ++ ) { if ( ! Character . isWhitespace ( chars [ i ] ) ) { // if char is not WS, just store chars [ count ++ ] = chars [ i...
Truncates whitespace from the given string .
199
10
156,097
private ImageServletResponse createImageServletResponse ( final ServletRequest pRequest , final ServletResponse pResponse ) { if ( pResponse instanceof ImageServletResponseImpl ) { ImageServletResponseImpl response = ( ImageServletResponseImpl ) pResponse ; // response.setRequest(pRequest); return response ; } return n...
Creates the image servlet response for this response .
92
11
156,098
protected RenderedImage doFilter ( BufferedImage pImage , ServletRequest pRequest , ImageServletResponse pResponse ) { // Get angle double ang = getAngle ( pRequest ) ; // Get bounds Rectangle2D rect = getBounds ( pRequest , pImage , ang ) ; int width = ( int ) rect . getWidth ( ) ; int height = ( int ) rect . getHeigh...
Reads the image from the requested URL rotates it and returns it in the Servlet stream . See above for details on parameters .
505
27
156,099
private double getAngle ( ServletRequest pReq ) { double angle = 0.0 ; String str = pReq . getParameter ( PARAM_ANGLE ) ; if ( ! StringUtil . isEmpty ( str ) ) { angle = Double . parseDouble ( str ) ; // Convert to radians, if needed str = pReq . getParameter ( PARAM_ANGLE_UNITS ) ; if ( ! StringUtil . isEmpty ( str ) ...
Gets the angle of rotation .
136
7