idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
156,300 | public static String getDirectoryname ( final String pPath , final char pSeparator ) { int index = pPath . lastIndexOf ( pSeparator ) ; if ( index < 0 ) { return "" ; } return pPath . substring ( 0 , index ) ; } | Extracts the directory path without the filename from a complete filename path . |
156,301 | public static String getFilename ( final String pPath , final char pSeparator ) { int index = pPath . lastIndexOf ( pSeparator ) ; if ( index < 0 ) { return pPath ; } return pPath . substring ( index + 1 ) ; } | Extracts the filename of a complete filename path . |
156,302 | public static boolean isEmpty ( File pFile ) { if ( pFile . isDirectory ( ) ) { return ( pFile . list ( ) . length == 0 ) ; } return ( pFile . length ( ) == 0 ) ; } | Tests if a file or directory has no content . A file is empty if it has a length of 0L . A non - existing file is also considered empty . A directory is considered empty if it contains no files . |
156,303 | public static String getTempDir ( ) { synchronized ( FileUtil . class ) { if ( TEMP_DIR == null ) { String tmpDir = System . getProperty ( "java.io.tmpdir" ) ; if ( StringUtil . isEmpty ( tmpDir ) ) { if ( new File ( "/temp" ) . exists ( ) ) { tmpDir = "/temp" ; } else { tmpDir = "/tmp" ; } } TEMP_DIR = tmpDir ; } } re... | Gets the default temp directory for the system . |
156,304 | public static byte [ ] read ( File pFile ) throws IOException { if ( ! pFile . exists ( ) ) { throw new FileNotFoundException ( pFile . toString ( ) ) ; } byte [ ] bytes = new byte [ ( int ) pFile . length ( ) ] ; InputStream in = null ; try { in = new BufferedInputStream ( new FileInputStream ( pFile ) , BUF_SIZE * 2 ... | Gets the contents of the given file as a byte array . |
156,305 | public static byte [ ] read ( InputStream pInput ) throws IOException { ByteArrayOutputStream bytes = new FastByteArrayOutputStream ( BUF_SIZE ) ; copy ( pInput , bytes ) ; return bytes . toByteArray ( ) ; } | Reads all data from the input stream to a byte array . |
156,306 | public static boolean write ( File pFile , byte [ ] pData ) throws IOException { boolean success = false ; OutputStream out = null ; try { out = new BufferedOutputStream ( new FileOutputStream ( pFile ) ) ; success = write ( out , pData ) ; } finally { close ( out ) ; } return success ; } | Writes the contents from a byte array to a file . |
156,307 | public static boolean delete ( final File pFile , final boolean pForce ) throws IOException { if ( pForce && pFile . isDirectory ( ) ) { return deleteDir ( pFile ) ; } return pFile . exists ( ) && pFile . delete ( ) ; } | Deletes the specified file . |
156,308 | private static boolean fixProfileXYZTag ( final ICC_Profile profile , final int tagSignature ) { byte [ ] data = profile . getData ( tagSignature ) ; if ( data != null && intFromBigEndian ( data , 0 ) == CORBIS_RGB_ALTERNATE_XYZ ) { intToBigEndian ( ICC_Profile . icSigXYZData , data , 0 ) ; profile . setData ( tagSigna... | Fixes problematic XYZ tags in Corbis RGB profile . |
156,309 | private static void buildYCCtoRGBtable ( ) { if ( ColorSpaces . DEBUG ) { System . err . println ( "Building YCC conversion table" ) ; } for ( int i = 0 , x = - CENTERJSAMPLE ; i <= MAXJSAMPLE ; i ++ , x ++ ) { Cr_R_LUT [ i ] = ( int ) ( ( 1.40200 * ( 1 << SCALEBITS ) + 0.5 ) * x + ONE_HALF ) >> SCALEBITS ; Cb_B_LUT [ ... | Initializes tables for YCC - > RGB color space conversion . |
156,310 | private int getOparamCountFromRequest ( HttpServletRequest pRequest ) { Integer count = ( Integer ) pRequest . getAttribute ( COUNTER ) ; if ( count == null ) { count = new Integer ( 0 ) ; } else { count = new Integer ( count . intValue ( ) + 1 ) ; } pRequest . setAttribute ( COUNTER , count ) ; return count . intValue... | Gets the current oparam count for this request |
156,311 | 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 ) ; if ( ! KEY_RESAMPLE_INTERPOLATION . isCompatibleValue ( value ) ) { throw new Illegal... | Gets the filter type specified by the given hints . |
156,312 | public String getColumn ( String pProperty ) { if ( mPropertiesMap == null || pProperty == null ) return null ; return ( String ) mPropertiesMap . get ( pProperty ) ; } | Gets the column for a given property . |
156,313 | 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 . |
156,314 | 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 . |
156,315 | public synchronized Object [ ] mapObjects ( ResultSet pRSet ) throws SQLException { Vector result = new Vector ( ) ; ResultSetMetaData meta = pRSet . getMetaData ( ) ; int cols = meta . getColumnCount ( ) ; String [ ] colNames = new String [ cols ] ; for ( int i = 0 ; i < cols ; i ++ ) { colNames [ i ] = meta . getColu... | Maps each row of the given result set to an object ot this OM s type . |
156,316 | String buildIdentitySQL ( String [ ] pKeys ) { mTables = new Hashtable ( ) ; mColumns = new Vector ( ) ; mColumns . addElement ( getPrimaryKey ( ) ) ; tableJoins ( null , false ) ; for ( int i = 0 ; i < pKeys . length ; i ++ ) { tableJoins ( getColumn ( pKeys [ i ] ) , true ) ; } return "SELECT " + getPrimaryKey ( ) + ... | Creates a SQL query string to get the primary keys for this ObjectMapper . |
156,317 | public String buildSQL ( ) { mTables = new Hashtable ( ) ; mColumns = new Vector ( ) ; String key = null ; for ( Enumeration keys = mPropertiesMap . keys ( ) ; keys . hasMoreElements ( ) ; ) { key = ( String ) keys . nextElement ( ) ; String column = ( String ) mPropertiesMap . get ( key ) ; mColumns . addElement ( col... | Creates a SQL query string to get objects for this ObjectMapper . |
156,318 | 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 mapType = ( String ) mMapTypes . get ... | Builds a SQL SELECT clause from the columns Vector |
156,319 | private void tableJoins ( String pColumn , boolean pWhereJoin ) { String join = null ; String table = null ; if ( pColumn == null ) { join = getIdentityJoin ( ) ; table = getTable ( getProperty ( getPrimaryKey ( ) ) ) ; } else { int dotIndex = - 1 ; if ( ( dotIndex = pColumn . lastIndexOf ( "." ) ) <= 0 ) { return ; } ... | 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 . |
156,320 | public final void seek ( long pPosition ) throws IOException { checkOpen ( ) ; if ( pPosition < flushedPosition ) { throw new IndexOutOfBoundsException ( "position < flushedPosition!" ) ; } seekImpl ( pPosition ) ; position = pPosition ; } | probably a good idea to extract a delegate .. ? |
156,321 | 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 . |
156,322 | 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 . |
156,323 | 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 |
156,324 | 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 |
156,325 | public int decode ( final InputStream stream , final ByteBuffer buffer ) throws IOException { while ( buffer . remaining ( ) >= 64 ) { int val = stream . read ( ) ; if ( val < 0 ) { break ; } if ( ( val & COMPRESSED_RUN_MASK ) == COMPRESSED_RUN_MASK ) { int count = val & ~ COMPRESSED_RUN_MASK ; int pixel = stream . rea... | even if this will make the output larger . |
156,326 | private boolean buildRegexpParser ( ) { String regexp = convertWildcardExpressionToRegularExpression ( mStringMask ) ; if ( regexp == null ) { out . println ( DebugUtil . getPrefixErrorMessage ( this ) + "irregularity in regexp conversion - now not able to parse any strings, all strings will be rejected!" ) ; return fa... | Builds the regexp parser . |
156,327 | private boolean checkStringToBeParsed ( final String pStringToBeParsed ) { if ( pStringToBeParsed == null ) { if ( mDebugging ) { out . println ( DebugUtil . getPrefixDebugMessage ( this ) + "string to be parsed is null - rejection!" ) ; } return false ; } for ( int i = 0 ; i < pStringToBeParsed . length ( ) ; i ++ ) {... | Simple check of the string to be parsed . |
156,328 | 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 . |
156,329 | @ SuppressWarnings ( { "UnusedDeclaration" , "UnusedAssignment" , "unchecked" } ) public static void main ( String [ ] pArgs ) { int howMany = 1000 ; if ( pArgs . length > 0 ) { howMany = Integer . parseInt ( pArgs [ 0 ] ) ; } long start ; long end ; String [ ] stringArr1 = new String [ ] { "zero" , "one" , "two" , "th... | Testing only . |
156,330 | 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 . |
156,331 | @ 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 ( ) ; Object array = Array . newInstance ( type , pLeng... | Merges two arrays into a new array . Elements from pArray1 and pArray2 will be copied into a new array that has pLength1 + pLength2 elements . |
156,332 | 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 . |
156,333 | < 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 . |
156,334 | 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 . |
156,335 | 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 . |
156,336 | public < T > boolean register ( final T pProvider , final Class < ? super T > pCategory ) { return registerImpl ( pProvider , pCategory ) ; } | Registers the given provider for the given category . |
156,337 | 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 . |
156,338 | public static boolean isEmpty ( String [ ] pStringArray ) { if ( pStringArray == null ) { return true ; } for ( String string : pStringArray ) { if ( ! isEmpty ( string ) ) { return false ; } } return true ; } | Tests a string array to see if all items are null or an empty string . |
156,339 | public static boolean contains ( String pContainer , String pLookFor ) { return ( ( pContainer != null ) && ( pLookFor != null ) && ( pContainer . indexOf ( pLookFor ) >= 0 ) ) ; } | Tests if a string contains another string . |
156,340 | 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 ) ) ) ; } | Tests if a string contains a specific character ignoring case . |
156,341 | public static int indexOfIgnoreCase ( String pString , int pChar , int pPos ) { if ( ( pString == null ) ) { return - 1 ; } char lower = Character . toLowerCase ( ( char ) pChar ) ; char upper = Character . toUpperCase ( ( char ) pChar ) ; int indexLower ; int indexUpper ; indexLower = pString . indexOf ( lower , pPos ... | Returns the index within this string of the first occurrence of the specified character starting at the specified index . |
156,342 | 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 . |
156,343 | public static int lastIndexOfIgnoreCase ( String pString , int pChar , int pPos ) { if ( ( pString == null ) ) { return - 1 ; } char lower = Character . toLowerCase ( ( char ) pChar ) ; char upper = Character . toUpperCase ( ( char ) pChar ) ; int indexLower ; int indexUpper ; indexLower = pString . lastIndexOf ( lower... | Returns the index within this string of the last occurrence of the specified character searching backward starting at the specified index . |
156,344 | public static String ltrim ( String pString ) { if ( ( pString == null ) || ( pString . length ( ) == 0 ) ) { return pString ; } for ( int i = 0 ; i < pString . length ( ) ; i ++ ) { if ( ! Character . isWhitespace ( pString . charAt ( i ) ) ) { if ( i == 0 ) { return pString ; } else { return pString . substring ( i )... | Trims the argument string for whitespace on the left side only . |
156,345 | public static String replace ( String pSource , String pPattern , String pReplace ) { if ( pPattern . length ( ) == 0 ) { return pSource ; } int match ; int offset = 0 ; StringBuilder result = new StringBuilder ( ) ; while ( ( match = pSource . indexOf ( pPattern , offset ) ) != - 1 ) { result . append ( pSource . subs... | Replaces a substring of a string with another string . All matches are replaced . |
156,346 | public static String replaceIgnoreCase ( String pSource , String pPattern , String pReplace ) { if ( pPattern . length ( ) == 0 ) { return pSource ; } int match ; int offset = 0 ; StringBuilder result = new StringBuilder ( ) ; while ( ( match = indexOfIgnoreCase ( pSource , pPattern , offset ) ) != - 1 ) { result . app... | Replaces a substring of a string with another string ignoring case . All matches are replaced . |
156,347 | 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 ; } if ( Character . isUpperCase ( pString . charAt ( pIndex ) ) ) { return ... | 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 . |
156,348 | 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 ; } int g... | String length check with simple concatenation of selected pad - string . E . g . a zip number from 123 to the correct 0123 . |
156,349 | 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 . |
156,350 | public static int [ ] toIntArray ( String pString , String pDelimiters , int pBase ) { if ( isEmpty ( pString ) ) { return new int [ 0 ] ; } String [ ] temp = toStringArray ( pString , pDelimiters ) ; int [ ] array = new int [ temp . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { array [ i ] = Integer . par... | Converts a comma - separated String to an array of ints . |
156,351 | public static long [ ] toLongArray ( String pString , String pDelimiters ) { if ( isEmpty ( pString ) ) { return new long [ 0 ] ; } String [ ] temp = toStringArray ( pString , pDelimiters ) ; long [ ] array = new long [ temp . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { array [ i ] = Long . parseLong ( t... | Converts a comma - separated String to an array of longs . |
156,352 | public static double [ ] toDoubleArray ( String pString , String pDelimiters ) { if ( isEmpty ( pString ) ) { return new double [ 0 ] ; } String [ ] temp = toStringArray ( pString , pDelimiters ) ; double [ ] array = new double [ temp . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { array [ i ] = Double . v... | Converts a comma - separated String to an array of doubles . |
156,353 | 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 . |
156,354 | static void loadLibrary0 ( String pLibrary , String pResource , ClassLoader pLoader ) { if ( pLibrary == null ) { throw new IllegalArgumentException ( "library == null" ) ; } UnsatisfiedLinkError unsatisfied ; try { System . loadLibrary ( pLibrary ) ; return ; } catch ( UnsatisfiedLinkError err ) { unsatisfied = err ; ... | Loads a native library . |
156,355 | public Rational plus ( final Rational pOther ) { if ( equals ( ZERO ) ) { return pOther ; } if ( pOther . equals ( ZERO ) ) { return this ; } long f = gcd ( numerator , pOther . numerator ) ; long g = gcd ( denominator , pOther . denominator ) ; return new Rational ( ( ( numerator / f ) * ( pOther . denominator / g ) +... | return a + b staving off overflow |
156,356 | 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 . |
156,357 | 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 |
156,358 | 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 . |
156,359 | void registerContent ( final String pCacheURI , final CacheRequest pRequest , final CachedResponse pCachedResponse ) throws IOException { if ( "HEAD" . equals ( pRequest . getMethod ( ) ) ) { return ; } String extension = MIMEUtil . getExtension ( pCachedResponse . getHeaderValue ( HEADER_CONTENT_TYPE ) ) ; if ( extens... | Registers content for the given URI in the cache . |
156,360 | 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 . |
156,361 | public void service ( ServletRequest pRequest , ServletResponse pResponse ) throws IOException , ServletException { int red = 0 ; int green = 0 ; int blue = 0 ; String rgb = pRequest . getParameter ( RGB_PARAME ) ; if ( rgb != null && rgb . length ( ) >= 6 && rgb . length ( ) <= 7 ) { int index = 0 ; if ( rgb . length ... | Renders the 1 x 1 single color PNG to the response . |
156,362 | 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 . |
156,363 | static < T > T getParameter ( final ServletRequest pReq , final String pName , final Class < T > pType , final String pFormat , final T pDefault ) { if ( pDefault != null && ! pType . isInstance ( pDefault ) ) { throw new IllegalArgumentException ( "default value not instance of " + pType + ": " + pDefault . getClass (... | 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 . |
156,364 | 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 . |
156,365 | 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 . |
156,366 | 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 . |
156,367 | 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 ( start == - 1 ) { start = pStream . g... | Scans for a given ASCII sequence . |
156,368 | private static InputStream getResourceAsStream ( ClassLoader pClassLoader , String pName , boolean pGuessSuffix ) { InputStream is ; if ( ! pGuessSuffix ) { is = pClassLoader . getResourceAsStream ( pName ) ; if ( is != null && pName . endsWith ( XML_PROPERTIES ) ) { is = new XMLPropertiesInputStream ( is ) ; } } else ... | 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 . |
156,369 | private static InputStream getFileAsStream ( String pName , boolean pGuessSuffix ) { InputStream is = null ; File propertiesFile ; try { if ( ! pGuessSuffix ) { propertiesFile = new File ( pName ) ; if ( propertiesFile . exists ( ) ) { is = new FileInputStream ( propertiesFile ) ; if ( pName . endsWith ( XML_PROPERTIES... | 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 . |
156,370 | private static Properties loadProperties ( InputStream pInput ) throws IOException { if ( pInput == null ) { throw new IllegalArgumentException ( "InputStream == null!" ) ; } Properties mapping = new Properties ( ) ; mapping . load ( pInput ) ; return mapping ; } | Returns a Properties loaded from the given inputstream . If the given inputstream is null then an empty Properties object is returned . |
156,371 | 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 . |
156,372 | private Rectangle getPICTFrame ( ) throws IOException { if ( frame == null ) { readPICTHeader ( imageInput ) ; if ( DEBUG ) { System . out . println ( "Done reading PICT header!" ) ; } } return frame ; } | Open and read the frame size of the PICT file . |
156,373 | private void readPICTHeader ( final ImageInputStream pStream ) throws IOException { pStream . seek ( 0l ) ; try { readPICTHeader0 ( pStream ) ; } catch ( IIOException e ) { pStream . seek ( 0l ) ; PICTImageReaderSpi . skipNullHeader ( pStream ) ; readPICTHeader0 ( pStream ) ; } } | Read the PICT header . The information read is shown on stdout if DEBUG is true . |
156,374 | 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 . |
156,375 | private Polygon readPoly ( DataInput pStream , Rectangle pBounds ) throws IOException { int size = pStream . readUnsignedShort ( ) ; readRectangle ( pStream , pBounds ) ; int points = ( size - 10 ) / 4 ; Polygon polygon = new Polygon ( ) ; for ( int i = 0 ; i < points ; i ++ ) { int y = getYPtCoord ( pStream . readShor... | Read in a polygon . The input stream should be positioned at the first byte of the polygon . |
156,376 | public void setMaxConcurrentThreadCount ( String pMaxConcurrentThreadCount ) { if ( ! StringUtil . isEmpty ( pMaxConcurrentThreadCount ) ) { try { maxConcurrentThreadCount = Integer . parseInt ( pMaxConcurrentThreadCount ) ; } catch ( NumberFormatException nfe ) { } } } | Sets the minimum free thread count . |
156,377 | private String getContentType ( HttpServletRequest pRequest ) { if ( responseMessageTypes != null ) { String accept = pRequest . getHeader ( "Accept" ) ; for ( String type : responseMessageTypes ) { if ( StringUtil . contains ( accept , type ) ) { return type ; } } } return DEFAULT_TYPE ; } | Gets the content type for the response suitable for the requesting user agent . |
156,378 | private String getMessage ( String pContentType ) { String fileName = responseMessageNames . get ( pContentType ) ; CacheEntry entry = responseCache . get ( fileName ) ; if ( ( entry == null ) || entry . isExpired ( ) ) { entry = new CacheEntry ( readMessage ( fileName ) ) ; responseCache . put ( fileName , entry ) ; }... | Gets the response message for the given content type . |
156,379 | private String readMessage ( String pFileName ) { try { InputStream is = getServletContext ( ) . getResourceAsStream ( pFileName ) ; if ( is != null ) { return new String ( FileUtil . read ( is ) ) ; } else { log ( "File not found: " + pFileName ) ; } } catch ( IOException ioe ) { log ( "Error reading file: " + pFileNa... | Reads the response message from a file in the current web app . |
156,380 | public void init ( ) throws ServletException { FilterConfig config = getFilterConfig ( ) ; boolean deleteCacheOnExit = "TRUE" . equalsIgnoreCase ( config . getInitParameter ( "deleteCacheOnExit" ) ) ; int expiryTime = 10 * 60 * 1000 ; String expiryTimeStr = config . getInitParameter ( "expiryTime" ) ; if ( ! StringUtil... | Initializes the filter |
156,381 | protected Entry < K , V > removeEntry ( Entry < K , V > pEntry ) { if ( pEntry == null ) { return null ; } Entry < K , V > candidate = getEntry ( pEntry . getKey ( ) ) ; if ( candidate == pEntry || ( candidate != null && candidate . equals ( pEntry ) ) ) { remove ( pEntry . getKey ( ) ) ; return pEntry ; } return null ... | Removes the given entry from the Map . |
156,382 | 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 ( "<" ) ; } 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 . |
156,383 | 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 . |
156,384 | 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 . |
156,385 | public InputStream getResourceAsStream ( String pPath ) { 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 . |
156,386 | 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 . |
156,387 | public Object toObject ( String pString , Class pType , String pFormat ) throws ConversionException { if ( StringUtil . isEmpty ( pString ) ) return null ; try { DateFormat format ; if ( pFormat == null ) { format = DateFormat . getDateTimeInstance ( ) ; } else { format = getDateFormat ( pFormat ) ; } Date date = Strin... | Converts the string to a date using the given format for parsing . |
156,388 | private static int [ ] toRGBArray ( int pARGB , int [ ] pBuffer ) { pBuffer [ 0 ] = ( ( pARGB & 0x00ff0000 ) >> 16 ) ; pBuffer [ 1 ] = ( ( pARGB & 0x0000ff00 ) >> 8 ) ; pBuffer [ 2 ] = ( ( pARGB & 0x000000ff ) ) ; return pBuffer ; } | Converts an int ARGB to int triplet . |
156,389 | protected RenderedImage doFilter ( BufferedImage pImage , ServletRequest pRequest , ImageServletResponse pResponse ) { int quality = getQuality ( pRequest . getParameter ( PARAM_SCALE_QUALITY ) ) ; int units = getUnits ( pRequest . getParameter ( PARAM_SCALE_UNITS ) ) ; if ( units == UNITS_UNKNOWN ) { log ( "Unknown un... | Reads the image from the requested URL scales it and returns it in the Servlet stream . See above for details on parameters . |
156,390 | protected int getQuality ( String pQualityStr ) { if ( ! StringUtil . isEmpty ( pQualityStr ) ) { try { Class cl = Image . class ; Field field = cl . getField ( pQualityStr . toUpperCase ( ) ) ; return field . getInt ( null ) ; } catch ( IllegalAccessException ia ) { log ( "Unable to get quality." , ia ) ; } catch ( No... | Gets the quality constant for the scaling from the string argument . |
156,391 | 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 . |
156,392 | 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 |
156,393 | public void write ( final byte [ ] pBytes , final int pOffset , final int pLength ) throws IOException { if ( ! flushOnWrite && pLength < buffer . remaining ( ) ) { buffer . put ( pBytes , pOffset , pLength ) ; } else { encodeBuffer ( ) ; encoder . encode ( out , ByteBuffer . wrap ( pBytes , pOffset , pLength ) ) ; } } | tell the EncoderStream how large buffer it prefers ... |
156,394 | private static URL getURLAndSetAuthorization ( final String pURL , final Properties pProperties ) throws MalformedURLException { String url = pURL ; String userPass = null ; String protocolPrefix = HTTP ; int httpIdx = url . indexOf ( HTTPS ) ; if ( httpIdx >= 0 ) { protocolPrefix = HTTPS ; url = url . substring ( http... | Registers the password from the URL string and returns the URL object . |
156,395 | public static HttpURLConnection createHttpURLConnection ( URL pURL , Properties pProperties , boolean pFollowRedirects , int pTimeout ) throws IOException { HttpURLConnection conn ; if ( pTimeout > 0 ) { conn = new com . twelvemonkeys . net . HttpURLConnection ( pURL , pTimeout ) ; } else { conn = ( HttpURLConnection )... | Creates a HTTP connection to the given URL . |
156,396 | 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 . |
156,397 | public void setSourceSubsampling ( int pXSub , int pYSub ) { if ( xSub != pXSub || ySub != pYSub ) { dispose ( ) ; } if ( pXSub > 1 ) { xSub = pXSub ; } if ( pYSub > 1 ) { ySub = pYSub ; } } | Sets the source subsampling for the new image . |
156,398 | 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 . |
156,399 | public void removeProgressListener ( ProgressListener pListener ) { if ( pListener == null ) { return ; } if ( listeners == null ) { return ; } listeners . remove ( pListener ) ; } | Removes a progress listener from this factory . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.