idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
7,000 | public static String decode ( final String toDecode , final int relocate ) { final StringBuffer sb = new StringBuffer ( ) ; final char [ ] encrypt = toDecode . toCharArray ( ) ; final int arraylength = encrypt . length ; for ( int i = 0 ; i < arraylength ; i ++ ) { final char a = ( char ) ( encrypt [ i ] - relocate ) ; sb . append ( a ) ; } return sb . toString ( ) . trim ( ) ; } | Decrypt the given String . |
7,001 | public static String encode ( final String secret , final int relocate ) { final StringBuffer sb = new StringBuffer ( ) ; final char [ ] encrypt = secret . toCharArray ( ) ; final int arraylength = encrypt . length ; for ( int i = 0 ; i < arraylength ; i ++ ) { final char a = ( char ) ( encrypt [ i ] + relocate ) ; sb . append ( a ) ; } return sb . toString ( ) . trim ( ) ; } | Encrypt the given String . |
7,002 | public static PublicKey readPemPublicKey ( final File file ) throws IOException , NoSuchAlgorithmException , InvalidKeySpecException , NoSuchProviderException { final String publicKeyAsString = readPemFileAsBase64 ( file ) ; final byte [ ] decoded = Base64 . decodeBase64 ( publicKeyAsString ) ; return readPublicKey ( decoded ) ; } | reads a public key from a file . |
7,003 | public static String toPemFormat ( final PublicKey publicKey ) { final String publicKeyAsBase64String = toBase64 ( publicKey ) ; final List < String > parts = StringExtensions . splitByFixedLength ( publicKeyAsBase64String , 64 ) ; final StringBuilder sb = new StringBuilder ( ) ; sb . append ( PublicKeyReader . BEGIN_PUBLIC_KEY_PREFIX ) ; for ( final String part : parts ) { sb . append ( part ) ; sb . append ( System . lineSeparator ( ) ) ; } sb . append ( PublicKeyReader . END_PUBLIC_KEY_SUFFIX ) ; sb . append ( System . lineSeparator ( ) ) ; return sb . toString ( ) ; } | Transform the public key in pem format . |
7,004 | protected void checkThreshold ( final int nCount ) throws IOException { if ( ! m_bThresholdExceeded && ( m_nWritten + nCount > m_nThreshold ) ) { m_bThresholdExceeded = true ; onThresholdReached ( ) ; } } | Checks to see if writing the specified number of bytes would cause the configured threshold to be exceeded . If so triggers an event to allow a concrete implementation to take action on |
7,005 | public ICommonsList < String > getHeaders ( final String sName ) { return new CommonsArrayList < > ( m_aHeaders . get ( _unifyHeaderName ( sName ) ) ) ; } | Return all values for the given header as a List of value objects . |
7,006 | public static EChange safeInvalidateSession ( final HttpSession aSession ) { if ( aSession != null ) { try { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Invalidating session " + aSession . getId ( ) ) ; aSession . invalidate ( ) ; return EChange . CHANGED ; } catch ( final IllegalStateException ex ) { } } return EChange . UNCHANGED ; } | Invalidate the session if the session is still active . |
7,007 | public static Enumeration < String > getAllAttributes ( final HttpSession aSession ) { ValueEnforcer . notNull ( aSession , "Session" ) ; try { return GenericReflection . uncheckedCast ( aSession . getAttributeNames ( ) ) ; } catch ( final IllegalStateException ex ) { return new EmptyEnumeration < > ( ) ; } } | Get all attribute names present in the specified session . |
7,008 | public IMicroDocument getAsDocument ( final String sFullContextPath ) { final String sNamespaceURL = CXMLSitemap . XML_NAMESPACE_0_9 ; final IMicroDocument ret = new MicroDocument ( ) ; final IMicroElement eSitemapindex = ret . appendElement ( sNamespaceURL , ELEMENT_SITEMAPINDEX ) ; int nIndex = 0 ; for ( final XMLSitemapURLSet aURLSet : m_aURLSets ) { final IMicroElement eSitemap = eSitemapindex . appendElement ( sNamespaceURL , ELEMENT_SITEMAP ) ; eSitemap . appendElement ( sNamespaceURL , ELEMENT_LOC ) . appendText ( sFullContextPath + "/" + getSitemapFilename ( nIndex ) ) ; final LocalDateTime aLastModification = aURLSet . getLastModificationDateTime ( ) ; if ( aLastModification != null ) { eSitemap . appendElement ( sNamespaceURL , ELEMENT_LASTMOD ) . appendText ( PDTWebDateHelper . getAsStringXSD ( aLastModification ) ) ; } ++ nIndex ; } return ret ; } | Get the Index as a micro document . |
7,009 | public static final < T extends AbstractSessionWebSingleton > T getSessionSingleton ( final Class < T > aClass ) { return getSingleton ( _getStaticScope ( true ) , aClass ) ; } | Get the singleton object in the current session web scope using the passed class . If the singleton is not yet instantiated a new instance is created . |
7,010 | @ SuppressWarnings ( "unchecked" ) public static boolean load ( GLImplementation implementation ) { try { final Constructor < ? > constructor = Class . forName ( implementation . getContextName ( ) ) . getDeclaredConstructor ( ) ; constructor . setAccessible ( true ) ; implementations . put ( implementation , ( Constructor < Context > ) constructor ) ; return true ; } catch ( ClassNotFoundException | NoSuchMethodException | SecurityException ex ) { CausticUtil . getCausticLogger ( ) . log ( Level . WARNING , "Couldn't load implementation" , ex ) ; return false ; } } | Loads the implementation making it accessible . |
7,011 | public void registerServlet ( final Class < ? extends Servlet > aServletClass , final String sServletPath , final String sServletName ) { registerServlet ( aServletClass , sServletPath , sServletName , ( Map < String , String > ) null ) ; } | Register a new servlet without servlet init parameters |
7,012 | public void registerServlet ( final Class < ? extends Servlet > aServletClass , final String sServletPath , final String sServletName , final Map < String , String > aServletInitParams ) { ValueEnforcer . notNull ( aServletClass , "ServletClass" ) ; ValueEnforcer . notEmpty ( sServletPath , "ServletPath" ) ; for ( final ServletItem aItem : m_aServlets ) { if ( aItem . getServletPath ( ) . equals ( sServletPath ) ) throw new IllegalArgumentException ( "Another servlet with the path '" + sServletPath + "' is already registered: " + aItem ) ; if ( aItem . getServletName ( ) . equals ( sServletName ) ) throw new IllegalArgumentException ( "Another servlet with the name '" + sServletName + "' is already registered: " + aItem ) ; } final Servlet aServlet = GenericReflection . newInstance ( aServletClass ) ; if ( aServlet == null ) throw new IllegalArgumentException ( "Failed to instantiate servlet class " + aServletClass ) ; final ServletConfig aServletConfig = m_aSC . createServletConfig ( sServletName , aServletInitParams ) ; try { aServlet . init ( aServletConfig ) ; } catch ( final ServletException ex ) { throw new IllegalStateException ( "Failed to init servlet " + aServlet + " with configuration " + aServletConfig + " for path '" + sServletPath + "'" ) ; } m_aServlets . add ( new ServletItem ( aServlet , sServletPath ) ) ; } | Register a new servlet |
7,013 | public Servlet getServletOfPath ( final String sPath ) { final ICommonsList < ServletItem > aMatchingItems = new CommonsArrayList < > ( ) ; if ( StringHelper . hasText ( sPath ) ) m_aServlets . findAll ( aItem -> aItem . matchesPath ( sPath ) , aMatchingItems :: add ) ; final int nMatchingItems = aMatchingItems . size ( ) ; if ( nMatchingItems == 0 ) return null ; if ( nMatchingItems > 1 ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Found more than 1 servlet matching path '" + sPath + "' - using first one: " + aMatchingItems ) ; return aMatchingItems . getFirst ( ) . getServlet ( ) ; } | Find the servlet matching the specified path . |
7,014 | public void invalidate ( ) { if ( m_bInvalidated ) throw new IllegalArgumentException ( "Servlet pool already invalidated!" ) ; m_bInvalidated = true ; for ( final ServletItem aServletItem : m_aServlets ) try { aServletItem . getServlet ( ) . destroy ( ) ; } catch ( final Exception ex ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "Failed to destroy servlet " + aServletItem , ex ) ; } m_aServlets . clear ( ) ; } | Invalidate the servlet pool by destroying all contained servlets . Also the list of registered servlets is cleared . |
7,015 | ReadIteratorResource < Read , ReadGroupSet , Reference > queryNextInterval ( ) { Stopwatch w = Stopwatch . createStarted ( ) ; if ( ! isAtEnd ( ) ) { intervalIndex ++ ; } if ( isAtEnd ( ) ) { return null ; } ReadIteratorResource < Read , ReadGroupSet , Reference > result = queryForInterval ( currentInterval ( ) ) ; LOG . info ( "Interval query took: " + w ) ; startTiming ( ) ; return result ; } | Re - queries the API for the next interval |
7,016 | ReadIteratorResource < Read , ReadGroupSet , Reference > queryForInterval ( GA4GHQueryInterval interval ) { try { return dataSource . getReads ( readSetId , interval . getSequence ( ) , interval . getStart ( ) , interval . getEnd ( ) ) ; } catch ( Exception ex ) { LOG . warning ( "Error getting data for interval " + ex . toString ( ) ) ; } return null ; } | Queries the API for an interval and returns the iterator resource or null if failed |
7,017 | void seekMatchingRead ( ) { while ( ! isAtEnd ( ) ) { if ( iterator == null || ! iterator . hasNext ( ) ) { LOG . info ( "Getting " + ( iterator == null ? "first" : "next" ) + " interval from the API" ) ; ReadIteratorResource < Read , ReadGroupSet , Reference > resource = queryNextInterval ( ) ; if ( resource != null ) { LOG . info ( "Got next interval from the API" ) ; header = resource . getSAMFileHeader ( ) ; iterator = resource . getSAMRecordIterable ( ) . iterator ( ) ; } else { LOG . info ( "Failed to get next interval from the API" ) ; header = null ; iterator = null ; } } else { nextRead = iterator . next ( ) ; if ( currentInterval ( ) . matches ( nextRead ) ) { return ; } else { LOG . info ( "Skipping non matching read" ) ; } } } } | Ensures next returned read will match the currently requested interval . Since the API always returns overlapping reads we might need to skip some reads if the interval asks for included or starts at types . Also deals with the case of iterator being at an end and needing to query for the next interval . |
7,018 | public CacheControlBuilder setMaxAge ( final TimeUnit eTimeUnit , final long nDuration ) { return setMaxAgeSeconds ( eTimeUnit . toSeconds ( nDuration ) ) ; } | Set the maximum age relative to the request time |
7,019 | public boolean hasGroup ( String groupName ) { boolean result = false ; for ( Group item : getGroupsList ( ) ) { if ( item . getName ( ) . equals ( groupName ) ) { result = true ; } } return result ; } | Check if a group with the given groupName exists in the list or not . The check will be done case - sensitive . |
7,020 | public Group getGroup ( String groupName ) { Group result = null ; for ( Group item : getGroupsList ( ) ) { if ( item . getName ( ) . equals ( groupName ) ) { result = item ; } } return result ; } | Get the Group instance from the list by name . |
7,021 | protected void processDigits ( List < Span > contextTokens , char compare , HashMap rule , int matchBegin , int currentPosition , LinkedHashMap < String , ConTextSpan > matches ) { mt = pdigit . matcher ( contextTokens . get ( currentPosition ) . text ) ; if ( mt . find ( ) ) { double thisDigit ; if ( mt . group ( 1 ) . length ( ) < 4 ) { String a = mt . group ( 1 ) ; thisDigit = Double . parseDouble ( mt . group ( 1 ) ) ; } else { thisDigit = 1000 ; } Set < String > numbers = rule . keySet ( ) ; for ( String num : numbers ) { double ruleDigit = Double . parseDouble ( num ) ; if ( ( compare == '>' && thisDigit > ruleDigit ) || ( compare == '<' && thisDigit < ruleDigit ) ) { if ( mt . group ( 2 ) == null ) { processRules ( contextTokens , ( HashMap ) rule . get ( num ) , matchBegin , currentPosition + 1 , matches ) ; } else { HashMap ruletmp = ( HashMap ) rule . get ( ruleDigit + "" ) ; String subtoken = mt . group ( 2 ) . substring ( 1 ) ; if ( ruletmp . containsKey ( subtoken ) ) { processRules ( contextTokens , ( HashMap ) ruletmp . get ( subtoken ) , matchBegin , currentPosition + 1 , matches ) ; } } } } } } | Because the digit regular expressions are revised into the format like > ; 13 days the rulesMap need to be handled differently to the token matching rulesMap |
7,022 | public boolean matches ( SAMRecord record ) { int myEnd = end == 0 ? Integer . MAX_VALUE : end ; switch ( readPositionConstraint ) { case OVERLAPPING : return CoordMath . overlaps ( start , myEnd , record . getAlignmentStart ( ) , record . getAlignmentEnd ( ) ) ; case CONTAINED : return CoordMath . encloses ( start , myEnd , record . getAlignmentStart ( ) , record . getAlignmentEnd ( ) ) ; case START_AT : return start == record . getAlignmentStart ( ) ; } return false ; } | Returns true iff the read specified by the record matches the interval given the interval s constraints and the read position . |
7,023 | public static void clearContextPath ( ) { if ( s_sServletContextPath != null ) { if ( LOGGER . isInfoEnabled ( ) && ! isSilentMode ( ) ) LOGGER . info ( "The servlet context path '" + s_sServletContextPath + "' was cleared!" ) ; s_sServletContextPath = null ; } if ( s_sCustomContextPath != null ) { if ( LOGGER . isInfoEnabled ( ) && ! isSilentMode ( ) ) LOGGER . info ( "The custom servlet context path '" + s_sCustomContextPath + "' was cleared!" ) ; s_sCustomContextPath = null ; } } | Clears both servlet context and custom context path . |
7,024 | public final void setDataSource ( DataSource dataSource ) { if ( this . jdbcTemplate == null || dataSource != this . jdbcTemplate . getDataSource ( ) ) { this . jdbcTemplate = createJdbcTemplate ( dataSource ) ; initTemplateConfig ( ) ; } } | Set the JDBC DataSource to be used by this DAO . |
7,025 | public static DigestAuthClientCredentials getDigestAuthClientCredentials ( final String sAuthHeader ) { final ICommonsOrderedMap < String , String > aParams = getDigestAuthParams ( sAuthHeader ) ; if ( aParams == null ) return null ; final String sUserName = aParams . remove ( "username" ) ; if ( sUserName == null ) { LOGGER . error ( "Digest Auth does not container 'username'" ) ; return null ; } final String sRealm = aParams . remove ( "realm" ) ; if ( sRealm == null ) { LOGGER . error ( "Digest Auth does not container 'realm'" ) ; return null ; } final String sNonce = aParams . remove ( "nonce" ) ; if ( sNonce == null ) { LOGGER . error ( "Digest Auth does not container 'nonce'" ) ; return null ; } final String sDigestURI = aParams . remove ( "uri" ) ; if ( sDigestURI == null ) { LOGGER . error ( "Digest Auth does not container 'uri'" ) ; return null ; } final String sResponse = aParams . remove ( "response" ) ; if ( sResponse == null ) { LOGGER . error ( "Digest Auth does not container 'response'" ) ; return null ; } final String sAlgorithm = aParams . remove ( "algorithm" ) ; final String sCNonce = aParams . remove ( "cnonce" ) ; final String sOpaque = aParams . remove ( "opaque" ) ; final String sMessageQOP = aParams . remove ( "qop" ) ; final String sNonceCount = aParams . remove ( "nc" ) ; if ( aParams . isNotEmpty ( ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Digest Auth contains unhandled parameters: " + aParams . toString ( ) ) ; return new DigestAuthClientCredentials ( sUserName , sRealm , sNonce , sDigestURI , sResponse , sAlgorithm , sCNonce , sOpaque , sMessageQOP , sNonceCount ) ; } | Get the Digest authentication credentials from the passed HTTP header value . |
7,026 | public static DigestAuthClientCredentials createDigestAuthClientCredentials ( final EHttpMethod eMethod , final String sDigestURI , final String sUserName , final String sPassword , final String sRealm , final String sServerNonce , final String sAlgorithm , final String sClientNonce , final String sOpaque , final String sMessageQOP , final int nNonceCount ) { ValueEnforcer . notNull ( eMethod , "Method" ) ; ValueEnforcer . notEmpty ( sDigestURI , "DigestURI" ) ; ValueEnforcer . notEmpty ( sUserName , "UserName" ) ; ValueEnforcer . notNull ( sPassword , "Password" ) ; ValueEnforcer . notEmpty ( sRealm , "Realm" ) ; ValueEnforcer . notEmpty ( sServerNonce , "ServerNonce" ) ; if ( sMessageQOP != null && StringHelper . hasNoText ( sClientNonce ) ) throw new IllegalArgumentException ( "If a QOP is defined, client nonce must be set!" ) ; if ( sMessageQOP != null && nNonceCount <= 0 ) throw new IllegalArgumentException ( "If a QOP is defined, nonce count must be positive!" ) ; final String sRealAlgorithm = sAlgorithm == null ? DEFAULT_ALGORITHM : sAlgorithm ; if ( ! sRealAlgorithm . equals ( ALGORITHM_MD5 ) && ! sRealAlgorithm . equals ( ALGORITHM_MD5_SESS ) ) throw new IllegalArgumentException ( "Currently only '" + ALGORITHM_MD5 + "' and '" + ALGORITHM_MD5_SESS + "' algorithms are supported!" ) ; if ( sMessageQOP != null && ! sMessageQOP . equals ( QOP_AUTH ) ) throw new IllegalArgumentException ( "Currently only '" + QOP_AUTH + "' QOP is supported!" ) ; final String sNonceCount = getNonceCountString ( nNonceCount ) ; String sHA1 = _md5 ( sUserName + SEPARATOR + sRealm + SEPARATOR + sPassword ) ; if ( sRealAlgorithm . equals ( ALGORITHM_MD5_SESS ) ) { if ( StringHelper . hasNoText ( sClientNonce ) ) throw new IllegalArgumentException ( "Algorithm requires client nonce!" ) ; sHA1 = _md5 ( sHA1 + SEPARATOR + sServerNonce + SEPARATOR + sClientNonce ) ; } final String sHA2 = _md5 ( eMethod . getName ( ) + SEPARATOR + sDigestURI ) ; String sRequestDigest ; if ( sMessageQOP == null ) { sRequestDigest = _md5 ( sHA1 + SEPARATOR + sServerNonce + SEPARATOR + sHA2 ) ; } else { sRequestDigest = _md5 ( sHA1 + SEPARATOR + sServerNonce + SEPARATOR + sNonceCount + SEPARATOR + sClientNonce + SEPARATOR + sMessageQOP + SEPARATOR + sHA2 ) ; } return new DigestAuthClientCredentials ( sUserName , sRealm , sServerNonce , sDigestURI , sRequestDigest , sAlgorithm , sClientNonce , sOpaque , sMessageQOP , sNonceCount ) ; } | Create HTTP Digest auth credentials for a client |
7,027 | @ SuppressWarnings ( "unchecked" ) public < U extends Uniform > U get ( String name ) { final Uniform uniform = uniforms . get ( name ) ; if ( uniform == null ) { return null ; } return ( U ) uniform ; } | Returns the uniform with the provided name or null if non can be found . |
7,028 | private static String _getFilename ( final String sContentDisposition ) { String sFilename = null ; if ( sContentDisposition != null ) { final String sContentDispositionLC = sContentDisposition . toLowerCase ( Locale . US ) ; if ( sContentDispositionLC . startsWith ( RequestHelper . FORM_DATA ) || sContentDispositionLC . startsWith ( RequestHelper . ATTACHMENT ) ) { final ICommonsMap < String , String > aParams = new ParameterParser ( ) . setLowerCaseNames ( true ) . parse ( sContentDisposition , ';' ) ; if ( aParams . containsKey ( "filename" ) ) { sFilename = aParams . get ( "filename" ) ; if ( sFilename != null ) { sFilename = sFilename . trim ( ) ; } else { sFilename = "" ; } } } } return sFilename ; } | Returns the given content - disposition headers file name . |
7,029 | private static String _getFieldName ( final String sContentDisposition ) { String sFieldName = null ; if ( sContentDisposition != null && sContentDisposition . toLowerCase ( Locale . US ) . startsWith ( RequestHelper . FORM_DATA ) ) { final ICommonsMap < String , String > aParams = new ParameterParser ( ) . setLowerCaseNames ( true ) . parse ( sContentDisposition , ';' ) ; sFieldName = aParams . get ( "name" ) ; if ( sFieldName != null ) sFieldName = sFieldName . trim ( ) ; } return sFieldName ; } | Returns the field name which is given by the content - disposition header . |
7,030 | public static boolean isForbiddenParamValueChar ( final char c ) { return ( c >= 0x0 && c <= 0x8 ) || ( c >= 0xb && c <= 0xc ) || ( c >= 0xe && c <= 0x1f ) || ( c == 0x7f ) || ( c >= 0xd800 && c <= 0xdfff ) || ( c >= 0xfffe && c <= 0xffff ) ; } | Check if the provided char is forbidden in a request value or not . |
7,031 | public static String getWithoutForbiddenChars ( final String s ) { if ( s == null ) return null ; final StringBuilder aCleanValue = new StringBuilder ( s . length ( ) ) ; int nForbidden = 0 ; for ( final char c : s . toCharArray ( ) ) if ( isForbiddenParamValueChar ( c ) ) nForbidden ++ ; else aCleanValue . append ( c ) ; if ( nForbidden == 0 ) { return s ; } if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Removed " + nForbidden + " forbidden character(s) from a request parameter value!" ) ; return aCleanValue . toString ( ) ; } | Remove all chars from the input that cannot be serialized as XML . |
7,032 | public void setString ( String string ) { rawString = string ; colorIndices . clear ( ) ; final StringBuilder stringBuilder = new StringBuilder ( string ) ; final Matcher matcher = COLOR_PATTERN . matcher ( string ) ; int removedCount = 0 ; while ( matcher . find ( ) ) { final int index = matcher . start ( ) - removedCount ; if ( index > 0 && stringBuilder . charAt ( index - 1 ) == '\\' ) { stringBuilder . deleteCharAt ( index - 1 ) ; removedCount ++ ; continue ; } final String colorCode = matcher . group ( ) ; colorIndices . put ( index , CausticUtil . fromPackedARGB ( Long . decode ( colorCode ) . intValue ( ) ) ) ; final int length = colorCode . length ( ) ; stringBuilder . delete ( index , index + length ) ; removedCount += length ; } this . string = stringBuilder . toString ( ) ; } | Sets the string to render . |
7,033 | public static PrivateKey readPrivateKey ( final File root , final String directory , final String fileName ) throws NoSuchAlgorithmException , InvalidKeySpecException , NoSuchProviderException , IOException { final File privatekeyDir = new File ( root , directory ) ; final File privatekeyFile = new File ( privatekeyDir , fileName ) ; final PrivateKey privateKey = PrivateKeyReader . readPrivateKey ( privatekeyFile ) ; return privateKey ; } | Constructs from the given root parent directory and file name the file and reads the private key . |
7,034 | protected String newAlgorithm ( ) { if ( getModel ( ) . getAlgorithm ( ) == null ) { return SunJCEAlgorithm . PBEWithMD5AndDES . getAlgorithm ( ) ; } return getModel ( ) . getAlgorithm ( ) . getAlgorithm ( ) ; } | Factory method for creating a new algorithm that will be used with the cipher object . Overwrite this method to provide a specific algorithm . |
7,035 | public final void init ( final ServletConfig aSC ) throws ServletException { super . init ( aSC ) ; m_aStatusMgr . onServletInit ( getClass ( ) ) ; try { final ICommonsMap < String , String > aInitParams = new CommonsHashMap < > ( ) ; final Enumeration < String > aEnum = aSC . getInitParameterNames ( ) ; while ( aEnum . hasMoreElements ( ) ) { final String sName = aEnum . nextElement ( ) ; aInitParams . put ( sName , aSC . getInitParameter ( sName ) ) ; } m_aHandlerRegistry . forEachHandlerThrowing ( x -> x . onServletInit ( aInitParams ) ) ; } catch ( final ServletException ex ) { m_aStatusMgr . onServletInitFailed ( ex , getClass ( ) ) ; throw ex ; } } | A final overload of init . Overload init instead . |
7,036 | public final void service ( final ServletRequest req , final ServletResponse res ) throws ServletException , IOException { super . service ( req , res ) ; } | Avoid overloading in sub classes |
7,037 | public static void beforeRequest ( final HttpUriRequest aRequest , final HttpContext aHttpContext ) { if ( isEnabled ( ) ) if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "Before HTTP call: " + aRequest . getMethod ( ) + " " + aRequest . getURI ( ) + ( aHttpContext != null ? " (with special HTTP context)" : "" ) ) ; } | Call before an invocation |
7,038 | public static void afterRequest ( final HttpUriRequest aRequest , final Object aResponse , final Throwable aCaughtException ) { if ( isEnabled ( ) ) if ( LOGGER . isInfoEnabled ( ) ) { final HttpResponseException aHex = aCaughtException instanceof HttpResponseException ? ( HttpResponseException ) aCaughtException : null ; LOGGER . info ( "After HTTP call: " + aRequest . getMethod ( ) + ( aResponse != null ? ". Response: " + aResponse : "" ) + ( aHex != null ? ". Status " + aHex . getStatusCode ( ) : "" ) , aHex != null ? null : aCaughtException ) ; } } | Call after an invocation . |
7,039 | private void transform ( JSONArray root ) { for ( int i = 0 , size = root . size ( ) ; i < size ; i ++ ) { Object target = root . get ( i ) ; if ( target instanceof JSONObject ) this . transform ( ( JSONObject ) target ) ; } } | Apply transform to each json object in the json array |
7,040 | public String hashAndHexPassword ( final String password , final String salt ) throws NoSuchAlgorithmException , InvalidKeyException , UnsupportedEncodingException , NoSuchPaddingException , IllegalBlockSizeException , BadPaddingException , InvalidKeySpecException , InvalidAlgorithmParameterException { return hashAndHexPassword ( password , salt , DEFAULT_ALGORITHM , DEFAULT_CHARSET ) ; } | Hash and hex password with the given salt . |
7,041 | public String hashAndHexPassword ( final String password , final String salt , final HashAlgorithm hashAlgorithm , final Charset charset ) throws NoSuchAlgorithmException , InvalidKeyException , UnsupportedEncodingException , NoSuchPaddingException , IllegalBlockSizeException , BadPaddingException , InvalidKeySpecException , InvalidAlgorithmParameterException { final String hashedPassword = Hasher . hashAndHex ( password , salt , hashAlgorithm , charset ) ; return hashedPassword ; } | Hash and hex the given password with the given salt hash algorithm and charset . |
7,042 | public String hashPassword ( final String password , final String salt , final HashAlgorithm hashAlgorithm , final Charset charset ) throws NoSuchAlgorithmException { final String hashedPassword = HashExtensions . hash ( password , salt , hashAlgorithm , charset ) ; return hashedPassword ; } | Hashes the given password with the given salt hash algorithm and charset . |
7,043 | public static final < T extends AbstractGlobalWebSingleton > T getGlobalSingleton ( final Class < T > aClass ) { return getSingleton ( _getStaticScope ( true ) , aClass ) ; } | Get the singleton object in the current global web scope using the passed class . If the singleton is not yet instantiated a new instance is created . |
7,044 | public static void setDNSCacheTime ( final int nSeconds ) { final String sValue = Integer . toString ( nSeconds ) ; Security . setProperty ( "networkaddress.cache.ttl" , sValue ) ; Security . setProperty ( "networkaddress.cache.negative.ttl" , sValue ) ; SystemProperties . setPropertyValue ( "disableWSAddressCaching" , nSeconds == 0 ) ; } | Set special DNS client properties that have influence on the DNS client behavior . This method should be called as soon as possible on startup . In most cases it may be beneficiary if the respective system properties are provided as system properties on the commandline! |
7,045 | public QValue getQValueOfCharset ( final String sCharset ) { ValueEnforcer . notNull ( sCharset , "Charset" ) ; QValue aQuality = m_aMap . get ( _unify ( sCharset ) ) ; if ( aQuality == null ) { aQuality = m_aMap . get ( AcceptCharsetHandler . ANY_CHARSET ) ; if ( aQuality == null ) { return sCharset . equals ( AcceptCharsetHandler . DEFAULT_CHARSET ) ? QValue . MAX_QVALUE : QValue . MIN_QVALUE ; } } return aQuality ; } | Return the associated quality of the given charset . |
7,046 | public static void checkForGLError ( ) { if ( CausticUtil . isDebugEnabled ( ) ) { final int errorValue = GL11 . glGetError ( ) ; if ( errorValue != GL11 . GL_NO_ERROR ) { throw new GLException ( "GL ERROR: " + GLU . gluErrorString ( errorValue ) ) ; } } } | Throws an exception if OpenGL reports an error . |
7,047 | public static PemObject getPemObject ( final File file ) throws IOException { PemObject pemObject ; try ( PemReader pemReader = new PemReader ( new InputStreamReader ( new FileInputStream ( file ) ) ) ) { pemObject = pemReader . readPemObject ( ) ; } return pemObject ; } | Gets the pem object . |
7,048 | public void clearAttributes ( ) { for ( final Map . Entry < String , Object > entry : m_aAttributes . entrySet ( ) ) { final String sName = entry . getKey ( ) ; final Object aValue = entry . getValue ( ) ; if ( aValue instanceof HttpSessionBindingListener ) ( ( HttpSessionBindingListener ) aValue ) . valueUnbound ( new HttpSessionBindingEvent ( this , sName , aValue ) ) ; } m_aAttributes . clear ( ) ; } | Clear all of this session s attributes . |
7,049 | public Serializable serializeState ( ) { final ICommonsMap < String , Object > aState = new CommonsHashMap < > ( ) ; for ( final Map . Entry < String , Object > entry : m_aAttributes . entrySet ( ) ) { final String sName = entry . getKey ( ) ; final Object aValue = entry . getValue ( ) ; if ( aValue instanceof Serializable ) { aState . put ( sName , aValue ) ; } else { if ( aValue instanceof HttpSessionBindingListener ) { ( ( HttpSessionBindingListener ) aValue ) . valueUnbound ( new HttpSessionBindingEvent ( this , sName , aValue ) ) ; } } } m_aAttributes . clear ( ) ; return aState ; } | Serialize the attributes of this session into an object that can be turned into a byte array with standard Java serialization . |
7,050 | public static EChange setAll ( final boolean bResponseCompressionEnabled , final boolean bResponseGzipEnabled , final boolean bResponseDeflateEnabled ) { return s_aRWLock . writeLocked ( ( ) -> { EChange eChange = EChange . UNCHANGED ; if ( s_bResponseCompressionEnabled != bResponseCompressionEnabled ) { s_bResponseCompressionEnabled = bResponseCompressionEnabled ; eChange = EChange . CHANGED ; LOGGER . info ( "ResponseHelper responseCompressEnabled=" + bResponseCompressionEnabled ) ; } if ( s_bResponseGzipEnabled != bResponseGzipEnabled ) { s_bResponseGzipEnabled = bResponseGzipEnabled ; eChange = EChange . CHANGED ; LOGGER . info ( "ResponseHelper responseGzipEnabled=" + bResponseGzipEnabled ) ; } if ( s_bResponseDeflateEnabled != bResponseDeflateEnabled ) { s_bResponseDeflateEnabled = bResponseDeflateEnabled ; eChange = EChange . CHANGED ; LOGGER . info ( "ResponseHelper responseDeflateEnabled=" + bResponseDeflateEnabled ) ; } return eChange ; } ) ; } | Set all parameters at once as an atomic transaction |
7,051 | public static EChange setExpirationSeconds ( final int nExpirationSeconds ) { return s_aRWLock . writeLocked ( ( ) -> { if ( s_nExpirationSeconds == nExpirationSeconds ) return EChange . UNCHANGED ; s_nExpirationSeconds = nExpirationSeconds ; LOGGER . info ( "ResponseHelper expirationSeconds=" + nExpirationSeconds ) ; return EChange . CHANGED ; } ) ; } | Set the default expiration settings to be used for objects that should use HTTP caching |
7,052 | public InputStream openStream ( ) throws IOException { if ( m_aIS instanceof ICloseable && ( ( ICloseable ) m_aIS ) . isClosed ( ) ) throw new MultipartItemSkippedException ( ) ; return m_aIS ; } | Returns an input stream which may be used to read the items contents . |
7,053 | public String text ( ) { return new NodeListSpliterator ( node . getChildNodes ( ) ) . stream ( ) . filter ( it -> it instanceof Text ) . map ( it -> ( ( Text ) it ) . getNodeValue ( ) ) . collect ( joining ( ) ) ; } | Returns the text content of this node . |
7,054 | public Map < String , String > attr ( ) { synchronized ( this ) { if ( attrMap . get ( ) == null ) { attrMap . set ( Optional . ofNullable ( node . getAttributes ( ) ) . map ( XQuery :: attributesToMap ) . map ( Collections :: unmodifiableMap ) . orElseGet ( Collections :: emptyMap ) ) ; } } return attrMap . get ( ) ; } | Returns a map of attributes . |
7,055 | private NodeList evaluate ( String xpath ) { try { XPathExpression expr = xpf . newXPath ( ) . compile ( xpath ) ; return ( NodeList ) expr . evaluate ( node , XPathConstants . NODESET ) ; } catch ( XPathExpressionException ex ) { throw new IllegalArgumentException ( "Invalid XPath '" + xpath + "'" , ex ) ; } } | Evaluates the XPath expression and returns a list of nodes . |
7,056 | private Optional < XQuery > findElement ( Function < Node , Node > iterator ) { Node it = node ; do { it = iterator . apply ( it ) ; } while ( it != null && ! ( it instanceof Element ) ) ; return Optional . ofNullable ( it ) . map ( XQuery :: new ) ; } | Finds an Element node by applying the iterator function until another Element was found . |
7,057 | public DigestAuthServerBuilder setOpaque ( final String sOpaque ) { if ( ! HttpStringHelper . isQuotedTextContent ( sOpaque ) ) throw new IllegalArgumentException ( "opaque is invalid: " + sOpaque ) ; m_sOpaque = sOpaque ; return this ; } | A string of data specified by the server which should be returned by the client unchanged in the Authorization header of subsequent requests with URIs in the same protection space . It is recommended that this string be base64 or hexadecimal data . |
7,058 | public static String getRequestPathInfo ( final HttpServletRequest aRequest ) { String ret = null ; if ( aRequest != null ) try { if ( aRequest . isAsyncSupported ( ) && aRequest . isAsyncStarted ( ) ) ret = ( String ) aRequest . getAttribute ( AsyncContext . ASYNC_PATH_INFO ) ; else ret = aRequest . getPathInfo ( ) ; } catch ( final UnsupportedOperationException ex ) { } catch ( final Exception ex ) { if ( isLogExceptions ( ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "[ServletHelper] Failed to determine path info of HTTP request" , ex ) ; } return ret == null ? "" : ret ; } | Get the path info of an request supporting sync and async requests . |
7,059 | public static String getRequestRequestURI ( final HttpServletRequest aRequest ) { String ret = "" ; if ( aRequest != null ) try { if ( aRequest . isAsyncSupported ( ) && aRequest . isAsyncStarted ( ) ) ret = ( String ) aRequest . getAttribute ( AsyncContext . ASYNC_REQUEST_URI ) ; else ret = aRequest . getRequestURI ( ) ; } catch ( final Exception ex ) { if ( isLogExceptions ( ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "[ServletHelper] Failed to determine request URI of HTTP request" , ex ) ; } return ret ; } | Get the request URI of an request supporting sync and async requests . |
7,060 | public static StringBuffer getRequestRequestURL ( final HttpServletRequest aRequest ) { StringBuffer ret = null ; if ( aRequest != null ) try { ret = aRequest . getRequestURL ( ) ; } catch ( final Exception ex ) { if ( isLogExceptions ( ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "[ServletHelper] Failed to determine request URL of HTTP request" , ex ) ; } return ret != null ? ret : new StringBuffer ( ) ; } | Get the request URL of an request supporting sync and async requests . |
7,061 | public static String getRequestServletPath ( final HttpServletRequest aRequest ) { String ret = "" ; if ( aRequest != null ) try { if ( aRequest . isAsyncSupported ( ) && aRequest . isAsyncStarted ( ) ) ret = ( String ) aRequest . getAttribute ( AsyncContext . ASYNC_SERVLET_PATH ) ; else ret = aRequest . getServletPath ( ) ; } catch ( final UnsupportedOperationException ex ) { } catch ( final Exception ex ) { if ( isLogExceptions ( ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "[ServletHelper] Failed to determine servlet path of HTTP request" , ex ) ; } return ret ; } | Get the servlet path of an request supporting sync and async requests . |
7,062 | public BasicAuthServerBuilder setRealm ( final String sRealm ) { ValueEnforcer . isTrue ( HttpStringHelper . isQuotedTextContent ( sRealm ) , ( ) -> "Realm is invalid: " + sRealm ) ; m_sRealm = sRealm ; return this ; } | Set the realm to be used . |
7,063 | public boolean contains ( String path ) { boolean result = false ; FileName fn = new FileName ( path ) ; if ( fn . getPath ( ) . startsWith ( getPath ( ) ) ) { result = true ; } return result ; } | This will check if the given path is part of the path which is represented by this instance . |
7,064 | public String getCurrentAttempt ( ) { if ( currentIndex < words . size ( ) ) { final String currentAttempt = words . get ( currentIndex ) ; return currentAttempt ; } return null ; } | Gets the current attempt . |
7,065 | public boolean process ( ) { boolean continueIterate = true ; boolean found = false ; String attempt = getCurrentAttempt ( ) ; while ( continueIterate ) { if ( attempt . equals ( toCheckAgainst ) ) { found = true ; break ; } attempt = getCurrentAttempt ( ) ; continueIterate = increment ( ) ; } return found ; } | Processes the word list . |
7,066 | public FailedMailData remove ( final String sID ) { if ( StringHelper . hasNoText ( sID ) ) return null ; return m_aRWLock . writeLocked ( ( ) -> internalRemove ( sID ) ) ; } | Remove the failed mail at the given index . |
7,067 | public static BasicAuthClientCredentials getBasicAuthClientCredentials ( final String sAuthHeader ) { final String sRealHeader = StringHelper . trim ( sAuthHeader ) ; if ( StringHelper . hasNoText ( sRealHeader ) ) return null ; final String [ ] aElements = RegExHelper . getSplitToArray ( sRealHeader , "\\s+" , 2 ) ; if ( aElements . length != 2 ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "String is not Basic Auth: " + sRealHeader ) ; return null ; } if ( ! aElements [ 0 ] . equals ( HEADER_VALUE_PREFIX_BASIC ) ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "String does not start with 'Basic': " + sRealHeader ) ; return null ; } final String sEncodedCredentials = aElements [ 1 ] ; final String sUsernamePassword = Base64 . safeDecodeAsString ( sEncodedCredentials , CHARSET ) ; if ( sUsernamePassword == null ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "Illegal Base64 encoded value '" + sEncodedCredentials + "'" ) ; return null ; } final int nIndex = sUsernamePassword . indexOf ( USERNAME_PASSWORD_SEPARATOR ) ; if ( nIndex >= 0 ) return new BasicAuthClientCredentials ( sUsernamePassword . substring ( 0 , nIndex ) , sUsernamePassword . substring ( nIndex + 1 ) ) ; return new BasicAuthClientCredentials ( sUsernamePassword ) ; } | Get the Basic authentication credentials from the passed HTTP header value . |
7,068 | public void onServletInit ( final Class < ? extends GenericServlet > aServletClass ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "onServletInit: " + aServletClass ) ; _updateStatus ( aServletClass , EServletStatus . INITED ) ; } | Invoked at the beginning of the servlet initialization . |
7,069 | public void onServletInvocation ( final Class < ? extends GenericServlet > aServletClass ) { m_aRWLock . writeLocked ( ( ) -> _getOrCreateServletStatus ( aServletClass ) . internalIncrementInvocationCount ( ) ) ; } | Invoked at the beginning of a servlet invocation |
7,070 | public static ENetworkPortStatus checkPortOpen ( final String sHostName , final int nPort , final int nTimeoutMillisecs ) { ValueEnforcer . notEmpty ( sHostName , "Hostname" ) ; ValueEnforcer . isGE0 ( nPort , "Port" ) ; ValueEnforcer . isGE0 ( nTimeoutMillisecs , "TimeoutMillisecs" ) ; LOGGER . info ( "Checking TCP port status for " + sHostName + ":" + nPort + " with timeouf of " + nTimeoutMillisecs + " ms" ) ; try ( final Socket aSocket = new Socket ( ) ) { aSocket . setReuseAddress ( true ) ; final SocketAddress aSocketAddr = new InetSocketAddress ( sHostName , nPort ) ; aSocket . connect ( aSocketAddr , nTimeoutMillisecs ) ; return ENetworkPortStatus . PORT_IS_OPEN ; } catch ( final IOException ex ) { if ( ex . getMessage ( ) . startsWith ( "Connection refused" ) ) return ENetworkPortStatus . PORT_IS_CLOSED ; if ( ex instanceof java . net . UnknownHostException ) return ENetworkPortStatus . HOST_NOT_EXISTING ; if ( ex instanceof java . net . SocketTimeoutException ) return ENetworkPortStatus . CONNECTION_TIMEOUT ; if ( ex instanceof java . net . ConnectException ) { return ENetworkPortStatus . GENERIC_IO_ERROR ; } LOGGER . error ( "Other error checking TCP port status" , ex ) ; return ENetworkPortStatus . GENERIC_IO_ERROR ; } } | Check the status of a remote port . |
7,071 | private static UserAgentElementList _decryptUserAgent ( final String sUserAgent ) { final UserAgentElementList ret = new UserAgentElementList ( ) ; final StringScanner aSS = new StringScanner ( sUserAgent . trim ( ) ) ; while ( true ) { aSS . skipWhitespaces ( ) ; final int nIndex = aSS . findFirstIndex ( '/' , ' ' , '[' , '(' ) ; if ( nIndex == - 1 ) break ; switch ( aSS . getCharAtIndex ( nIndex ) ) { case '/' : { final String sKey = aSS . getUntilIndex ( nIndex ) ; final String sValue = aSS . skip ( 1 ) . getUntilWhiteSpace ( ) ; final String sFullValue = sKey + "/" + sValue ; if ( URLProtocolRegistry . getInstance ( ) . hasKnownProtocol ( sFullValue ) ) ret . add ( sFullValue ) ; else ret . add ( Pair . create ( sKey , sValue ) ) ; break ; } case ' ' : { final String sText = aSS . getUntilIndex ( nIndex ) . trim ( ) ; final Matcher aMatcher = RegExHelper . getMatcher ( "([^\\s]+)\\s+([0-9]+\\.[0-9]+)" , sText ) ; if ( aMatcher . matches ( ) ) ret . add ( Pair . create ( aMatcher . group ( 1 ) , aMatcher . group ( 2 ) ) ) ; else ret . add ( sText ) ; break ; } case '[' : { aSS . setIndex ( nIndex ) . skip ( 1 ) ; ret . add ( aSS . getUntil ( ']' ) ) ; aSS . skip ( 1 ) ; break ; } case '(' : { aSS . setIndex ( nIndex ) . skip ( 1 ) ; final String sParams = aSS . getUntilBalanced ( 1 , '(' , ')' ) ; final ICommonsList < String > aParams = StringHelper . getExploded ( ';' , sParams ) ; ret . add ( aParams . getAllMapped ( String :: trim ) ) ; break ; } default : throw new IllegalStateException ( "Invalid character: " + aSS . getCharAtIndex ( nIndex ) ) ; } } final String sRest = aSS . getRest ( ) . trim ( ) ; if ( sRest . length ( ) > 0 ) ret . add ( sRest ) ; return ret ; } | Parse the passed user agent . |
7,072 | public static IUserAgent decryptUserAgentString ( final String sUserAgent ) { ValueEnforcer . notNull ( sUserAgent , "UserAgent" ) ; String sRealUserAgent = sUserAgent ; if ( sRealUserAgent . length ( ) >= 2 ) { final char cFirst = sRealUserAgent . charAt ( 0 ) ; if ( ( cFirst == '\'' || cFirst == '"' ) && StringHelper . getLastChar ( sRealUserAgent ) == cFirst ) sRealUserAgent = sRealUserAgent . substring ( 1 , sRealUserAgent . length ( ) - 1 ) ; } if ( sRealUserAgent . startsWith ( SKIP_PREFIX ) ) sRealUserAgent = sRealUserAgent . substring ( SKIP_PREFIX . length ( ) ) ; return new UserAgent ( sRealUserAgent , _decryptUserAgent ( sRealUserAgent ) ) ; } | Decrypt the passed user agent string . |
7,073 | public static PasswordAuthentication requestProxyPasswordAuthentication ( final String sHostName , final int nPort , final String sProtocol ) { return requestPasswordAuthentication ( sHostName , ( InetAddress ) null , nPort , sProtocol , ( String ) null , ( String ) null , ( URL ) null , RequestorType . PROXY ) ; } | Shortcut method for requesting proxy password authentication . This method can also be used if this class is NOT the default Authenticator . |
7,074 | public static < T > T get ( final Class < T > pageClass , final String ... params ) { cryIfNotAnnotated ( pageClass ) ; try { final String pageUrl = pageClass . getAnnotation ( Page . class ) . value ( ) ; return loadPage ( pageUrl , pageClass , Arrays . asList ( params ) ) ; } catch ( final Exception e ) { throw new RuntimeException ( e ) ; } } | Loads content from url from the Page annotation on pageClass onto an instance of pageClass . |
7,075 | private ICommonsOrderedMap < String , RequestParamMapItem > _getChildMapExceptLast ( final String ... aPath ) { ValueEnforcer . notEmpty ( aPath , "Path" ) ; ICommonsOrderedMap < String , RequestParamMapItem > aMap = m_aMap ; for ( int i = 0 ; i < aPath . length - 1 ; ++ i ) { aMap = _getChildMap ( aMap , aPath [ i ] ) ; if ( aMap == null ) return null ; } return aMap ; } | Iterate the root map down to the map specified by the passed path except for the last element . |
7,076 | public static String getFieldName ( final String sBaseName ) { ValueEnforcer . notEmpty ( sBaseName , "BaseName" ) ; return sBaseName ; } | This method doesn t make sense but it should stay so that it s easy to spot usage of this invalid method . |
7,077 | public static void setSeparators ( final char cOpen , final char cClose ) { ValueEnforcer . isFalse ( cOpen == cClose , "Open and closing element may not be identical!" ) ; s_sOpen = Character . toString ( cOpen ) ; s_sClose = Character . toString ( cClose ) ; } | Set the separator chars to use . |
7,078 | public static void setSeparators ( final String sOpen , final String sClose ) { ValueEnforcer . notEmpty ( sOpen , "Open" ) ; ValueEnforcer . notEmpty ( sClose , "Close" ) ; ValueEnforcer . isFalse ( sOpen . contains ( sClose ) , "open may not contain close" ) ; ValueEnforcer . isFalse ( sClose . contains ( sOpen ) , "close may not contain open" ) ; s_sOpen = sOpen ; s_sClose = sClose ; } | Set the separators to use . |
7,079 | public static SimpleURL getWithoutSessionID ( final ISimpleURL aURL ) { ValueEnforcer . notNull ( aURL , "URL" ) ; return new SimpleURL ( new URLData ( getWithoutSessionID ( aURL . getPath ( ) ) , aURL . params ( ) , aURL . getAnchor ( ) ) ) ; } | Get the passed string without an eventually contained session ID like in test . html ; JSESSIONID = 1234?param = value . |
7,080 | public static String getPathWithinServletContext ( final HttpServletRequest aHttpRequest ) { ValueEnforcer . notNull ( aHttpRequest , "HttpRequest" ) ; final String sRequestURI = getRequestURI ( aHttpRequest ) ; if ( StringHelper . hasNoText ( sRequestURI ) ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Having empty request URI '" + sRequestURI + "' from request " + aHttpRequest ) ; return "/" ; } final String sContextPath = ServletContextPathHolder . getContextPath ( ) ; if ( StringHelper . hasNoText ( sContextPath ) || ! sRequestURI . startsWith ( sContextPath ) ) return sRequestURI ; final String sPath = sRequestURI . substring ( sContextPath . length ( ) ) ; return sPath . length ( ) > 0 ? sPath : "/" ; } | Return the URI of the request within the servlet context . |
7,081 | public static EHttpVersion getHttpVersion ( final HttpServletRequest aHttpRequest ) { ValueEnforcer . notNull ( aHttpRequest , "HttpRequest" ) ; final String sProtocol = aHttpRequest . getProtocol ( ) ; return EHttpVersion . getFromNameOrNull ( sProtocol ) ; } | Get the HTTP version associated with the given HTTP request |
7,082 | public static EHttpMethod getHttpMethod ( final HttpServletRequest aHttpRequest ) { ValueEnforcer . notNull ( aHttpRequest , "HttpRequest" ) ; final String sMethod = aHttpRequest . getMethod ( ) ; return EHttpMethod . getFromNameOrNull ( sMethod ) ; } | Get the HTTP method associated with the given HTTP request |
7,083 | public static HttpHeaderMap getRequestHeaderMap ( final HttpServletRequest aHttpRequest ) { ValueEnforcer . notNull ( aHttpRequest , "HttpRequest" ) ; final HttpHeaderMap ret = new HttpHeaderMap ( ) ; final Enumeration < String > aHeaders = aHttpRequest . getHeaderNames ( ) ; while ( aHeaders . hasMoreElements ( ) ) { final String sName = aHeaders . nextElement ( ) ; final Enumeration < String > eHeaderValues = aHttpRequest . getHeaders ( sName ) ; while ( eHeaderValues . hasMoreElements ( ) ) { final String sValue = eHeaderValues . nextElement ( ) ; ret . addHeader ( sName , sValue ) ; } } return ret ; } | Get a complete request header map as a copy . |
7,084 | public static X509Certificate [ ] getRequestClientCertificates ( final HttpServletRequest aHttpRequest ) { return _getRequestAttr ( aHttpRequest , SERVLET_ATTR_CLIENT_CERTIFICATE , X509Certificate [ ] . class ) ; } | Get the client certificates provided by a HTTP servlet request . |
7,085 | public static String getHttpUserAgentStringFromRequest ( final HttpServletRequest aHttpRequest ) { String sUserAgent = aHttpRequest . getHeader ( CHttpHeader . UA ) ; if ( sUserAgent == null ) { sUserAgent = aHttpRequest . getHeader ( CHttpHeader . X_DEVICE_USER_AGENT ) ; if ( sUserAgent == null ) sUserAgent = aHttpRequest . getHeader ( CHttpHeader . USER_AGENT ) ; } return sUserAgent ; } | Get the user agent from the given request . |
7,086 | public static String getCheckBoxHiddenFieldName ( final String sFieldName ) { ValueEnforcer . notEmpty ( sFieldName , "FieldName" ) ; return DEFAULT_CHECKBOX_HIDDEN_FIELD_PREFIX + sFieldName ; } | Get the name of the automatic hidden field associated with a check - box . |
7,087 | public static Cookie createCookie ( final String sName , final String sValue , final String sPath , final boolean bExpireWhenBrowserIsClosed ) { final Cookie aCookie = new Cookie ( sName , sValue ) ; aCookie . setPath ( sPath ) ; if ( bExpireWhenBrowserIsClosed ) aCookie . setMaxAge ( - 1 ) ; else aCookie . setMaxAge ( DEFAULT_MAX_AGE_SECONDS ) ; return aCookie ; } | Create a cookie that is bound on a certain path within the local web server . |
7,088 | public static void removeCookie ( final HttpServletResponse aHttpResponse , final Cookie aCookie ) { ValueEnforcer . notNull ( aHttpResponse , "HttpResponse" ) ; ValueEnforcer . notNull ( aCookie , "aCookie" ) ; aCookie . setMaxAge ( 0 ) ; aHttpResponse . addCookie ( aCookie ) ; } | Remove a cookie by setting the max age to 0 . |
7,089 | public static PrivateKey readPasswordProtectedPrivateKey ( final byte [ ] encryptedPrivateKeyBytes , final String password , final String algorithm ) throws IOException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidKeySpecException , InvalidKeyException , InvalidAlgorithmParameterException { final EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new EncryptedPrivateKeyInfo ( encryptedPrivateKeyBytes ) ; final String algName = encryptedPrivateKeyInfo . getAlgName ( ) ; final Cipher cipher = CipherFactory . newCipher ( algName ) ; final KeySpec pbeKeySpec = KeySpecFactory . newPBEKeySpec ( password ) ; final SecretKeyFactory secretKeyFactory = SecretKeyFactoryExtensions . newSecretKeyFactory ( algName ) ; final Key pbeKey = secretKeyFactory . generateSecret ( pbeKeySpec ) ; final AlgorithmParameters algParameters = encryptedPrivateKeyInfo . getAlgParameters ( ) ; cipher . init ( Cipher . DECRYPT_MODE , pbeKey , algParameters ) ; final KeySpec pkcs8KeySpec = encryptedPrivateKeyInfo . getKeySpec ( cipher ) ; final KeyFactory keyFactory = KeyFactory . getInstance ( algorithm ) ; return keyFactory . generatePrivate ( pkcs8KeySpec ) ; } | Reads the given byte array that contains a password protected private key . |
7,090 | public static ServletAsyncSpec createAsync ( final long nTimeoutMillis , final Iterable < ? extends AsyncListener > aAsyncListeners ) { return new ServletAsyncSpec ( true , nTimeoutMillis , aAsyncListeners ) ; } | Create an async spec . |
7,091 | protected OutputStream initOutput ( final File file ) throws MojoExecutionException { final OutputStream stream ; try { if ( file . isDirectory ( ) ) { throw new MojoExecutionException ( "File " + file . getAbsolutePath ( ) + " is directory!" ) ; } if ( file . exists ( ) && ! file . delete ( ) ) { throw new MojoExecutionException ( "Could not remove file: " + file . getAbsolutePath ( ) ) ; } final File fileDirectory = file . getParentFile ( ) ; if ( ! fileDirectory . exists ( ) && ! fileDirectory . mkdirs ( ) ) { throw new MojoExecutionException ( "Could not create directory: " + fileDirectory . getAbsolutePath ( ) ) ; } if ( ! fileDirectory . isDirectory ( ) ) { throw new MojoExecutionException ( "Not a directory: " + fileDirectory . getAbsolutePath ( ) ) ; } if ( ! file . createNewFile ( ) ) { throw new MojoExecutionException ( "Could not create file: " + file . getAbsolutePath ( ) ) ; } stream = new FileOutputStream ( file ) ; } catch ( FileNotFoundException e ) { throw new MojoExecutionException ( "Could not find file: " + file . getAbsolutePath ( ) , e ) ; } catch ( IOException e ) { throw new MojoExecutionException ( "Could not write to file: " + file . getAbsolutePath ( ) , e ) ; } return stream ; } | Opens an OutputStream based on the supplied file |
7,092 | protected InputStream initInput ( final File file ) throws MojoExecutionException { InputStream stream = null ; try { if ( file . isDirectory ( ) ) { throw new MojoExecutionException ( "File " + file . getAbsolutePath ( ) + " is directory!" ) ; } if ( ! file . exists ( ) ) { throw new MojoExecutionException ( "File " + file . getAbsolutePath ( ) + " does not exist!" ) ; } stream = new FileInputStream ( file ) ; } catch ( FileNotFoundException e ) { throw new MojoExecutionException ( "Could not find file: " + file . getAbsolutePath ( ) , e ) ; } return stream ; } | Opens an InputStream based on the supplied file |
7,093 | protected void appendStream ( final InputStream input , final OutputStream output ) throws MojoExecutionException { int character ; try { final String newLine = System . getProperty ( "line.separator" ) ; while ( ( character = input . read ( ) ) != - 1 ) { output . write ( character ) ; } output . write ( newLine . getBytes ( ) ) ; output . flush ( ) ; } catch ( IOException e ) { throw new MojoExecutionException ( "Error in buffering/writing " + e . getMessage ( ) , e ) ; } } | Appends inputstream to outputstream |
7,094 | protected void onThresholdReached ( ) throws IOException { FileOutputStream aFOS = null ; try { aFOS = new FileOutputStream ( m_aOutputFile ) ; m_aMemoryOS . writeTo ( aFOS ) ; m_aCurrentOS = aFOS ; StreamHelper . close ( m_aMemoryOS ) ; m_aMemoryOS = null ; } catch ( final IOException ex ) { StreamHelper . close ( aFOS ) ; throw ex ; } } | Switches the underlying output stream from a memory based stream to one that is backed by disk . This is the point at which we realise that too much data is being written to keep in memory so we elect to switch to disk - based storage . |
7,095 | public void writeTo ( final OutputStream aOS ) throws IOException { if ( ! m_bClosed ) throw new IOException ( "This stream is not closed" ) ; if ( isInMemory ( ) ) { m_aMemoryOS . writeTo ( aOS ) ; } else { final InputStream aIS = FileHelper . getInputStream ( m_aOutputFile ) ; StreamHelper . copyInputStreamToOutputStream ( aIS , aOS ) ; } } | Writes the data from this output stream to the specified output stream after it has been closed . |
7,096 | public static VertexData generatePlane ( Vector2f size ) { final VertexData destination = new VertexData ( ) ; final VertexAttribute positionsAttribute = new VertexAttribute ( "positions" , DataType . FLOAT , 3 ) ; destination . addAttribute ( 0 , positionsAttribute ) ; final TFloatList positions = new TFloatArrayList ( ) ; final VertexAttribute normalsAttribute = new VertexAttribute ( "normals" , DataType . FLOAT , 3 ) ; destination . addAttribute ( 1 , normalsAttribute ) ; final TFloatList normals = new TFloatArrayList ( ) ; final VertexAttribute textureCoordsAttribute = new VertexAttribute ( "textureCoords" , DataType . FLOAT , 2 ) ; destination . addAttribute ( 2 , textureCoordsAttribute ) ; final TFloatList textureCoords = new TFloatArrayList ( ) ; final TIntList indices = destination . getIndices ( ) ; generatePlane ( positions , normals , textureCoords , indices , size ) ; positionsAttribute . setData ( positions ) ; normalsAttribute . setData ( normals ) ; textureCoordsAttribute . setData ( textureCoords ) ; return destination ; } | Generates a plane on xy . The center is at the middle of the plane . |
7,097 | public static void generatePlane ( TFloatList positions , TFloatList normals , TFloatList textureCoords , TIntList indices , Vector2f size ) { final Vector2f p = size . div ( 2 ) ; final Vector3f p3 = new Vector3f ( p . getX ( ) , p . getY ( ) , 0 ) ; final Vector3f p2 = new Vector3f ( - p . getX ( ) , p . getY ( ) , 0 ) ; final Vector3f p1 = new Vector3f ( p . getX ( ) , - p . getY ( ) , 0 ) ; final Vector3f p0 = new Vector3f ( - p . getX ( ) , - p . getY ( ) , 0 ) ; final Vector3f n = new Vector3f ( 0 , 0 , 1 ) ; addVector ( positions , p0 ) ; addVector ( normals , n ) ; addAll ( textureCoords , 0 , 0 ) ; addVector ( positions , p1 ) ; addVector ( normals , n ) ; addAll ( textureCoords , 1 , 0 ) ; addVector ( positions , p2 ) ; addVector ( normals , n ) ; addAll ( textureCoords , 0 , 1 ) ; addVector ( positions , p3 ) ; addVector ( normals , n ) ; addAll ( textureCoords , 1 , 1 ) ; addAll ( indices , 0 , 3 , 2 , 0 , 1 , 3 ) ; } | Generates a textured plane on xy . The center is at the middle of the plane . |
7,098 | public static void generateCylinder ( TFloatList positions , TFloatList normals , TIntList indices , float radius , float height ) { final float halfHeight = height / 2 ; final List < Vector3f > rims = new ArrayList < > ( ) ; for ( int angle = 0 ; angle < 360 ; angle += 15 ) { final double angleRads = Math . toRadians ( angle ) ; rims . add ( new Vector3f ( radius * TrigMath . cos ( angleRads ) , halfHeight , radius * - TrigMath . sin ( angleRads ) ) ) ; } final Vector3f topNormal = new Vector3f ( 0 , 1 , 0 ) ; final Vector3f bottomNormal = new Vector3f ( 0 , - 1 , 0 ) ; addVector ( positions , new Vector3f ( 0 , halfHeight , 0 ) ) ; addVector ( normals , topNormal ) ; addVector ( positions , new Vector3f ( 0 , - halfHeight , 0 ) ) ; addVector ( normals , bottomNormal ) ; final int rimsSize = rims . size ( ) ; for ( int i = 0 ; i < rimsSize ; i ++ ) { final Vector3f t = rims . get ( i ) ; final Vector3f b = new Vector3f ( t . getX ( ) , - t . getY ( ) , t . getZ ( ) ) ; final Vector3f n = new Vector3f ( t . getX ( ) , 0 , t . getZ ( ) ) . normalize ( ) ; addVector ( positions , t ) ; addVector ( normals , topNormal ) ; addVector ( positions , b ) ; addVector ( normals , bottomNormal ) ; addVector ( positions , t ) ; addVector ( normals , n ) ; addVector ( positions , b ) ; addVector ( normals , n ) ; final int currentIndex = i * 4 + 2 ; final int nextIndex = ( i == rimsSize - 1 ? 0 : i + 1 ) * 4 + 2 ; addAll ( indices , 0 , currentIndex , nextIndex ) ; addAll ( indices , 1 , nextIndex + 1 , currentIndex + 1 ) ; addAll ( indices , currentIndex + 2 , currentIndex + 3 , nextIndex + 2 ) ; addAll ( indices , currentIndex + 3 , nextIndex + 3 , nextIndex + 2 ) ; } } | Generates a cylindrical solid mesh . The center is at middle of the of the cylinder . |
7,099 | public EChange setFrom ( final MockEventListenerList aList ) { ValueEnforcer . notNull ( aList , "List" ) ; if ( this == aList ) return EChange . UNCHANGED ; final ICommonsList < EventListener > aOtherListeners = aList . getAllListeners ( ) ; return m_aRWLock . writeLocked ( ( ) -> { if ( m_aListener . isEmpty ( ) && aOtherListeners . isEmpty ( ) ) return EChange . UNCHANGED ; m_aListener . setAll ( aOtherListeners ) ; return EChange . CHANGED ; } ) ; } | Set all listeners from the passed list to this list |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.