idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
137,500
public static Map . Entry < String , String > match ( Map < String , String > categoriesByPackage , String pkg ) { if ( categoriesByPackage != null && pkg != null ) { for ( Map . Entry < String , String > e : categoriesByPackage . entrySet ( ) ) { if ( Minimatch . minimatch ( pkg . replaceAll ( "\\." , "/" ) , e . getK...
Check if there is a pattern in the map that match the given package
137,501
private static long getCachedLastModified ( ServletContext servletContext , HeaderAndPath hap ) { @ SuppressWarnings ( "unchecked" ) Map < HeaderAndPath , GetLastModifiedCacheValue > cache = ( Map < HeaderAndPath , GetLastModifiedCacheValue > ) servletContext . getAttribute ( GET_LAST_MODIFIED_CACHE_ATTRIBUTE_NAME ) ; ...
Gets a modified time from either a file or URL . Caches results for up to a second .
137,502
public static long getLastModified ( ServletContext servletContext , HttpServletRequest request , String path ) { return getLastModified ( servletContext , request , path , FileUtils . getExtension ( path ) ) ; }
Automatically determines extension from path .
137,503
protected long getLastModified ( HttpServletRequest req ) { try { ReadableInstant mostRecent = null ; for ( Tuple2 < Book , ReadableInstant > sitemapBook : getSitemapBooks ( getServletContext ( ) , req , ( HttpServletResponse ) req . getAttribute ( RESPONSE_IN_REQUEST_ATTRIBUTE ) ) ) { ReadableInstant lastModified = si...
Last modified is known only when the last modified is known for all books and it is the most recent of all the per - book last modified .
137,504
private static boolean hasSiteMapUrl ( final ServletContext servletContext , final HttpServletRequest req , final HttpServletResponse resp , final SortedSet < View > views , final Book book , PageRef pageRef ) throws ServletException , IOException { Boolean result = CapturePage . traversePagesAnyOrder ( servletContext ...
Checks if the sitemap has at least one page . This version implemented as a traversal .
137,505
protected String getMessageType ( final String message ) { if ( StringUtils . isBlank ( defaultMessageType ) || MESSAGE_TYPE_TEXT_VALUE . equalsIgnoreCase ( defaultMessageType ) || MESSAGE_TYPE_LONG_TEXT_VALUE . equalsIgnoreCase ( defaultMessageType ) ) { return message . length ( ) > getMaxLengthOfOneSms ( ) ? MESSAGE...
Returns the message type .
137,506
protected String createSendTime ( final Date sendTime ) { if ( sendTime == null || new Date ( System . currentTimeMillis ( ) + 1000L * 60L ) . after ( sendTime ) ) { return null ; } String customSendTimePattern = StringUtils . isBlank ( this . sendTimePattern ) ? DEFAULT_SEND_TIME_PATTERN : this . sendTimePattern ; Sim...
Creates the send time URL parameter value .
137,507
protected TrustManager [ ] createTrustAllManagers ( ) { return new TrustManager [ ] { new X509TrustManager ( ) { public X509Certificate [ ] getAcceptedIssuers ( ) { return null ; } public void checkClientTrusted ( X509Certificate [ ] certs , String authType ) { } public void checkServerTrusted ( X509Certificate [ ] cer...
Creates an array of trust managers which trusts all X509 certificates .
137,508
private String encode ( final String value , final Charset charset ) { if ( StringUtils . isBlank ( value ) ) { return "" ; } try { return URLEncoder . encode ( value , charset . name ( ) ) ; } catch ( UnsupportedEncodingException e ) { return value ; } }
Encode query parameter .
137,509
public static SourceMapGenerator fromSourceMap ( SourceMapConsumer aSourceMapConsumer ) { String sourceRoot = aSourceMapConsumer . sourceRoot ; SourceMapGenerator generator = new SourceMapGenerator ( aSourceMapConsumer . file , sourceRoot ) ; aSourceMapConsumer . eachMapping ( ) . forEach ( mapping -> { Mapping newMapp...
Creates a new SourceMapGenerator based on a SourceMapConsumer
137,510
public void setSourceContent ( String aSourceFile , String aSourceContent ) { String source = aSourceFile ; if ( this . _sourceRoot != null ) { source = Util . relative ( this . _sourceRoot , source ) ; } if ( aSourceContent != null ) { if ( this . _sourcesContents == null ) { this . _sourcesContents = new HashMap < > ...
Set the source content for a source file .
137,511
private String serializeMappings ( ) { int previousGeneratedColumn = 0 ; int previousGeneratedLine = 1 ; int previousOriginalColumn = 0 ; int previousOriginalLine = 0 ; int previousName = 0 ; int previousSource = 0 ; String result = "" ; Mapping mapping ; int nameIdx ; int sourceIdx ; List < Mapping > mappings = this ....
Serialize the accumulated mappings in to the stream of base 64 VLQs specified by the source map format .
137,512
public SourceMap toJSON ( ) { SourceMap map = new SourceMap ( ) ; map . version = this . _version ; map . sources = this . _sources . toArray ( ) ; map . names = this . _names . toArray ( ) ; map . mappings = serializeMappings ( ) ; map . file = this . _file ; map . sourceRoot = this . _sourceRoot ; if ( this . _source...
Externalize the source map .
137,513
public Result < V , E > get ( K key , Refresher < ? super K , ? extends V , ? extends E > refresher ) { Result < V , E > result = get ( key ) ; if ( result == null ) result = put ( key , refresher ) ; return result ; }
Gets the value if currently in the cache . If not Runs the refresher immediately to obtain the result then places an entry into the cache .
137,514
public Result < V , E > get ( K key ) { CacheEntry entry = map . get ( key ) ; if ( entry == null ) { return null ; } else { return entry . getResult ( ) ; } }
Gets a cached result for the given key null if not cached . Extends the expiration of the cache entry .
137,515
public Result < V , E > put ( K key , Refresher < ? super K , ? extends V , ? extends E > refresher ) { Result < V , E > result = runRefresher ( refresher , key ) ; put ( key , refresher , result ) ; return result ; }
Runs the refresher immediately to obtain the result then places an entry into the cache replacing any existing entry under this key .
137,516
public void put ( K key , Refresher < ? super K , ? extends V , ? extends E > refresher , V value ) { put ( key , refresher , new Result < V , E > ( value ) ) ; }
Places a result into the cache replacing any existing entry under this key .
137,517
public void doTag ( ) throws JspTagException , IOException { try { final PageContext pageContext = ( PageContext ) getJspContext ( ) ; NavigationTreeRenderer . writeNavigationTree ( pageContext . getServletContext ( ) , pageContext . getELContext ( ) , ( HttpServletRequest ) pageContext . getRequest ( ) , ( HttpServlet...
Creates the nested &lt ; ul&gt ; and &lt ; li&gt ; tags used by TreeView . The first level is expanded .
137,518
public static BasicSourceMapConsumer fromSourceMap ( SourceMapGenerator aSourceMap ) { BasicSourceMapConsumer smc = new BasicSourceMapConsumer ( ) ; ArraySet < String > names = smc . _names = ArraySet . fromArray ( aSourceMap . _names . toArray ( ) , true ) ; ArraySet < String > sources = smc . _sources = ArraySet . fr...
Create a BasicSourceMapConsumer from a SourceMapGenerator .
137,519
void computeColumnSpans ( ) { for ( int index = 0 ; index < _generatedMappings ( ) . size ( ) ; ++ index ) { ParsedMapping mapping = _generatedMappings ( ) . get ( index ) ; if ( index + 1 < _generatedMappings ( ) . size ( ) ) { ParsedMapping nextMapping = _generatedMappings ( ) . get ( index + 1 ) ; if ( mapping . gen...
Compute the last column for each generated mapping . The last column is inclusive .
137,520
public boolean hasContentsOfAllSources ( ) { if ( sourcesContent == null ) { return false ; } return this . sourcesContent . size ( ) >= this . _sources . size ( ) && ! this . sourcesContent . stream ( ) . anyMatch ( sc -> sc == null ) ; }
Return true if we have the source content for every source in the source map false otherwise .
137,521
public static String createFingerprint ( Class cl , Method m ) { return FingerprintGenerator . fingerprint ( cl , m ) ; }
Create fingerprint for java test method
137,522
public static void enrichContext ( Context context ) { context . setPostProperty ( Context . MEMORY_TOTAL , Runtime . getRuntime ( ) . totalMemory ( ) ) ; context . setPostProperty ( Context . MEMORY_FREE , Runtime . getRuntime ( ) . freeMemory ( ) ) ; context . setPostProperty ( Context . MEMORY_USED , Runtime . getRu...
Enrich a context
137,523
public Version getVersion ( String product ) throws IllegalArgumentException { String three = properties . getProperty ( product ) ; if ( three == null ) throw new IllegalArgumentException ( accessor . getMessage ( "PropertiesVersions.getVersion.productNotFound" , product ) ) ; return Version . valueOf ( three + "." + ...
Gets the version number for the provided product .
137,524
public int getBuild ( ) throws IllegalArgumentException { String build = properties . getProperty ( "build.number" ) ; if ( build == null ) throw new IllegalArgumentException ( accessor . getMessage ( "PropertiesVersions.getVersion.buildNotFound" ) ) ; return Integer . parseInt ( build ) ; }
Gets the build number that is applied to all products .
137,525
public int getNextFiles ( final File [ ] files , final int batchSize ) throws IOException { int c = 0 ; while ( c < batchSize ) { File file = getNextFile ( ) ; if ( file == null ) break ; files [ c ++ ] = file ; } return c ; }
Gets the next files up to batchSize .
137,526
protected boolean isFilesystemRoot ( String filename ) throws IOException { String [ ] roots = getFilesystemRoots ( ) ; for ( int c = 0 , len = roots . length ; c < len ; c ++ ) { if ( roots [ c ] . equals ( filename ) ) return true ; } return false ; }
Determines if a path is a possible file system root
137,527
private FilesystemIteratorRule getBestRule ( final String filename ) { String longestPrefix = null ; FilesystemIteratorRule rule = null ; String path = filename ; while ( true ) { rule = rules . get ( path ) ; if ( rule != null ) { longestPrefix = path ; break ; } int pathLen = path . length ( ) ; if ( pathLen == 0 ) b...
Gets the rule that best suits the provided filename . The rule is the longer rule between the regular rules and the prefix rules .
137,528
public static ServletContextCache getCache ( ServletContext servletContext ) { ServletContextCache cache = ( ServletContextCache ) servletContext . getAttribute ( ATTRIBUTE_KEY ) ; if ( cache == null ) { cache = new ServletContextCache ( servletContext ) ; servletContext . setAttribute ( ATTRIBUTE_KEY , cache ) ; } els...
Gets or creates the cache for the provided servlet context .
137,529
public URL getResource ( String path ) throws MalformedURLException { Result < URL , MalformedURLException > result = getResourceCache . get ( path , getResourceRefresher ) ; MalformedURLException exception = result . getException ( ) ; if ( exception != null ) throw exception ; return result . getValue ( ) ; }
Gets the possibly cached URL . This URL is not copied and caller should not fiddle with its state . Thank you Java for this not being immutable .
137,530
protected int binarySearch ( int value ) { int left = 0 ; int right = size - 1 ; while ( left <= right ) { int mid = ( left + right ) >> 1 ; int midValue = elementData [ mid ] ; if ( value == midValue ) return mid ; if ( value < midValue ) right = mid - 1 ; else left = mid + 1 ; } return - ( left + 1 ) ; }
Performs a binary search for the provide value . It will return any matching element not necessarily the first or the last .
137,531
public int indexOf ( int elem ) { int pos = binarySearch ( elem ) ; if ( pos < 0 ) return - 1 ; while ( pos > 0 && elementData [ pos - 1 ] == elem ) pos -- ; return pos ; }
Searches for the first occurrence of the given value .
137,532
public boolean add ( int o ) { int mySize = size ( ) ; if ( mySize == 0 ) { super . add ( o ) ; } else { if ( o >= elementData [ mySize - 1 ] ) { super . add ( o ) ; } else { int index = binarySearch ( o ) ; if ( index < 0 ) { super . add ( - ( index + 1 ) , o ) ; } else { super . add ( index + 1 , o ) ; } } } return t...
Adds the specified element in sorted position within this list .
137,533
public boolean addAll ( Collection < ? extends Integer > c ) { Iterator < ? extends Integer > iter = c . iterator ( ) ; boolean didOne = false ; while ( iter . hasNext ( ) ) { add ( iter . next ( ) . intValue ( ) ) ; didOne = true ; } return didOne ; }
Adds all of the elements in the specified Collection and sorts during the add . This may operate slowly as it is the same as individual calls to the add method .
137,534
@ XmlElement ( name = "successfullySent" , required = true ) @ JsonProperty ( value = "successfullySent" , required = true ) public boolean isSuccessfullySent ( ) { return successfullySent ; }
Is successfully sent boolean .
137,535
public byte get ( long position ) throws IOException { return mappedBuffers . get ( getBufferNum ( position ) ) . get ( getIndex ( position ) ) ; }
Gets a single byte from the buffer .
137,536
public static void dispatchInclude ( RequestDispatcher dispatcher , HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException , SkipPageException { final boolean isOutmostInclude = request . getAttribute ( IS_INCLUDED_REQUEST_ATTRIBUTE_NAME ) == null ; if ( logger . isLoggable ( ...
Performs the actual include supporting propagation of SkipPageException and sendError .
137,537
public static void setLocation ( HttpServletRequest request , HttpServletResponse response , String location ) { if ( request . getAttribute ( IS_INCLUDED_REQUEST_ATTRIBUTE_NAME ) == null ) { response . setHeader ( "Location" , location ) ; } else { request . setAttribute ( LOCATION_REQUEST_ATTRIBUTE_NAME , location ) ...
Sets a Location header . When not in an included page calls setHeader directly . When inside of an include will set request attribute so outermost include can call setHeader .
137,538
public static void sendError ( HttpServletRequest request , HttpServletResponse response , int status , String message ) throws IOException { if ( request . getAttribute ( IS_INCLUDED_REQUEST_ATTRIBUTE_NAME ) == null ) { if ( message == null ) { response . sendError ( status ) ; } else { response . sendError ( status ,...
Sends an error . When not in an included page calls sendError directly . When inside of an include will set request attribute so outermost include can call sendError .
137,539
protected String createAndlogStackTrace ( Failure failure ) { StringBuilder sb = new StringBuilder ( ) ; if ( failure . getMessage ( ) != null && ! failure . getMessage ( ) . isEmpty ( ) ) { sb . append ( "Failure message: " ) . append ( failure . getMessage ( ) ) ; } if ( failure . getException ( ) != null ) { sb . ap...
Build a stack trace string
137,540
protected final String getFingerprint ( Description description ) { return TestResultDataUtils . getFingerprint ( description . getTestClass ( ) , description . getMethodName ( ) ) ; }
Retrieve the fingerprint of a test based on its description
137,541
protected final String getPackage ( Class cls ) { return cls . getPackage ( ) != null ? cls . getPackage ( ) . getName ( ) : "defaultPackage" ; }
Retrieve the package name if available if not default package name is used .
137,542
public static String getHumanName ( String methodName ) { char [ ] name = methodName . toCharArray ( ) ; StringBuilder humanName = new StringBuilder ( ) ; boolean digit = false ; boolean upper = true ; int upCount = 0 ; for ( int i = 0 ; i < name . length ; i ++ ) { if ( i == 0 ) { humanName . append ( Character . toUp...
Create a human name from a method name
137,543
private static void waitForAll ( Iterable < ? extends Future < ? > > futures ) throws InterruptedException , ExecutionException { for ( Future < ? > future : futures ) { future . get ( ) ; } }
Waits for all futures to complete discarding any results .
137,544
public static StringMessage decode ( ByteArray encodedMessage ) { if ( encodedMessage . size == 0 ) return EMPTY_STRING_MESSAGE ; return new StringMessage ( new String ( encodedMessage . array , 0 , encodedMessage . size , CHARSET ) ) ; }
UTF - 8 decodes the message .
137,545
public ByteArray encodeAsByteArray ( ) { if ( message . isEmpty ( ) ) return ByteArray . EMPTY_BYTE_ARRAY ; return new ByteArray ( message . getBytes ( CHARSET ) ) ; }
UTF - 8 encodes the message .
137,546
public static int readCompressedInt ( InputStream in ) throws IOException { int b1 = in . read ( ) ; if ( b1 == - 1 ) throw new EOFException ( ) ; if ( ( b1 & 0x80 ) != 0 ) { int b2 = in . read ( ) ; if ( b2 == - 1 ) throw new EOFException ( ) ; int b3 = in . read ( ) ; if ( b3 == - 1 ) throw new EOFException ( ) ; int...
Reads a compressed integer from the stream .
137,547
public String readLongUTF ( ) throws IOException { int length = readCompressedInt ( ) ; StringBuilder SB = new StringBuilder ( length ) ; for ( int position = 0 ; position < length ; position += 20480 ) { int expectedLen = length - position ; if ( expectedLen > 20480 ) expectedLen = 20480 ; String block = readUTF ( ) ;...
Reads a string of any length .
137,548
public void synchronize ( DefaultTreeModel treeModel , Tree < E > tree ) throws IOException , SQLException { assert SwingUtilities . isEventDispatchThread ( ) : ApplicationResources . accessor . getMessage ( "assert.notRunningInSwingEventThread" ) ; synchronize ( treeModel , tree . getRootNodes ( ) ) ; }
Synchronizes the children of this node with the roots of the provided tree while adding and removing only a minimum number of nodes . Comparisons are performed using equals on the value objects . This must be called from the Swing event dispatch thread .
137,549
@ SuppressWarnings ( "unchecked" ) public void synchronize ( DefaultTreeModel treeModel , List < Node < E > > children ) throws IOException , SQLException { assert SwingUtilities . isEventDispatchThread ( ) : ApplicationResources . accessor . getMessage ( "assert.notRunningInSwingEventThread" ) ; if ( children == null ...
Synchronizes the children of this node with the provided children while adding and removing only a minimum number of nodes . Comparisons are performed using equals on the value objects . This must be called from the Swing event dispatch thread .
137,550
private void checkDates ( ) { DateTime created = this . dateCreated ; DateTime published = this . datePublished ; DateTime modified = this . dateModified ; DateTime reviewed = this . dateReviewed ; if ( created != null && published != null && published . compareTo ( created ) < 0 ) throw new IllegalArgumentException ( ...
Checks the dates for consistency .
137,551
public Map < String , Element > getElementsById ( ) { synchronized ( lock ) { if ( elementsById == null ) return Collections . emptyMap ( ) ; if ( frozen ) return elementsById ; return AoCollections . unmodifiableCopyMap ( elementsById ) ; } }
Gets the elements indexed by id in no particular order . Note while the page is being created elements with automatic IDs will not be in this map . However once frozen every element will have an ID .
137,552
public Set < String > getGeneratedIds ( ) { synchronized ( lock ) { if ( generatedIds == null ) return Collections . emptySet ( ) ; if ( frozen ) return generatedIds ; return AoCollections . unmodifiableCopySet ( generatedIds ) ; } }
Gets which element IDs were generated .
137,553
public void addElement ( Element element ) { synchronized ( lock ) { checkNotFrozen ( ) ; element . setPage ( this ) ; if ( elements == null ) elements = new ArrayList < > ( ) ; elements . add ( element ) ; addToElementsById ( element , false ) ; } }
Adds an element to this page .
137,554
public static void closeQuietly ( final MessageConsumer consumer ) { if ( consumer != null ) { try { consumer . close ( ) ; } catch ( JMSException je ) { if ( je . getCause ( ) instanceof InterruptedException ) { LOG . trace ( "ActiveMQ caught and wrapped InterruptedException" ) ; } if ( je . getCause ( ) instanceof In...
Close a message consumer .
137,555
public static void closeQuietly ( final MessageProducer producer ) { if ( producer != null ) { try { producer . close ( ) ; } catch ( JMSException je ) { if ( je . getCause ( ) instanceof InterruptedException ) { LOG . trace ( "ActiveMQ caught and wrapped InterruptedException" ) ; } if ( je . getCause ( ) instanceof In...
Close a message producer .
137,556
public static ByteArrayMessage decode ( String encodedMessage ) { if ( encodedMessage . isEmpty ( ) ) return EMPTY_BYTE_ARRAY_MESSAGE ; return new ByteArrayMessage ( Base64Coder . decode ( encodedMessage ) ) ; }
base - 64 decodes the message .
137,557
public static String encode ( String value ) { if ( value == null ) return null ; StringBuilder encoded = null ; int len = value . length ( ) ; for ( int c = 0 ; c < len ; c ++ ) { char ch = value . charAt ( c ) ; if ( ( ch < ' ' && ch != '\n' && ch != '\r' ) || ch == '\\' ) { if ( encoded == null ) { encoded = new Str...
Encodes string for binary transparency over SOAP .
137,558
public static DescriptionDescriptor createDescription ( DescriptionType descriptionType , Store store ) { DescriptionDescriptor descriptionDescriptor = store . create ( DescriptionDescriptor . class ) ; descriptionDescriptor . setLang ( descriptionType . getLang ( ) ) ; descriptionDescriptor . setValue ( descriptionTyp...
Create a description descriptor .
137,559
public static IconDescriptor createIcon ( IconType iconType , Store store ) { IconDescriptor iconDescriptor = store . create ( IconDescriptor . class ) ; iconDescriptor . setLang ( iconType . getLang ( ) ) ; PathType largeIcon = iconType . getLargeIcon ( ) ; if ( largeIcon != null ) { iconDescriptor . setLargeIcon ( la...
Create an icon descriptor .
137,560
public static DisplayNameDescriptor createDisplayName ( DisplayNameType displayNameType , Store store ) { DisplayNameDescriptor displayNameDescriptor = store . create ( DisplayNameDescriptor . class ) ; displayNameDescriptor . setLang ( displayNameType . getLang ( ) ) ; displayNameDescriptor . setValue ( displayNameTyp...
Create a display name descriptor .
137,561
public static String getRequestEncoding ( ServletRequest request ) { String requestEncoding = request . getCharacterEncoding ( ) ; return requestEncoding != null ? requestEncoding : DEFAULT_REQUEST_ENCODING ; }
Gets the request encoding or ISO - 8859 - 1 when not available .
137,562
public static void getAbsoluteURL ( HttpServletRequest request , String relPath , Appendable out ) throws IOException { out . append ( request . isSecure ( ) ? "https://" : "http://" ) ; out . append ( request . getServerName ( ) ) ; int port = request . getServerPort ( ) ; if ( port != ( request . isSecure ( ) ? 443 :...
Gets an absolute URL for the given context - relative path . This includes protocol port context path and relative path . No URL rewriting is performed .
137,563
public static String getRedirectLocation ( HttpServletRequest request , HttpServletResponse response , String servletPath , String href ) throws MalformedURLException , UnsupportedEncodingException { href = getAbsolutePath ( servletPath , href ) ; href = UrlUtils . encodeUrlPath ( href , response . getCharacterEncoding...
Gets the absolute URL that should be used for a redirect .
137,564
public static void sendRedirect ( HttpServletResponse response , String location , int status ) throws IllegalStateException , IOException { if ( response . isCommitted ( ) ) throw new IllegalStateException ( "Unable to redirect: Response already committed" ) ; response . setHeader ( "Location" , location ) ; response ...
Sends a redirect to the provided absolute URL location .
137,565
public static void sendRedirect ( HttpServletRequest request , HttpServletResponse response , String href , int status ) throws IllegalStateException , IOException { sendRedirect ( response , getRedirectLocation ( request , response , request . getServletPath ( ) , href ) , status ) ; }
Sends a redirect with relative paths determined from the request servlet path .
137,566
public static String getContextRequestUri ( HttpServletRequest request ) { String requestUri = request . getRequestURI ( ) ; String contextPath = request . getContextPath ( ) ; int cpLen = contextPath . length ( ) ; if ( cpLen > 0 ) { assert requestUri . startsWith ( contextPath ) ; return requestUri . substring ( cpLe...
Gets the current request URI in context - relative form . The contextPath stripped .
137,567
public static < S extends HttpServlet > void doOptions ( HttpServletResponse response , Class < S > stopClass , Class < ? extends S > thisClass , String doGet , String doPost , String doPut , String doDelete , Class < ? > [ ] paramTypes ) { boolean ALLOW_GET = false ; boolean ALLOW_HEAD = false ; boolean ALLOW_POST = f...
A reusable doOptions implementation for servlets .
137,568
public int getPort ( ) { if ( port != 0 ) { return port ; } else { final Connector connector = connectorHolder . get ( ) ; if ( connector != null ) { Preconditions . checkState ( connector . getLocalPort ( ) > 0 , "no port was set and the connector is not yet started!" ) ; return connector . getLocalPort ( ) ; } else {...
Returns the system port for this connector .
137,569
public static boolean isAllowed ( ServletContext servletContext , ServletRequest request ) { return Boolean . parseBoolean ( servletContext . getInitParameter ( ENABLE_INIT_PARAM ) ) && isAllowedAddr ( request . getRemoteAddr ( ) ) ; }
Checks if the given request is allowed to open files on the server . The servlet init param must have it enabled as well as be from an allowed IP .
137,570
public static void addFileOpener ( ServletContext servletContext , FileOpener fileOpener , String ... extensions ) { synchronized ( fileOpenersLock ) { @ SuppressWarnings ( "unchecked" ) Map < String , FileOpener > fileOpeners = ( Map < String , FileOpener > ) servletContext . getAttribute ( FILE_OPENERS_REQUEST_ATTRIB...
Registers a file opener .
137,571
public static void removeFileOpener ( ServletContext servletContext , String ... extensions ) { synchronized ( fileOpenersLock ) { @ SuppressWarnings ( "unchecked" ) Map < String , FileOpener > fileOpeners = ( Map < String , FileOpener > ) servletContext . getAttribute ( FILE_OPENERS_REQUEST_ATTRIBUTE_NAME ) ; if ( fil...
Removes file openers .
137,572
public static void addCookie ( HttpServletRequest request , HttpServletResponse response , String cookieName , String value , String comment , int maxAge , boolean secure , boolean contextOnlyPath ) { Cookie newCookie = new Cookie ( cookieName , value ) ; if ( comment != null ) newCookie . setComment ( comment ) ; newC...
Adds a cookie .
137,573
public static void removeCookie ( HttpServletRequest request , HttpServletResponse response , String cookieName , boolean secure , boolean contextOnlyPath ) { addCookie ( request , response , cookieName , "Removed" , null , 0 , secure , contextOnlyPath ) ; }
Removes a cookie by adding it with maxAge of zero .
137,574
public int compareTo ( Column o ) { int diff = name . compareToIgnoreCase ( o . name ) ; if ( diff != 0 ) return diff ; return name . compareTo ( o . name ) ; }
Ordered by column name only .
137,575
public int read ( ) throws IOException { int c = in . read ( ) ; if ( c == - 1 ) return - 1 ; md5 . Update ( c ) ; return c ; }
Read a byte of data .
137,576
public int read ( byte bytes [ ] , int offset , int length ) throws IOException { int r ; if ( ( r = in . read ( bytes , offset , length ) ) == - 1 ) return - 1 ; md5 . Update ( bytes , offset , r ) ; return r ; }
Reads into an array of bytes .
137,577
void addBundle ( EditableResourceBundle bundle ) { Locale locale = bundle . getBundleLocale ( ) ; if ( ! locales . contains ( locale ) ) throw new AssertionError ( "locale not in locales: " + locale ) ; bundles . put ( locale , bundle ) ; }
The constructor of EditableResourceBundle adds itself here .
137,578
public EditableResourceBundle getResourceBundle ( Locale locale ) { EditableResourceBundle localeBundle = bundles . get ( locale ) ; if ( localeBundle == null ) { ResourceBundle resourceBundle = ResourceBundle . getBundle ( baseName , locale ) ; if ( ! resourceBundle . getLocale ( ) . equals ( locale ) ) throw new Asse...
Gets the editable bundle for the provided locale .
137,579
public static Boolean getEnvironmentBoolean ( String name , Boolean defaultValue ) { if ( envVars == null ) { throw new IllegalStateException ( "The environment vars must be provided before calling getEnvironmentBoolean." ) ; } String value = getEnvironmentString ( name , null ) ; if ( value == null ) { return defaultV...
Retrieve boolean value for the environment variable name
137,580
public static Integer getEnvironmentInteger ( String name , Integer defaultValue ) { if ( envVars == null ) { throw new IllegalStateException ( "The environment vars must be provided before calling getEnvironmentInteger." ) ; } String value = getEnvironmentString ( name , null ) ; if ( value == null ) { return defaultV...
Retrieve integer value for the environment variable name
137,581
public static String getEnvironmentString ( String name , String defaultValue ) { if ( envVars == null ) { throw new IllegalStateException ( "The environment vars must be provided before calling getEnvironmentString." ) ; } return envVars . get ( ENV_PREFIX + name ) != null ? envVars . get ( ENV_PREFIX + name ) : defau...
Retrieve string value for the environment variable name
137,582
public String encodeAsString ( ) throws IOException { final int size = messages . size ( ) ; if ( size == 0 ) return "" ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( size ) . append ( DELIMITER ) ; int count = 0 ; for ( Message message : messages ) { count ++ ; String str = message . encodeAsString ( ) ; s...
Encodes the messages into a single string .
137,583
public ByteArray encodeAsByteArray ( ) throws IOException { final int size = messages . size ( ) ; if ( size == 0 ) return ByteArray . EMPTY_BYTE_ARRAY ; AoByteArrayOutputStream bout = new AoByteArrayOutputStream ( ) ; try { try ( DataOutputStream out = new DataOutputStream ( bout ) ) { out . writeInt ( size ) ; int co...
Encodes the messages into a single ByteArray . There is likely a more efficient implementation that reads - through but this is a simple implementation .
137,584
protected void setLength ( long length ) throws IOException { if ( length < 0 ) throw new IllegalArgumentException ( "Invalid length: " + length ) ; synchronized ( this ) { file . seek ( 8 ) ; file . writeLong ( length ) ; if ( length == 0 ) setFirstIndex ( 0 ) ; } }
Sets the number of bytes currently contained by the FIFO .
137,585
private boolean isExcludedPath ( String requestURI ) { if ( requestURI == null ) return false ; if ( _excludedPaths != null ) { for ( String excludedPath : _excludedPaths ) { if ( requestURI . startsWith ( excludedPath ) ) { return true ; } } } if ( _excludedPathPatterns != null ) { for ( Pattern pattern : _excludedPat...
Checks to see if the path is excluded
137,586
@ SuppressWarnings ( "unchecked" ) public static boolean isRunnable ( Class cl , Method method , List < FilterDefinition > filters ) { ProbeTest mAnnotation = method . getAnnotation ( ProbeTest . class ) ; ProbeTestClass cAnnotation = method . getDeclaringClass ( ) . getAnnotation ( ProbeTestClass . class ) ; String fi...
Define if a test is runnable or not based on a method and class
137,587
private String readUid ( File uidFile ) { String uid = null ; try ( BufferedReader br = new BufferedReader ( new FileReader ( uidFile ) ) ) { String line ; while ( ( line = br . readLine ( ) ) != null ) { uid = line ; } } catch ( IOException ioe ) { } return uid ; }
Read a UID file
137,588
public static Version getInstance ( int major , int minor , int release , int build ) { return new Version ( major , minor , release , build ) ; }
Gets a version number instance from its component parts .
137,589
public static Version valueOf ( String version ) throws IllegalArgumentException { NullArgumentException . checkNotNull ( version , "version" ) ; int dot1Pos = version . indexOf ( '.' ) ; if ( dot1Pos == - 1 ) throw new IllegalArgumentException ( version ) ; int dot2Pos = version . indexOf ( '.' , dot1Pos + 1 ) ; if ( ...
Parses a version number from its string representation .
137,590
public static Config getConfig ( ) { final Configuration systemConfig = new SystemConfiguration ( ) ; final String configName = systemConfig . getString ( CONFIG_PROPERTY_NAME ) ; final String configLocation = systemConfig . getString ( CONFIG_LOCATION_PROPERTY_NAME ) ; Preconditions . checkState ( configLocation != nu...
Loads the configuration . The no - args method uses system properties to determine which configurations to load .
137,591
public static Config getConfig ( final URI configLocation , final String configName ) { final ConfigFactory configFactory = new ConfigFactory ( configLocation , configName ) ; return new Config ( configFactory . load ( ) ) ; }
Load Configuration using the supplied URI as base . The loaded configuration can be overridden using system properties .
137,592
public static Config getOverriddenConfig ( final Config config , final AbstractConfiguration ... overrideConfigurations ) { if ( overrideConfigurations == null || overrideConfigurations . length == 0 ) { return config ; } final CombinedConfiguration cc = new CombinedConfiguration ( new OverrideCombiner ( ) ) ; int inde...
Create a new configuration object from an existing object using overrides . If no overrides are passed in the same object is returned .
137,593
public int start ( ) throws Exception { if ( isStarted . compareAndSet ( false , true ) ) { try { for ( Reporter reporter : reporters ) { reporter . start ( ) ; } } catch ( Exception e ) { stop ( ) ; throw e ; } } return reporters . size ( ) ; }
Starts all reporters .
137,594
public void stop ( ) { if ( isStarted . compareAndSet ( true , false ) ) { for ( Reporter reporter : reporters ) { reporter . stop ( ) ; } } }
Stops all reporting .
137,595
public static < T > T xmlNodeToObject ( final Node node , final Class < T > valueType , final JAXBContext jaxbContext ) throws JAXBException { if ( node == null ) { return null ; } Validate . notNull ( valueType , "valueType must not be null" ) ; if ( jaxbContext == null ) { return valueType . cast ( getJaxbContext ( v...
Transforms a XML node into an object .
137,596
public static < T > T jsonMapToObject ( final Map < String , Object > map , final Class < T > valueType , final ObjectMapper objectMapper ) throws IOException { if ( map == null ) { return null ; } Validate . notNull ( valueType , "valueType must not be null" ) ; if ( objectMapper == null ) { return DEFAULT_OBJECT_MAPP...
Transforms a JSON map into an object .
137,597
static < T > ArraySet < T > fromArray ( List < T > aArray , Boolean aAllowDuplicates ) { ArraySet < T > set = new ArraySet < > ( ) ; for ( int i = 0 , len = aArray . size ( ) ; i < len ; i ++ ) { set . add ( aArray . get ( i ) , aAllowDuplicates ) ; } return set ; }
Static method for creating ArraySet instances from an existing array .
137,598
Integer indexOf ( T t ) { if ( t == null ) { return null ; } Integer i = _set . get ( t ) ; if ( i == null ) { return - 1 ; } return i ; }
What is the index of the given string in the array?
137,599
T at ( Integer i ) { if ( i == null ) { return null ; } if ( i >= _array . size ( ) ) { return null ; } return _array . get ( i ) ; }
What is the element at the given index?