idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
40,300 | public String getHost ( ) { if ( _addr == null ) return __0_0_0_0 ; return _addrIsHost ? _addr . getHostName ( ) : _addr . getHostAddress ( ) ; } | Get the Host . |
40,301 | 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 . |
40,302 | 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 ++ ) { EventListener listener = ( EventListener ) LazyList . get ( _eventListeners , i ) ; if ( listener instanceof LifeCycleListener ) ( ( LifeCycleListener ) listener ) . lifeCycleStarting ( event ) ; } try { doStart ( ) ; _started = true ; log . info ( "Started " + this ) ; for ( int i = 0 ; i < LazyList . size ( _eventListeners ) ; i ++ ) { EventListener listener = ( EventListener ) LazyList . get ( _eventListeners , i ) ; if ( listener instanceof LifeCycleListener ) ( ( LifeCycleListener ) listener ) . lifeCycleStarted ( event ) ; } } catch ( Throwable e ) { LifeCycleEvent failed = new LifeCycleEvent ( this , e ) ; for ( int i = 0 ; i < LazyList . size ( _eventListeners ) ; i ++ ) { EventListener listener = ( EventListener ) LazyList . get ( _eventListeners , i ) ; if ( listener instanceof LifeCycleListener ) ( ( LifeCycleListener ) listener ) . lifeCycleFailure ( event ) ; } if ( e instanceof Exception ) throw ( Exception ) e ; if ( e instanceof RuntimeException ) throw ( RuntimeException ) e ; if ( e instanceof Error ) throw ( Error ) e ; log . warn ( LogSupport . EXCEPTION , e ) ; } finally { _starting = false ; } } | Start the server . Generate LifeCycleEvents for starting and started either side of a call to doStart |
40,303 | 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 ++ ) { EventListener listener = ( EventListener ) LazyList . get ( _eventListeners , i ) ; if ( listener instanceof LifeCycleListener ) ( ( LifeCycleListener ) listener ) . lifeCycleStopping ( event ) ; } try { doStop ( ) ; _started = false ; log . info ( "Stopped " + this ) ; for ( int i = 0 ; i < LazyList . size ( _eventListeners ) ; i ++ ) { EventListener listener = ( EventListener ) LazyList . get ( _eventListeners , i ) ; if ( listener instanceof LifeCycleListener ) ( ( LifeCycleListener ) listener ) . lifeCycleStopped ( event ) ; } } catch ( Throwable e ) { event = new LifeCycleEvent ( this , e ) ; for ( int i = 0 ; i < LazyList . size ( _eventListeners ) ; i ++ ) { EventListener listener = ( EventListener ) LazyList . get ( _eventListeners , i ) ; if ( listener instanceof LifeCycleListener ) ( ( LifeCycleListener ) listener ) . lifeCycleFailure ( event ) ; } if ( e instanceof InterruptedException ) throw ( InterruptedException ) e ; if ( e instanceof RuntimeException ) throw ( RuntimeException ) e ; if ( e instanceof Error ) throw ( Error ) e ; log . warn ( LogSupport . EXCEPTION , e ) ; } finally { _stopping = false ; } } | Stop the container . Generate LifeCycleEvents for stopping and stopped either side of a call to doStop |
40,304 | 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: " + listener ) ; _eventListeners = LazyList . add ( _eventListeners , listener ) ; } } | Add a server event listener . |
40,305 | 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 . |
40,306 | 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 ) ; } return buf ; } | Get a buffer to write to this InputStream . The buffer wll either be a new direct buffer or a recycled buffer . |
40,307 | 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 . |
40,308 | 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 . |
40,309 | 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 . |
40,310 | 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 IllegalArgumentException ( resourceBase + ":" + e . toString ( ) ) ; } } | 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 . |
40,311 | 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 ( pathInContext ) ; if ( cached != null ) { if ( log . isTraceEnabled ( ) ) log . trace ( "CACHE HIT: " + cached ) ; CachedMetaData cmd = ( CachedMetaData ) cached . getAssociate ( ) ; if ( cmd != null && cmd . isValid ( ) ) return cached ; } resource = _resourceBase . addPath ( _resourceBase . encode ( pathInContext ) ) ; if ( log . isTraceEnabled ( ) ) log . trace ( "CACHE MISS: " + resource ) ; if ( resource == null ) return null ; if ( resource . getAlias ( ) != null ) { log . warn ( "Alias request of '" + resource . getAlias ( ) + "' for '" + resource + "'" ) ; return null ; } long len = resource . length ( ) ; if ( resource . exists ( ) ) { if ( ! resource . isDirectory ( ) && pathInContext . endsWith ( "/" ) ) return null ; if ( resource . isDirectory ( ) ) { if ( resource . list ( ) != null ) len = resource . list ( ) . length * 100 ; else len = 0 ; } if ( len > 0 && len < _maxCachedFileSize && len < _maxCacheSize ) { int needed = _maxCacheSize - ( int ) len ; while ( _cacheSize > needed ) _leastRecentlyUsed . invalidate ( ) ; cached = resource . cache ( ) ; if ( log . isTraceEnabled ( ) ) log . trace ( "CACHED: " + resource ) ; new CachedMetaData ( cached , pathInContext ) ; return cached ; } } } new ResourceMetaData ( resource ) ; return resource ; } | 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 . |
40,312 | public String getEncodingByMimeType ( String type ) { String encoding = null ; if ( type != null ) encoding = ( String ) _encodingMap . get ( type ) ; return encoding ; } | Get char encoding by mime type . |
40,313 | public ResourceMetaData getResourceMetaData ( Resource resource ) { Object o = resource . getAssociate ( ) ; if ( o instanceof ResourceMetaData ) return ( ResourceMetaData ) o ; return new ResourceMetaData ( resource ) ; } | Get Resource MetaData . |
40,314 | 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 . _revision ) return 1 ; if ( this . _subrevision < other . _subrevision ) return - 1 ; if ( this . _subrevision > other . _subrevision ) return 1 ; return 0 ; } | Compares with other version . Does not take extension into account as there is no reliable way to order them . |
40,315 | 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_suffix = res . getString ( "primary_dns_suffix" ) ; String dns_suffix = res . getString ( "dns_suffix" ) ; String dns_servers = res . getString ( "dns_servers" ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( in ) ) ; try { List lserver = new ArrayList ( ) ; List lsearch = new ArrayList ( ) ; String line = null ; boolean readingServers = false ; boolean readingSearches = false ; while ( ( line = br . readLine ( ) ) != null ) { StringTokenizer st = new StringTokenizer ( line ) ; if ( ! st . hasMoreTokens ( ) ) { readingServers = false ; readingSearches = false ; continue ; } String s = st . nextToken ( ) ; if ( line . indexOf ( ":" ) != - 1 ) { readingServers = false ; readingSearches = false ; } if ( line . indexOf ( host_name ) != - 1 ) { while ( st . hasMoreTokens ( ) ) s = st . nextToken ( ) ; Name name ; try { name = Name . fromString ( s , null ) ; } catch ( TextParseException e ) { continue ; } if ( name . labels ( ) == 1 ) continue ; addSearch ( s , lsearch ) ; } else if ( line . indexOf ( primary_dns_suffix ) != - 1 ) { while ( st . hasMoreTokens ( ) ) s = st . nextToken ( ) ; if ( s . equals ( ":" ) ) continue ; addSearch ( s , lsearch ) ; readingSearches = true ; } else if ( readingSearches || line . indexOf ( dns_suffix ) != - 1 ) { while ( st . hasMoreTokens ( ) ) s = st . nextToken ( ) ; if ( s . equals ( ":" ) ) continue ; addSearch ( s , lsearch ) ; readingSearches = true ; } else if ( readingServers || line . indexOf ( dns_servers ) != - 1 ) { while ( st . hasMoreTokens ( ) ) s = st . nextToken ( ) ; if ( s . equals ( ":" ) ) continue ; addServer ( s , lserver ) ; readingServers = true ; } } configureFromLists ( lserver , lsearch ) ; } catch ( IOException e ) { } finally { try { br . close ( ) ; } catch ( IOException e ) { } } return ; } | Parses the output of winipcfg or ipconfig . |
40,316 | 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 . |
40,317 | 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 ( records == null ) records = new Lookup ( name , Type . A ) . run ( ) ; if ( records == null && ! preferV6 ) records = new Lookup ( name , Type . AAAA ) . run ( ) ; if ( records == null ) throw new UnknownHostException ( host ) ; InetAddress [ ] array = new InetAddress [ records . length ] ; for ( int i = 0 ; i < records . length ; i ++ ) { Record record = records [ i ] ; if ( records [ i ] instanceof ARecord ) { ARecord a = ( ARecord ) records [ i ] ; array [ i ] = a . getAddress ( ) ; } else { AAAARecord aaaa = ( AAAARecord ) records [ i ] ; array [ i ] = aaaa . getAddress ( ) ; } } return array ; } | Performs a forward DNS lookup for the host name . |
40,318 | 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 ] ) . getTarget ( ) . toString ( ) ; } | Performs a reverse DNS lookup . |
40,319 | 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 ( rawOctets , 0 , rawOctets . length ) ; digest . doFinal ( digestOctets , 0 ) ; return new String ( Base64 . encode ( digestOctets ) ) ; } | Generates a SHA1 thumbprint of a certificate for long - term mapping . |
40,320 | public synchronized Node parse ( String url ) throws IOException , SAXException { if ( log . isDebugEnabled ( ) ) log . debug ( "parse: " + url ) ; return parse ( new InputSource ( url ) ) ; } | Parse string URL . |
40,321 | 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 . |
40,322 | 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 InputSource ( in ) , handler ) ; if ( handler . _error != null ) throw handler . _error ; Node doc = ( Node ) handler . _top . get ( 0 ) ; handler . clear ( ) ; return doc ; } | Parse InputStream . |
40,323 | 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 . |
40,324 | 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 . |
40,325 | 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 |
40,326 | 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 . |
40,327 | 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 . |
40,328 | 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 . |
40,329 | 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 . |
40,330 | 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 . |
40,331 | 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 . |
40,332 | 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 . |
40,333 | 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 ; } else if ( version . equalsIgnoreCase ( __HTTP_0_9 ) ) { _dotVersion = - 1 ; _version = __HTTP_0_9 ; } else throw new IllegalArgumentException ( "Unknown version" ) ; } | Set the request version |
40,334 | 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 ( setField && _mimeType != null ) { _header . put ( HttpFields . __ContentType , _mimeType + ";charset=" + QuotedStringTokenizer . quote ( _characterEncoding , ";= " ) ) ; } } } | Set Character Encoding . |
40,335 | 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 . |
40,336 | public Object getAttribute ( String name ) { if ( _attributes == null ) return null ; return _attributes . get ( name ) ; } | Get a request attribute . |
40,337 | public Object setAttribute ( String name , Object attribute ) { if ( _attributes == null ) _attributes = new HashMap ( 11 ) ; return _attributes . put ( name , attribute ) ; } | Set a request attribute . |
40,338 | public Enumeration getAttributeNames ( ) { if ( _attributes == null ) return Collections . enumeration ( Collections . EMPTY_LIST ) ; return Collections . enumeration ( _attributes . keySet ( ) ) ; } | Get Attribute names . |
40,339 | 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 . |
40,340 | public synchronized Object get ( Object name ) { if ( _initParams == null ) return null ; return _initParams . get ( name ) ; } | Map get method . FilterHolder implements the Map interface as a configuration conveniance . The methods are mapped to the filter properties . |
40,341 | public Enumeration getFieldNames ( ) { return new Enumeration ( ) { int i = 0 ; Field field = null ; public boolean hasMoreElements ( ) { if ( field != null ) return true ; while ( i < _fields . size ( ) ) { Field f = ( Field ) _fields . get ( i ++ ) ; if ( f != null && f . _version == _version && f . _prev == null ) { field = f ; return true ; } } return false ; } public Object nextElement ( ) throws NoSuchElementException { if ( field != null || hasMoreElements ( ) ) { String n = field . _info . _name ; field = null ; return n ; } throw new NoSuchElementException ( ) ; } } ; } | Get enumeration of header _names . Returns an enumeration of strings representing the header _names for this request . |
40,342 | public int getIntField ( String name ) throws NumberFormatException { String val = valueParameters ( get ( name ) , null ) ; if ( val != null ) return Integer . parseInt ( val ) ; return - 1 ; } | Get a header as an integer value . Returns the value of an integer field or - 1 if not found . The case of the field name is ignored . |
40,343 | public void addDateField ( String name , long date ) { if ( _dateBuffer == null ) { _dateBuffer = new StringBuffer ( 32 ) ; _calendar = new HttpCal ( ) ; } _dateBuffer . setLength ( 0 ) ; _calendar . setTimeInMillis ( date ) ; formatDate ( _dateBuffer , _calendar , false ) ; add ( name , _dateBuffer . toString ( ) ) ; } | Adds the value of a date field . |
40,344 | public void clear ( ) { _version ++ ; if ( _version > 1000 ) { _version = 0 ; for ( int i = _fields . size ( ) ; i -- > 0 ; ) { Field field = ( Field ) _fields . get ( i ) ; if ( field != null ) field . clear ( ) ; } } } | Clear the header . |
40,345 | public void destroy ( ) { for ( int i = _fields . size ( ) ; i -- > 0 ; ) { Field field = ( Field ) _fields . get ( i ) ; if ( field != null ) field . destroy ( ) ; } _fields = null ; _index = null ; _dateBuffer = null ; _calendar = null ; _dateReceive = null ; } | Destroy the header . Help the garbage collector by null everything that we can . |
40,346 | public void addSetCookie ( Cookie cookie ) { String name = cookie . getName ( ) ; String value = cookie . getValue ( ) ; int version = cookie . getVersion ( ) ; if ( name == null || name . length ( ) == 0 ) throw new IllegalArgumentException ( "Bad cookie name" ) ; StringBuffer buf = new StringBuffer ( 128 ) ; String name_value_params = null ; synchronized ( buf ) { buf . append ( name ) ; buf . append ( '=' ) ; if ( value != null && value . length ( ) > 0 ) { if ( version == 0 ) URI . encodeString ( buf , value , "\";, '" ) ; else buf . append ( QuotedStringTokenizer . quote ( value , "\";, '" ) ) ; } if ( version > 0 ) { buf . append ( ";Version=" ) ; buf . append ( version ) ; String comment = cookie . getComment ( ) ; if ( comment != null && comment . length ( ) > 0 ) { buf . append ( ";Comment=" ) ; QuotedStringTokenizer . quote ( buf , comment ) ; } } String path = cookie . getPath ( ) ; if ( path != null && path . length ( ) > 0 ) { buf . append ( ";Path=" ) ; buf . append ( path ) ; } String domain = cookie . getDomain ( ) ; if ( domain != null && domain . length ( ) > 0 ) { buf . append ( ";Domain=" ) ; buf . append ( domain . toLowerCase ( ) ) ; } long maxAge = cookie . getMaxAge ( ) ; if ( maxAge >= 0 ) { if ( version == 0 ) { buf . append ( ";Expires=" ) ; if ( maxAge == 0 ) buf . append ( __01Jan1970 ) ; else formatDate ( buf , System . currentTimeMillis ( ) + 1000L * maxAge , true ) ; } else { buf . append ( ";Max-Age=" ) ; buf . append ( cookie . getMaxAge ( ) ) ; } } else if ( version > 0 ) { buf . append ( ";Discard" ) ; } if ( cookie . getSecure ( ) ) { buf . append ( ";Secure" ) ; } if ( cookie instanceof HttpOnlyCookie ) buf . append ( ";HttpOnly" ) ; name_value_params = buf . toString ( ) ; } put ( __Expires , __01Jan1970 ) ; add ( __SetCookie , name_value_params ) ; } | Format a set cookie value |
40,347 | public void add ( HttpFields fields ) { if ( fields == null ) return ; Enumeration enm = fields . getFieldNames ( ) ; while ( enm . hasMoreElements ( ) ) { String name = ( String ) enm . nextElement ( ) ; Enumeration values = fields . getValues ( name ) ; while ( values . hasMoreElements ( ) ) add ( name , ( String ) values . nextElement ( ) ) ; } } | Add fields from another HttpFields instance . Single valued fields are replaced while all others are added . |
40,348 | public void readHeader ( HttpInputStream in ) throws IOException { _state = __MSG_BAD ; log . warn ( LogSupport . NOT_IMPLEMENTED ) ; } | Not Implemented . |
40,349 | public void sendError ( int code , String message ) throws IOException { setStatus ( code , message ) ; HttpRequest request = getHttpRequest ( ) ; if ( code != __204_No_Content && code != __304_Not_Modified && code != __206_Partial_Content && code >= 200 ) { if ( getHttpContext ( ) != null ) { Object o = getHttpContext ( ) . getAttribute ( HttpContext . __ErrorHandler ) ; if ( o != null && o instanceof HttpHandler ) ( ( HttpHandler ) o ) . handle ( request . getPath ( ) , null , request , this ) ; } } else if ( code != __206_Partial_Content ) { _header . remove ( HttpFields . __ContentType ) ; _header . remove ( HttpFields . __ContentLength ) ; _characterEncoding = null ; _mimeType = null ; } commit ( ) ; } | Send Error Response . |
40,350 | public void addSetCookie ( String name , String value ) { _header . addSetCookie ( new Cookie ( name , value ) ) ; } | Add a Set - Cookie field . |
40,351 | void recycle ( HttpConnection connection ) { super . recycle ( connection ) ; _status = __200_OK ; _reason = null ; _httpContext = null ; } | Recycle the response . |
40,352 | public void configure ( String configuration ) throws IOException { URL url = Resource . newResource ( configuration ) . getURL ( ) ; if ( _configuration != null && _configuration . equals ( url . toString ( ) ) ) return ; if ( _configuration != null ) throw new IllegalStateException ( "Already configured with " + _configuration ) ; try { XmlConfiguration config = new XmlConfiguration ( url ) ; _configuration = url . toString ( ) ; config . configure ( this ) ; } catch ( IOException e ) { throw e ; } catch ( Exception e ) { log . warn ( LogSupport . EXCEPTION , e ) ; throw new IOException ( "Jetty configuration problem: " + e ) ; } } | Configure the server from an XML file . |
40,353 | public void setWebApplicationConfigurationClassNames ( String [ ] configurationClassNames ) { if ( configurationClassNames != null ) { _webAppConfigurationClassNames = new String [ configurationClassNames . length ] ; System . arraycopy ( configurationClassNames , 0 , _webAppConfigurationClassNames , 0 , configurationClassNames . length ) ; } } | setWebApplicationConfigurationClasses Set up the list of classnames of WebApplicationContext . Configuration implementations that will be applied to configure every webapp . The list can be overridden by individual WebApplicationContexts . |
40,354 | public void addText ( String label , String value ) { Composite c = new Composite ( ) ; c . add ( value ) ; addField ( label , c ) ; } | Add an informational section . |
40,355 | public Input addTextField ( String tag , String label , int length , String value ) { Input i = new Input ( Input . Text , tag , value ) ; i . setSize ( length ) ; addField ( label , i ) ; return i ; } | Add a Text Entry Field . |
40,356 | public TextArea addTextArea ( String tag , String label , int width , int height , String value ) { TextArea ta = new TextArea ( tag , value ) ; ta . setSize ( width , height ) ; addField ( label , ta ) ; return ta ; } | Add a Text Area . |
40,357 | public Input addFileField ( String tag , String label ) { Input i = new Input ( Input . File , tag ) ; addField ( label , i ) ; return i ; } | Add a File Entry Field . |
40,358 | public void addInfoField ( String tag , String label , String value ) { addText ( label , value ) ; addHiddenField ( tag , value ) ; } | Add an informational field which also passes the data as hidden . |
40,359 | public void addHiddenField ( String tag , String value ) { Element e = new Input ( Input . Hidden , tag , value ) ; hidden . add ( e ) ; } | Add a hidden field . |
40,360 | public void addPassword ( String tag , String label , int length ) { Input i = new Input ( Input . Password , tag ) ; i . setSize ( length ) ; addField ( label , i ) ; } | Add a password field . |
40,361 | public Select addSelect ( String tag , String label , boolean multiple , int size ) { Select s = new Select ( tag , multiple ) ; s . setSize ( size ) ; addField ( label , s ) ; return s ; } | Add a Select field . |
40,362 | public Select addSelect ( String tag , String label , boolean multiple , int size , Enumeration values ) { Select s = addSelect ( tag , label , multiple , size ) ; s . setSize ( size ) ; while ( values . hasMoreElements ( ) ) s . add ( values . nextElement ( ) . toString ( ) ) ; return s ; } | Add a Select field initialised with fields . |
40,363 | public Input addButton ( String tag , String label ) { if ( buttons == null ) buttonsAtBottom ( ) ; Input e = new Input ( Input . Submit , tag , label ) ; if ( extendRow ) addField ( null , e ) ; else buttons . add ( e ) ; return e ; } | Add a Submit Button . |
40,364 | public void addReset ( String label ) { if ( buttons == null ) buttonsAtBottom ( ) ; Element e = new Input ( Input . Reset , "Reset" , label ) ; if ( extendRow ) addField ( null , e ) ; else buttons . add ( e ) ; } | Add a reset button . |
40,365 | public void addField ( String label , Element field ) { if ( label == null ) label = " " ; else label = "<b>" + label + ":</b>" ; if ( extendRow ) { column . add ( field ) ; extendRow = false ; } else { column . newRow ( ) ; column . addCell ( label ) ; column . cell ( ) . right ( ) ; if ( fieldAttributes != null ) { column . addCell ( field , fieldAttributes ) ; fieldAttributes = null ; } else column . addCell ( field ) ; } } | Add an arbitrary element to the table . |
40,366 | public void addColumn ( int spacing ) { table . addCell ( " " , "width=" + spacing ) ; column = new Table ( 0 ) ; table . addCell ( column ) ; table . cell ( ) . top ( ) ; columns ++ ; } | Create a new column in the form . |
40,367 | public void newColumns ( ) { column = new Table ( 0 ) ; columns = 1 ; table . newRow ( ) ; table . addCell ( column ) ; table . cell ( ) . top ( ) ; } | Add a new sections of columns . |
40,368 | public void newTable ( ) { table = new Table ( 0 ) ; column = new Table ( 0 ) ; columns = 1 ; super . add ( table ) ; table . newRow ( ) ; table . addCell ( column ) . top ( ) ; } | Start using a new Table . Anything added to the Composite parent of this object before this is called will be added between the two tables . |
40,369 | public final boolean isSecure ( Socket sock ) throws IllegalArgumentException { if ( sock == null ) { throw new IllegalArgumentException ( "Socket may not be null." ) ; } if ( sock . isClosed ( ) ) { throw new IllegalArgumentException ( "Socket is closed." ) ; } return false ; } | Checks whether a socket connection is secure . This factory creates plain socket connections which are not considered secure . |
40,370 | public synchronized void release ( ) { if ( _in != null ) { try { _in . close ( ) ; } catch ( IOException e ) { LogSupport . ignore ( log , e ) ; } _in = null ; } if ( _connection != null ) _connection = null ; } | Release any resources held by the resource . |
40,371 | public boolean exists ( ) { try { synchronized ( this ) { if ( checkConnection ( ) && _in == null ) _in = _connection . getInputStream ( ) ; } } catch ( IOException e ) { LogSupport . ignore ( log , e ) ; } return _in != null ; } | Returns true if the respresened resource exists . |
40,372 | public File getFile ( ) throws IOException { if ( checkConnection ( ) ) { Permission perm = _connection . getPermission ( ) ; if ( perm instanceof java . io . FilePermission ) return new File ( perm . getName ( ) ) ; } try { return new File ( _url . getFile ( ) ) ; } catch ( Exception e ) { LogSupport . ignore ( log , e ) ; } return null ; } | Returns an File representing the given resource or NULL if this is not possible . |
40,373 | public synchronized InputStream getInputStream ( ) throws java . io . IOException { if ( ! checkConnection ( ) ) throw new IOException ( "Invalid resource" ) ; try { if ( _in != null ) { InputStream in = _in ; _in = null ; return in ; } return _connection . getInputStream ( ) ; } finally { _connection = null ; } } | Returns an input stream to the resource |
40,374 | public Resource addPath ( String path ) throws IOException , MalformedURLException { if ( path == null ) return null ; path = URI . canonicalPath ( path ) ; return newResource ( URI . addPaths ( _url . toExternalForm ( ) , path ) ) ; } | Returns the resource contained inside the current resource with the given name |
40,375 | public synchronized ServletHandler getServletHandler ( ) { if ( _servletHandler == null ) _servletHandler = ( ServletHandler ) getHandler ( ServletHandler . class ) ; if ( _servletHandler == null ) { _servletHandler = new ServletHandler ( ) ; addHandler ( _servletHandler ) ; } return _servletHandler ; } | Get the context ServletHandler . Conveniance method . If no ServletHandler exists a new one is added to the context . |
40,376 | public synchronized ServletHolder addServlet ( String pathSpec , String className ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { return addServlet ( className , pathSpec , className ) ; } | Add a servlet to the context . Conveniance method . If no ServletHandler is found in the context a new one is added . |
40,377 | public synchronized ServletHolder addServlet ( String name , String pathSpec , String className ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { return getServletHandler ( ) . addServlet ( name , pathSpec , className , null ) ; } | Add a servlet to the context . If no ServletHandler is found in the context a new one is added . |
40,378 | public String getLocaleEncoding ( Locale locale ) { String encoding = ( String ) _localeEncodingMap . get ( locale . toString ( ) ) ; if ( encoding == null ) encoding = ( String ) _localeEncodingMap . get ( locale . getLanguage ( ) ) ; return encoding ; } | Get the character encoding for a locale . The full locale name is first looked up in the map of encodings . If no encoding is found then the locale language is looked up . |
40,379 | public Map . Entry getEntry ( String key , int offset , int length ) { if ( key == null ) return _nullEntry ; Node node = _root ; int ni = - 1 ; charLoop : for ( int i = 0 ; i < length ; i ++ ) { char c = key . charAt ( offset + i ) ; if ( ni == - 1 ) { ni = 0 ; node = ( node . _children == null ) ? null : node . _children [ c % _width ] ; } while ( node != null ) { if ( node . _char [ ni ] == c || _ignoreCase && node . _ochar [ ni ] == c ) { ni ++ ; if ( ni == node . _char . length ) ni = - 1 ; continue charLoop ; } if ( ni > 0 ) return null ; node = node . _next ; } return null ; } if ( ni > 0 ) return null ; if ( node != null && node . _key == null ) return null ; return node ; } | Get a map entry by substring key . |
40,380 | public static void recursivelyDeleteDir ( File customProfileDir ) { if ( customProfileDir == null || ! customProfileDir . exists ( ) ) { return ; } Delete delete = new Delete ( ) ; delete . setProject ( new Project ( ) ) ; delete . setDir ( customProfileDir ) ; delete . setFailOnError ( true ) ; delete . execute ( ) ; } | Delete a directory and all subdirectories |
40,381 | public void flush ( ) throws IOException { try { if ( ! _commited ) { _commited = true ; if ( _commitObserver != null ) _commitObserver . outputNotify ( this , OutputObserver . __COMMITING , null ) ; } wrapBuffer ( ) ; if ( _httpMessageWriter . size ( ) > 0 ) { prewrite ( _httpMessageWriter . getBuf ( ) , 0 , _httpMessageWriter . size ( ) ) ; _httpMessageWriter . resetWriter ( ) ; } if ( size ( ) > 0 ) writeTo ( _out ) ; } catch ( IOException e ) { throw new EOFException ( e ) ; } finally { reset ( _preReserve ) ; } } | This implementation calls the commitObserver on the first flush since construction or reset . |
40,382 | public synchronized void reset ( ) { info ( "reset" ) ; if ( _sinks != null ) { for ( int s = _sinks . length ; s -- > 0 ; ) { try { if ( _sinks [ s ] != null ) _sinks [ s ] . stop ( ) ; _sinks [ s ] = null ; } catch ( InterruptedException e ) { if ( getDebug ( ) && getVerbose ( ) > 0 ) message ( "WARN" , e ) ; } } _sinks = null ; } _initialized = true ; } | No logging . All log sinks are stopped and removed . |
40,383 | public synchronized void message ( String tag , Object msg , Frame frame , long time ) { if ( ! _initialized ) defaultInit ( ) ; boolean logged = false ; if ( _sinks != null ) { for ( int s = _sinks . length ; s -- > 0 ; ) { if ( _sinks [ s ] == null ) continue ; if ( _sinks [ s ] . isStarted ( ) ) { logged = true ; _sinks [ s ] . log ( tag , msg , frame , time ) ; } } } if ( ! logged ) System . err . println ( time + ": " + tag + ":" + msg + " @ " + frame ) ; } | Log a message . |
40,384 | public synchronized void setDebug ( boolean debug ) { boolean oldDebug = _debugOn ; if ( _debugOn && ! debug ) this . message ( DEBUG , "DEBUG OFF" ) ; _debugOn = debug ; if ( ! oldDebug && debug ) this . message ( DEBUG , "DEBUG ON" ) ; } | Set if debugging is on or off . |
40,385 | public void setDebugPatterns ( String patterns ) { _patterns = patterns ; if ( patterns != null && patterns . length ( ) > 0 ) { _debugPatterns = new ArrayList ( ) ; StringTokenizer tok = new StringTokenizer ( patterns , ", \t" ) ; while ( tok . hasMoreTokens ( ) ) { String pattern = tok . nextToken ( ) ; _debugPatterns . add ( pattern ) ; } } else _debugPatterns = null ; } | Set debug patterns . |
40,386 | public synchronized String encode ( String charset , boolean equalsForNullValue ) { if ( charset == null ) charset = StringUtil . __ISO_8859_1 ; StringBuffer result = new StringBuffer ( 128 ) ; synchronized ( result ) { Iterator iter = entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; String key = entry . getKey ( ) . toString ( ) ; Object list = entry . getValue ( ) ; int s = LazyList . size ( list ) ; if ( s == 0 ) { result . append ( encodeString ( key , charset ) ) ; if ( equalsForNullValue ) result . append ( '=' ) ; } else { for ( int i = 0 ; i < s ; i ++ ) { if ( i > 0 ) result . append ( '&' ) ; Object val = LazyList . get ( list , i ) ; result . append ( encodeString ( key , charset ) ) ; if ( val != null ) { String str = val . toString ( ) ; if ( str . length ( ) > 0 ) { result . append ( '=' ) ; result . append ( encodeString ( str , charset ) ) ; } else if ( equalsForNullValue ) result . append ( '=' ) ; } else if ( equalsForNullValue ) result . append ( '=' ) ; } } if ( iter . hasNext ( ) ) result . append ( '&' ) ; } return result . toString ( ) ; } } | Encode Hashtable with % encoding . |
40,387 | public static String decodeString ( String encoded ) { return decodeString ( encoded , 0 , encoded . length ( ) , StringUtil . __ISO_8859_1 ) ; } | Decode String with % encoding . This method makes the assumption that the majority of calls will need no decoding and uses the 8859 encoding . |
40,388 | protected synchronized void checkDataMaps ( ) throws IOException { if ( lastUpdateCheck == 0 || lastUpdateCheck < System . currentTimeMillis ( ) - updateInterval ) { String versionOnServer = getVersionFromServer ( ) ; if ( currentVersion == null || versionOnServer . compareTo ( currentVersion ) > 0 ) { loadDataFromInternet ( ) ; currentVersion = versionOnServer ; } lastUpdateCheck = System . currentTimeMillis ( ) ; } } | Since we ve online access to the data file we check every day for an update |
40,389 | private void loadDataFromInternet ( ) throws IOException { URL url = new URL ( DATA_RETRIVE_URL ) ; InputStream is = url . openStream ( ) ; try { PHPFileParser fp = new PHPFileParser ( is ) ; createInternalDataStructre ( fp . getSections ( ) ) ; } finally { is . close ( ) ; } } | Loads the data file from user - agent - string . info |
40,390 | protected String getVersionFromServer ( ) throws IOException { URL url = new URL ( VERSION_CHECK_URL ) ; InputStream is = url . openStream ( ) ; try { byte [ ] buff = new byte [ 4048 ] ; int len = is . read ( buff ) ; return new String ( buff , 0 , len ) ; } finally { is . close ( ) ; } } | Gets the current version from user - agent - string . info |
40,391 | public static Object add ( Object list , Object item ) { if ( list == null ) { if ( item instanceof List || item == null ) { List l = new ArrayList ( ) ; l . add ( item ) ; return l ; } return item ; } if ( list instanceof List ) { ( ( List ) list ) . add ( item ) ; return list ; } List l = new ArrayList ( ) ; l . add ( list ) ; l . add ( item ) ; return l ; } | Add an item to a LazyList |
40,392 | protected Object add ( Object list , Collection collection ) { Iterator i = collection . iterator ( ) ; while ( i . hasNext ( ) ) list = LazyList . add ( list , i . next ( ) ) ; return list ; } | Add the contents of a Collection to a LazyList |
40,393 | public static int indexFrom ( String s , String chars ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) if ( chars . indexOf ( s . charAt ( i ) ) >= 0 ) return i ; return - 1 ; } | returns the next index of a character from the chars string |
40,394 | public static String replace ( String s , String sub , String with ) { int c = 0 ; int i = s . indexOf ( sub , c ) ; if ( i == - 1 ) return s ; StringBuffer buf = new StringBuffer ( s . length ( ) + with . length ( ) ) ; synchronized ( buf ) { do { buf . append ( s . substring ( c , i ) ) ; buf . append ( with ) ; c = i + sub . length ( ) ; } while ( ( i = s . indexOf ( sub , c ) ) != - 1 ) ; if ( c < s . length ( ) ) buf . append ( s . substring ( c , s . length ( ) ) ) ; return buf . toString ( ) ; } } | replace substrings within string . |
40,395 | public Element setAttributesFrom ( Element e ) { attributes = e . attributes ; attributeMap = ( Hashtable ) e . attributeMap . clone ( ) ; return this ; } | Set attributes from another Element . |
40,396 | public void setPoolClass ( Class poolClass ) throws IllegalStateException { synchronized ( this ) { if ( _class != poolClass ) { if ( _running > 0 ) throw new IllegalStateException ( "Thread Pool Running" ) ; if ( ! PondLife . class . isAssignableFrom ( poolClass ) ) throw new IllegalArgumentException ( "Not PondLife: " + poolClass ) ; _class = poolClass ; _className = _class . getName ( ) ; } } } | Set the class . |
40,397 | public int compareTo ( Object o ) { if ( o instanceof ServletHolder ) { ServletHolder sh = ( ServletHolder ) o ; if ( sh == this ) return 0 ; if ( sh . _initOrder < _initOrder ) return 1 ; if ( sh . _initOrder > _initOrder ) return - 1 ; int c = _className . compareTo ( sh . _className ) ; if ( c == 0 ) c = _name . compareTo ( sh . _name ) ; if ( c == 0 ) c = this . hashCode ( ) > o . hashCode ( ) ? 1 : - 1 ; return c ; } return 1 ; } | Comparitor by init order . |
40,398 | public synchronized void setUserRoleLink ( String name , String link ) { if ( _roleMap == null ) _roleMap = new HashMap ( ) ; _roleMap . put ( name , link ) ; } | Link a user role . Translate the role name used by a servlet to the link name used by the container . |
40,399 | public String getUserRoleLink ( String name ) { if ( _roleMap == null ) return name ; String link = ( String ) _roleMap . get ( name ) ; return ( link == null ) ? name : link ; } | get a user role link . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.