idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
122,900
public String getFilename ( String name ) { List part = ( List ) _partMap . getValues ( name ) ; if ( part == null ) return null ; return ( ( Part ) part . get ( 0 ) ) . _filename ; }
Get any file name associated with a part .
122,901
public synchronized ServletHandler getServletHandler ( ) { if ( _webAppHandler == null ) { _webAppHandler = ( WebApplicationHandler ) getHandler ( WebApplicationHandler . class ) ; if ( _webAppHandler == null ) { if ( getHandler ( ServletHandler . class ) != null ) throw new IllegalStateException ( "Cannot have Servlet...
Get the context ServletHandler . Conveniance method . If no ServletHandler exists a new one is added to the context . This derivation of the method creates a WebApplicationHandler extension of ServletHandler .
122,902
protected void doStart ( ) throws Exception { if ( isStarted ( ) ) return ; Thread thread = Thread . currentThread ( ) ; ClassLoader lastContextLoader = thread . getContextClassLoader ( ) ; MultiException mex = null ; try { resolveWebApp ( ) ; getServletHandler ( ) ; _configurations = loadConfigurations ( ) ; configure...
Start the Web Application .
122,903
public void setResourceAlias ( String alias , String uri ) { if ( _resourceAliases == null ) _resourceAliases = new HashMap ( 5 ) ; _resourceAliases . put ( alias , uri ) ; }
Set Resource Alias . Resource aliases map resource uri s within a context . They may optionally be used by a handler when looking for a resource .
122,904
public void setErrorPage ( String error , String uriInContext ) { if ( _errorPages == null ) _errorPages = new HashMap ( ) ; _errorPages . put ( error , uriInContext ) ; }
set error page URI .
122,905
public String getErrorPage ( String error ) { if ( _errorPages == null ) return null ; return ( String ) _errorPages . get ( error ) ; }
get error page URI .
122,906
public void setName ( String name ) { synchronized ( Pool . class ) { if ( isStarted ( ) ) { if ( ( name == null && _pool . getPoolName ( ) != null ) || ( name != null && ! name . equals ( _pool . getPoolName ( ) ) ) ) throw new IllegalStateException ( "started" ) ; return ; } if ( name == null ) { if ( _pool . getPool...
Set the Pool name . All ThreadPool instances with the same Pool name will share the same Pool instance . Thus they will share the same max min and available Threads . The field values of the first ThreadPool to call setPoolName with a specific name are used for the named Pool . Subsequent ThreadPools that join the name...
122,907
public int getThreadsPriority ( ) { int priority = Thread . NORM_PRIORITY ; Object o = _pool . getAttribute ( __PRIORITY ) ; if ( o != null ) { priority = ( ( Integer ) o ) . intValue ( ) ; } return priority ; }
Get the priority of the pool threads .
122,908
public void run ( Object job ) throws InterruptedException { if ( job == null ) return ; try { PoolThread thread = ( PoolThread ) _pool . get ( getMaxIdleTimeMs ( ) ) ; if ( thread != null ) thread . run ( this , job ) ; else { log . warn ( "No thread for " + job ) ; stopJob ( null , job ) ; } } catch ( InterruptedExce...
Run job . Give a job to the pool .
122,909
protected void handle ( Object job ) throws InterruptedException { if ( job != null && job instanceof Runnable ) ( ( Runnable ) job ) . run ( ) ; else log . warn ( "Invalid job: " + job ) ; }
Handle a job . Called by the allocated thread to handle a job . If the job is a Runnable it s run method is called . Otherwise this method needs to be specialized by a derived class to provide specific handling .
122,910
public static PublicKey parseRecord ( DNSKEYRecord r ) { int alg = r . getAlgorithm ( ) ; byte [ ] data = r . getKey ( ) ; return parseRecord ( alg , data ) ; }
Converts a DNSKEY record into a PublicKey
122,911
public static PublicKey parseRecord ( KEYRecord r ) { int alg = r . getAlgorithm ( ) ; byte [ ] data = r . getKey ( ) ; return parseRecord ( alg , data ) ; }
Converts a KEY record into a PublicKey
122,912
public static KEYRecord buildRecord ( Name name , int dclass , long ttl , int flags , int proto , PublicKey key ) { byte alg ; if ( key instanceof RSAPublicKey ) { alg = DNSSEC . RSAMD5 ; } else if ( key instanceof DHPublicKey ) { alg = DNSSEC . DH ; } else if ( key instanceof DSAPublicKey ) { alg = DNSSEC . DSA ; } el...
Builds a KEY record from a PublicKey
122,913
public static Record buildRecord ( Name name , int type , int dclass , long ttl , int flags , int proto , int alg , PublicKey key ) { byte [ ] data ; if ( type != Type . KEY && type != Type . DNSKEY ) throw new IllegalArgumentException ( "type must be KEY " + "or DNSKEY" ) ; if ( key instanceof RSAPublicKey ) { data = ...
Builds a DNSKEY or KEY record from a PublicKey
122,914
public void setByteLimit ( int bytes ) { _byteLimit = bytes ; if ( bytes >= 0 ) { _newByteLimit = true ; _byteLimit -= _contents - _pos ; if ( _byteLimit < 0 ) { _avail += _byteLimit ; _byteLimit = 0 ; } } else { _newByteLimit = false ; _avail = _contents ; _eof = false ; } }
Set the byte limit . If set only this number of bytes are read before EOF .
122,915
public int readLine ( byte [ ] b , int off , int len ) throws IOException { len = fillLine ( len ) ; if ( len < 0 ) return - 1 ; if ( len == 0 ) return 0 ; System . arraycopy ( _buf , _mark , b , off , len ) ; _mark = - 1 ; return len ; }
Read a line ended by CR LF or CRLF .
122,916
public LineBuffer readLineBuffer ( int len ) throws IOException { len = fillLine ( len > 0 ? len : _buf . length ) ; if ( len < 0 ) return null ; if ( len == 0 ) { _lineBuffer . size = 0 ; return _lineBuffer ; } _byteBuffer . setStream ( _mark , len ) ; _lineBuffer . size = 0 ; int read = 0 ; while ( read < len && _rea...
Read a Line ended by CR LF or CRLF . Read a line into a shared LineBuffer instance . The LineBuffer is resused between calls and should not be held by the caller . The default or supplied encoding is used to convert bytes to characters .
122,917
public static String dump ( String description , byte [ ] b , int offset , int length ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( length + "b" ) ; if ( description != null ) sb . append ( " (" + description + ")" ) ; sb . append ( ':' ) ; int prefixlen = sb . toString ( ) . length ( ) ; prefixlen = ( pre...
Dumps a byte array into hex format .
122,918
public static Resource newResource ( URL url ) throws IOException { if ( url == null ) return null ; String urls = url . toExternalForm ( ) ; if ( urls . startsWith ( "file:" ) ) { try { FileResource fileResource = new FileResource ( url ) ; return fileResource ; } catch ( Exception e ) { log . debug ( LogSupport . EXC...
Construct a resource from a url .
122,919
public static Resource newResource ( String resource ) throws MalformedURLException , IOException { URL url = null ; try { url = new URL ( resource ) ; } catch ( MalformedURLException e ) { if ( ! resource . startsWith ( "ftp:" ) && ! resource . startsWith ( "file:" ) && ! resource . startsWith ( "jar:" ) ) { try { if ...
Construct a resource from a string .
122,920
public static Resource newSystemResource ( String resource ) throws IOException { URL url = null ; ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( loader != null ) { url = loader . getResource ( resource ) ; if ( url == null && resource . startsWith ( "/" ) ) url = loader . getResourc...
Construct a system resource from a string . The resource is tried as classloader resource before being treated as a normal resource .
122,921
public String getListHTML ( String base , boolean parent ) throws IOException { if ( ! isDirectory ( ) ) return null ; String [ ] ls = list ( ) ; if ( ls == null ) return null ; Arrays . sort ( ls ) ; String title = "Directory: " + URI . decodePath ( base ) ; title = StringUtil . replace ( StringUtil . replace ( title ...
Get the resource list as a HTML directory listing .
122,922
private void scavenge ( ) { Thread thread = Thread . currentThread ( ) ; ClassLoader old_loader = thread . getContextClassLoader ( ) ; try { if ( _handler == null ) return ; ClassLoader loader = _handler . getClassLoader ( ) ; if ( loader != null ) thread . setContextClassLoader ( loader ) ; long now = System . current...
Find sessions that have timed out and invalidate them . This runs in the SessionScavenger thread .
122,923
public void loadConfig ( String config ) throws IOException { Properties properties = new Properties ( ) ; Resource resource = Resource . newResource ( config ) ; properties . load ( resource . getInputStream ( ) ) ; _jdbcDriver = properties . getProperty ( "jdbcdriver" ) ; _url = properties . getProperty ( "url" ) ; _...
Load JDBC connection configuration from properties file .
122,924
protected void initWebXmlElement ( String element , XmlParser . Node node ) throws Exception { if ( "display-name" . equals ( element ) ) initDisplayName ( node ) ; else if ( "description" . equals ( element ) ) { } else if ( "context-param" . equals ( element ) ) initContextParam ( node ) ; else if ( "servlet" . equal...
Handle web . xml element . This method is called for each top level element within the web . xml file . It may be specialized by derived WebApplicationContexts to provide additional configuration and handling .
122,925
public HttpListener addListener ( InetAddrPort address ) throws IOException { HttpListener listener = new SocketListener ( address ) ; listener . setHttpServer ( this ) ; _listeners . add ( listener ) ; addComponent ( listener ) ; return listener ; }
Create and add a SocketListener . Conveniance method .
122,926
public HttpListener addListener ( HttpListener listener ) throws IllegalArgumentException { listener . setHttpServer ( this ) ; _listeners . add ( listener ) ; addComponent ( listener ) ; return listener ; }
Add a HTTP Listener to the server .
122,927
public void removeListener ( HttpListener listener ) { if ( listener == null ) return ; for ( int l = 0 ; l < _listeners . size ( ) ; l ++ ) { if ( listener . equals ( _listeners . get ( l ) ) ) { _listeners . remove ( l ) ; removeComponent ( listener ) ; if ( listener . isStarted ( ) ) try { listener . stop ( ) ; } ca...
Remove a HTTP Listener .
122,928
protected synchronized void doStart ( ) throws Exception { log . info ( "Version " + Version . getImplVersion ( ) ) ; MultiException mex = new MultiException ( ) ; statsReset ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "LISTENERS: " + _listeners ) ; log . debug ( "HANDLER: " + _virtualHostMap ) ; } if ( _requ...
Start all handlers then listeners . If a subcomponent fails to start it s exception is added to a org . mortbay . util . MultiException and the start method continues .
122,929
public synchronized void stop ( boolean graceful ) throws InterruptedException { boolean ov = _gracefulStop ; try { _gracefulStop = graceful ; stop ( ) ; } finally { _gracefulStop = ov ; } }
Stop all listeners then all contexts .
122,930
public void join ( ) throws InterruptedException { for ( int l = 0 ; l < _listeners . size ( ) ; l ++ ) { HttpListener listener = ( HttpListener ) _listeners . get ( l ) ; if ( listener . isStarted ( ) && listener instanceof ThreadPool ) { ( ( ThreadPool ) listener ) . join ( ) ; } } }
Join the listeners . Join all listeners that are instances of ThreadPool .
122,931
public void addHostAlias ( String virtualHost , String alias ) { log . warn ( "addHostAlias is deprecated. Use HttpContext.addVirtualHost" ) ; Object contextMap = _virtualHostMap . get ( virtualHost ) ; if ( contextMap == null ) throw new IllegalArgumentException ( "No Such Host: " + virtualHost ) ; _virtualHostMap . p...
Define a virtual host alias . All requests to the alias are handled the same as request for the virtualHost .
122,932
public synchronized void setRequestLog ( RequestLog log ) { if ( _requestLog != null ) removeComponent ( _requestLog ) ; _requestLog = log ; if ( _requestLog != null ) addComponent ( _requestLog ) ; }
Set the request log .
122,933
void log ( HttpRequest request , HttpResponse response , int length ) { if ( _requestLog != null && request != null && response != null ) _requestLog . log ( request , response , length ) ; }
Log a request to the request log
122,934
public HttpContext service ( HttpRequest request , HttpResponse response ) throws IOException , HttpException { String host = request . getHost ( ) ; if ( _requestsPerGC > 0 && _gcRequests ++ > _requestsPerGC ) { _gcRequests = 0 ; System . gc ( ) ; } while ( true ) { PathMap contextMap = ( PathMap ) _virtualHostMap . g...
Service a request . Handle the request by passing it to the HttpHandler contained in the mapped HttpContexts . The requests host and path are used to select a list of HttpContexts . Each HttpHandler in these context is offered the request in turn until the request is handled .
122,935
public HttpHandler findHandler ( Class handlerClass , String uri , String [ ] vhosts ) { uri = URI . stripPath ( uri ) ; if ( vhosts == null || vhosts . length == 0 ) vhosts = __noVirtualHost ; for ( int h = 0 ; h < vhosts . length ; h ++ ) { String host = vhosts [ h ] ; PathMap contextMap = ( PathMap ) _virtualHostMap...
Find handler . Find a handler for a URI . This method is provided for the servlet context getContext method to search for another context by URI . A list of hosts may be passed to qualify the search .
122,936
public UserRealm getRealm ( String realmName ) { if ( realmName == null ) { if ( _realmMap . size ( ) == 1 ) return ( UserRealm ) _realmMap . values ( ) . iterator ( ) . next ( ) ; log . warn ( "Null realmName with multiple known realms" ) ; } return ( UserRealm ) _realmMap . get ( realmName ) ; }
Get a named UserRealm .
122,937
public void statsReset ( ) { _statsStartedAt = System . currentTimeMillis ( ) ; _connections = 0 ; _connectionsOpenMin = _connectionsOpen ; _connectionsOpenMax = _connectionsOpen ; _connectionsOpen = 0 ; _connectionsDurationMin = 0 ; _connectionsDurationMax = 0 ; _connectionsDurationTotal = 0 ; _errors = 0 ; _requests ...
Reset statistics .
122,938
public void save ( String saveat ) throws MalformedURLException , IOException { Resource resource = Resource . newResource ( saveat ) ; ObjectOutputStream out = new ObjectOutputStream ( resource . getOutputStream ( ) ) ; out . writeObject ( this ) ; out . flush ( ) ; out . close ( ) ; log . info ( "Saved " + this + " t...
Save the HttpServer The server is saved by serialization to the given filename or URL .
122,939
public static void main ( String [ ] args ) { if ( args . length == 0 || args . length > 2 ) { System . err . println ( "\nUsage - java org.browsermob.proxy.jetty.http.HttpServer [<addr>:]<port>" ) ; System . err . println ( "\nUsage - java org.browsermob.proxy.jetty.http.HttpServer -r [savefile]" ) ; System . err . pr...
Construct server from command line arguments .
122,940
public static Certificate parseRecord ( CERTRecord r ) { int type = r . getCertType ( ) ; byte [ ] data = r . getCert ( ) ; Certificate cert ; try { switch ( type ) { case CERTRecord . PKIX : { CertificateFactory cf ; ByteArrayInputStream bs ; cf = CertificateFactory . getInstance ( "X.509" ) ; bs = new ByteArrayInputS...
Converts a CERT record into a Certificate
122,941
public static CERTRecord buildRecord ( Name name , int dclass , long ttl , Certificate cert , int tag , int alg ) { int type ; byte [ ] data ; try { if ( cert instanceof X509Certificate ) { type = CERTRecord . PKIX ; data = cert . getEncoded ( ) ; } else return null ; return new CERTRecord ( name , dclass , ttl , type ...
Builds a CERT record from a Certificate associated with a key also in DNS
122,942
public static CERTRecord buildRecord ( Name name , int dclass , long ttl , Certificate cert ) { return buildRecord ( name , dclass , ttl , cert , 0 , 0 ) ; }
Builds a CERT record from a Certificate
122,943
public static byte [ ] getByteArray ( int size ) { byte [ ] [ ] pool = ( byte [ ] [ ] ) __pools . get ( ) ; boolean full = true ; for ( int i = pool . length ; i -- > 0 ; ) { if ( pool [ i ] != null && pool [ i ] . length == size ) { byte [ ] b = pool [ i ] ; pool [ i ] = null ; return b ; } else full = false ; } if ( ...
Get a byte array from the pool of known size .
122,944
public static String quote ( String s , String delim ) { if ( s == null ) return null ; if ( s . length ( ) == 0 ) return "\"\"" ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == '"' || c == '\\' || c == '\'' || delim . indexOf ( c ) >= 0 ) { StringBuffer b = new StringBuffer ( s ....
Quote a string . The string is quoted only if quoting is required due to embeded delimiters quote characters or the empty string .
122,945
public static void quote ( StringBuffer buf , String s ) { synchronized ( buf ) { buf . append ( '"' ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == '"' ) { buf . append ( "\\\"" ) ; continue ; } if ( c == '\\' ) { buf . append ( "\\\\" ) ; continue ; } buf . append ( c ) ; con...
Quote a string into a StringBuffer .
122,946
public void truncate ( int offset ) throws IOException { if ( ( offset < 0 ) || ( offset > _write_pos ) ) throw new IOException ( "bad truncate offset" ) ; if ( _read_pos > offset ) _read_pos = offset ; if ( _mark_pos > offset ) _mark_pos = offset ; _write_pos = offset ; if ( _file_high > offset ) _file_high = offset ;...
Truncates buffered data to specified size . Can not be used to extend data . Repositions OutputStream at the end of truncated data . If current read offset or mark is past the new end of data it is moved at the new end .
122,947
public void setTempDirectory ( File dir ) throws IOException { File td = dir . getCanonicalFile ( ) ; if ( td . isDirectory ( ) ) { _temp_directory = td ; } }
Override directory to create temporary file in . Does not affect already open temp file .
122,948
public String getString ( String character_encoding ) throws java . io . UnsupportedEncodingException { if ( _file_mode ) throw new IllegalStateException ( "data too large" ) ; return new String ( _memory_buffer , 0 , _write_pos , character_encoding ) ; }
Returns buffered data as String using given character encoding .
122,949
public java . io . InputStream getInputStream ( ) { if ( _input_stream == null ) { _input_stream = new TempByteHolder . InputStream ( ) ; } return _input_stream ; }
Returns InputSream for reading buffered data .
122,950
public void writeTo ( java . io . OutputStream os , int start_offset , int length ) throws IOException { int towrite = min ( length , _write_pos - start_offset ) ; int writeoff = start_offset ; if ( towrite > 0 ) { while ( towrite >= _window_size ) { moveWindow ( writeoff ) ; os . write ( _memory_buffer , 0 , _window_s...
Writes efficiently part of the content to output stream .
122,951
public void readFrom ( java . io . InputStream is ) throws IOException { int howmuch = 0 ; do { _write_pos += howmuch ; moveWindow ( _write_pos ) ; howmuch = is . read ( _memory_buffer ) ; } while ( howmuch != - 1 ) ; }
Reads all available data from input stream .
122,952
private void createTempFile ( ) throws IOException { _tempfilef = File . createTempFile ( "org.browsermob.proxy.jetty.util.TempByteHolder-" , ".tmp" , _temp_directory ) . getCanonicalFile ( ) ; _tempfilef . deleteOnExit ( ) ; _tempfile = new RandomAccessFile ( _tempfilef , "rw" ) ; }
Create tempfile if it does not already exist
122,953
private void writeToTempFile ( int at_offset , byte [ ] data , int offset , int len ) throws IOException { if ( _tempfile == null ) { createTempFile ( ) ; _file_pos = - 1 ; } _file_mode = true ; if ( at_offset != _file_pos ) { _tempfile . seek ( ( long ) at_offset ) ; } _tempfile . write ( data , offset , len ) ; _file...
Write chunk of data at specified offset in temp file . Marks data as big . Updates high water mark on tempfile content .
122,954
private void readFromTempFile ( int at_offset , byte [ ] data , int offset , int len ) throws IOException { if ( _file_pos != at_offset ) { _tempfile . seek ( ( long ) at_offset ) ; } _tempfile . readFully ( data , offset , len ) ; _file_pos = at_offset + len ; }
Read chunk of data from specified offset in tempfile
122,955
private static int min ( int a , int b , int c ) { int r = a ; if ( r > b ) r = b ; if ( r > c ) r = c ; return r ; }
Simple minimum for 3 ints
122,956
public synchronized Object put ( Object pathSpec , Object object ) { StringTokenizer tok = new StringTokenizer ( pathSpec . toString ( ) , __pathSpecSeparators ) ; Object old = null ; while ( tok . hasMoreTokens ( ) ) { String spec = tok . nextToken ( ) ; if ( ! spec . startsWith ( "/" ) && ! spec . startsWith ( "*." )...
Add a single path match to the PathMap .
122,957
public Object match ( String path ) { Map . Entry entry = getMatch ( path ) ; if ( entry != null ) return entry . getValue ( ) ; return null ; }
Get object matched by the path .
122,958
public Map . Entry getMatch ( String path ) { Map . Entry entry ; if ( path == null ) return null ; int l = path . indexOf ( ';' ) ; if ( l < 0 ) { l = path . indexOf ( '?' ) ; if ( l < 0 ) l = path . length ( ) ; } entry = _exactMap . getEntry ( path , 0 , l ) ; if ( entry != null ) return ( Map . Entry ) entry . getV...
Get the entry mapped by the best specification .
122,959
public List getMatches ( String path ) { Map . Entry entry ; Object entries = null ; if ( path == null ) return LazyList . getList ( entries ) ; int l = path . indexOf ( ';' ) ; if ( l < 0 ) { l = path . indexOf ( '?' ) ; if ( l < 0 ) l = path . length ( ) ; } entry = _exactMap . getEntry ( path , 0 , l ) ; if ( entry ...
Get all entries matched by the path . Best match first .
122,960
public static String pathMatch ( String pathSpec , String path ) { char c = pathSpec . charAt ( 0 ) ; if ( c == '/' ) { if ( pathSpec . length ( ) == 1 ) return path ; if ( pathSpec . equals ( path ) ) return path ; if ( pathSpec . endsWith ( "/*" ) && pathSpec . regionMatches ( 0 , path , 0 , pathSpec . length ( ) - 2...
Return the portion of a path that matches a path spec .
122,961
public static String pathInfo ( String pathSpec , String path ) { char c = pathSpec . charAt ( 0 ) ; if ( c == '/' ) { if ( pathSpec . length ( ) == 1 ) return null ; if ( pathSpec . equals ( path ) ) return null ; if ( pathSpec . endsWith ( "/*" ) && pathSpec . regionMatches ( 0 , path , 0 , pathSpec . length ( ) - 2 ...
Return the portion of a path that is after a path spec .
122,962
public static String relativePath ( String base , String pathSpec , String path ) { String info = pathInfo ( pathSpec , path ) ; if ( info == null ) info = path ; if ( info . startsWith ( "./" ) ) info = info . substring ( 2 ) ; if ( base . endsWith ( "/" ) ) if ( info . startsWith ( "/" ) ) path = base + info . substr...
Relative path .
122,963
public static void ignore ( Log log , Throwable th ) { if ( log . isTraceEnabled ( ) ) log . trace ( IGNORED , th ) ; }
Ignore an exception unless trace is enabled . This works around the problem that log4j does not support the trace level .
122,964
public int verify ( RRset set , Cache cache ) { Iterator sigs = set . sigs ( ) ; if ( Options . check ( "verbosesec" ) ) System . out . print ( "Verifying " + set . getName ( ) + "/" + Type . string ( set . getType ( ) ) + ": " ) ; if ( ! sigs . hasNext ( ) ) { if ( Options . check ( "verbosesec" ) ) System . out . pri...
Attempts to verify an RRset . This does not modify the set .
122,965
public int readU16 ( ) throws WireParseException { require ( 2 ) ; int b1 = array [ pos ++ ] & 0xFF ; int b2 = array [ pos ++ ] & 0xFF ; return ( ( b1 << 8 ) + b2 ) ; }
Reads an unsigned 16 bit value from the stream as an int .
122,966
public long readU32 ( ) throws WireParseException { require ( 4 ) ; int b1 = array [ pos ++ ] & 0xFF ; int b2 = array [ pos ++ ] & 0xFF ; int b3 = array [ pos ++ ] & 0xFF ; int b4 = array [ pos ++ ] & 0xFF ; return ( ( ( long ) b1 << 24 ) + ( b2 << 16 ) + ( b3 << 8 ) + b4 ) ; }
Reads an unsigned 32 bit value from the stream as a long .
122,967
private static long simulate ( long bytesPerSecond , long latency , int bytes , long timeTaken , boolean roundUp ) { if ( bytesPerSecond <= 0 ) { return 0 ; } double d = ( ( double ) bytes / bytesPerSecond ) * 1000 ; long expectedTime = ( long ) ( roundUp ? Math . ceil ( d ) : Math . floor ( d ) ) + latency ; long diff...
to adjust the waiting time
122,968
public static X509Certificate mitmDuplicateCertificate ( final X509Certificate originalCert , final PublicKey newPubKey , final X509Certificate caCert , final PrivateKey caPrivateKey , Set < String > extensionOidsNotToCopy ) throws CertificateParsingException , SignatureException , InvalidKeyException , CertificateExce...
This method creates an X509v3 certificate based on an an existing certificate . It attempts to create as faithful a copy of the existing certificate as possible by duplicating all certificate extensions .
122,969
public static X509Certificate mitmDuplicateCertificate ( final X509Certificate originalCert , final PublicKey newPubKey , final X509Certificate caCert , final PrivateKey caPrivateKey ) throws CertificateParsingException , SignatureException , InvalidKeyException , CertificateExpiredException , CertificateNotYetValidExc...
Convenience method for the most common case of certificate duplication .
122,970
public static void copyThread ( InputStream in , OutputStream out ) { try { instance ( ) . run ( new Job ( in , out ) ) ; } catch ( InterruptedException e ) { log . warn ( LogSupport . EXCEPTION , e ) ; } }
Copy Stream in to Stream out until EOF or exception . in own thread
122,971
public static void copyThread ( Reader in , Writer out ) { try { instance ( ) . run ( new Job ( in , out ) ) ; } catch ( InterruptedException e ) { log . warn ( LogSupport . EXCEPTION , e ) ; } }
Copy Stream in to Stream out until EOF or exception in own thread
122,972
public static void copy ( Reader in , Writer out , long byteCount ) throws IOException { char buffer [ ] = new char [ bufferSize ] ; int len = bufferSize ; if ( byteCount >= 0 ) { while ( byteCount > 0 ) { if ( byteCount < bufferSize ) len = in . read ( buffer , 0 , ( int ) byteCount ) ; else len = in . read ( buffer ,...
Copy Reader to Writer for byteCount bytes or until EOF or exception .
122,973
static public TSIG fromString ( String str ) { String [ ] parts = str . split ( "[:/]" ) ; if ( parts . length < 2 || parts . length > 3 ) throw new IllegalArgumentException ( "Invalid TSIG key " + "specification" ) ; if ( parts . length == 3 ) return new TSIG ( parts [ 0 ] , parts [ 1 ] , parts [ 2 ] ) ; else return n...
Creates a new TSIG object with the hmac - md5 algorithm which can be used to sign or verify a message .
122,974
public void setTimeZone ( TimeZone tz ) { setTzFormatString ( tz ) ; if ( _locale != null ) { _tzFormat = new SimpleDateFormat ( _tzFormatString , _locale ) ; _minFormat = new SimpleDateFormat ( _minFormatString , _locale ) ; } else if ( _dfs != null ) { _tzFormat = new SimpleDateFormat ( _tzFormatString , _dfs ) ; _mi...
Set the timezone .
122,975
public synchronized String format ( long inDate ) { long seconds = inDate / 1000 ; if ( seconds < _lastSeconds || _lastSeconds > 0 && seconds > _lastSeconds + __hitWindow ) { _misses ++ ; if ( _misses < __MaxMisses ) { Date d = new Date ( inDate ) ; return _tzFormat . format ( d ) ; } } else if ( _misses > 0 ) _misses ...
Format a date according to our stored formatter .
122,976
public List getOptions ( int code ) { if ( options == null ) return Collections . EMPTY_LIST ; List list = null ; for ( Iterator it = options . iterator ( ) ; it . hasNext ( ) ; ) { Option opt = ( Option ) it . next ( ) ; if ( opt . code == code ) { if ( list == null ) list = new ArrayList ( ) ; list . add ( opt . data...
Gets all options in the OPTRecord with a specific code . This returns a list of byte arrays .
122,977
protected HttpConnection createConnection ( Socket socket ) throws IOException { HttpConnection c = new HttpConnection ( this , socket . getInetAddress ( ) , socket . getInputStream ( ) , socket . getOutputStream ( ) , socket ) ; return c ; }
Create an HttpConnection instance . This method can be used to override the connection instance .
122,978
public void persistConnection ( HttpConnection connection ) { try { Socket socket = ( Socket ) ( connection . getConnection ( ) ) ; if ( _lowResourcePersistTimeMs > 0 && isLowOnResources ( ) ) { socket . setSoTimeout ( _lowResourcePersistTimeMs ) ; connection . setThrottled ( true ) ; } else connection . setThrottled (...
Persist the connection . This method is called by the HttpConnection in order to prepare a connection to be persisted . For this implementation if the listener is low on resources the connection read timeout is set to lowResourcePersistTimeMs . The customizeRequest method is used to reset this to the normal value after...
122,979
public void resetStream ( ) throws IllegalStateException { if ( ( _deChunker != null && _deChunker . _chunkSize > 0 ) || _realIn . getByteLimit ( ) > 0 ) throw new IllegalStateException ( "Unread input" ) ; if ( log . isTraceEnabled ( ) ) log . trace ( "resetStream()" ) ; in = _realIn ; if ( _deChunker != null ) _deChu...
Reset the stream . Turn chunking off and disable all filters .
122,980
public void setContentLength ( int len ) { if ( _chunking && len >= 0 && getExpectContinues ( ) == null ) throw new IllegalStateException ( "Chunking" ) ; _realIn . setByteLimit ( len ) ; }
Set the content length . Only this number of bytes can be read before EOF is returned .
122,981
public void fetchMetadata ( final String uuid , final DataSetMetadataCallback listener ) throws Exception { final DataSetMetadata metadata = clientDataSetManager . getDataSetMetadata ( uuid ) ; if ( metadata != null ) { listener . callback ( metadata ) ; } else if ( dataSetLookupServices != null ) { if ( remoteMetadata...
Fetch the metadata instance for the specified data set .
122,982
public DataSetMetadata getMetadata ( String uuid ) { DataSetMetadata metadata = clientDataSetManager . getDataSetMetadata ( uuid ) ; if ( metadata != null ) { return metadata ; } return remoteMetadataMap . get ( uuid ) ; }
Get the cached metadata instance for the specified data set .
122,983
public void exportDataSetCSV ( final DataSetLookup request , final DataSetExportReadyCallback listener ) throws Exception { if ( dataSetLookupServices != null ) { if ( clientDataSetManager . getDataSet ( request . getDataSetUUID ( ) ) != null ) { DataSet dataSet = clientDataSetManager . lookupDataSet ( request ) ; data...
Export a data set specified by a data set lookup request to CSV format .
122,984
public void exportDataSetExcel ( final DataSetLookup request , final DataSetExportReadyCallback listener ) throws Exception { if ( dataSetLookupServices != null ) { if ( clientDataSetManager . getDataSet ( request . getDataSetUUID ( ) ) != null ) { DataSet dataSet = clientDataSetManager . lookupDataSet ( request ) ; tr...
Export a data set specified by a data set lookup request to Excel format .
122,985
public void newDataSet ( DataSetProviderType type , RemoteCallback < DataSetDef > callback ) throws Exception { dataSetDefServices . call ( callback ) . createDataSetDef ( type ) ; }
Creates a brand new data set definition for the provider type specified
122,986
public void lookupDataSet ( final DataSetDef def , final DataSetLookup request , final DataSetReadyCallback listener ) throws Exception { if ( dataSetLookupServices != null ) { try { dataSetLookupServices . call ( new RemoteCallback < DataSet > ( ) { public void callback ( DataSet result ) { if ( result == null ) { lis...
Process the specified data set lookup request for a given definition .
122,987
public void lookupDataSet ( final DataSetLookup request , final DataSetReadyCallback listener ) throws Exception { if ( clientDataSetManager . getDataSet ( request . getDataSetUUID ( ) ) != null ) { DataSet dataSet = clientDataSetManager . lookupDataSet ( request ) ; listener . callback ( dataSet ) ; } else if ( dataSe...
Process the specified data set lookup request .
122,988
void onFilterLabelRemoved ( String columnId , int row ) { super . filterUpdate ( columnId , row ) ; if ( ! displayerSettings . isFilterSelfApplyEnabled ( ) ) { updateVisualization ( ) ; } }
Filter label set component notifications
122,989
public void onFilterEnabled ( Displayer displayer , DataSetGroup groupOp ) { view . gotoFirstPage ( ) ; super . onFilterEnabled ( displayer , groupOp ) ; }
Reset the current navigation status on filter requests from external displayers
122,990
public void editOn ( ) { editOn = true ; for ( Displayer displayer : displayerCoordinator . getDisplayerList ( ) ) { displayer . setRefreshOn ( false ) ; } }
Turn on the edition of the perspective
122,991
public void onFilterEnabled ( Displayer displayer , DataSetGroup groupOp ) { String firstColumnId = dataSet . getColumnByIndex ( 0 ) . getId ( ) ; List < Integer > currentFilter = super . filterIndexes ( firstColumnId ) ; if ( currentFilter . isEmpty ( ) ) { if ( firstColumnId . equals ( groupOp . getColumnGroup ( ) . ...
KEEP IN SYNC THE CURRENT SELECTION WITH ANY EXTERNAL FILTER
122,992
public void onFilterEnabled ( Displayer displayer , DataSetGroup groupOp ) { currentPage = 1 ; super . onFilterEnabled ( displayer , groupOp ) ; }
Reset the current navigation status on filter requests from external displayers .
122,993
public void onValueRestricted ( final String value ) { this . restrictedColumns . add ( value ) ; setEditorEnabled ( value , false , DataSetEditorConstants . INSTANCE . columnIsUsedInFilter ( ) ) ; }
Set the column that cannot be removed from the list as it s used by the filter .
122,994
public void onValueUnRestricted ( final String value ) { this . restrictedColumns . remove ( value ) ; if ( listEditor . getList ( ) . size ( ) == 1 ) { setEditorEnabled ( 0 , false , DataSetEditorConstants . INSTANCE . dataSetMustHaveAtLeastOneColumn ( ) ) ; } else { setEditorEnabled ( value , true , null ) ; } }
Set the column that can be removed again from the list as it s no longer used by the filter .
122,995
private boolean checkSingleColumnEditorDisabled ( ) { final int size = listEditor . getList ( ) . size ( ) ; final boolean hasEditors = ! listEditor . getEditors ( ) . isEmpty ( ) ; if ( size == 1 && hasEditors ) { setEditorEnabled ( 0 , false , DataSetEditorConstants . INSTANCE . dataSetMustHaveAtLeastOneColumn ( ) ) ...
Checks that if only single column used in data set - > it cannot be unselected .
122,996
private boolean checkMultipleColumnsEditorEnabled ( ) { final int size = listEditor . getList ( ) . size ( ) ; if ( size == 2 && ! listEditor . getEditors ( ) . isEmpty ( ) ) { final String cId = listEditor . getEditors ( ) . get ( 0 ) . id ( ) . getValue ( ) ; if ( ! restrictedColumns . contains ( cId ) ) { setEditorE...
Checks that if multiple columns are used in data set - > the column editors must be enabed if the columns are not are restricted .
122,997
public void setDisplayerSetting ( DisplayerAttributeDef displayerAttributeDef , String value ) { settings . put ( getSettingPath ( displayerAttributeDef ) , value ) ; }
Generic setter method
122,998
public void removeDisplayerSetting ( DisplayerAttributeGroupDef displayerAttributeGroup ) { for ( DisplayerAttributeDef attributeDef : displayerAttributeGroup . getChildren ( ) ) { settings . remove ( getSettingPath ( attributeDef ) ) ; } }
Generic remove method
122,999
public void draw ( ) { if ( googleRenderer == null ) { getPresenter ( ) . showError ( new ClientRuntimeError ( "Google renderer not set" ) ) ; } else if ( ! getPresenter ( ) . isDrawn ( ) ) { List < Displayer > displayerList = new ArrayList < Displayer > ( ) ; displayerList . add ( getPresenter ( ) ) ; googleRenderer ....
GCharts drawing is performed asynchronously