idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
32,500
public byte [ ] getData ( String path , Stat stat , Watcher watcher ) throws KeeperException . NoNodeException { return dataTree . getData ( path , stat , watcher ) ; }
get data and stat for a path
32,501
public void setWatches ( long relativeZxid , List < String > dataWatches , List < String > existWatches , List < String > childWatches , Watcher watcher ) { dataTree . setWatches ( relativeZxid , dataWatches , existWatches , childWatches , watcher ) ; }
set watches on the datatree
32,502
public List < ACL > getACL ( String path , Stat stat ) throws NoNodeException { return dataTree . getACL ( path , stat ) ; }
get acl for a path
32,503
public List < String > getChildren ( String path , Stat stat , Watcher watcher ) throws KeeperException . NoNodeException { return dataTree . getChildren ( path , stat , watcher ) ; }
get children list for this path
32,504
public SiteTasker take ( ) throws InterruptedException { SiteTasker task = m_tasks . poll ( ) ; if ( task == null ) { m_starvationTracker . beginStarvation ( ) ; } else { m_queueDepthTracker . pollUpdate ( task . getQueueOfferTime ( ) ) ; return task ; } try { task = CoreUtils . queueSpinTake ( m_tasks ) ; m_queueDepthTracker . pollUpdate ( task . getQueueOfferTime ( ) ) ; return task ; } finally { m_starvationTracker . endStarvation ( ) ; } }
Block on the site tasker queue .
32,505
public SiteTasker poll ( ) { SiteTasker task = m_tasks . poll ( ) ; if ( task != null ) { m_queueDepthTracker . pollUpdate ( task . getQueueOfferTime ( ) ) ; } return task ; }
Non - blocking poll on the site tasker queue .
32,506
public static BufferedWriter newWriter ( File file , Charset charset ) throws FileNotFoundException { checkNotNull ( file ) ; checkNotNull ( charset ) ; return new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( file ) , charset ) ) ; }
Returns a buffered writer that writes to a file using the given character set .
32,507
private static void write ( CharSequence from , File to , Charset charset , boolean append ) throws IOException { asCharSink ( to , charset , modes ( append ) ) . write ( from ) ; }
Private helper method . Writes a character sequence to a file optionally appending .
32,508
public static void copy ( File from , Charset charset , Appendable to ) throws IOException { asCharSource ( from , charset ) . copyTo ( to ) ; }
Copies all characters from a file to an appendable object using the given character set .
32,509
public static boolean equal ( File file1 , File file2 ) throws IOException { checkNotNull ( file1 ) ; checkNotNull ( file2 ) ; if ( file1 == file2 || file1 . equals ( file2 ) ) { return true ; } long len1 = file1 . length ( ) ; long len2 = file2 . length ( ) ; if ( len1 != 0 && len2 != 0 && len1 != len2 ) { return false ; } return asByteSource ( file1 ) . contentEquals ( asByteSource ( file2 ) ) ; }
Returns true if the files contains the same bytes .
32,510
public static List < String > readLines ( File file , Charset charset ) throws IOException { return readLines ( file , charset , new LineProcessor < List < String > > ( ) { final List < String > result = Lists . newArrayList ( ) ; public boolean processLine ( String line ) { result . add ( line ) ; return true ; } public List < String > getResult ( ) { return result ; } } ) ; }
Reads all of the lines from a file . The lines do not include line - termination characters but do include other leading and trailing whitespace .
32,511
public static < T > T readBytes ( File file , ByteProcessor < T > processor ) throws IOException { return asByteSource ( file ) . read ( processor ) ; }
Process the bytes of a file .
32,512
static Expression decomposeCondition ( Expression e , HsqlArrayList conditions ) { if ( e == null ) { return Expression . EXPR_TRUE ; } Expression arg1 = e . getLeftNode ( ) ; Expression arg2 = e . getRightNode ( ) ; int type = e . getType ( ) ; if ( type == OpTypes . AND ) { arg1 = decomposeCondition ( arg1 , conditions ) ; arg2 = decomposeCondition ( arg2 , conditions ) ; if ( arg1 == Expression . EXPR_TRUE ) { return arg2 ; } if ( arg2 == Expression . EXPR_TRUE ) { return arg1 ; } e . setLeftNode ( arg1 ) ; e . setRightNode ( arg2 ) ; return e ; } else if ( type == OpTypes . EQUAL ) { if ( arg1 . getType ( ) == OpTypes . ROW && arg2 . getType ( ) == OpTypes . ROW ) { for ( int i = 0 ; i < arg1 . nodes . length ; i ++ ) { Expression part = new ExpressionLogical ( arg1 . nodes [ i ] , arg2 . nodes [ i ] ) ; part . resolveTypes ( null , null ) ; conditions . add ( part ) ; } return Expression . EXPR_TRUE ; } } if ( e != Expression . EXPR_TRUE ) { conditions . add ( e ) ; } return Expression . EXPR_TRUE ; }
Divides AND conditions and assigns
32,513
void assignToLists ( ) { int lastOuterIndex = - 1 ; for ( int i = 0 ; i < rangeVariables . length ; i ++ ) { if ( rangeVariables [ i ] . isLeftJoin || rangeVariables [ i ] . isRightJoin ) { lastOuterIndex = i ; } if ( lastOuterIndex == i ) { joinExpressions [ i ] . addAll ( tempJoinExpressions [ i ] ) ; } else { for ( int j = 0 ; j < tempJoinExpressions [ i ] . size ( ) ; j ++ ) { assignToLists ( ( Expression ) tempJoinExpressions [ i ] . get ( j ) , joinExpressions , lastOuterIndex + 1 ) ; } } } for ( int i = 0 ; i < queryExpressions . size ( ) ; i ++ ) { assignToLists ( ( Expression ) queryExpressions . get ( i ) , whereExpressions , lastOuterIndex ) ; } }
Assigns the conditions to separate lists
32,514
void assignToLists ( Expression e , HsqlArrayList [ ] expressionLists , int first ) { set . clear ( ) ; e . collectRangeVariables ( rangeVariables , set ) ; int index = rangeVarSet . getLargestIndex ( set ) ; if ( index == - 1 ) { index = 0 ; } if ( index < first ) { index = first ; } expressionLists [ index ] . add ( e ) ; }
Assigns a single condition to the relevant list of conditions
32,515
void assignToRangeVariables ( ) { for ( int i = 0 ; i < rangeVariables . length ; i ++ ) { boolean isOuter = rangeVariables [ i ] . isLeftJoin || rangeVariables [ i ] . isRightJoin ; if ( isOuter ) { assignToRangeVariable ( rangeVariables [ i ] , i , joinExpressions [ i ] , true ) ; assignToRangeVariable ( rangeVariables [ i ] , i , whereExpressions [ i ] , false ) ; } else { joinExpressions [ i ] . addAll ( whereExpressions [ i ] ) ; assignToRangeVariable ( rangeVariables [ i ] , i , joinExpressions [ i ] , true ) ; } if ( inExpressions [ i ] != null ) { if ( ! flags [ i ] && isOuter ) { rangeVariables [ i ] . addJoinCondition ( inExpressions [ i ] ) ; } else { rangeVariables [ i ] . addWhereCondition ( inExpressions [ i ] ) ; } inExpressions [ i ] = null ; inExpressionCount -- ; } } if ( inExpressionCount != 0 ) { assert ( false ) ; setInConditionsAsTables ( ) ; } }
Assigns conditions to range variables and converts suitable IN conditions to table lookup .
32,516
void setInConditionsAsTables ( ) { for ( int i = rangeVariables . length - 1 ; i >= 0 ; i -- ) { RangeVariable rangeVar = rangeVariables [ i ] ; Expression in = inExpressions [ i ] ; if ( in != null ) { Index index = rangeVar . rangeTable . getIndexForColumn ( in . getLeftNode ( ) . nodes [ 0 ] . getColumnIndex ( ) ) ; RangeVariable newRangeVar = new RangeVariable ( in . getRightNode ( ) . subQuery . getTable ( ) , null , null , null , compileContext ) ; RangeVariable [ ] newList = new RangeVariable [ rangeVariables . length + 1 ] ; ArrayUtil . copyAdjustArray ( rangeVariables , newList , newRangeVar , i , 1 ) ; rangeVariables = newList ; ColumnSchema left = rangeVar . rangeTable . getColumn ( in . getLeftNode ( ) . nodes [ 0 ] . getColumnIndex ( ) ) ; ColumnSchema right = newRangeVar . rangeTable . getColumn ( 0 ) ; Expression e = new ExpressionLogical ( rangeVar , left , newRangeVar , right ) ; rangeVar . addIndexCondition ( e , index , flags [ i ] ) ; } } }
Converts an IN conditions into a JOIN
32,517
public static LargeBlockTask getStoreTask ( BlockId blockId , ByteBuffer block ) { return new LargeBlockTask ( ) { public LargeBlockResponse call ( ) throws Exception { Exception theException = null ; try { LargeBlockManager . getInstance ( ) . storeBlock ( blockId , block ) ; } catch ( Exception exc ) { theException = exc ; } return new LargeBlockResponse ( theException ) ; } } ; }
Get a new store task
32,518
public static LargeBlockTask getReleaseTask ( BlockId blockId ) { return new LargeBlockTask ( ) { public LargeBlockResponse call ( ) throws Exception { Exception theException = null ; try { LargeBlockManager . getInstance ( ) . releaseBlock ( blockId ) ; } catch ( Exception exc ) { theException = exc ; } return new LargeBlockResponse ( theException ) ; } } ; }
Get a new release task
32,519
public static LargeBlockTask getLoadTask ( BlockId blockId , ByteBuffer block ) { return new LargeBlockTask ( ) { public LargeBlockResponse call ( ) throws Exception { Exception theException = null ; try { LargeBlockManager . getInstance ( ) . loadBlock ( blockId , block ) ; } catch ( Exception exc ) { theException = exc ; } return new LargeBlockResponse ( theException ) ; } } ; }
Get a new load task
32,520
public static < T , U > Pair < T , U > of ( T x , U y ) { return new Pair < T , U > ( x , y ) ; }
Convenience class method for constructing pairs using Java s generic type inference .
32,521
public static Routine newRoutine ( Method method ) { Routine routine = new Routine ( SchemaObject . FUNCTION ) ; int offset = 0 ; Class [ ] params = method . getParameterTypes ( ) ; String className = method . getDeclaringClass ( ) . getName ( ) ; StringBuffer sb = new StringBuffer ( ) ; sb . append ( "CLASSPATH:" ) ; sb . append ( method . getDeclaringClass ( ) . getName ( ) ) . append ( '.' ) ; sb . append ( method . getName ( ) ) ; if ( params . length > 0 && params [ 0 ] . equals ( java . sql . Connection . class ) ) { offset = 1 ; } String name = sb . toString ( ) ; if ( className . equals ( "org.hsqldb_voltpatches.Library" ) || className . equals ( "java.lang.Math" ) ) { routine . isLibraryRoutine = true ; } for ( int j = offset ; j < params . length ; j ++ ) { Type methodParamType = Type . getDefaultTypeWithSize ( Types . getParameterSQLTypeNumber ( params [ j ] ) ) ; ColumnSchema param = new ColumnSchema ( null , methodParamType , ! params [ j ] . isPrimitive ( ) , false , null ) ; routine . addParameter ( param ) ; } routine . setLanguage ( Routine . LANGUAGE_JAVA ) ; routine . setMethod ( method ) ; routine . setMethodURL ( name ) ; routine . setDataImpact ( Routine . NO_SQL ) ; Type methodReturnType = Type . getDefaultTypeWithSize ( Types . getParameterSQLTypeNumber ( method . getReturnType ( ) ) ) ; routine . javaMethodWithConnection = offset == 1 ; ; routine . setReturnType ( methodReturnType ) ; routine . resolve ( ) ; return routine ; }
Returns a new function Routine object based solely on a Java Method object .
32,522
public ByteBuffer saveToBuffer ( InstanceId instId ) throws IOException { if ( instId == null ) { throw new IOException ( "Null instance ID." ) ; } if ( m_serData == null ) { throw new IOException ( "Uninitialized hashinator snapshot data." ) ; } ByteBuffer buf = ByteBuffer . allocate ( m_serData . length + OFFSET_DATA ) ; buf . putLong ( OFFSET_CRC , 0 ) ; buf . putInt ( OFFSET_INSTID_COORD , instId . getCoord ( ) ) ; buf . putLong ( OFFSET_INSTID_TIMESTAMP , instId . getTimestamp ( ) ) ; buf . putLong ( OFFSET_VERSION , m_version ) ; buf . position ( OFFSET_DATA ) ; buf . put ( m_serData ) ; final PureJavaCrc32 crc = new PureJavaCrc32 ( ) ; crc . update ( buf . array ( ) ) ; buf . putLong ( OFFSET_CRC , crc . getValue ( ) ) ; buf . rewind ( ) ; return buf ; }
Save to output buffer including header and config data .
32,523
public InstanceId restoreFromBuffer ( ByteBuffer buf ) throws IOException { buf . rewind ( ) ; int dataSize = buf . remaining ( ) - OFFSET_DATA ; if ( dataSize <= 0 ) { throw new IOException ( "Hashinator snapshot data is too small." ) ; } long crcHeader = buf . getLong ( OFFSET_CRC ) ; buf . putLong ( OFFSET_CRC , 0 ) ; final PureJavaCrc32 crcBuffer = new PureJavaCrc32 ( ) ; assert ( buf . hasArray ( ) ) ; crcBuffer . update ( buf . array ( ) ) ; if ( crcHeader != crcBuffer . getValue ( ) ) { throw new IOException ( "Hashinator snapshot data CRC mismatch." ) ; } int coord = buf . getInt ( OFFSET_INSTID_COORD ) ; long timestamp = buf . getLong ( OFFSET_INSTID_TIMESTAMP ) ; InstanceId instId = new InstanceId ( coord , timestamp ) ; m_version = buf . getLong ( OFFSET_VERSION ) ; m_serData = new byte [ dataSize ] ; buf . position ( OFFSET_DATA ) ; buf . get ( m_serData ) ; return instId ; }
Restore and check hashinator config data .
32,524
public void restoreFromFile ( File file ) throws IOException { byte [ ] rawData = new byte [ ( int ) file . length ( ) ] ; ByteBuffer bufData = null ; FileInputStream fis = null ; DataInputStream dis = null ; try { fis = new FileInputStream ( file ) ; dis = new DataInputStream ( fis ) ; dis . readFully ( rawData ) ; bufData = ByteBuffer . wrap ( rawData ) ; restoreFromBuffer ( bufData ) ; } finally { if ( dis != null ) { dis . close ( ) ; } if ( fis != null ) { fis . close ( ) ; } } }
Restore and check hashinator config data from a file .
32,525
public static File createFileForSchema ( String ddlText ) throws IOException { File temp = File . createTempFile ( "literalschema" , ".sql" ) ; temp . deleteOnExit ( ) ; FileWriter out = new FileWriter ( temp ) ; out . write ( ddlText ) ; out . close ( ) ; return temp ; }
Creates a temporary file for the supplied schema text . The file is not left open and will be deleted upon process exit .
32,526
public void addLiteralSchema ( String ddlText ) throws IOException { File temp = createFileForSchema ( ddlText ) ; addSchema ( URLEncoder . encode ( temp . getAbsolutePath ( ) , "UTF-8" ) ) ; }
Adds the supplied schema by creating a temp file for it .
32,527
public void addStmtProcedure ( String name , String sql , String partitionInfoString ) { addProcedures ( new ProcedureInfo ( new String [ 0 ] , name , sql , ProcedurePartitionData . fromPartitionInfoString ( partitionInfoString ) ) ) ; }
compatible with old deprecated syntax for test ONLY
32,528
public static byte [ ] hexStringToByteArray ( String s ) throws IOException { int l = s . length ( ) ; byte [ ] data = new byte [ l / 2 + ( l % 2 ) ] ; int n , b = 0 ; boolean high = true ; int i = 0 ; for ( int j = 0 ; j < l ; j ++ ) { char c = s . charAt ( j ) ; if ( c == ' ' ) { continue ; } n = getNibble ( c ) ; if ( n == - 1 ) { throw new IOException ( "hexadecimal string contains non hex character" ) ; } if ( high ) { b = ( n & 0xf ) << 4 ; high = false ; } else { b += ( n & 0xf ) ; high = true ; data [ i ++ ] = ( byte ) b ; } } if ( ! high ) { throw new IOException ( "hexadecimal string with odd number of characters" ) ; } if ( i < data . length ) { data = ( byte [ ] ) ArrayUtil . resizeArray ( data , i ) ; } return data ; }
Converts a hexadecimal string into a byte array
32,529
public static BitMap sqlBitStringToBitMap ( String s ) throws IOException { int l = s . length ( ) ; int n ; int bitIndex = 0 ; BitMap map = new BitMap ( l ) ; for ( int j = 0 ; j < l ; j ++ ) { char c = s . charAt ( j ) ; if ( c == ' ' ) { continue ; } n = getNibble ( c ) ; if ( n != 0 && n != 1 ) { throw new IOException ( "hexadecimal string contains non hex character" ) ; } if ( n == 1 ) { map . set ( bitIndex ) ; } bitIndex ++ ; } map . setSize ( bitIndex ) ; return map ; }
Compacts a bit string into a BitMap
32,530
public static String byteArrayToBitString ( byte [ ] bytes , int bitCount ) { char [ ] s = new char [ bitCount ] ; for ( int j = 0 ; j < bitCount ; j ++ ) { byte b = bytes [ j / 8 ] ; s [ j ] = BitMap . isSet ( b , j % 8 ) ? '1' : '0' ; } return new String ( s ) ; }
Converts a byte array into a bit string
32,531
public static String byteArrayToSQLBitString ( byte [ ] bytes , int bitCount ) { char [ ] s = new char [ bitCount + 3 ] ; s [ 0 ] = 'B' ; s [ 1 ] = '\'' ; int pos = 2 ; for ( int j = 0 ; j < bitCount ; j ++ ) { byte b = bytes [ j / 8 ] ; s [ pos ++ ] = BitMap . isSet ( b , j % 8 ) ? '1' : '0' ; } s [ pos ] = '\'' ; return new String ( s ) ; }
Converts a byte array into an SQL binary string
32,532
public static void writeHexBytes ( byte [ ] o , int from , byte [ ] b ) { int len = b . length ; for ( int i = 0 ; i < len ; i ++ ) { int c = ( ( int ) b [ i ] ) & 0xff ; o [ from ++ ] = HEXBYTES [ c >> 4 & 0xf ] ; o [ from ++ ] = HEXBYTES [ c & 0xf ] ; } }
Converts a byte array into hexadecimal characters which are written as ASCII to the given output stream .
32,533
public static int stringToUTFBytes ( String str , HsqlByteArrayOutputStream out ) { int strlen = str . length ( ) ; int c , count = 0 ; if ( out . count + strlen + 8 > out . buffer . length ) { out . ensureRoom ( strlen + 8 ) ; } char [ ] arr = str . toCharArray ( ) ; for ( int i = 0 ; i < strlen ; i ++ ) { c = arr [ i ] ; if ( c >= 0x0001 && c <= 0x007F ) { out . buffer [ out . count ++ ] = ( byte ) c ; count ++ ; } else if ( c > 0x07FF ) { out . buffer [ out . count ++ ] = ( byte ) ( 0xE0 | ( ( c >> 12 ) & 0x0F ) ) ; out . buffer [ out . count ++ ] = ( byte ) ( 0x80 | ( ( c >> 6 ) & 0x3F ) ) ; out . buffer [ out . count ++ ] = ( byte ) ( 0x80 | ( ( c >> 0 ) & 0x3F ) ) ; count += 3 ; } else { out . buffer [ out . count ++ ] = ( byte ) ( 0xC0 | ( ( c >> 6 ) & 0x1F ) ) ; out . buffer [ out . count ++ ] = ( byte ) ( 0x80 | ( ( c >> 0 ) & 0x3F ) ) ; count += 2 ; } if ( out . count + 8 > out . buffer . length ) { out . ensureRoom ( strlen - i + 8 ) ; } } return count ; }
Writes a string to the specified DataOutput using UTF - 8 encoding in a machine - independent manner .
32,534
public static String inputStreamToString ( InputStream x , String encoding ) throws IOException { InputStreamReader in = new InputStreamReader ( x , encoding ) ; StringWriter writer = new StringWriter ( ) ; int blocksize = 8 * 1024 ; char [ ] buffer = new char [ blocksize ] ; for ( ; ; ) { int read = in . read ( buffer ) ; if ( read == - 1 ) { break ; } writer . write ( buffer , 0 , read ) ; } writer . close ( ) ; return writer . toString ( ) ; }
Using a Reader and a Writer returns a String from an InputStream .
32,535
static int count ( final String s , final char c ) { int pos = 0 ; int count = 0 ; if ( s != null ) { while ( ( pos = s . indexOf ( c , pos ) ) > - 1 ) { count ++ ; pos ++ ; } } return count ; }
Counts Character c in String s
32,536
public static void registerLog4jMBeans ( ) throws JMException { if ( Boolean . getBoolean ( "zookeeper.jmx.log4j.disable" ) == true ) { return ; } MBeanServer mbs = ManagementFactory . getPlatformMBeanServer ( ) ; HierarchyDynamicMBean hdm = new HierarchyDynamicMBean ( ) ; ObjectName mbo = new ObjectName ( "log4j:hiearchy=default" ) ; mbs . registerMBean ( hdm , mbo ) ; Logger rootLogger = Logger . getRootLogger ( ) ; hdm . addLoggerMBean ( rootLogger . getName ( ) ) ; LoggerRepository r = LogManager . getLoggerRepository ( ) ; Enumeration enumer = r . getCurrentLoggers ( ) ; Logger logger = null ; while ( enumer . hasMoreElements ( ) ) { logger = ( Logger ) enumer . nextElement ( ) ; hdm . addLoggerMBean ( logger . getName ( ) ) ; } }
Register the log4j JMX mbeans . Set environment variable zookeeper . jmx . log4j . disable to true to disable registration .
32,537
public void create ( final String path , byte data [ ] , List < ACL > acl , CreateMode createMode , StringCallback cb , Object ctx ) { verbotenThreadCheck ( ) ; final String clientPath = path ; PathUtils . validatePath ( clientPath , createMode . isSequential ( ) ) ; final String serverPath = prependChroot ( clientPath ) ; RequestHeader h = new RequestHeader ( ) ; h . setType ( ZooDefs . OpCode . create ) ; CreateRequest request = new CreateRequest ( ) ; CreateResponse response = new CreateResponse ( ) ; ReplyHeader r = new ReplyHeader ( ) ; request . setData ( data ) ; request . setFlags ( createMode . toFlag ( ) ) ; request . setPath ( serverPath ) ; request . setAcl ( acl ) ; cnxn . queuePacket ( h , r , request , response , cb , clientPath , serverPath , ctx , null ) ; }
The Asynchronous version of create . The request doesn t actually until the asynchronous callback is called .
32,538
public void delete ( final String path , int version , VoidCallback cb , Object ctx ) { verbotenThreadCheck ( ) ; final String clientPath = path ; PathUtils . validatePath ( clientPath ) ; final String serverPath ; if ( clientPath . equals ( "/" ) ) { serverPath = clientPath ; } else { serverPath = prependChroot ( clientPath ) ; } RequestHeader h = new RequestHeader ( ) ; h . setType ( ZooDefs . OpCode . delete ) ; DeleteRequest request = new DeleteRequest ( ) ; request . setPath ( serverPath ) ; request . setVersion ( version ) ; cnxn . queuePacket ( h , new ReplyHeader ( ) , request , null , cb , clientPath , serverPath , ctx , null ) ; }
The Asynchronous version of delete . The request doesn t actually until the asynchronous callback is called .
32,539
public void setData ( final String path , byte data [ ] , int version , StatCallback cb , Object ctx ) { verbotenThreadCheck ( ) ; final String clientPath = path ; PathUtils . validatePath ( clientPath ) ; final String serverPath = prependChroot ( clientPath ) ; RequestHeader h = new RequestHeader ( ) ; h . setType ( ZooDefs . OpCode . setData ) ; SetDataRequest request = new SetDataRequest ( ) ; request . setPath ( serverPath ) ; request . setData ( data ) ; request . setVersion ( version ) ; SetDataResponse response = new SetDataResponse ( ) ; cnxn . queuePacket ( h , new ReplyHeader ( ) , request , response , cb , clientPath , serverPath , ctx , null ) ; }
The Asynchronous version of setData . The request doesn t actually until the asynchronous callback is called .
32,540
public void getACL ( final String path , Stat stat , ACLCallback cb , Object ctx ) { verbotenThreadCheck ( ) ; final String clientPath = path ; PathUtils . validatePath ( clientPath ) ; final String serverPath = prependChroot ( clientPath ) ; RequestHeader h = new RequestHeader ( ) ; h . setType ( ZooDefs . OpCode . getACL ) ; GetACLRequest request = new GetACLRequest ( ) ; request . setPath ( serverPath ) ; GetACLResponse response = new GetACLResponse ( ) ; cnxn . queuePacket ( h , new ReplyHeader ( ) , request , response , cb , clientPath , serverPath , ctx , null ) ; }
The Asynchronous version of getACL . The request doesn t actually until the asynchronous callback is called .
32,541
public void setACL ( final String path , List < ACL > acl , int version , StatCallback cb , Object ctx ) { verbotenThreadCheck ( ) ; final String clientPath = path ; PathUtils . validatePath ( clientPath ) ; final String serverPath = prependChroot ( clientPath ) ; RequestHeader h = new RequestHeader ( ) ; h . setType ( ZooDefs . OpCode . setACL ) ; SetACLRequest request = new SetACLRequest ( ) ; request . setPath ( serverPath ) ; request . setAcl ( acl ) ; request . setVersion ( version ) ; SetACLResponse response = new SetACLResponse ( ) ; cnxn . queuePacket ( h , new ReplyHeader ( ) , request , response , cb , clientPath , serverPath , ctx , null ) ; }
The Asynchronous version of setACL . The request doesn t actually until the asynchronous callback is called .
32,542
public void sync ( final String path , VoidCallback cb , Object ctx ) { verbotenThreadCheck ( ) ; final String clientPath = path ; PathUtils . validatePath ( clientPath ) ; final String serverPath = prependChroot ( clientPath ) ; RequestHeader h = new RequestHeader ( ) ; h . setType ( ZooDefs . OpCode . sync ) ; SyncRequest request = new SyncRequest ( ) ; SyncResponse response = new SyncResponse ( ) ; request . setPath ( serverPath ) ; cnxn . queuePacket ( h , new ReplyHeader ( ) , request , response , cb , clientPath , serverPath , ctx , null ) ; }
Asynchronous sync . Flushes channel between process and leader .
32,543
public final boolean callProcedureWithTimeout ( ProcedureCallback callback , int batchTimeout , String procName , Object ... parameters ) throws IOException , NoConnectionsException { return callProcedureWithClientTimeout ( callback , batchTimeout , false , procName , Distributer . USE_DEFAULT_CLIENT_TIMEOUT , TimeUnit . NANOSECONDS , parameters ) ; }
Asynchronously invoke a procedure call with timeout .
32,544
private Object [ ] getUpdateCatalogParams ( File catalogPath , File deploymentPath ) throws IOException { Object [ ] params = new Object [ 2 ] ; if ( catalogPath != null ) { params [ 0 ] = ClientUtils . fileToBytes ( catalogPath ) ; } else { params [ 0 ] = null ; } if ( deploymentPath != null ) { params [ 1 ] = new String ( ClientUtils . fileToBytes ( deploymentPath ) , Constants . UTF8ENCODING ) ; } else { params [ 1 ] = null ; } return params ; }
Serializes catalog and deployment file for UpdateApplicationCatalog . Catalog is serialized into byte array deployment file is serialized into string .
32,545
public void close ( ) throws InterruptedException { if ( m_blessedThreadIds . contains ( Thread . currentThread ( ) . getId ( ) ) ) { throw new RuntimeException ( "Can't invoke backpressureBarrier from within the client callback thread " + " without deadlocking the client library" ) ; } m_isShutdown = true ; synchronized ( m_backpressureLock ) { m_backpressureLock . notifyAll ( ) ; } if ( m_reconnectStatusListener != null ) { m_distributer . removeClientStatusListener ( m_reconnectStatusListener ) ; m_reconnectStatusListener . close ( ) ; } if ( m_ex != null ) { m_ex . shutdown ( ) ; if ( CoreUtils . isJunitTest ( ) ) { m_ex . awaitTermination ( 1 , TimeUnit . SECONDS ) ; } else { m_ex . awaitTermination ( 365 , TimeUnit . DAYS ) ; } } m_distributer . shutdown ( ) ; ClientFactory . decreaseClientNum ( ) ; }
Shutdown the client closing all network connections and release all memory resources .
32,546
public boolean backpressureBarrier ( final long start , long timeoutNanos ) throws InterruptedException { if ( m_isShutdown ) { return false ; } if ( m_blessedThreadIds . contains ( Thread . currentThread ( ) . getId ( ) ) ) { throw new RuntimeException ( "Can't invoke backpressureBarrier from within the client callback thread " + " without deadlocking the client library" ) ; } if ( m_backpressure ) { synchronized ( m_backpressureLock ) { if ( m_backpressure ) { while ( m_backpressure && ! m_isShutdown ) { if ( start != 0 ) { if ( timeoutNanos <= 0 ) { return true ; } m_backpressureLock . wait ( timeoutNanos / TimeUnit . MILLISECONDS . toNanos ( 1 ) , ( int ) ( timeoutNanos % TimeUnit . MILLISECONDS . toNanos ( 1 ) ) ) ; if ( ! m_backpressure ) { break ; } final long nowNanos = System . nanoTime ( ) ; final long deltaNanos = Math . max ( 1 , nowNanos - start ) ; if ( deltaNanos >= timeoutNanos ) { return true ; } timeoutNanos -= deltaNanos ; } else { m_backpressureLock . wait ( ) ; } } } } } return false ; }
Wait on backpressure with a timeout . Returns true on timeout false otherwise . Timeout nanos is the initial timeout quantity which will be adjusted to reflect remaining time on spurious wakeups
32,547
public Object [ ] readData ( Type [ ] colTypes ) throws IOException , HsqlException { int l = colTypes . length ; Object [ ] data = new Object [ l ] ; Object o ; Type type ; for ( int i = 0 ; i < l ; i ++ ) { if ( checkNull ( ) ) { continue ; } o = null ; type = colTypes [ i ] ; switch ( type . typeCode ) { case Types . SQL_ALL_TYPES : case Types . SQL_CHAR : case Types . SQL_VARCHAR : case Types . VARCHAR_IGNORECASE : o = readChar ( type ) ; break ; case Types . TINYINT : case Types . SQL_SMALLINT : o = readSmallint ( ) ; break ; case Types . SQL_INTEGER : o = readInteger ( ) ; break ; case Types . SQL_BIGINT : o = readBigint ( ) ; break ; case Types . SQL_REAL : case Types . SQL_FLOAT : case Types . SQL_DOUBLE : o = readReal ( ) ; break ; case Types . SQL_NUMERIC : case Types . SQL_DECIMAL : o = readDecimal ( type ) ; break ; case Types . SQL_DATE : o = readDate ( type ) ; break ; case Types . SQL_TIME : case Types . SQL_TIME_WITH_TIME_ZONE : o = readTime ( type ) ; break ; case Types . SQL_TIMESTAMP : case Types . SQL_TIMESTAMP_WITH_TIME_ZONE : o = readTimestamp ( type ) ; break ; case Types . SQL_INTERVAL_YEAR : case Types . SQL_INTERVAL_YEAR_TO_MONTH : case Types . SQL_INTERVAL_MONTH : o = readYearMonthInterval ( type ) ; break ; case Types . SQL_INTERVAL_DAY : case Types . SQL_INTERVAL_DAY_TO_HOUR : case Types . SQL_INTERVAL_DAY_TO_MINUTE : case Types . SQL_INTERVAL_DAY_TO_SECOND : case Types . SQL_INTERVAL_HOUR : case Types . SQL_INTERVAL_HOUR_TO_MINUTE : case Types . SQL_INTERVAL_HOUR_TO_SECOND : case Types . SQL_INTERVAL_MINUTE : case Types . SQL_INTERVAL_MINUTE_TO_SECOND : case Types . SQL_INTERVAL_SECOND : o = readDaySecondInterval ( type ) ; break ; case Types . SQL_BOOLEAN : o = readBoole ( ) ; break ; case Types . OTHER : o = readOther ( ) ; break ; case Types . SQL_CLOB : o = readClob ( ) ; break ; case Types . SQL_BLOB : o = readBlob ( ) ; break ; case Types . SQL_BINARY : case Types . SQL_VARBINARY : o = readBinary ( ) ; break ; case Types . SQL_BIT : case Types . SQL_BIT_VARYING : o = readBit ( ) ; break ; default : throw Error . runtimeError ( ErrorCode . U_S0500 , "RowInputBase " + type . getNameString ( ) ) ; } data [ i ] = o ; } return data ; }
reads row data from a stream using the JDBC types in colTypes
32,548
public static int matchGenreDescription ( String description ) { if ( description != null && description . length ( ) > 0 ) { for ( int i = 0 ; i < ID3v1Genres . GENRES . length ; i ++ ) { if ( ID3v1Genres . GENRES [ i ] . equalsIgnoreCase ( description ) ) { return i ; } } } return - 1 ; }
Match provided description against genres ignoring case .
32,549
private int measureSize ( int specType , int contentSize , int measureSpec ) { int result ; int specMode = MeasureSpec . getMode ( measureSpec ) ; int specSize = MeasureSpec . getSize ( measureSpec ) ; if ( specMode == MeasureSpec . EXACTLY ) { result = Math . max ( contentSize , specSize ) ; } else { result = contentSize ; if ( specType == 1 ) { result += ( getPaddingLeft ( ) + getPaddingRight ( ) ) ; } else { result += ( getPaddingTop ( ) + getPaddingBottom ( ) ) ; } } return result ; }
measure view Size
32,550
private void initSuffixMargin ( ) { int defSuffixLRMargin = Utils . dp2px ( mContext , DEFAULT_SUFFIX_LR_MARGIN ) ; boolean isSuffixLRMarginNull = true ; if ( mSuffixLRMargin >= 0 ) { isSuffixLRMarginNull = false ; } if ( isShowDay && mSuffixDayTextWidth > 0 ) { if ( mSuffixDayLeftMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixDayLeftMargin = mSuffixLRMargin ; } else { mSuffixDayLeftMargin = defSuffixLRMargin ; } } if ( mSuffixDayRightMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixDayRightMargin = mSuffixLRMargin ; } else { mSuffixDayRightMargin = defSuffixLRMargin ; } } } else { mSuffixDayLeftMargin = 0 ; mSuffixDayRightMargin = 0 ; } if ( isShowHour && mSuffixHourTextWidth > 0 ) { if ( mSuffixHourLeftMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixHourLeftMargin = mSuffixLRMargin ; } else { mSuffixHourLeftMargin = defSuffixLRMargin ; } } if ( mSuffixHourRightMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixHourRightMargin = mSuffixLRMargin ; } else { mSuffixHourRightMargin = defSuffixLRMargin ; } } } else { mSuffixHourLeftMargin = 0 ; mSuffixHourRightMargin = 0 ; } if ( isShowMinute && mSuffixMinuteTextWidth > 0 ) { if ( mSuffixMinuteLeftMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixMinuteLeftMargin = mSuffixLRMargin ; } else { mSuffixMinuteLeftMargin = defSuffixLRMargin ; } } if ( isShowSecond ) { if ( mSuffixMinuteRightMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixMinuteRightMargin = mSuffixLRMargin ; } else { mSuffixMinuteRightMargin = defSuffixLRMargin ; } } } else { mSuffixMinuteRightMargin = 0 ; } } else { mSuffixMinuteLeftMargin = 0 ; mSuffixMinuteRightMargin = 0 ; } if ( isShowSecond ) { if ( mSuffixSecondTextWidth > 0 ) { if ( mSuffixSecondLeftMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixSecondLeftMargin = mSuffixLRMargin ; } else { mSuffixSecondLeftMargin = defSuffixLRMargin ; } } if ( isShowMillisecond ) { if ( mSuffixSecondRightMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixSecondRightMargin = mSuffixLRMargin ; } else { mSuffixSecondRightMargin = defSuffixLRMargin ; } } } else { mSuffixSecondRightMargin = 0 ; } } else { mSuffixSecondLeftMargin = 0 ; mSuffixSecondRightMargin = 0 ; } if ( isShowMillisecond && mSuffixMillisecondTextWidth > 0 ) { if ( mSuffixMillisecondLeftMargin < 0 ) { if ( ! isSuffixLRMarginNull ) { mSuffixMillisecondLeftMargin = mSuffixLRMargin ; } else { mSuffixMillisecondLeftMargin = defSuffixLRMargin ; } } } else { mSuffixMillisecondLeftMargin = 0 ; } } else { mSuffixSecondLeftMargin = 0 ; mSuffixSecondRightMargin = 0 ; mSuffixMillisecondLeftMargin = 0 ; } }
initialize suffix margin
32,551
public int getAllContentWidth ( ) { float width = getAllContentWidthBase ( mTimeTextWidth ) ; if ( ! isConvertDaysToHours && isShowDay ) { if ( isDayLargeNinetyNine ) { Rect rect = new Rect ( ) ; String tempDay = String . valueOf ( mDay ) ; mTimeTextPaint . getTextBounds ( tempDay , 0 , tempDay . length ( ) , rect ) ; mDayTimeTextWidth = rect . width ( ) ; width += mDayTimeTextWidth ; } else { mDayTimeTextWidth = mTimeTextWidth ; width += mTimeTextWidth ; } } return ( int ) Math . ceil ( width ) ; }
get all view width
32,552
private float initTimeTextBaselineAndTimeBgTopPadding ( int viewHeight , int viewPaddingTop , int viewPaddingBottom , int contentAllHeight ) { float topPaddingSize ; if ( viewPaddingTop == viewPaddingBottom ) { topPaddingSize = ( viewHeight - contentAllHeight ) / 2 ; } else { topPaddingSize = viewPaddingTop ; } if ( isShowDay && mSuffixDayTextWidth > 0 ) { mSuffixDayTextBaseline = getSuffixTextBaseLine ( mSuffixDay , topPaddingSize ) ; } if ( isShowHour && mSuffixHourTextWidth > 0 ) { mSuffixHourTextBaseline = getSuffixTextBaseLine ( mSuffixHour , topPaddingSize ) ; } if ( isShowMinute && mSuffixMinuteTextWidth > 0 ) { mSuffixMinuteTextBaseline = getSuffixTextBaseLine ( mSuffixMinute , topPaddingSize ) ; } if ( mSuffixSecondTextWidth > 0 ) { mSuffixSecondTextBaseline = getSuffixTextBaseLine ( mSuffixSecond , topPaddingSize ) ; } if ( isShowMillisecond && mSuffixMillisecondTextWidth > 0 ) { mSuffixMillisecondTextBaseline = getSuffixTextBaseLine ( mSuffixMillisecond , topPaddingSize ) ; } return topPaddingSize ; }
initialize time text baseline and time background top padding
32,553
public int filterRGB ( int pX , int pY , int pARGB ) { int r = pARGB >> 16 & 0xFF ; int g = pARGB >> 8 & 0xFF ; int b = pARGB & 0xFF ; r = LUT [ r ] ; g = LUT [ g ] ; b = LUT [ b ] ; return ( pARGB & 0xFF000000 ) | ( r << 16 ) | ( g << 8 ) | b ; }
Filters one pixel adjusting brightness and contrast according to this filter .
32,554
protected static String buildTimestamp ( final Calendar pCalendar ) { if ( pCalendar == null ) { return CALENDAR_IS_NULL_ERROR_MESSAGE ; } StringBuilder timestamp = new StringBuilder ( ) ; timestamp . append ( DateFormat . getDateInstance ( DateFormat . MEDIUM ) . format ( pCalendar . getTime ( ) ) ) ; timestamp . append ( " " ) ; timestamp . append ( StringUtil . pad ( new Integer ( pCalendar . get ( Calendar . HOUR_OF_DAY ) ) . toString ( ) , 2 , "0" , true ) + ":" ) ; timestamp . append ( StringUtil . pad ( new Integer ( pCalendar . get ( Calendar . MINUTE ) ) . toString ( ) , 2 , "0" , true ) + ":" ) ; timestamp . append ( StringUtil . pad ( new Integer ( pCalendar . get ( Calendar . SECOND ) ) . toString ( ) , 2 , "0" , true ) + ":" ) ; timestamp . append ( StringUtil . pad ( new Integer ( pCalendar . get ( Calendar . MILLISECOND ) ) . toString ( ) , 3 , "0" , true ) ) ; return timestamp . toString ( ) ; }
Builds a presentation of the given calendar s time . This method contains the common timestamp format used in this class .
32,555
public static long roundToHour ( final long pTime , final TimeZone pTimeZone ) { int offset = pTimeZone . getOffset ( pTime ) ; return ( ( pTime / HOUR ) * HOUR ) - offset ; }
Rounds the given time down to the closest hour using the given timezone .
32,556
public static long roundToDay ( final long pTime , final TimeZone pTimeZone ) { int offset = pTimeZone . getOffset ( pTime ) ; return ( ( ( pTime + offset ) / DAY ) * DAY ) - offset ; }
Rounds the given time down to the closest day using the given timezone .
32,557
private PropertyConverter getConverterForType ( Class pType ) { Object converter ; Class cl = pType ; do { if ( ( converter = getInstance ( ) . converters . get ( cl ) ) != null ) { return ( PropertyConverter ) converter ; } } while ( ( cl = cl . getSuperclass ( ) ) != null ) ; return null ; }
Gets the registered converter for the given type .
32,558
public Object toObject ( String pString , Class pType , String pFormat ) throws ConversionException { if ( pString == null ) { return null ; } if ( pType == null ) { throw new MissingTypeException ( ) ; } PropertyConverter converter = getConverterForType ( pType ) ; if ( converter == null ) { throw new NoAvailableConverterException ( "Cannot convert to object, no converter available for type \"" + pType . getName ( ) + "\"" ) ; } return converter . toObject ( pString , pType , pFormat ) ; }
Converts the string to an object of the given type parsing after the given format .
32,559
public static void merge ( List < File > inputFiles , File outputFile ) throws IOException { ImageOutputStream output = null ; try { output = ImageIO . createImageOutputStream ( outputFile ) ; for ( File file : inputFiles ) { ImageInputStream input = null ; try { input = ImageIO . createImageInputStream ( file ) ; List < TIFFPage > pages = getPages ( input ) ; writePages ( output , pages ) ; } finally { if ( input != null ) { input . close ( ) ; } } } } finally { if ( output != null ) { output . flush ( ) ; output . close ( ) ; } } }
Merges all pages from the input TIFF files into one TIFF file at the output location .
32,560
public static List < File > split ( File inputFile , File outputDirectory ) throws IOException { ImageInputStream input = null ; List < File > outputFiles = new ArrayList < > ( ) ; try { input = ImageIO . createImageInputStream ( inputFile ) ; List < TIFFPage > pages = getPages ( input ) ; int pageNo = 1 ; for ( TIFFPage tiffPage : pages ) { ArrayList < TIFFPage > outputPages = new ArrayList < TIFFPage > ( 1 ) ; ImageOutputStream outputStream = null ; try { File outputFile = new File ( outputDirectory , String . format ( "%04d" , pageNo ) + ".tif" ) ; outputStream = ImageIO . createImageOutputStream ( outputFile ) ; outputPages . clear ( ) ; outputPages . add ( tiffPage ) ; writePages ( outputStream , outputPages ) ; outputFiles . add ( outputFile ) ; } finally { if ( outputStream != null ) { outputStream . flush ( ) ; outputStream . close ( ) ; } } ++ pageNo ; } } finally { if ( input != null ) { input . close ( ) ; } } return outputFiles ; }
Splits all pages from the input TIFF file to one file per page in the output directory .
32,561
public static String getStats ( ) { long total = sCacheHit + sCacheMiss + sCacheUn ; double hit = ( ( double ) sCacheHit / ( double ) total ) * 100.0 ; double miss = ( ( double ) sCacheMiss / ( double ) total ) * 100.0 ; double un = ( ( double ) sCacheUn / ( double ) total ) * 100.0 ; java . text . NumberFormat nf = java . text . NumberFormat . getInstance ( ) ; return "Total: " + total + " reads. " + "Cache hits: " + sCacheHit + " (" + nf . format ( hit ) + "%), " + "Cache misses: " + sCacheMiss + " (" + nf . format ( miss ) + "%), " + "Unattempted: " + sCacheUn + " (" + nf . format ( un ) + "%) " ; }
Gets a string containing the stats for this ObjectReader .
32,562
private Object [ ] readIdentities ( Class pObjClass , Hashtable pMapping , Hashtable pWhere , ObjectMapper pOM ) throws SQLException { sCacheUn ++ ; if ( pWhere == null ) pWhere = new Hashtable ( ) ; String [ ] keys = new String [ pWhere . size ( ) ] ; int i = 0 ; for ( Enumeration en = pWhere . keys ( ) ; en . hasMoreElements ( ) ; i ++ ) { keys [ i ] = ( String ) en . nextElement ( ) ; } String sql = pOM . buildIdentitySQL ( keys ) + buildWhereClause ( keys , pMapping ) ; mLog . logDebug ( sql + " (" + pWhere + ")" ) ; PreparedStatement statement = mConnection . prepareStatement ( sql ) ; for ( int j = 0 ; j < keys . length ; j ++ ) { Object key = pWhere . get ( keys [ j ] ) ; if ( key instanceof Integer ) statement . setInt ( j + 1 , ( ( Integer ) key ) . intValue ( ) ) ; else if ( key instanceof BigDecimal ) statement . setBigDecimal ( j + 1 , ( BigDecimal ) key ) ; else statement . setString ( j + 1 , key . toString ( ) ) ; } ResultSet rs = null ; try { rs = statement . executeQuery ( ) ; } catch ( SQLException e ) { mLog . logError ( sql + " (" + pWhere + ")" , e ) ; throw e ; } Vector result = new Vector ( ) ; while ( rs . next ( ) ) { Object obj = null ; try { obj = pObjClass . newInstance ( ) ; } catch ( IllegalAccessException iae ) { iae . printStackTrace ( ) ; } catch ( InstantiationException ie ) { ie . printStackTrace ( ) ; } pOM . mapColumnProperty ( rs , 1 , pOM . getProperty ( pOM . getPrimaryKey ( ) ) , obj ) ; result . addElement ( obj ) ; } return result . toArray ( ( Object [ ] ) Array . newInstance ( pObjClass , result . size ( ) ) ) ; }
Get an array containing Objects of type objClass with the identity values for the given class set .
32,563
public Object readObject ( DatabaseReadable pReadable ) throws SQLException { return readObject ( pReadable . getId ( ) , pReadable . getClass ( ) , pReadable . getMapping ( ) ) ; }
Reads one object implementing the DatabaseReadable interface from the database .
32,564
public Object readObject ( Object pId , Class pObjClass , Hashtable pMapping ) throws SQLException { return readObject ( pId , pObjClass , pMapping , null ) ; }
Reads the object with the given id from the database using the given mapping .
32,565
public Object [ ] readObjects ( DatabaseReadable pReadable ) throws SQLException { return readObjects ( pReadable . getClass ( ) , pReadable . getMapping ( ) , null ) ; }
Reads all the objects of the given type from the database . The object must implement the DatabaseReadable interface .
32,566
private void setPropertyValue ( Object pObj , String pProperty , Object pValue ) { Method m = null ; Class [ ] cl = { pValue . getClass ( ) } ; try { m = pObj . getClass ( ) . getMethod ( "set" + StringUtil . capitalize ( pProperty ) , cl ) ; Object [ ] args = { pValue } ; m . invoke ( pObj , args ) ; } catch ( NoSuchMethodException e ) { e . printStackTrace ( ) ; } catch ( IllegalAccessException iae ) { iae . printStackTrace ( ) ; } catch ( InvocationTargetException ite ) { ite . printStackTrace ( ) ; } }
Sets the property value to an object using reflection
32,567
private Object getPropertyValue ( Object pObj , String pProperty ) { Method m = null ; Class [ ] cl = new Class [ 0 ] ; try { m = pObj . getClass ( ) . getMethod ( "get" + StringUtil . capitalize ( pProperty ) , new Class [ 0 ] ) ; Object result = m . invoke ( pObj , new Object [ 0 ] ) ; return result ; } catch ( NoSuchMethodException e ) { e . printStackTrace ( ) ; } catch ( IllegalAccessException iae ) { iae . printStackTrace ( ) ; } catch ( InvocationTargetException ite ) { ite . printStackTrace ( ) ; } return null ; }
Gets the property value from an object using reflection
32,568
private void setChildObjects ( Object pParent , ObjectMapper pOM ) throws SQLException { if ( pOM == null ) { throw new NullPointerException ( "ObjectMapper in readChildObjects " + "cannot be null!!" ) ; } for ( Enumeration keys = pOM . mMapTypes . keys ( ) ; keys . hasMoreElements ( ) ; ) { String property = ( String ) keys . nextElement ( ) ; String mapType = ( String ) pOM . mMapTypes . get ( property ) ; if ( property . length ( ) <= 0 || mapType == null ) { continue ; } Object id = getPropertyValue ( pParent , pOM . getProperty ( pOM . getPrimaryKey ( ) ) ) ; if ( mapType . equals ( ObjectMapper . OBJECTMAP ) ) { Class objectClass = ( Class ) pOM . mClasses . get ( property ) ; DatabaseReadable dbr = null ; try { dbr = ( DatabaseReadable ) objectClass . newInstance ( ) ; } catch ( Exception e ) { mLog . logError ( e ) ; } if ( pOM . mJoins . containsKey ( property ) ) dbr . getMapping ( ) . put ( ".join" , pOM . mJoins . get ( property ) ) ; Hashtable where = new Hashtable ( ) ; String foreignKey = ( String ) dbr . getMapping ( ) . get ( ".foreignKey" ) ; if ( foreignKey != null ) { where . put ( ".foreignKey" , id ) ; } Object [ ] child = readObjects ( dbr , where ) ; if ( child . length < 1 ) throw new SQLException ( "No child object with foreign key " + foreignKey + "=" + id ) ; else if ( child . length != 1 ) throw new SQLException ( "More than one object with foreign " + "key " + foreignKey + "=" + id ) ; setPropertyValue ( pParent , property , child [ 0 ] ) ; } else if ( mapType . equals ( ObjectMapper . COLLECTIONMAP ) ) { Hashtable mapping = pOM . getPropertyMapping ( property ) ; Hashtable where = new Hashtable ( ) ; String foreignKey = ( String ) mapping . get ( ".foreignKey" ) ; if ( foreignKey != null ) { where . put ( ".foreignKey" , id ) ; } DBObject dbr = new DBObject ( ) ; dbr . mapping = mapping ; Object [ ] objs = readObjects ( dbr , where ) ; Hashtable children = new Hashtable ( ) ; for ( int i = 0 ; i < objs . length ; i ++ ) { children . put ( ( ( DBObject ) objs [ i ] ) . getId ( ) , ( ( DBObject ) objs [ i ] ) . getObject ( ) ) ; } setPropertyValue ( pParent , property , children ) ; } } }
Reads and sets the child properties of the given parent object .
32,569
private String buildWhereClause ( String [ ] pKeys , Hashtable pMapping ) { StringBuilder sqlBuf = new StringBuilder ( ) ; for ( int i = 0 ; i < pKeys . length ; i ++ ) { String column = ( String ) pMapping . get ( pKeys [ i ] ) ; sqlBuf . append ( " AND " ) ; sqlBuf . append ( column ) ; sqlBuf . append ( " = ?" ) ; } return sqlBuf . toString ( ) ; }
Builds extra SQL WHERE clause
32,570
public static Properties loadMapping ( Class pClass ) { try { return SystemUtil . loadProperties ( pClass ) ; } catch ( FileNotFoundException fnf ) { System . err . println ( "ERROR: " + fnf . getMessage ( ) ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } return new Properties ( ) ; }
Utility method for reading a property mapping from a properties - file
32,571
protected Class getType ( String pType ) { Class cl = ( Class ) mTypes . get ( pType ) ; if ( cl == null ) { } return cl ; }
Gets the class for a type
32,572
protected Object getObject ( String pType ) { Class cl = getType ( pType ) ; try { return cl . newInstance ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } }
Gets a java object of the class for a given type .
32,573
protected void checkBounds ( int index ) throws IOException { assertInput ( ) ; if ( index < getMinIndex ( ) ) { throw new IndexOutOfBoundsException ( "index < minIndex" ) ; } int numImages = getNumImages ( false ) ; if ( numImages != - 1 && index >= numImages ) { throw new IndexOutOfBoundsException ( "index >= numImages (" + index + " >= " + numImages + ")" ) ; } }
Convenience method to make sure image index is within bounds .
32,574
protected static boolean hasExplicitDestination ( final ImageReadParam pParam ) { return pParam != null && ( pParam . getDestination ( ) != null || pParam . getDestinationType ( ) != null || ! ORIGIN . equals ( pParam . getDestinationOffset ( ) ) ) ; }
Tests if param has explicit destination .
32,575
public BufferedImage getImage ( ) throws IOException { if ( image == null ) { if ( bufferedOut == null ) { return null ; } InputStream byteStream = bufferedOut . createInputStream ( ) ; ImageInputStream input = null ; try { input = ImageIO . createImageInputStream ( byteStream ) ; Iterator readers = ImageIO . getImageReaders ( input ) ; if ( readers . hasNext ( ) ) { ImageReader reader = ( ImageReader ) readers . next ( ) ; try { reader . setInput ( input ) ; ImageReadParam param = reader . getDefaultReadParam ( ) ; int originalWidth = reader . getWidth ( 0 ) ; int originalHeight = reader . getHeight ( 0 ) ; Rectangle aoi = extractAOIFromRequest ( originalWidth , originalHeight , originalRequest ) ; if ( aoi != null ) { param . setSourceRegion ( aoi ) ; originalWidth = aoi . width ; originalHeight = aoi . height ; } Dimension size = extractSizeFromRequest ( originalWidth , originalHeight , originalRequest ) ; double readSubSamplingFactor = getReadSubsampleFactorFromRequest ( originalRequest ) ; if ( size != null ) { if ( param . canSetSourceRenderSize ( ) ) { param . setSourceRenderSize ( size ) ; } else { int subX = ( int ) Math . max ( originalWidth / ( size . width * readSubSamplingFactor ) , 1.0 ) ; int subY = ( int ) Math . max ( originalHeight / ( size . height * readSubSamplingFactor ) , 1.0 ) ; if ( subX > 1 || subY > 1 ) { param . setSourceSubsampling ( subX , subY , subX > 1 ? subX / 2 : 0 , subY > 1 ? subY / 2 : 0 ) ; } } } maybeSetBaseURIFromRequest ( param ) ; BufferedImage image = reader . read ( 0 , param ) ; image = resampleImage ( image , size ) ; extractAndSetBackgroundColor ( image ) ; this . image = image ; } finally { reader . dispose ( ) ; } } else { context . log ( "ERROR: No suitable image reader found (content-type: " + originalContentType + ")." ) ; context . log ( "ERROR: Available formats: " + getFormatsString ( ) ) ; throw new IIOException ( "Unable to transcode image: No suitable image reader found (content-type: " + originalContentType + ")." ) ; } bufferedOut = null ; } finally { if ( input != null ) { input . close ( ) ; } } } return image != null ? ImageUtil . toBuffered ( image ) : null ; }
Gets the decoded image from the response .
32,576
private static QTDecompressor getDecompressor ( final ImageDesc pDescription ) { for ( QTDecompressor decompressor : sDecompressors ) { if ( decompressor . canDecompress ( pDescription ) ) { return decompressor ; } } return null ; }
Gets a decompressor that can decompress the described data .
32,577
public static BufferedImage decompress ( final ImageInputStream pStream ) throws IOException { ImageDesc description = ImageDesc . read ( pStream ) ; if ( PICTImageReader . DEBUG ) { System . out . println ( description ) ; } QTDecompressor decompressor = getDecompressor ( description ) ; if ( decompressor == null ) { return null ; } InputStream streamAdapter = IIOUtil . createStreamAdapter ( pStream , description . dataSize ) ; try { return decompressor . decompress ( description , streamAdapter ) ; } finally { streamAdapter . close ( ) ; } }
Decompresses the QuickTime image data from the given stream .
32,578
protected boolean trigger ( ServletRequest pRequest ) { boolean trigger = false ; if ( pRequest instanceof HttpServletRequest ) { HttpServletRequest request = ( HttpServletRequest ) pRequest ; String accept = getAcceptedFormats ( request ) ; String originalFormat = getServletContext ( ) . getMimeType ( request . getRequestURI ( ) ) ; if ( ! StringUtil . contains ( accept , originalFormat ) ) { trigger = true ; } } return trigger || super . trigger ( pRequest ) ; }
Makes sure the filter triggers for unknown file formats .
32,579
private static String findBestFormat ( Map < String , Float > pFormatQuality ) { String acceptable = null ; float acceptQuality = 0.0f ; for ( Map . Entry < String , Float > entry : pFormatQuality . entrySet ( ) ) { float qValue = entry . getValue ( ) ; if ( qValue > acceptQuality ) { acceptQuality = qValue ; acceptable = entry . getKey ( ) ; } } return acceptable ; }
Finds the best available format .
32,580
private void adjustQualityFromAccept ( Map < String , Float > pFormatQuality , HttpServletRequest pRequest ) { String accept = getAcceptedFormats ( pRequest ) ; float anyImageFactor = getQualityFactor ( accept , MIME_TYPE_IMAGE_ANY ) ; anyImageFactor = ( anyImageFactor == 1 ) ? 0.02f : anyImageFactor ; float anyFactor = getQualityFactor ( accept , MIME_TYPE_ANY ) ; anyFactor = ( anyFactor == 1 ) ? 0.01f : anyFactor ; for ( String format : pFormatQuality . keySet ( ) ) { String formatMIME = MIME_TYPE_IMAGE_PREFIX + format ; float qFactor = getQualityFactor ( accept , formatMIME ) ; qFactor = ( qFactor == 0f ) ? Math . max ( anyFactor , anyImageFactor ) : qFactor ; adjustQuality ( pFormatQuality , format , qFactor ) ; } }
Adjust quality from HTTP Accept header
32,581
private static void adjustQualityFromImage ( Map < String , Float > pFormatQuality , BufferedImage pImage ) { if ( pImage . getColorModel ( ) instanceof IndexColorModel ) { adjustQuality ( pFormatQuality , FORMAT_JPEG , 0.6f ) ; if ( pImage . getType ( ) != BufferedImage . TYPE_BYTE_BINARY || ( ( IndexColorModel ) pImage . getColorModel ( ) ) . getMapSize ( ) != 2 ) { adjustQuality ( pFormatQuality , FORMAT_WBMP , 0.5f ) ; } } else { adjustQuality ( pFormatQuality , FORMAT_GIF , 0.01f ) ; adjustQuality ( pFormatQuality , FORMAT_PNG , 0.99f ) ; } if ( ImageUtil . hasTransparentPixels ( pImage , true ) ) { adjustQuality ( pFormatQuality , FORMAT_JPEG , 0.009f ) ; adjustQuality ( pFormatQuality , FORMAT_WBMP , 0.009f ) ; if ( pImage . getColorModel ( ) . getTransparency ( ) != Transparency . BITMASK ) { adjustQuality ( pFormatQuality , FORMAT_GIF , 0.8f ) ; } } }
Adjusts source quality settings from image properties .
32,582
private static void adjustQuality ( Map < String , Float > pFormatQuality , String pFormat , float pFactor ) { Float oldValue = pFormatQuality . get ( pFormat ) ; if ( oldValue != null ) { pFormatQuality . put ( pFormat , oldValue * pFactor ) ; } }
Updates the quality in the map .
32,583
private float getKnownFormatQuality ( String pFormat ) { for ( int i = 0 ; i < sKnownFormats . length ; i ++ ) { if ( pFormat . equals ( sKnownFormats [ i ] ) ) { return knownFormatQuality [ i ] ; } } return 0.1f ; }
Gets the initial quality if this is a known format otherwise 0 . 1
32,584
public void write ( final byte pBytes [ ] , final int pOff , final int pLen ) throws IOException { out . write ( pBytes , pOff , pLen ) ; }
Overide for efficiency
32,585
public int decode ( final InputStream stream , final ByteBuffer buffer ) throws IOException { if ( reachedEOF ) { return - 1 ; } while ( buffer . hasRemaining ( ) ) { int n ; if ( splitRun ) { n = leftOfRun ; splitRun = false ; } else { int b = stream . read ( ) ; if ( b < 0 ) { reachedEOF = true ; break ; } n = ( byte ) b ; } if ( n >= 0 && n + 1 > buffer . remaining ( ) ) { leftOfRun = n ; splitRun = true ; break ; } else if ( n < 0 && - n + 1 > buffer . remaining ( ) ) { leftOfRun = n ; splitRun = true ; break ; } try { if ( n >= 0 ) { readFully ( stream , buffer , sample . length * ( n + 1 ) ) ; } else if ( disableNoOp || n != - 128 ) { for ( int s = 0 ; s < sample . length ; s ++ ) { sample [ s ] = readByte ( stream ) ; } for ( int i = - n + 1 ; i > 0 ; i -- ) { buffer . put ( sample ) ; } } } catch ( IndexOutOfBoundsException e ) { throw new DecodeException ( "Error in PackBits decompression, data seems corrupt" , e ) ; } } return buffer . position ( ) ; }
Decodes bytes from the given input stream to the given buffer .
32,586
private float [ ] LABtoXYZ ( float L , float a , float b , float [ ] xyzResult ) { float y = ( L + 16.0f ) / 116.0f ; float y3 = y * y * y ; float x = ( a / 500.0f ) + y ; float x3 = x * x * x ; float z = y - ( b / 200.0f ) ; float z3 = z * z * z ; if ( y3 > 0.008856f ) { y = y3 ; } else { y = ( y - ( 16.0f / 116.0f ) ) / 7.787f ; } if ( x3 > 0.008856f ) { x = x3 ; } else { x = ( x - ( 16.0f / 116.0f ) ) / 7.787f ; } if ( z3 > 0.008856f ) { z = z3 ; } else { z = ( z - ( 16.0f / 116.0f ) ) / 7.787f ; } xyzResult [ 0 ] = x * whitePoint [ 0 ] ; xyzResult [ 1 ] = y * whitePoint [ 1 ] ; xyzResult [ 2 ] = z * whitePoint [ 2 ] ; return xyzResult ; }
Convert LAB to XYZ .
32,587
public Object toObject ( final String pString , final Class pType , final String pFormat ) throws ConversionException { if ( StringUtil . isEmpty ( pString ) ) { return null ; } try { if ( pType . equals ( BigInteger . class ) ) { return new BigInteger ( pString ) ; } if ( pType . equals ( BigDecimal . class ) ) { return new BigDecimal ( pString ) ; } NumberFormat format ; if ( pFormat == null ) { format = sDefaultFormat ; } else { format = getNumberFormat ( pFormat ) ; } Number num ; synchronized ( format ) { num = format . parse ( pString ) ; } if ( pType == Integer . TYPE || pType == Integer . class ) { return num . intValue ( ) ; } else if ( pType == Long . TYPE || pType == Long . class ) { return num . longValue ( ) ; } else if ( pType == Double . TYPE || pType == Double . class ) { return num . doubleValue ( ) ; } else if ( pType == Float . TYPE || pType == Float . class ) { return num . floatValue ( ) ; } else if ( pType == Byte . TYPE || pType == Byte . class ) { return num . byteValue ( ) ; } else if ( pType == Short . TYPE || pType == Short . class ) { return num . shortValue ( ) ; } return num ; } catch ( ParseException pe ) { throw new ConversionException ( pe ) ; } catch ( RuntimeException rte ) { throw new ConversionException ( rte ) ; } }
Converts the string to a number using the given format for parsing .
32,588
public void setPenSize ( Dimension2D pSize ) { penSize . setSize ( pSize ) ; graphics . setStroke ( getStroke ( penSize ) ) ; }
Sets the pen size . PenSize
32,589
protected void setupForFill ( final Pattern pPattern ) { graphics . setPaint ( pPattern ) ; graphics . setComposite ( getCompositeFor ( QuickDraw . PAT_COPY ) ) ; }
Sets up paint context for fill .
32,590
private static Arc2D . Double toArc ( final Rectangle2D pRectangle , int pStartAngle , int pArcAngle , final boolean pClosed ) { return new Arc2D . Double ( pRectangle , 90 - pStartAngle , - pArcAngle , pClosed ? Arc2D . PIE : Arc2D . OPEN ) ; }
Converts a rectangle to an arc .
32,591
public void drawString ( String pString ) { setupForText ( ) ; graphics . drawString ( pString , ( float ) getPenPosition ( ) . getX ( ) , ( float ) getPenPosition ( ) . getY ( ) ) ; }
DrawString - draws the text of a Pascal string .
32,592
public static Dimension readDimension ( final DataInput pStream ) throws IOException { int h = pStream . readShort ( ) ; int v = pStream . readShort ( ) ; return new Dimension ( h , v ) ; }
Reads a dimension from the given stream .
32,593
public static String readStr31 ( final DataInput pStream ) throws IOException { String text = readPascalString ( pStream ) ; int length = 31 - text . length ( ) ; if ( length < 0 ) { throw new IOException ( "String length exceeds maximum (31): " + text . length ( ) ) ; } pStream . skipBytes ( length ) ; return text ; }
Reads a 32 byte fixed length Pascal string from the given input . The input stream must be positioned at the length byte of the text the text will be no longer than 31 characters long .
32,594
public static String readPascalString ( final DataInput pStream ) throws IOException { int length = pStream . readUnsignedByte ( ) ; byte [ ] bytes = new byte [ length ] ; pStream . readFully ( bytes , 0 , length ) ; return new String ( bytes , ENCODING ) ; }
Reads a Pascal String from the given stream . The input stream must be positioned at the length byte of the text which can thus be a maximum of 255 characters long .
32,595
protected void doFilterImpl ( ServletRequest pRequest , ServletResponse pResponse , FilterChain pChain ) throws IOException , ServletException { int width = ServletUtil . getIntParameter ( pRequest , sizeWidthParam , - 1 ) ; int height = ServletUtil . getIntParameter ( pRequest , sizeHeightParam , - 1 ) ; if ( width > 0 || height > 0 ) { pRequest . setAttribute ( ImageServletResponse . ATTRIB_SIZE , new Dimension ( width , height ) ) ; } boolean uniform = ServletUtil . getBooleanParameter ( pRequest , sizeUniformParam , true ) ; if ( ! uniform ) { pRequest . setAttribute ( ImageServletResponse . ATTRIB_SIZE_UNIFORM , Boolean . FALSE ) ; } boolean percent = ServletUtil . getBooleanParameter ( pRequest , sizePercentParam , false ) ; if ( percent ) { pRequest . setAttribute ( ImageServletResponse . ATTRIB_SIZE_PERCENT , Boolean . TRUE ) ; } int x = ServletUtil . getIntParameter ( pRequest , regionLeftParam , - 1 ) ; int y = ServletUtil . getIntParameter ( pRequest , regionTopParam , - 1 ) ; width = ServletUtil . getIntParameter ( pRequest , regionWidthParam , - 1 ) ; height = ServletUtil . getIntParameter ( pRequest , regionHeightParam , - 1 ) ; if ( width > 0 || height > 0 ) { pRequest . setAttribute ( ImageServletResponse . ATTRIB_AOI , new Rectangle ( x , y , width , height ) ) ; } uniform = ServletUtil . getBooleanParameter ( pRequest , regionUniformParam , false ) ; if ( uniform ) { pRequest . setAttribute ( ImageServletResponse . ATTRIB_SIZE_UNIFORM , Boolean . TRUE ) ; } percent = ServletUtil . getBooleanParameter ( pRequest , regionPercentParam , false ) ; if ( percent ) { pRequest . setAttribute ( ImageServletResponse . ATTRIB_SIZE_PERCENT , Boolean . TRUE ) ; } super . doFilterImpl ( pRequest , pResponse , pChain ) ; }
Extracts request parameters and sets the corresponding request attributes if specified .
32,596
public void setTimeout ( int pTimeout ) { if ( pTimeout < 0 ) { throw new IllegalArgumentException ( "Timeout must be positive." ) ; } timeout = pTimeout ; if ( socket != null ) { try { socket . setSoTimeout ( pTimeout ) ; } catch ( SocketException se ) { } } }
Sets the read timeout for the undelying socket . A timeout of zero is interpreted as an infinite timeout .
32,597
public synchronized InputStream getInputStream ( ) throws IOException { if ( ! connected ) { connect ( ) ; } if ( responseCode == HTTP_NOT_FOUND ) { throw new FileNotFoundException ( url . toString ( ) ) ; } int length ; if ( inputStream == null ) { return null ; } else if ( "chunked" . equalsIgnoreCase ( getHeaderField ( "Transfer-Encoding" ) ) ) { if ( ! ( inputStream instanceof ChunkedInputStream ) ) { inputStream = new ChunkedInputStream ( inputStream ) ; } } else if ( ( length = getHeaderFieldInt ( "Content-Length" , - 1 ) ) >= 0 ) { if ( ! ( inputStream instanceof FixedLengthInputStream ) ) { inputStream = new FixedLengthInputStream ( inputStream , length ) ; } } return inputStream ; }
Returns an input stream that reads from this open connection .
32,598
private void connect ( final URL pURL , PasswordAuthentication pAuth , String pAuthType , int pRetries ) throws IOException { final int port = ( pURL . getPort ( ) > 0 ) ? pURL . getPort ( ) : HTTP_DEFAULT_PORT ; if ( socket == null ) { socket = createSocket ( pURL , port , connectTimeout ) ; socket . setSoTimeout ( timeout ) ; } OutputStream os = socket . getOutputStream ( ) ; writeRequestHeaders ( os , pURL , method , requestProperties , usingProxy ( ) , pAuth , pAuthType ) ; InputStream sis = socket . getInputStream ( ) ; BufferedInputStream is = new BufferedInputStream ( sis ) ; InputStream header = detatchResponseHeader ( is ) ; responseHeaders = parseResponseHeader ( header ) ; responseHeaderFields = parseHeaderFields ( responseHeaders ) ; switch ( getResponseCode ( ) ) { case HTTP_OK : inputStream = is ; errorStream = null ; break ; case HTTP_UNAUTHORIZED : responseCode = - 1 ; String auth = getHeaderField ( HEADER_WWW_AUTH ) ; if ( StringUtil . isEmpty ( auth ) ) { throw new ProtocolException ( "Missing \"" + HEADER_WWW_AUTH + "\" header for response: 401 " + responseMessage ) ; } int SP = auth . indexOf ( " " ) ; String method ; String realm = null ; if ( SP >= 0 ) { method = auth . substring ( 0 , SP ) ; if ( auth . length ( ) >= SP + 7 ) { realm = auth . substring ( SP + 7 ) ; } } else { method = SimpleAuthenticator . BASIC ; } PasswordAuthentication pa = Authenticator . requestPasswordAuthentication ( NetUtil . createInetAddressFromURL ( pURL ) , port , pURL . getProtocol ( ) , realm , method ) ; if ( pRetries ++ <= 0 ) { throw new ProtocolException ( "Server redirected too many times (" + maxRedirects + ") (Authentication required: " + auth + ")" ) ; } else if ( pa != null ) { connect ( pURL , pa , method , pRetries ) ; } break ; case HTTP_MOVED_PERM : case HTTP_MOVED_TEMP : case HTTP_SEE_OTHER : case HTTP_REDIRECT : if ( instanceFollowRedirects ) { responseCode = - 1 ; String location = getHeaderField ( "Location" ) ; URL newLoc = new URL ( pURL , location ) ; if ( ! ( newLoc . getAuthority ( ) . equals ( pURL . getAuthority ( ) ) && ( newLoc . getPort ( ) == pURL . getPort ( ) ) ) ) { socket . close ( ) ; socket = null ; } if ( location != null ) { if ( -- pRetries <= 0 ) { throw new ProtocolException ( "Server redirected too many times (5)" ) ; } else { connect ( newLoc , pAuth , pAuthType , pRetries ) ; } } break ; } default : errorStream = is ; inputStream = null ; } outputStream = os ; }
Internal connect method .
32,599
private Socket createSocket ( final URL pURL , final int pPort , int pConnectTimeout ) throws IOException { Socket socket ; final Object current = this ; SocketConnector connector ; Thread t = new Thread ( connector = new SocketConnector ( ) { private IOException mConnectException = null ; private Socket mLocalSocket = null ; public Socket getSocket ( ) throws IOException { if ( mConnectException != null ) { throw mConnectException ; } return mLocalSocket ; } public void run ( ) { try { mLocalSocket = new Socket ( pURL . getHost ( ) , pPort ) ; } catch ( IOException ioe ) { mConnectException = ioe ; } synchronized ( current ) { current . notify ( ) ; } } } ) ; t . start ( ) ; synchronized ( this ) { try { if ( t . isAlive ( ) ) { if ( pConnectTimeout > 0 ) { wait ( pConnectTimeout ) ; } else { wait ( ) ; } } } catch ( InterruptedException ie ) { } } if ( ( socket = connector . getSocket ( ) ) == null ) { throw new ConnectException ( "Socket connect timed out!" ) ; } return socket ; }
Creates a socket to the given URL and port with the given connect timeout . If the socket waits more than the given timout to connect an ConnectException is thrown .