idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
122,700
public static ServletHttpResponse unwrap ( ServletResponse response ) { while ( ! ( response instanceof ServletHttpResponse ) ) { if ( response instanceof ServletResponseWrapper ) { ServletResponseWrapper wrapper = ( ServletResponseWrapper ) response ; response = wrapper . getResponse ( ) ; } else throw new IllegalArgu...
Unwrap a ServletResponse .
122,701
public static int [ ] toArray ( String s , int family ) { byte [ ] byteArray = toByteArray ( s , family ) ; if ( byteArray == null ) return null ; int [ ] intArray = new int [ byteArray . length ] ; for ( int i = 0 ; i < byteArray . length ; i ++ ) intArray [ i ] = byteArray [ i ] & 0xFF ; return intArray ; }
Convert a string containing an IP address to an array of 4 or 16 integers .
122,702
public static byte [ ] toByteArray ( String s , int family ) { if ( family == IPv4 ) return parseV4 ( s ) ; else if ( family == IPv6 ) return parseV6 ( s ) ; else throw new IllegalArgumentException ( "unknown address family" ) ; }
Convert a string containing an IP address to an array of 4 or 16 bytes .
122,703
public static boolean isDottedQuad ( String s ) { byte [ ] address = Address . toByteArray ( s , IPv4 ) ; return ( address != null ) ; }
Determines if a string contains a valid IP address .
122,704
public static InetAddress getByName ( String name ) throws UnknownHostException { try { return getByAddress ( name ) ; } catch ( UnknownHostException e ) { Record [ ] records = lookupHostName ( name ) ; return addrFromRecord ( name , records [ 0 ] ) ; } }
Determines the IP address of a host
122,705
public static InetAddress [ ] getAllByName ( String name ) throws UnknownHostException { try { InetAddress addr = getByAddress ( name ) ; return new InetAddress [ ] { addr } ; } catch ( UnknownHostException e ) { Record [ ] records = lookupHostName ( name ) ; InetAddress [ ] addrs = new InetAddress [ records . length ]...
Determines all IP address of a host
122,706
public static InetAddress getByAddress ( String addr ) throws UnknownHostException { byte [ ] bytes ; bytes = toByteArray ( addr , IPv4 ) ; if ( bytes != null ) return InetAddress . getByAddress ( bytes ) ; bytes = toByteArray ( addr , IPv6 ) ; if ( bytes != null ) return InetAddress . getByAddress ( bytes ) ; throw ne...
Converts an address from its string representation to an IP address . The address can be either IPv4 or IPv6 .
122,707
public static InetAddress getByAddress ( String addr , int family ) throws UnknownHostException { if ( family != IPv4 && family != IPv6 ) throw new IllegalArgumentException ( "unknown address family" ) ; byte [ ] bytes ; bytes = toByteArray ( addr , family ) ; if ( bytes != null ) return InetAddress . getByAddress ( by...
Converts an address from its string representation to an IP address in a particular family .
122,708
public static int familyOf ( InetAddress address ) { if ( address instanceof Inet4Address ) return IPv4 ; if ( address instanceof Inet6Address ) return IPv6 ; throw new IllegalArgumentException ( "unknown address family" ) ; }
Returns the family of an InetAddress .
122,709
public static byte [ ] fromString ( String str ) { ByteArrayOutputStream bs = new ByteArrayOutputStream ( ) ; byte [ ] raw = str . getBytes ( ) ; for ( int i = 0 ; i < raw . length ; i ++ ) { if ( ! Character . isWhitespace ( ( char ) raw [ i ] ) ) bs . write ( raw [ i ] ) ; } byte [ ] in = bs . toByteArray ( ) ; if ( ...
Convert a hex - encoded String to binary data
122,710
public void put ( Object o ) throws InterruptedException { synchronized ( lock ) { while ( size == maxSize ) lock . wait ( ) ; elements [ tail ] = o ; if ( ++ tail == maxSize ) tail = 0 ; size ++ ; lock . notify ( ) ; } }
Put object in queue .
122,711
public Object get ( ) throws InterruptedException { synchronized ( lock ) { while ( size == 0 ) lock . wait ( ) ; Object o = elements [ head ] ; elements [ head ] = null ; if ( ++ head == maxSize ) head = 0 ; if ( size == maxSize ) lock . notifyAll ( ) ; size -- ; return o ; } }
Get object from queue . Block if there are no objects to get .
122,712
public Object peek ( ) throws InterruptedException { synchronized ( lock ) { if ( size == 0 ) lock . wait ( ) ; if ( size == 0 ) return null ; Object o = elements [ head ] ; return o ; } }
Peek at the queue . Block if there are no objects to peek .
122,713
public boolean exists ( ) { if ( _exists ) return true ; if ( _urlString . endsWith ( "!/" ) ) { String file_url = _urlString . substring ( 4 , _urlString . length ( ) - 2 ) ; try { return newResource ( file_url ) . exists ( ) ; } catch ( Exception e ) { LogSupport . ignore ( log , e ) ; return false ; } } boolean chec...
Returns true if the respresenetd resource exists .
122,714
public UserAgentInfo parse ( String useragent ) throws IOException { UserAgentInfo retObj = new UserAgentInfo ( ) ; if ( useragent == null ) { return retObj ; } useragent = useragent . trim ( ) ; checkDataMaps ( ) ; if ( ! processRobot ( useragent , retObj ) ) { boolean osFound = processBrowserRegex ( useragent , retOb...
Parse the given user agent string and returns a UserAgentInfo object with the related data
122,715
private void processOsRegex ( String useragent , UserAgentInfo retObj ) { try { lock . lock ( ) ; for ( Map . Entry < Pattern , Long > entry : osRegMap . entrySet ( ) ) { Matcher matcher = entry . getKey ( ) . matcher ( useragent ) ; if ( matcher . find ( ) ) { Long idOs = entry . getValue ( ) ; OsEntry os = osMap . ge...
Searches in the os regex table . if found a match copies the os data
122,716
private boolean processBrowserRegex ( String useragent , UserAgentInfo retObj ) { try { lock . lock ( ) ; boolean osFound = false ; for ( Map . Entry < String , Long > entry : browserRegMap . entrySet ( ) ) { Pattern pattern = Pattern . compile ( entry . getKey ( ) , Pattern . CASE_INSENSITIVE | Pattern . DOTALL ) ; Ma...
Searchs in the browser regex table . if found a match copies the browser data and if possible os data
122,717
private void copyType ( UserAgentInfo retObj , Long idBrowser ) { try { lock . lock ( ) ; BrowserEntry be = browserMap . get ( idBrowser ) ; if ( be != null ) { Long type = be . getType ( ) ; if ( type != null ) { String typeString = browserTypeMap . get ( type ) ; if ( typeString != null ) { retObj . setTyp ( typeStri...
Sets the source type if possible
122,718
private boolean processRobot ( String useragent , UserAgentInfo retObj ) { try { lock . lock ( ) ; if ( robotsMap . containsKey ( useragent ) ) { retObj . setTyp ( "Robot" ) ; RobotEntry robotEntry = robotsMap . get ( useragent ) ; robotEntry . copyTo ( retObj ) ; if ( robotEntry . getOsId ( ) != null ) { OsEntry os = ...
Checks if the useragent comes from a robot . if yes copies all the data to the result object
122,719
public synchronized static SSLSocketFactory getTrustingSSLSocketFactory ( ) { if ( socketFactory != null ) return socketFactory ; TrustManager [ ] trustManagers = new TrustManager [ ] { new TrustEverythingSSLTrustManager ( ) } ; SSLContext sc ; try { sc = SSLContext . getInstance ( "SSL" ) ; sc . init ( null , trustMan...
Returns an SSLSocketFactory that will trust all SSL certificates ; this is suitable for passing to HttpsURLConnection either to its instance method setSSLSocketFactory or to its static method setDefaultSSLSocketFactory .
122,720
public static void trustAllSSLCertificates ( HttpsURLConnection connection ) { getTrustingSSLSocketFactory ( ) ; connection . setSSLSocketFactory ( socketFactory ) ; connection . setHostnameVerifier ( new HostnameVerifier ( ) { public boolean verify ( String s , SSLSession sslSession ) { return true ; } } ) ; }
Configures a single HttpsURLConnection to trust all SSL certificates .
122,721
private void doit ( String [ ] args ) { try { loadParameters ( args ) ; importKeyPair ( ) ; } catch ( Exception e ) { System . out . println ( "Exception: " + e . getMessage ( ) ) ; e . printStackTrace ( ) ; System . exit ( 23 ) ; } }
Load parameters and perform the import command . Catch any exceptions and clear the password arrays .
122,722
private PrivateKey loadPrivateKey ( File privateKeyFile ) throws Exception { System . out . println ( "Loading private key from " + privateKeyFile + ", using " + providerClassName + " as the private key loading provider" ) ; FileInputStream privateKeyInputStream = null ; byte [ ] keyBytes ; try { privateKeyInputStream ...
Load an RSA private key from the given File
122,723
public void setFilename ( String filename ) { if ( filename != null ) { filename = filename . trim ( ) ; if ( filename . length ( ) == 0 ) filename = null ; } _filename = filename ; }
Set the log filename .
122,724
protected void logExtended ( HttpRequest request , HttpResponse response , Writer log ) throws IOException { String referer = request . getField ( HttpFields . __Referer ) ; if ( referer == null ) log . write ( "\"-\" " ) ; else { log . write ( '"' ) ; log . write ( referer ) ; log . write ( "\" " ) ; } String agent = ...
Log Extended fields . This method can be extended by a derived class to add extened fields to each log entry . It is called by the log method after all standard fields have been added but before the line terminator . Derived implementations should write extra fields to the Writer provided . The default implementation w...
122,725
public void setHeaderValue ( String name , String value ) { _fields . put ( name , Collections . singletonList ( value ) ) ; }
Set a header override every response handled will have this header set .
122,726
public void setHeaderValues ( String name , String [ ] values ) { _fields . put ( name , Arrays . asList ( values ) ) ; }
Set a multivalued header every response handled will have this header set with the provided values .
122,727
public void handle ( String pathInContext , String pathParams , HttpRequest request , HttpResponse response ) throws HttpException , IOException { log . debug ( "SetResponseHeadersHandler.handle()" ) ; for ( Iterator iterator = _fields . entrySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { Map . Entry entry = ( M...
Handle a request by pre - populating the headers from the configured set of _fields .
122,728
private Socket createSimulatedSocket ( SSLSocket socket ) { SimulatedSocketFactory . configure ( socket ) ; socket . setEnabledProtocols ( new String [ ] { SSLAlgorithm . SSLv3 . name ( ) , SSLAlgorithm . TLSv1 . name ( ) } ) ; return new SimulatedSSLSocket ( socket , streamManager ) ; }
just an helper function to wrap a normal sslSocket into a simulated one so we can do throttling
122,729
protected synchronized void checkDataMaps ( ) throws IOException { if ( lastUpdateCheck == 0 || lastUpdateCheck < System . currentTimeMillis ( ) - updateInterval ) { String versionOnServer = getVersionFromServer ( ) ; if ( currentVersion == null || versionOnServer . compareTo ( currentVersion ) > 0 ) { loadDataFromInte...
This implementation uses a local properties file to keep the lastUpdate time and the local data file version
122,730
private void loadDataFromInternetAndSave ( ) throws IOException { InputStream is = null ; FileOutputStream fos = null ; try { URL url = new URL ( DATA_RETRIVE_URL ) ; is = url . openStream ( ) ; fos = new FileOutputStream ( getCacheFile ( ) ) ; byte [ ] buff = new byte [ 1024 * 8 ] ; int len = 0 ; while ( ( len = is . ...
loads the data file from the server and saves it to the local file system
122,731
private void saveProperties ( Properties prop ) throws FileNotFoundException , IOException { FileOutputStream fos = new FileOutputStream ( getPropertiesFile ( ) ) ; try { prop . store ( fos , null ) ; } finally { fos . close ( ) ; } }
Saves the properties file to the local filesystem
122,732
public synchronized void setInetAddrPort ( InetAddrPort address ) { if ( _address != null && _address . equals ( address ) ) return ; if ( isStarted ( ) ) log . warn ( this + " is started" ) ; _address = address ; }
Set the server InetAddress and port .
122,733
public void open ( ) throws IOException { if ( _listen == null ) { _listen = newServerSocket ( _address , _acceptQueueSize ) ; if ( _address == null ) _address = new InetAddrPort ( _listen . getInetAddress ( ) , _listen . getLocalPort ( ) ) ; else { if ( _address . getInetAddress ( ) == null ) _address . setInetAddress...
Open the server socket . This method can be called to open the server socket in advance of starting the listener . This can be used to test if the port is available .
122,734
protected void stopJob ( Thread thread , Object job ) { if ( job instanceof Socket ) { try { ( ( Socket ) job ) . close ( ) ; } catch ( Exception e ) { LogSupport . ignore ( log , e ) ; } } super . stopJob ( thread , job ) ; }
Kill a job . This method closes IDLE and socket associated with a job
122,735
public Object getValue ( Object name , int i ) { Object l = super . get ( name ) ; if ( i == 0 && LazyList . size ( l ) == 0 ) return null ; return LazyList . get ( l , i ) ; }
Get a value from a multiple value . If the value is not a multivalue then index 0 retrieves the value or null .
122,736
public Object put ( Object name , Object value ) { return super . put ( name , LazyList . add ( null , value ) ) ; }
Put and entry into the map .
122,737
public void putAll ( Map m ) { Iterator i = m . entrySet ( ) . iterator ( ) ; boolean multi = m instanceof MultiMap ; while ( i . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) i . next ( ) ; if ( multi ) super . put ( entry . getKey ( ) , LazyList . clone ( entry . getValue ( ) ) ) ; else put ( entry . getKey ( )...
Put all contents of map .
122,738
public static byte [ ] fromDNS ( byte [ ] sig ) { final int len = 20 ; int n = 0 ; byte rlen , slen , seqlen ; rlen = len ; if ( sig [ 1 ] < 0 ) rlen ++ ; slen = len ; if ( sig [ len + 1 ] < 0 ) slen ++ ; seqlen = ( byte ) ( rlen + slen + 4 ) ; byte [ ] array = new byte [ seqlen + 2 ] ; array [ n ++ ] = ASN1_SEQ ; arra...
Converts the signature field in a SIG record to the format expected by the DSA verification routines .
122,739
public void setBufferSize ( int size ) throws IllegalStateException { if ( size <= _bufferSize ) return ; if ( _bufferedOut != null && _bufferedOut . size ( ) > 0 ) throw new IllegalStateException ( "Not Reset" ) ; try { _bufferSize = size ; if ( _bufferedOut != null ) { boolean fixed = _bufferedOut . isFixed ( ) ; _bu...
Set the output buffer size . Note that this is the minimal buffer size and that installed filters may perform their own buffering and are likely to change the size of the output . Also the pre and post reserve buffers may be allocated within the buffer for headers and chunking .
122,740
public void resetBuffer ( ) throws IllegalStateException { if ( _out != null && _out != _realOut ) { ArrayList save_observers = _observers ; _observers = null ; _nulled = true ; try { if ( _bufferedOut != null ) { _bufferedOut . resetStream ( ) ; if ( _bufferedOut instanceof ChunkingOutputStream ) ( ( ChunkingOutputStr...
Reset Buffered output . If no data has been committed the buffer output is discarded and the filters may be reinitialized .
122,741
public void setChunking ( ) { checkOutput ( ) ; if ( _bufferedOut instanceof ChunkingOutputStream ) ( ( ChunkingOutputStream ) _bufferedOut ) . setChunking ( true ) ; else throw new IllegalStateException ( _bufferedOut . getClass ( ) . toString ( ) ) ; }
Set chunking mode .
122,742
public void resetStream ( ) throws IOException , IllegalStateException { if ( isChunking ( ) ) close ( ) ; _out = null ; _nulled = true ; if ( _bufferedOut != null ) { _bufferedOut . resetStream ( ) ; if ( _bufferedOut instanceof ChunkingOutputStream ) ( ( ChunkingOutputStream ) _bufferedOut ) . setChunking ( false ) ;...
Reset the stream . Turn disable all filters .
122,743
public void handle ( String pathInContext , String pathParams , HttpRequest request , HttpResponse response ) throws HttpException , IOException { if ( request . getAttribute ( "javax.servlet.error.status_code" ) != null ) return ; try { String ip = request . getRemoteAddr ( ) ; boolean authorized = checkIP ( ip ) ; if...
Handles the incoming request
122,744
public void setStandard ( String s ) { s = s . toLowerCase ( ) ; if ( s . indexOf ( "allow" ) > - 1 ) { standard = true ; } else { standard = false ; } }
Set the standard action beeing taken when not registred IPs wants access
122,745
private static void main ( String [ ] args ) { IPAccessHandler ipah = new IPAccessHandler ( ) ; ipah . setStandard ( "deny" ) ; ipah . setAllowIP ( "217.215.71.167" ) ; ipah . setDenyIP ( "217.215.71.149" ) ; System . out . println ( ipah . checkIP ( "217.215.71.245" ) + " = false" ) ; System . out . println ( ipah . c...
Main method for testing & debugging .
122,746
void setServletPaths ( String servletPath , String pathInfo , ServletHolder holder ) { _servletPath = servletPath ; _pathInfo = pathInfo ; _servletHolder = holder ; }
Set servletpath and pathInfo . Called by the Handler before passing a request to a particular holder to split the context path into a servlet path and path info .
122,747
public static ServletHttpRequest unwrap ( ServletRequest request ) { while ( ! ( request instanceof ServletHttpRequest ) ) { if ( request instanceof ServletRequestWrapper ) { ServletRequestWrapper wrapper = ( ServletRequestWrapper ) request ; request = wrapper . getRequest ( ) ; } else throw new IllegalArgumentExceptio...
Unwrap a ServletRequest .
122,748
public String getTimeStampStr ( ) { if ( _timeStampStr == null && _timeStamp > 0 ) _timeStampStr = HttpFields . __dateCache . format ( _timeStamp ) ; return _timeStampStr ; }
Get Request TimeStamp
122,749
public boolean isHandled ( ) { if ( _handled ) return true ; HttpResponse response = getHttpResponse ( ) ; return ( response != null && response . getState ( ) != HttpMessage . __MSG_EDITABLE ) ; }
Is the request handled .
122,750
public void readHeader ( LineInput in ) throws IOException { _state = __MSG_BAD ; org . browsermob . proxy . jetty . util . LineInput . LineBuffer line_buffer ; do { line_buffer = in . readLineBuffer ( ) ; if ( line_buffer == null ) throw new EOFException ( ) ; } while ( line_buffer . size == 0 ) ; if ( line_buffer . s...
Read the request line and header .
122,751
public void writeRequestLine ( Writer writer ) throws IOException { writer . write ( _method ) ; writer . write ( ' ' ) ; writer . write ( _uri != null ? _uri . toString ( ) : "null" ) ; writer . write ( ' ' ) ; writer . write ( _version ) ; }
Write the HTTP request line as it was received .
122,752
public String getScheme ( ) { String scheme = _uri . getScheme ( ) ; if ( scheme == null && _connection != null ) scheme = _connection . getDefaultScheme ( ) ; return scheme == null ? "http" : scheme ; }
Get the request Scheme . The scheme is obtained from an absolute URI . If the URI in the request is not absolute then the connections default scheme is returned . If there is no connection http is returned .
122,753
public String getHost ( ) { if ( _host != null ) return _host ; _host = _uri . getHost ( ) ; _port = _uri . getPort ( ) ; if ( _host != null ) return _host ; _hostPort = _header . get ( HttpFields . __Host ) ; _host = _hostPort ; _port = 0 ; if ( _host != null && _host . length ( ) > 0 ) { int colon = _host . lastIndex...
Get the request host .
122,754
public int getPort ( ) { if ( _port > 0 ) return _port ; if ( _host != null ) return 0 ; if ( _uri . isAbsolute ( ) ) _port = _uri . getPort ( ) ; else if ( _connection != null ) _port = _connection . getServerPort ( ) ; return _port ; }
Get the request port . The port is obtained either from an absolute URI the HTTP Host header field the connection or the default .
122,755
Object forceRemoveField ( String name ) { int saved_state = _state ; try { _state = __MSG_EDITABLE ; return removeField ( name ) ; } finally { _state = saved_state ; } }
Force a removeField . This call ignores the message state and forces a field to be removed from the request . It is required for the handling of the Connection field .
122,756
public List getAcceptableTransferCodings ( ) { if ( _dotVersion < 1 ) return null ; if ( _te != null ) return _te ; Enumeration tenum = getFieldValues ( HttpFields . __TE , HttpFields . __separators ) ; if ( tenum != null ) { List te = HttpFields . qualityList ( tenum ) ; int size = te . size ( ) ; if ( size > 0 ) { Ob...
Get the acceptable transfer encodings . The TE field is used to construct a list of acceptable extension transfer codings in quality order . An empty list implies that only chunked is acceptable . A null list implies that no transfer coding can be applied .
122,757
public String getParameter ( String name ) { if ( ! _paramsExtracted ) extractParameters ( ) ; return ( String ) _parameters . getValue ( name , 0 ) ; }
Get a parameter value .
122,758
void recycle ( HttpConnection connection ) { _method = null ; _host = null ; _hostPort = null ; _port = 0 ; _te = null ; if ( _parameters != null ) _parameters . clear ( ) ; _paramsExtracted = false ; _handled = false ; _cookiesExtracted = false ; _timeStamp = 0 ; _timeStampStr = null ; _authUser = null ; _authType = n...
Recycle the request .
122,759
public void destroy ( ) { _parameters = null ; _method = null ; _uri = null ; _host = null ; _hostPort = null ; _te = null ; _cookies = null ; _lastCookies = null ; _timeStampStr = null ; _userPrincipal = null ; _authUser = null ; _authUser = null ; if ( _attributes != null ) _attributes . clear ( ) ; super . destroy (...
Destroy the request . Help the garbage collector by null everything that we can .
122,760
public String getHost ( ) { if ( _addr == null ) return __0_0_0_0 ; return _addrIsHost ? _addr . getHostName ( ) : _addr . getHostAddress ( ) ; }
Get the Host .
122,761
public void setHost ( String host ) throws java . net . UnknownHostException { _addr = null ; if ( host != null ) { if ( host . indexOf ( '/' ) > 0 ) host = host . substring ( 0 , host . indexOf ( '/' ) ) ; _addrIsHost = ! Character . isDigit ( ( host . charAt ( 0 ) ) ) ; _addr = InetAddress . getByName ( host ) ; } }
Set the Host .
122,762
public synchronized final void start ( ) throws Exception { if ( _started || _starting ) return ; _starting = true ; if ( log . isDebugEnabled ( ) ) log . debug ( "Starting " + this ) ; LifeCycleEvent event = new LifeCycleEvent ( this ) ; for ( int i = 0 ; i < LazyList . size ( _eventListeners ) ; i ++ ) { EventListene...
Start the server . Generate LifeCycleEvents for starting and started either side of a call to doStart
122,763
public synchronized final void stop ( ) throws InterruptedException { if ( ! _started || _stopping ) return ; _stopping = true ; if ( log . isDebugEnabled ( ) ) log . debug ( "Stopping " + this ) ; LifeCycleEvent event = new LifeCycleEvent ( this ) ; for ( int i = 0 ; i < LazyList . size ( _eventListeners ) ; i ++ ) { ...
Stop the container . Generate LifeCycleEvents for stopping and stopped either side of a call to doStop
122,764
public void addEventListener ( EventListener listener ) throws IllegalArgumentException { if ( _eventListeners == null ) _eventListeners = new ArrayList ( ) ; if ( listener instanceof ComponentListener || listener instanceof LifeCycleListener ) { if ( log . isDebugEnabled ( ) ) log . debug ( "addEventListener: " + list...
Add a server event listener .
122,765
public static boolean isFlag ( int index ) { flags . check ( index ) ; if ( ( index >= 1 && index <= 4 ) || ( index >= 12 ) ) return false ; return true ; }
Indicates if a bit in the flags field is a flag or not . If it s part of the rcode or opcode it s not .
122,766
public synchronized ByteBuffer getBuffer ( ) { ByteBuffer buf = null ; int s = LazyList . size ( _recycle ) ; if ( s > 0 ) { s -- ; buf = ( ByteBuffer ) LazyList . get ( _recycle , s ) ; _recycle = LazyList . remove ( _recycle , s ) ; buf . clear ( ) ; } else { buf = ByteBuffer . allocateDirect ( _bufferSize ) ; } retu...
Get a buffer to write to this InputStream . The buffer wll either be a new direct buffer or a recycled buffer .
122,767
public Table newRow ( ) { unnest ( ) ; nest ( row = new Block ( "tr" ) ) ; if ( _defaultRow != null ) { row . setAttributesFrom ( _defaultRow ) ; if ( _defaultRow . size ( ) > 0 ) row . add ( _defaultRow . contents ( ) ) ; } cell = null ; return this ; }
Create new table row . Attributes set after this call and before a call to newCell or newHeader are considered row attributes .
122,768
public Table spacing ( int h , int v ) { if ( h >= 0 ) attribute ( "hspace" , h ) ; if ( v >= 0 ) attribute ( "vspace" , v ) ; return this ; }
Set horizontal and vertical spacing .
122,769
public static void setCellNestingFactory ( CompositeFactory factory ) { if ( threadNestingMap == null ) threadNestingMap = new Hashtable ( ) ; if ( factory == null ) threadNestingMap . remove ( Thread . currentThread ( ) ) ; else threadNestingMap . put ( Thread . currentThread ( ) , factory ) ; }
Add cell nesting factory . Set the CompositeFactory for this thread . Each new cell in the table added by this thread will have a new Composite from this factory nested in the Cell .
122,770
public void setResourceBase ( String resourceBase ) { try { _resourceBase = Resource . newResource ( resourceBase ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "resourceBase=" + _resourceBase + " for " + this ) ; } catch ( IOException e ) { log . debug ( LogSupport . EXCEPTION , e ) ; throw new IllegalArgumentExcep...
Set the Resource Base . The base resource is the Resource to use as a relative base for all context resources . The ResourceBase attribute is a string version of the baseResource . If a relative file is passed it is converted to a file URL based on the current working directory .
122,771
public Resource getResource ( String pathInContext ) throws IOException { if ( log . isTraceEnabled ( ) ) log . trace ( "getResource " + pathInContext ) ; if ( _resourceBase == null ) return null ; Resource resource = null ; synchronized ( _cache ) { CachedResource cached = ( CachedResource ) _cache . get ( pathInConte...
Get a resource from the context . Cached Resources are returned if the resource fits within the LRU cache . Directories may have CachedResources returned but the caller must use the CachedResource . setCachedData method to set the formatted directory content .
122,772
public String getEncodingByMimeType ( String type ) { String encoding = null ; if ( type != null ) encoding = ( String ) _encodingMap . get ( type ) ; return encoding ; }
Get char encoding by mime type .
122,773
public ResourceMetaData getResourceMetaData ( Resource resource ) { Object o = resource . getAssociate ( ) ; if ( o instanceof ResourceMetaData ) return ( ResourceMetaData ) o ; return new ResourceMetaData ( resource ) ; }
Get Resource MetaData .
122,774
public int compare ( Version other ) { if ( other == null ) throw new NullPointerException ( "other version is null" ) ; if ( this . _version < other . _version ) return - 1 ; if ( this . _version > other . _version ) return 1 ; if ( this . _revision < other . _revision ) return - 1 ; if ( this . _revision > other . _r...
Compares with other version . Does not take extension into account as there is no reliable way to order them .
122,775
private void findWin ( InputStream in ) { String packageName = ResolverConfig . class . getPackage ( ) . getName ( ) ; String resPackageName = packageName + ".windows.DNSServer" ; ResourceBundle res = ResourceBundle . getBundle ( resPackageName ) ; String host_name = res . getString ( "host_name" ) ; String primary_dns...
Parses the output of winipcfg or ipconfig .
122,776
void complete ( ) { _file = _stack [ _top ] . getFileName ( ) + ":" + _stack [ _top ] . getLineNumber ( ) ; _method = _stack [ _top ] . getClassName ( ) + "." + _stack [ _top ] . getMethodName ( ) ; _depth = _stack . length - _top ; _thread = Thread . currentThread ( ) . getName ( ) ; }
Complete partial constructor .
122,777
public InetAddress [ ] lookupAllHostAddr ( String host ) throws UnknownHostException { Name name = null ; try { name = new Name ( host ) ; } catch ( TextParseException e ) { throw new UnknownHostException ( host ) ; } Record [ ] records = null ; if ( preferV6 ) records = new Lookup ( name , Type . AAAA ) . run ( ) ; if...
Performs a forward DNS lookup for the host name .
122,778
public String getHostByAddr ( byte [ ] addr ) throws UnknownHostException { Name name = ReverseMap . fromAddress ( InetAddress . getByAddress ( addr ) ) ; Record [ ] records = new Lookup ( name , Type . PTR ) . run ( ) ; if ( records == null ) throw new UnknownHostException ( ) ; return ( ( PTRRecord ) records [ 0 ] ) ...
Performs a reverse DNS lookup .
122,779
public static String getThumbprint ( final X509Certificate cert ) throws CertificateEncodingException { if ( cert == null ) { return null ; } byte [ ] rawOctets = cert . getEncoded ( ) ; SHA1Digest digest = new SHA1Digest ( ) ; byte [ ] digestOctets = new byte [ digest . getDigestSize ( ) ] ; digest . update ( rawOctet...
Generates a SHA1 thumbprint of a certificate for long - term mapping .
122,780
public synchronized Node parse ( String url ) throws IOException , SAXException { if ( log . isDebugEnabled ( ) ) log . debug ( "parse: " + url ) ; return parse ( new InputSource ( url ) ) ; }
Parse string URL .
122,781
public synchronized Node parse ( File file ) throws IOException , SAXException { if ( log . isDebugEnabled ( ) ) log . debug ( "parse: " + file ) ; return parse ( new InputSource ( file . toURL ( ) . toString ( ) ) ) ; }
Parse File .
122,782
public synchronized Node parse ( InputStream in ) throws IOException , SAXException { Handler handler = new Handler ( ) ; XMLReader reader = _parser . getXMLReader ( ) ; reader . setContentHandler ( handler ) ; reader . setErrorHandler ( handler ) ; reader . setEntityResolver ( handler ) ; _parser . parse ( new InputSo...
Parse InputStream .
122,783
public synchronized Node parse ( URL url ) throws IOException , SAXException { Node n = null ; InputStream is = url . openStream ( ) ; try { n = parse ( is ) ; } finally { try { is . close ( ) ; } catch ( Exception e ) { } } return n ; }
Parse URL .
122,784
public void initialize ( HttpContext context ) { if ( _context == null ) _context = context ; else if ( _context != context ) throw new IllegalStateException ( "Can't initialize handler for different context" ) ; }
Initialize with a HttpContext . Called by addHandler methods of HttpContext .
122,785
public synchronized ObjectName uniqueObjectName ( MBeanServer server , String on ) { ObjectName oName = null ; try { oName = new ObjectName ( on + ",config=" + _config . getClass ( ) . getName ( ) ) ; } catch ( Exception e ) { log . warn ( LogSupport . EXCEPTION , e ) ; } return oName ; }
uniqueObjectName Make a unique jmx name for this configuration object
122,786
public static void setLogStdErr ( boolean log ) { if ( log ) { if ( ! ( System . err instanceof LogStream ) ) System . setErr ( new LogStream . STDERR ( ) ) ; } else System . setErr ( STDERR_STREAM ) ; }
Log standard error stream . If set to true output to stderr will be directed to an instance of LogStream and logged . Beware of log loops from logs that write to stderr .
122,787
public static void setLogStdOut ( boolean log ) { if ( log ) { if ( ! ( System . out instanceof LogStream ) ) System . setOut ( new LogStream . STDOUT ( ) ) ; } else System . setOut ( STDOUT_STREAM ) ; }
Log standard output stream . If set to true output to stdout will be directed to an instance of LogStream and logged . Beware of log loops from logs that write to stdout .
122,788
public Enumeration getFieldValues ( String name , String separators ) { return _header . getValues ( name , separators ) ; }
Get a multi valued message field . Get a field from a message header .
122,789
public void setIntField ( String name , int value ) { if ( _state != __MSG_EDITABLE ) return ; _header . put ( name , TypeUtil . toString ( value ) ) ; }
Sets the value of an integer field . Header or Trailer fields are set depending on message state .
122,790
public void addIntField ( String name , int value ) { if ( _state != __MSG_EDITABLE ) return ; _header . add ( name , TypeUtil . toString ( value ) ) ; }
Adds the value of an integer field . Header or Trailer fields are set depending on message state .
122,791
public void addDateField ( String name , Date date ) { if ( _state != __MSG_EDITABLE ) return ; _header . addDateField ( name , date ) ; }
Adds the value of a date field . Header or Trailer fields are set depending on message state .
122,792
public void setDateField ( String name , long date ) { if ( _state != __MSG_EDITABLE ) return ; _header . putDateField ( name , date ) ; }
Sets the value of a date field . Header or Trailer fields are set depending on message state .
122,793
public void setVersion ( String version ) { if ( _state != __MSG_EDITABLE ) throw new IllegalStateException ( "Not EDITABLE" ) ; if ( version . equalsIgnoreCase ( __HTTP_1_1 ) ) { _dotVersion = 1 ; _version = __HTTP_1_1 ; } else if ( version . equalsIgnoreCase ( __HTTP_1_0 ) ) { _dotVersion = 0 ; _version = __HTTP_1_0 ...
Set the request version
122,794
public void setCharacterEncoding ( String encoding , boolean setField ) { if ( isCommitted ( ) ) return ; if ( encoding == null ) { if ( _characterEncoding != null ) { _characterEncoding = null ; if ( setField ) _header . put ( HttpFields . __ContentType , _mimeType ) ; } } else { _characterEncoding = encoding ; if ( s...
Set Character Encoding .
122,795
void recycle ( HttpConnection connection ) { _state = __MSG_EDITABLE ; _version = __HTTP_1_1 ; _dotVersion = 1 ; _header . clear ( ) ; _connection = connection ; _characterEncoding = null ; _mimeType = null ; if ( _attributes != null ) _attributes . clear ( ) ; }
Recycle the message .
122,796
public Object getAttribute ( String name ) { if ( _attributes == null ) return null ; return _attributes . get ( name ) ; }
Get a request attribute .
122,797
public Object setAttribute ( String name , Object attribute ) { if ( _attributes == null ) _attributes = new HashMap ( 11 ) ; return _attributes . put ( name , attribute ) ; }
Set a request attribute .
122,798
public Enumeration getAttributeNames ( ) { if ( _attributes == null ) return Collections . enumeration ( Collections . EMPTY_LIST ) ; return Collections . enumeration ( _attributes . keySet ( ) ) ; }
Get Attribute names .
122,799
public synchronized Object put ( Object name , Object value ) { if ( _initParams == null ) _initParams = new HashMap ( 3 ) ; return _initParams . put ( name , value ) ; }
Map put method . FilterHolder implements the Map interface as a configuration conveniance . The methods are mapped to the filter properties .