idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
6,900 | @ Pure public static < T extends Node > T getChild ( Node parent , Class < T > type ) { assert parent != null : AssertMessages . notNullParameter ( 0 ) ; assert type != null : AssertMessages . notNullParameter ( 1 ) ; final NodeList children = parent . getChildNodes ( ) ; final int len = children . getLength ( ) ; for ( int i = 0 ; i < len ; ++ i ) { final Node child = children . item ( i ) ; if ( type . isInstance ( child ) ) { return type . cast ( child ) ; } } return null ; } | Replies the first child node that has the specified type . | 133 | 12 |
6,901 | @ Pure public static Document getDocumentFor ( Node node ) { Node localnode = node ; while ( localnode != null ) { if ( localnode instanceof Document ) { return ( Document ) localnode ; } localnode = localnode . getParentNode ( ) ; } return null ; } | Replies the XML Document that is containing the given node . | 61 | 12 |
6,902 | @ Pure public static String getText ( Node document , String ... path ) { assert document != null : AssertMessages . notNullParameter ( 0 ) ; Node parentNode = getNodeFromPath ( document , path ) ; if ( parentNode == null ) { parentNode = document ; } final StringBuilder text = new StringBuilder ( ) ; final NodeList children = parentNode . getChildNodes ( ) ; final int len = children . getLength ( ) ; for ( int i = 0 ; i < len ; ++ i ) { final Node child = children . item ( i ) ; if ( child instanceof Text ) { text . append ( ( ( Text ) child ) . getWholeText ( ) ) ; } } if ( text . length ( ) > 0 ) { return text . toString ( ) ; } return null ; } | Replies the text inside the node at the specified path . | 177 | 12 |
6,903 | @ Pure public static Iterator < Node > iterate ( Node parent , String nodeName ) { assert parent != null : AssertMessages . notNullParameter ( 0 ) ; assert nodeName != null && ! nodeName . isEmpty ( ) : AssertMessages . notNullParameter ( 0 ) ; return new NameBasedIterator ( parent , nodeName ) ; } | Replies an iterator on nodes that have the specified node name . | 77 | 13 |
6,904 | @ Pure public static Object parseObject ( String xmlSerializedObject ) throws IOException , ClassNotFoundException { assert xmlSerializedObject != null : AssertMessages . notNullParameter ( 0 ) ; try ( ByteArrayInputStream bais = new ByteArrayInputStream ( Base64 . getDecoder ( ) . decode ( xmlSerializedObject ) ) ) { final ObjectInputStream ois = new ObjectInputStream ( bais ) ; return ois . readObject ( ) ; } } | Deserialize an object from the given XML string . | 104 | 11 |
6,905 | @ Pure public static byte [ ] parseString ( String text ) { return Base64 . getDecoder ( ) . decode ( Strings . nullToEmpty ( text ) . trim ( ) ) ; } | Parse a Base64 string with contains a set of bytes . | 42 | 13 |
6,906 | @ Pure public static Document parseXML ( String xmlString ) { assert xmlString != null : AssertMessages . notNullParameter ( 0 ) ; try { return readXML ( new StringReader ( xmlString ) ) ; } catch ( Exception e ) { // } return null ; } | Parse a string representation of an XML document . | 61 | 10 |
6,907 | public static void writeResources ( Element node , XMLResources resources , XMLBuilder builder ) { if ( resources != null ) { final Element resourcesNode = builder . createElement ( NODE_RESOURCES ) ; for ( final java . util . Map . Entry < Long , Entry > pair : resources . getPairs ( ) . entrySet ( ) ) { final Entry e = pair . getValue ( ) ; if ( e . isURL ( ) ) { final Element resourceNode = builder . createElement ( NODE_RESOURCE ) ; resourceNode . setAttribute ( ATTR_ID , XMLResources . getStringIdentifier ( pair . getKey ( ) ) ) ; resourceNode . setAttribute ( ATTR_URL , e . getURL ( ) . toExternalForm ( ) ) ; resourceNode . setAttribute ( ATTR_MIMETYPE , e . getMimeType ( ) ) ; resourcesNode . appendChild ( resourceNode ) ; } else if ( e . isFile ( ) ) { final Element resourceNode = builder . createElement ( NODE_RESOURCE ) ; resourceNode . setAttribute ( ATTR_ID , XMLResources . getStringIdentifier ( pair . getKey ( ) ) ) ; final File file = e . getFile ( ) ; final StringBuilder url = new StringBuilder ( ) ; url . append ( "file:" ) ; //$NON-NLS-1$ boolean addSlash = false ; for ( final String elt : FileSystem . split ( file ) ) { try { if ( addSlash ) { url . append ( "/" ) ; //$NON-NLS-1$ } url . append ( URLEncoder . encode ( elt , Charset . defaultCharset ( ) . name ( ) ) ) ; } catch ( UnsupportedEncodingException e1 ) { throw new Error ( e1 ) ; } addSlash = true ; } resourceNode . setAttribute ( ATTR_FILE , url . toString ( ) ) ; resourceNode . setAttribute ( ATTR_MIMETYPE , e . getMimeType ( ) ) ; resourcesNode . appendChild ( resourceNode ) ; } else if ( e . isEmbeddedData ( ) ) { final Element resourceNode = builder . createElement ( NODE_RESOURCE ) ; resourceNode . setAttribute ( ATTR_ID , XMLResources . getStringIdentifier ( pair . getKey ( ) ) ) ; resourceNode . setAttribute ( ATTR_MIMETYPE , e . getMimeType ( ) ) ; final byte [ ] data = e . getEmbeddedData ( ) ; final CDATASection cdata = builder . createCDATASection ( toString ( data ) ) ; resourceNode . appendChild ( cdata ) ; resourcesNode . appendChild ( resourceNode ) ; } } if ( resourcesNode . getChildNodes ( ) . getLength ( ) > 0 ) { node . appendChild ( resourcesNode ) ; } } } | Write the given resources into the given XML node . | 639 | 10 |
6,908 | @ Pure public static URL readResourceURL ( Element node , XMLResources resources , String ... path ) { final String stringValue = getAttributeValue ( node , path ) ; if ( XMLResources . isStringIdentifier ( stringValue ) ) { try { final long id = XMLResources . getNumericalIdentifier ( stringValue ) ; return resources . getResourceURL ( id ) ; } catch ( Throwable exception ) { // } } return null ; } | Replies the resource URL that is contained inside the XML attribute defined in the given node and with the given XML path . | 95 | 24 |
6,909 | protected static StackTraceElement getTraceElementAt ( int level ) { if ( level < 0 ) { return null ; } try { final StackTraceElement [ ] stackTrace = Thread . currentThread ( ) . getStackTrace ( ) ; int j = - 1 ; boolean found = false ; Class < ? > type ; for ( int i = 0 ; i < stackTrace . length ; ++ i ) { if ( found ) { if ( ( i - j ) == level ) { return stackTrace [ i ] ; } } else { type = loadClass ( stackTrace [ i ] . getClassName ( ) ) ; if ( type != null && Caller . class . isAssignableFrom ( type ) ) { j = i + 1 ; } else if ( j >= 0 ) { // First ocurrence of a class in the stack, after the // inner invocation of StackTraceCaller found = true ; if ( ( i - j ) == level ) { return stackTrace [ i ] ; } } } } } catch ( AssertionError e ) { throw e ; } catch ( Throwable exception ) { // } return null ; } | Replies the stack trace element for the given level . | 249 | 11 |
6,910 | public boolean moveTo ( N newParent ) { if ( newParent == null ) { return false ; } return moveTo ( newParent , newParent . getChildCount ( ) ) ; } | Move this node in the given new parent node . | 40 | 10 |
6,911 | public final boolean addChild ( int index , N newChild ) { if ( newChild == null ) { return false ; } final int count = ( this . children == null ) ? 0 : this . children . size ( ) ; final N oldParent = newChild . getParentNode ( ) ; if ( oldParent != this && oldParent != null ) { newChild . removeFromParent ( ) ; } final int insertionIndex ; if ( this . children == null ) { this . children = newInternalList ( index + 1 ) ; } if ( index < count ) { // set the element insertionIndex = Math . max ( index , 0 ) ; this . children . add ( insertionIndex , newChild ) ; } else { // Resize the array insertionIndex = this . children . size ( ) ; this . children . add ( newChild ) ; } ++ this . notNullChildCount ; newChild . setParentNodeReference ( toN ( ) , true ) ; firePropertyChildAdded ( insertionIndex , newChild ) ; return true ; } | Add a child node at the specified index . | 219 | 9 |
6,912 | public static final < T extends Comparable < T > > Ordering < Scored < T > > ByScoreThenByItem ( Ordering < T > itemOrdering ) { final Ordering < Scored < T > > byItem = itemOrdering . onResultOf ( Scoreds . < T > itemsOnly ( ) ) ; final Ordering < Scored < T > > byScore = Scoreds . < T > ByScoreOnly ( ) ; return Ordering . compound ( ImmutableList . of ( byScore , byItem ) ) ; } | Comparator which compares Scoreds first by score then by item where the item ordering to use is explicitly specified . | 118 | 23 |
6,913 | public static final < T extends Comparable < T > > Ordering < Scored < T > > ByScoreThenByItem ( ) { final Ordering < Scored < T > > byItem = Scoreds . < T > ByItemOnly ( ) ; final Ordering < Scored < T > > byScore = Scoreds . < T > ByScoreOnly ( ) ; return Ordering . compound ( ImmutableList . of ( byScore , byItem ) ) ; } | Comparator which compares Scoreds first by score then by item . | 102 | 14 |
6,914 | protected void onFileChoose ( JFileChooser fileChooser , ActionEvent actionEvent ) { final int returnVal = fileChooser . showOpenDialog ( parent ) ; if ( returnVal == JFileChooser . APPROVE_OPTION ) { final File file = fileChooser . getSelectedFile ( ) ; onApproveOption ( file , actionEvent ) ; } else { onCancel ( actionEvent ) ; } } | Callback method to interact on file choose . | 94 | 8 |
6,915 | LayoutProcessorOutput applyLayout ( FileResource resource , Locale locale , Map < String , Object > model ) { Optional < Path > layout = findLayout ( resource ) ; return layout . map ( Path :: toString ) // . map ( Files :: getFileExtension ) // . map ( layoutEngines :: get ) // . orElse ( lParam -> new LayoutProcessorOutput ( lParam . model . get ( "content" ) . toString ( ) , "none" , lParam . layoutTemplate , lParam . locale ) ) . apply ( new LayoutParameters ( layout , resource . getPath ( ) , locale , model ) ) ; } | has been found the file will be copied as it is | 137 | 11 |
6,916 | @ Deprecated public Timex2Time modifiedCopy ( final Modifier modifier ) { return new Timex2Time ( val , modifier , set , granularity , periodicity , anchorVal , anchorDir , nonSpecific ) ; } | Returns a copy of this Timex which is the same except with the specified modifier | 47 | 16 |
6,917 | @ Pure public static MACNumber [ ] parse ( String addresses ) { if ( ( addresses == null ) || ( "" . equals ( addresses ) ) ) { //$NON-NLS-1$ return new MACNumber [ 0 ] ; } final String [ ] adrs = addresses . split ( Pattern . quote ( Character . toString ( MACNUMBER_SEPARATOR ) ) ) ; final List < MACNumber > list = new ArrayList <> ( ) ; for ( final String adr : adrs ) { list . add ( new MACNumber ( adr ) ) ; } final MACNumber [ ] tab = new MACNumber [ list . size ( ) ] ; list . toArray ( tab ) ; list . clear ( ) ; return tab ; } | Parse the specified string an repleis the corresponding MAC numbers . | 159 | 14 |
6,918 | @ Pure public static String join ( MACNumber ... addresses ) { if ( ( addresses == null ) || ( addresses . length == 0 ) ) { return null ; } final StringBuilder buf = new StringBuilder ( ) ; for ( final MACNumber number : addresses ) { if ( buf . length ( ) > 0 ) { buf . append ( MACNUMBER_SEPARATOR ) ; } buf . append ( number ) ; } return buf . toString ( ) ; } | Join the specified MAC numbers to reply a string . | 97 | 10 |
6,919 | @ Pure public static Collection < MACNumber > getAllAdapters ( ) { final List < MACNumber > av = new ArrayList <> ( ) ; final Enumeration < NetworkInterface > interfaces ; try { interfaces = NetworkInterface . getNetworkInterfaces ( ) ; } catch ( SocketException exception ) { return av ; } if ( interfaces != null ) { NetworkInterface inter ; while ( interfaces . hasMoreElements ( ) ) { inter = interfaces . nextElement ( ) ; try { final byte [ ] addr = inter . getHardwareAddress ( ) ; if ( addr != null ) { av . add ( new MACNumber ( addr ) ) ; } } catch ( SocketException exception ) { // Continue to the next loop. } } } return av ; } | Get all of the ethernet addresses associated with the local machine . | 158 | 13 |
6,920 | @ Pure public static Map < InetAddress , MACNumber > getAllMappings ( ) { final Map < InetAddress , MACNumber > av = new HashMap <> ( ) ; final Enumeration < NetworkInterface > interfaces ; try { interfaces = NetworkInterface . getNetworkInterfaces ( ) ; } catch ( SocketException exception ) { return av ; } if ( interfaces != null ) { NetworkInterface inter ; MACNumber mac ; InetAddress inet ; while ( interfaces . hasMoreElements ( ) ) { inter = interfaces . nextElement ( ) ; try { final byte [ ] addr = inter . getHardwareAddress ( ) ; if ( addr != null ) { mac = new MACNumber ( addr ) ; final Enumeration < InetAddress > inets = inter . getInetAddresses ( ) ; while ( inets . hasMoreElements ( ) ) { inet = inets . nextElement ( ) ; av . put ( inet , mac ) ; } } } catch ( SocketException exception ) { // Continue to the next loop. } } } return av ; } | Get all of the internet address and ethernet address mappings on the local machine . | 230 | 17 |
6,921 | @ Pure public static MACNumber getPrimaryAdapter ( ) { final Enumeration < NetworkInterface > interfaces ; try { interfaces = NetworkInterface . getNetworkInterfaces ( ) ; } catch ( SocketException exception ) { return null ; } if ( interfaces != null ) { NetworkInterface inter ; while ( interfaces . hasMoreElements ( ) ) { inter = interfaces . nextElement ( ) ; try { final byte [ ] addr = inter . getHardwareAddress ( ) ; if ( addr != null ) { return new MACNumber ( addr ) ; } } catch ( SocketException exception ) { // Continue to the next loop. } } } return null ; } | Try to determine the primary ethernet address of the machine . | 134 | 12 |
6,922 | @ Pure public static Collection < InetAddress > getPrimaryAdapterAddresses ( ) { final Enumeration < NetworkInterface > interfaces ; try { interfaces = NetworkInterface . getNetworkInterfaces ( ) ; } catch ( SocketException exception ) { return Collections . emptyList ( ) ; } if ( interfaces != null ) { NetworkInterface inter ; while ( interfaces . hasMoreElements ( ) ) { inter = interfaces . nextElement ( ) ; try { final byte [ ] addr = inter . getHardwareAddress ( ) ; if ( addr != null ) { final Collection < InetAddress > inetList = new ArrayList <> ( ) ; final Enumeration < InetAddress > inets = inter . getInetAddresses ( ) ; while ( inets . hasMoreElements ( ) ) { inetList . add ( inets . nextElement ( ) ) ; } return inetList ; } } catch ( SocketException exception ) { // Continue to the next loop. } } } return Collections . emptyList ( ) ; } | Try to determine the primary ethernet address of the machine and replies the associated internet addresses . | 217 | 18 |
6,923 | @ Pure public boolean isNull ( ) { for ( int i = 0 ; i < this . bytes . length ; ++ i ) { if ( this . bytes [ i ] != 0 ) { return false ; } } return true ; } | Replies if all the MAC address number are equal to zero . | 49 | 13 |
6,924 | public Optional < Path > getSourcePath ( ) { File f = this . nytdoc . getSourceFile ( ) ; return f == null ? Optional . empty ( ) : Optional . of ( f . toPath ( ) ) ; } | Accessor for the sourceFile property . | 50 | 8 |
6,925 | public Optional < URL > getUrl ( ) { URL u = this . nytdoc . getUrl ( ) ; return Optional . ofNullable ( u ) ; } | Accessor for the url property . | 36 | 7 |
6,926 | public void load ( File authorizationFile ) throws AuthorizationFileException { FileInputStream fis = null ; try { fis = new FileInputStream ( authorizationFile ) ; ANTLRInputStream stream = new ANTLRInputStream ( fis ) ; SAFPLexer lexer = new SAFPLexer ( stream ) ; CommonTokenStream tokens = new CommonTokenStream ( lexer ) ; SAFPParser parser = new SAFPParser ( tokens ) ; parser . prog ( ) ; setAccessRules ( parser . getAccessRules ( ) ) ; setGroups ( parser . getGroups ( ) ) ; setAliases ( parser . getAliases ( ) ) ; } catch ( FileNotFoundException e ) { throw new AuthorizationFileException ( "FileNotFoundException: " , e ) ; } catch ( IOException e ) { throw new AuthorizationFileException ( "IOException: " , e ) ; } catch ( RecognitionException e ) { throw new AuthorizationFileException ( "Parser problem: " , e ) ; } finally { try { fis . close ( ) ; } catch ( IOException e ) { throw new AuthorizationFileException ( "IOExcetion during close: " , e ) ; } } } | Load the authorization file . | 257 | 5 |
6,927 | public static void deleteAlias ( final File keystoreFile , String alias , final String password ) throws NoSuchAlgorithmException , CertificateException , FileNotFoundException , KeyStoreException , IOException { KeyStore keyStore = KeyStoreFactory . newKeyStore ( KeystoreType . JKS . name ( ) , password , keystoreFile ) ; keyStore . deleteEntry ( alias ) ; keyStore . store ( new FileOutputStream ( keystoreFile ) , password . toCharArray ( ) ) ; } | Delete the given alias from the given keystore file . | 106 | 11 |
6,928 | @ Nonnull public static EChange setResponseCompressionEnabled ( final boolean bResponseCompressionEnabled ) { return s_aRWLock . writeLocked ( ( ) -> { if ( s_bResponseCompressionEnabled == bResponseCompressionEnabled ) return EChange . UNCHANGED ; s_bResponseCompressionEnabled = bResponseCompressionEnabled ; LOGGER . info ( "CompressFilter responseCompressionEnabled=" + bResponseCompressionEnabled ) ; return EChange . CHANGED ; } ) ; } | Enable or disable the overall compression . | 110 | 7 |
6,929 | @ Nonnull public static EChange setDebugModeEnabled ( final boolean bDebugModeEnabled ) { return s_aRWLock . writeLocked ( ( ) -> { if ( s_bDebugModeEnabled == bDebugModeEnabled ) return EChange . UNCHANGED ; s_bDebugModeEnabled = bDebugModeEnabled ; LOGGER . info ( "CompressFilter debugMode=" + bDebugModeEnabled ) ; return EChange . CHANGED ; } ) ; } | Enable or disable debug mode | 101 | 5 |
6,930 | @ Override public SAMFileHeader makeSAMFileHeader ( ReadGroupSet readGroupSet , List < Reference > references ) { return ReadUtils . makeSAMFileHeader ( readGroupSet , references ) ; } | Generates a SAMFileHeader from a ReadGroupSet and Reference metadata | 44 | 14 |
6,931 | public boolean hasUser ( String userName ) { boolean result = false ; for ( User item : getUsersList ( ) ) { if ( item . getName ( ) . equals ( userName ) ) { result = true ; } } return result ; } | Check to see if a given user name is within the list of users . Checking will be done case sensitive . | 53 | 22 |
6,932 | public User getUser ( String userName ) { User result = null ; for ( User item : getUsersList ( ) ) { if ( item . getName ( ) . equals ( userName ) ) { result = item ; } } return result ; } | Get the particular User instance if the user can be found . Null otherwise . | 53 | 15 |
6,933 | @ Nonnull public CSP2SourceList addScheme ( @ Nonnull @ Nonempty final String sScheme ) { ValueEnforcer . notEmpty ( sScheme , "Scheme" ) ; ValueEnforcer . isTrue ( sScheme . length ( ) > 1 && sScheme . endsWith ( ":" ) , ( ) -> "Passed scheme '" + sScheme + "' is invalid!" ) ; m_aList . add ( sScheme ) ; return this ; } | Add a scheme | 107 | 3 |
6,934 | public final void setProxy ( @ Nullable final HttpHost aProxy , @ Nullable final Credentials aProxyCredentials ) { m_aProxy = aProxy ; m_aProxyCredentials = aProxyCredentials ; } | Set proxy host and proxy credentials . | 53 | 7 |
6,935 | @ Nonnull public final HttpClientFactory setRetries ( @ Nonnegative final int nRetries ) { ValueEnforcer . isGE0 ( nRetries , "Retries" ) ; m_nRetries = nRetries ; return this ; } | Set the number of internal retries . | 55 | 8 |
6,936 | @ Nonnull public final HttpClientFactory setRetryMode ( @ Nonnull final ERetryMode eRetryMode ) { ValueEnforcer . notNull ( eRetryMode , "RetryMode" ) ; m_eRetryMode = eRetryMode ; return this ; } | Set the retry mode to use . | 63 | 8 |
6,937 | @ Nullable public static String dnsResolve ( @ Nonnull final String sHostName ) { final InetAddress aAddress = resolveByName ( sHostName ) ; if ( aAddress == null ) return null ; return new IPV4Addr ( aAddress . getAddress ( ) ) . getAsString ( ) ; } | JavaScript callback function! Do not rename! | 71 | 9 |
6,938 | @ Nonnull @ OverrideOnDemand public EContinue onFilterBefore ( @ Nonnull final HttpServletRequest aHttpRequest , @ Nonnull final HttpServletResponse aHttpResponse , @ Nonnull final IRequestWebScope aRequestScope ) throws IOException , ServletException { // By default continue return EContinue . CONTINUE ; } | Invoked before the rest of the request is processed . | 73 | 11 |
6,939 | public boolean supportsMimeType ( @ Nullable final IMimeType aMimeType ) { if ( aMimeType == null ) return false ; return getQValueOfMimeType ( aMimeType ) . isAboveMinimumQuality ( ) ; } | Check if the passed MIME type is supported incl . fallback handling | 55 | 14 |
6,940 | public void configure ( String rootUrl , Settings settings ) { Data < Read , ReadGroupSet , Reference > data = dataSources . get ( rootUrl ) ; if ( data == null ) { data = new Data < Read , ReadGroupSet , Reference > ( settings , null ) ; dataSources . put ( rootUrl , data ) ; } else { data . settings = settings ; } } | Sets the settings for a given root url that will be used for creating the data source . Has no effect if the data source has already been created . | 81 | 31 |
6,941 | public GenomicsDataSource < Read , ReadGroupSet , Reference > get ( String rootUrl ) { Data < Read , ReadGroupSet , Reference > data = dataSources . get ( rootUrl ) ; if ( data == null ) { data = new Data < Read , ReadGroupSet , Reference > ( new Settings ( ) , null ) ; dataSources . put ( rootUrl , data ) ; } if ( data . dataSource == null ) { data . dataSource = makeDataSource ( rootUrl , data . settings ) ; } return data . dataSource ; } | Lazily creates and returns the data source for a given root url . | 118 | 15 |
6,942 | @ Nonnull public EChange setConnectionTimeoutMilliSecs ( final long nMilliSecs ) { if ( m_nConnectionTimeoutMilliSecs == nMilliSecs ) return EChange . UNCHANGED ; m_nConnectionTimeoutMilliSecs = nMilliSecs ; return EChange . CHANGED ; } | Set the connection timeout in milliseconds . Values &le ; 0 are interpreted as indefinite timeout which is not recommended! | 75 | 22 |
6,943 | @ Nonnull public EChange setTimeoutMilliSecs ( final long nMilliSecs ) { if ( m_nTimeoutMilliSecs == nMilliSecs ) return EChange . UNCHANGED ; m_nTimeoutMilliSecs = nMilliSecs ; return EChange . CHANGED ; } | Set the socket timeout in milliseconds . Values &le ; 0 are interpreted as indefinite timeout which is not recommended! | 72 | 22 |
6,944 | @ Nonnull @ ReturnsMutableCopy public static HttpHeaderMap getResponseHeaderMap ( @ Nonnull final HttpServletResponse aHttpResponse ) { ValueEnforcer . notNull ( aHttpResponse , "HttpResponse" ) ; final HttpHeaderMap ret = new HttpHeaderMap ( ) ; for ( final String sName : aHttpResponse . getHeaderNames ( ) ) for ( final String sValue : aHttpResponse . getHeaders ( sName ) ) ret . addHeader ( sName , sValue ) ; return ret ; } | Get a complete response header map as a copy . | 117 | 10 |
6,945 | @ Nonnull public final UnifiedResponse setContentAndCharset ( @ Nonnull final String sContent , @ Nonnull final Charset aCharset ) { ValueEnforcer . notNull ( sContent , "Content" ) ; setCharset ( aCharset ) ; setContent ( sContent . getBytes ( aCharset ) ) ; return this ; } | Utility method to set content and charset at once . | 81 | 12 |
6,946 | @ Nonnull public final UnifiedResponse setContent ( @ Nonnull final IHasInputStream aISP ) { ValueEnforcer . notNull ( aISP , "InputStreamProvider" ) ; if ( hasContent ( ) ) logInfo ( "Overwriting content with content provider!" ) ; m_aContentArray = null ; m_nContentArrayOfs = - 1 ; m_nContentArrayLength = - 1 ; m_aContentISP = aISP ; return this ; } | Set the response content provider . | 105 | 6 |
6,947 | @ Nonnull public final UnifiedResponse setContentDispositionFilename ( @ Nonnull @ Nonempty final String sFilename ) { ValueEnforcer . notEmpty ( sFilename , "Filename" ) ; // Ensure that a valid filename is used // -> Strip all paths and replace all invalid characters final String sFilenameToUse = FilenameHelper . getWithoutPath ( FilenameHelper . getAsSecureValidFilename ( sFilename ) ) ; if ( ! sFilename . equals ( sFilenameToUse ) ) logWarn ( "Content-Dispostion filename was internally modified from '" + sFilename + "' to '" + sFilenameToUse + "'" ) ; // Disabled because of the extended UTF-8 handling (RFC 5987) if ( false ) { // Check if encoding as ISO-8859-1 is possible if ( m_aContentDispositionEncoder == null ) m_aContentDispositionEncoder = StandardCharsets . ISO_8859_1 . newEncoder ( ) ; if ( ! m_aContentDispositionEncoder . canEncode ( sFilenameToUse ) ) logError ( "Content-Dispostion filename '" + sFilenameToUse + "' cannot be encoded to ISO-8859-1!" ) ; } // Are we overwriting? if ( m_sContentDispositionFilename != null ) logInfo ( "Overwriting Content-Dispostion filename from '" + m_sContentDispositionFilename + "' to '" + sFilenameToUse + "'" ) ; // No URL encoding necessary. // Filename must be in ISO-8859-1 // See http://greenbytes.de/tech/tc2231/ m_sContentDispositionFilename = sFilenameToUse ; return this ; } | Set the content disposition filename for attachment download . | 372 | 9 |
6,948 | @ Nonnull public final UnifiedResponse removeCaching ( ) { // Remove any eventually set headers removeExpires ( ) ; removeCacheControl ( ) ; removeETag ( ) ; removeLastModified ( ) ; m_aResponseHeaderMap . removeHeaders ( CHttpHeader . PRAGMA ) ; return this ; } | Remove all settings and headers relevant to caching . | 68 | 9 |
6,949 | @ Nonnull public final UnifiedResponse disableCaching ( ) { // Remove any eventually set headers removeCaching ( ) ; if ( m_eHttpVersion . is10 ( ) ) { // Set to expire far in the past for HTTP/1.0. m_aResponseHeaderMap . setHeader ( CHttpHeader . EXPIRES , ResponseHelperSettings . EXPIRES_NEVER_STRING ) ; // Set standard HTTP/1.0 no-cache header. m_aResponseHeaderMap . setHeader ( CHttpHeader . PRAGMA , "no-cache" ) ; } else { final CacheControlBuilder aCacheControlBuilder = new CacheControlBuilder ( ) . setNoStore ( true ) . setNoCache ( true ) . setMustRevalidate ( true ) . setProxyRevalidate ( true ) ; // Set IE extended HTTP/1.1 no-cache headers. // http://aspnetresources.com/blog/cache_control_extensions // Disabled because: // http://blogs.msdn.com/b/ieinternals/archive/2009/07/20/using-post_2d00_check-and-pre_2d00_check-cache-directives.aspx if ( false ) aCacheControlBuilder . addExtension ( "post-check=0" ) . addExtension ( "pre-check=0" ) ; setCacheControl ( aCacheControlBuilder ) ; } return this ; } | A utility method that disables caching for this response . | 311 | 11 |
6,950 | @ Nonnull public final UnifiedResponse enableCaching ( @ Nonnegative final int nSeconds ) { ValueEnforcer . isGT0 ( nSeconds , "Seconds" ) ; // Remove any eventually set headers // Note: don't remove Last-Modified and ETag! removeExpires ( ) ; removeCacheControl ( ) ; m_aResponseHeaderMap . removeHeaders ( CHttpHeader . PRAGMA ) ; if ( m_eHttpVersion . is10 ( ) ) { m_aResponseHeaderMap . setDateHeader ( CHttpHeader . EXPIRES , PDTFactory . getCurrentLocalDateTime ( ) . plusSeconds ( nSeconds ) ) ; } else { final CacheControlBuilder aCacheControlBuilder = new CacheControlBuilder ( ) . setPublic ( true ) . setMaxAgeSeconds ( nSeconds ) ; setCacheControl ( aCacheControlBuilder ) ; } return this ; } | Enable caching of this resource for the specified number of seconds . | 197 | 12 |
6,951 | @ Nonnull public final UnifiedResponse setStatusUnauthorized ( @ Nullable final String sAuthenticate ) { _setStatus ( HttpServletResponse . SC_UNAUTHORIZED ) ; if ( StringHelper . hasText ( sAuthenticate ) ) m_aResponseHeaderMap . setHeader ( CHttpHeader . WWW_AUTHENTICATE , sAuthenticate ) ; return this ; } | Special handling for returning status code 401 UNAUTHORIZED . | 89 | 14 |
6,952 | public final void setCustomResponseHeaders ( @ Nullable final HttpHeaderMap aOther ) { m_aResponseHeaderMap . removeAll ( ) ; if ( aOther != null ) m_aResponseHeaderMap . setAllHeaders ( aOther ) ; } | Set many custom headers at once . All existing headers are unconditionally removed . | 57 | 15 |
6,953 | static private JsonTransformer factory ( Object jsonObject ) throws InvalidTransformerException { if ( jsonObject instanceof JSONObject ) { return factory ( ( JSONObject ) jsonObject ) ; } else if ( jsonObject instanceof JSONArray ) { return factory ( ( JSONArray ) jsonObject ) ; } else if ( jsonObject instanceof String ) { return factoryAction ( ( String ) jsonObject ) ; } throw new InvalidTransformerException ( "Not supported transformer type: " + jsonObject ) ; } | Convenient private method | 105 | 4 |
6,954 | public void invalidate ( ) { if ( m_bInvalidated ) throw new IllegalStateException ( "Request scope already invalidated!" ) ; m_bInvalidated = true ; if ( m_aServletContext != null ) { final ServletRequestEvent aSRE = new ServletRequestEvent ( m_aServletContext , this ) ; for ( final ServletRequestListener aListener : MockHttpListener . getAllServletRequestListeners ( ) ) aListener . requestDestroyed ( aSRE ) ; } close ( ) ; clearAttributes ( ) ; } | Invalidate this request clearing its state and invoking all HTTP event listener . | 122 | 14 |
6,955 | @ Nonnull public QValue getQValueOfEncoding ( @ Nonnull final String sEncoding ) { ValueEnforcer . notNull ( sEncoding , "Encoding" ) ; // Direct search encoding QValue aQuality = m_aMap . get ( _unify ( sEncoding ) ) ; if ( aQuality == null ) { // If not explicitly given, check for "*" aQuality = m_aMap . get ( AcceptEncodingHandler . ANY_ENCODING ) ; if ( aQuality == null ) { // Neither encoding nor "*" is present // -> assume minimum quality return QValue . MIN_QVALUE ; } } return aQuality ; } | Return the associated quality of the given encoding . | 145 | 9 |
6,956 | public void bind ( ) { program . use ( ) ; if ( textures != null ) { final TIntObjectIterator < Texture > iterator = textures . iterator ( ) ; while ( iterator . hasNext ( ) ) { iterator . advance ( ) ; // Bind the texture to the unit final int unit = iterator . key ( ) ; iterator . value ( ) . bind ( unit ) ; // Bind the shader sampler uniform to the unit program . bindSampler ( unit ) ; } } } | Binds the material to the OpenGL context . | 101 | 9 |
6,957 | public void setProgram ( Program program ) { if ( program == null ) { throw new IllegalStateException ( "Program cannot be null" ) ; } program . checkCreated ( ) ; this . program = program ; } | Sets the program to be used by this material to shade the models . | 45 | 15 |
6,958 | public void addTexture ( int unit , Texture texture ) { if ( texture == null ) { throw new IllegalStateException ( "Texture cannot be null" ) ; } texture . checkCreated ( ) ; if ( textures == null ) { textures = new TIntObjectHashMap <> ( ) ; } textures . put ( unit , texture ) ; } | Adds a texture to the material . If a texture is a already present in the same unit as this one it will be replaced . | 72 | 26 |
6,959 | @ Override public boolean maybeAddRead ( Read read ) { if ( ! isUnmappedMateOfMappedRead ( read ) ) { return false ; } final String reference = read . getNextMatePosition ( ) . getReferenceName ( ) ; String key = getReadKey ( read ) ; Map < String , ArrayList < Read > > reads = unmappedReads . get ( reference ) ; if ( reads == null ) { reads = new HashMap < String , ArrayList < Read > > ( ) ; unmappedReads . put ( reference , reads ) ; } ArrayList < Read > mates = reads . get ( key ) ; if ( mates == null ) { mates = new ArrayList < Read > ( ) ; reads . put ( key , mates ) ; } if ( getReadCount ( ) < MAX_READS ) { mates . add ( read ) ; readCount ++ ; return true ; } else { LOG . warning ( "Reached the limit of in-memory unmapped mates for injection." ) ; } return false ; } | Checks and adds the read if we need to remember it for injection . Returns true if the read was added . | 223 | 23 |
6,960 | @ Override public ArrayList < Read > getUnmappedMates ( Read read ) { if ( read . getNumberReads ( ) < 2 || ( read . hasNextMatePosition ( ) && read . getNextMatePosition ( ) != null ) || ! read . hasAlignment ( ) || read . getAlignment ( ) == null || ! read . getAlignment ( ) . hasPosition ( ) || read . getAlignment ( ) . getPosition ( ) == null || read . getAlignment ( ) . getPosition ( ) . getReferenceName ( ) == null || read . getAlignment ( ) . getPosition ( ) . getReferenceName ( ) . isEmpty ( ) || read . getFragmentName ( ) == null || read . getFragmentName ( ) . isEmpty ( ) ) { return null ; } final String reference = read . getAlignment ( ) . getPosition ( ) . getReferenceName ( ) ; final String key = getReadKey ( read ) ; Map < String , ArrayList < Read > > reads = unmappedReads . get ( reference ) ; if ( reads != null ) { final ArrayList < Read > mates = reads . get ( key ) ; if ( mates != null && mates . size ( ) > 1 ) { Collections . sort ( mates , matesComparator ) ; } return mates ; } return null ; } | Checks if the passed read has unmapped mates that need to be injected and if so - returns them . The returned list is sorted by read number to handle the case of multi - read fragments . | 293 | 40 |
6,961 | public static void setSessionPassivationAllowed ( final boolean bSessionPassivationAllowed ) { s_aSessionPassivationAllowed . set ( bSessionPassivationAllowed ) ; if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "Session passivation is now " + ( bSessionPassivationAllowed ? "enabled" : "disabled" ) ) ; // For passivation to work, the session scopes may not be invalidated at the // end of the global scope! final ScopeSessionManager aSSM = ScopeSessionManager . getInstance ( ) ; aSSM . setDestroyAllSessionsOnScopeEnd ( ! bSessionPassivationAllowed ) ; aSSM . setEndAllSessionsOnScopeEnd ( ! bSessionPassivationAllowed ) ; // Ensure that all session web scopes have the activator set or removed for ( final ISessionWebScope aSessionWebScope : WebScopeSessionManager . getAllSessionWebScopes ( ) ) { final HttpSession aHttpSession = aSessionWebScope . getSession ( ) ; if ( bSessionPassivationAllowed ) { // Ensure the activator is present if ( aHttpSession . getAttribute ( SESSION_ATTR_SESSION_SCOPE_ACTIVATOR ) == null ) aHttpSession . setAttribute ( SESSION_ATTR_SESSION_SCOPE_ACTIVATOR , new SessionWebScopeActivator ( aSessionWebScope ) ) ; } else { // Ensure the activator is not present aHttpSession . removeAttribute ( SESSION_ATTR_SESSION_SCOPE_ACTIVATOR ) ; } } } | Allow or disallow session passivation | 347 | 7 |
6,962 | @ Nullable @ DevelopersNote ( "This is only for project-internal use!" ) public static ISessionWebScope internalGetOrCreateSessionScope ( @ Nonnull final HttpSession aHttpSession , final boolean bCreateIfNotExisting , final boolean bItsOkayToCreateANewScope ) { ValueEnforcer . notNull ( aHttpSession , "HttpSession" ) ; // Do we already have a session web scope for the session? final String sSessionID = aHttpSession . getId ( ) ; ISessionScope aSessionWebScope = ScopeSessionManager . getInstance ( ) . getSessionScopeOfID ( sSessionID ) ; if ( aSessionWebScope == null && bCreateIfNotExisting ) { if ( ! bItsOkayToCreateANewScope ) { // This can e.g. happen in tests, when there are no registered // listeners for session events! if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Creating a new session web scope for ID '" + sSessionID + "' but there should already be one!" + " Check your HttpSessionListener implementation." ) ; } // Create a new session scope aSessionWebScope = onSessionBegin ( aHttpSession ) ; } try { return ( ISessionWebScope ) aSessionWebScope ; } catch ( final ClassCastException ex ) { throw new IllegalStateException ( "Session scope object is not a web scope but: " + aSessionWebScope , ex ) ; } } | Internal method which does the main logic for session web scope creation | 316 | 12 |
6,963 | @ Nullable @ DevelopersNote ( "This is only for project-internal use!" ) public static ISessionWebScope internalGetSessionScope ( final boolean bCreateIfNotExisting , final boolean bItsOkayToCreateANewSession ) { // Try to to resolve the current request scope final IRequestWebScope aRequestScope = getRequestScopeOrNull ( ) ; return internalGetSessionScope ( aRequestScope , bCreateIfNotExisting , bItsOkayToCreateANewSession ) ; } | Get the session scope from the current request scope . | 104 | 10 |
6,964 | @ Nullable @ DevelopersNote ( "This is only for project-internal use!" ) public static ISessionWebScope internalGetSessionScope ( @ Nullable final IRequestWebScope aRequestScope , final boolean bCreateIfNotExisting , final boolean bItsOkayToCreateANewSession ) { // Try to to resolve the current request scope if ( aRequestScope != null ) { // Check if we have an HTTP session object final HttpSession aHttpSession = aRequestScope . getSession ( bCreateIfNotExisting ) ; if ( aHttpSession != null ) return internalGetOrCreateSessionScope ( aHttpSession , bCreateIfNotExisting , bItsOkayToCreateANewSession ) ; } else { // If we want a session scope, we expect the return value to be non-null! if ( bCreateIfNotExisting ) throw new IllegalStateException ( "No request scope is present, so no session scope can be retrieved!" ) ; } return null ; } | Get the session scope of the provided request scope . | 208 | 10 |
6,965 | public ByteBuffer getIndicesBuffer ( ) { final ByteBuffer buffer = CausticUtil . createByteBuffer ( indices . size ( ) * DataType . INT . getByteSize ( ) ) ; for ( int i = 0 ; i < indices . size ( ) ; i ++ ) { buffer . putInt ( indices . get ( i ) ) ; } buffer . flip ( ) ; return buffer ; } | Returns a byte buffer containing all the current indices . | 86 | 10 |
6,966 | public void addAttribute ( int index , VertexAttribute attribute ) { attributes . put ( index , attribute ) ; nameToIndex . put ( attribute . getName ( ) , index ) ; } | Adds an attribute . | 40 | 4 |
6,967 | public int getAttributeSize ( int index ) { final VertexAttribute attribute = getAttribute ( index ) ; if ( attribute == null ) { return - 1 ; } return attribute . getSize ( ) ; } | Returns the size of the attribute at the provided index or - 1 if none can be found . | 43 | 19 |
6,968 | public DataType getAttributeType ( int index ) { final VertexAttribute attribute = getAttribute ( index ) ; if ( attribute == null ) { return null ; } return attribute . getType ( ) ; } | Returns the type of the attribute at the provided index or null if none can be found . | 43 | 18 |
6,969 | public String getAttributeName ( int index ) { final VertexAttribute attribute = getAttribute ( index ) ; if ( attribute == null ) { return null ; } return attribute . getName ( ) ; } | Returns the name of the attribute at the provided index or null if none can be found . | 42 | 18 |
6,970 | public ByteBuffer getAttributeBuffer ( int index ) { final VertexAttribute attribute = getAttribute ( index ) ; if ( attribute == null ) { return null ; } return attribute . getData ( ) ; } | Returns the buffer for the attribute at the provided index or null if none can be found . The buffer is returned filled and ready for reading . | 43 | 28 |
6,971 | public void copy ( VertexData data ) { clear ( ) ; indices . addAll ( data . indices ) ; final TIntObjectIterator < VertexAttribute > iterator = data . attributes . iterator ( ) ; while ( iterator . hasNext ( ) ) { iterator . advance ( ) ; attributes . put ( iterator . key ( ) , iterator . value ( ) . clone ( ) ) ; } nameToIndex . putAll ( data . nameToIndex ) ; } | Replaces the contents of this vertex data by the provided one . This is a deep copy . The vertex attribute are each individually cloned . | 97 | 28 |
6,972 | @ Nonnull public QValue getQValueOfLanguage ( @ Nonnull final String sLanguage ) { ValueEnforcer . notNull ( sLanguage , "Language" ) ; // Find language direct QValue aQuality = m_aMap . get ( _unify ( sLanguage ) ) ; if ( aQuality == null ) { // If not explicitly given, check for "*" aQuality = m_aMap . get ( AcceptLanguageHandler . ANY_LANGUAGE ) ; if ( aQuality == null ) { // Neither language nor "*" is present // -> assume minimum quality return QValue . MIN_QVALUE ; } } return aQuality ; } | Return the associated quality of the given language . | 140 | 9 |
6,973 | public void setVertexArray ( VertexArray vertexArray ) { if ( vertexArray == null ) { throw new IllegalArgumentException ( "Vertex array cannot be null" ) ; } vertexArray . checkCreated ( ) ; this . vertexArray = vertexArray ; } | Sets the vertex array for this model . | 57 | 9 |
6,974 | public Matrix4f getMatrix ( ) { if ( updateMatrix ) { final Matrix4f matrix = Matrix4f . createScaling ( scale . toVector4 ( 1 ) ) . rotate ( rotation ) . translate ( position ) ; if ( parent == null ) { this . matrix = matrix ; } else { childMatrix = matrix ; } updateMatrix = false ; } if ( parent != null ) { final Matrix4f parentMatrix = parent . getMatrix ( ) ; if ( parentMatrix != lastParentMatrix ) { matrix = parentMatrix . mul ( childMatrix ) ; lastParentMatrix = parentMatrix ; } } return matrix ; } | Returns the transformation matrix that represent the model s current scale rotation and position . | 132 | 15 |
6,975 | public void setParent ( Model parent ) { if ( parent == this ) { throw new IllegalArgumentException ( "The model can't be its own parent" ) ; } if ( parent == null ) { this . parent . children . remove ( this ) ; } else { parent . children . add ( this ) ; } this . parent = parent ; } | Sets the parent model . This model s position rotation and scale will be relative to that model if not null . | 74 | 23 |
6,976 | public boolean hasAlias ( String aliasName ) { boolean result = false ; for ( Alias item : getAliasesList ( ) ) { if ( item . getName ( ) . equals ( aliasName ) ) { result = true ; } } return result ; } | Check if the given alias exists in the list of aliases or not . | 55 | 14 |
6,977 | @ Nullable public static String encode ( @ Nullable final String sValue , @ Nonnull final Charset aCharset , final ECodec eCodec ) { if ( sValue == null ) return null ; try { switch ( eCodec ) { case Q : return new RFC1522QCodec ( aCharset ) . getEncoded ( sValue ) ; case B : default : return new RFC1522BCodec ( aCharset ) . getEncoded ( sValue ) ; } } catch ( final Exception ex ) { return sValue ; } } | Used to encode a string as specified by RFC 2047 | 125 | 11 |
6,978 | @ Nullable public static String decode ( @ Nullable final String sValue ) { if ( sValue == null ) return null ; try { // try BCodec first return new RFC1522BCodec ( ) . getDecoded ( sValue ) ; } catch ( final DecodeException de ) { // try QCodec next try { return new RFC1522QCodec ( ) . getDecoded ( sValue ) ; } catch ( final Exception ex ) { return sValue ; } } catch ( final Exception e ) { return sValue ; } } | Used to decode a string as specified by RFC 2047 | 118 | 11 |
6,979 | public static void addRequest ( @ Nonnull @ Nonempty final String sRequestID , @ Nonnull final IRequestWebScope aRequestScope ) { getInstance ( ) . m_aRequestTrackingMgr . addRequest ( sRequestID , aRequestScope , s_aParallelRunningCallbacks ) ; } | Add new request to the tracking | 67 | 6 |
6,980 | public static void removeRequest ( @ Nonnull @ Nonempty final String sRequestID ) { final RequestTracker aTracker = getGlobalSingletonIfInstantiated ( RequestTracker . class ) ; if ( aTracker != null ) aTracker . m_aRequestTrackingMgr . removeRequest ( sRequestID , s_aParallelRunningCallbacks ) ; } | Remove a request from the tracking . | 76 | 7 |
6,981 | @ Nonnull public ESuccess queueMail ( @ Nonnull final ISMTPSettings aSMTPSettings , @ Nonnull final IMutableEmailData aMailData ) { return MailAPI . queueMail ( aSMTPSettings , aMailData ) ; } | Unconditionally queue a mail | 53 | 6 |
6,982 | @ Nonnegative public int queueMails ( @ Nonnull final ISMTPSettings aSMTPSettings , @ Nonnull final Collection < ? extends IMutableEmailData > aMailDataList ) { return MailAPI . queueMails ( aSMTPSettings , aMailDataList ) ; } | Queue multiple mails at once . | 61 | 7 |
6,983 | public static void setPerformMXRecordCheck ( final boolean bPerformMXRecordCheck ) { s_aPerformMXRecordCheck . set ( bPerformMXRecordCheck ) ; if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "Email address record check is " + ( bPerformMXRecordCheck ? "enabled" : "disabled" ) ) ; } | Set the global check MX record flag . | 82 | 8 |
6,984 | private static boolean _hasMXRecord ( @ Nonnull final String sHostName ) { try { final Record [ ] aRecords = new Lookup ( sHostName , Type . MX ) . run ( ) ; return aRecords != null && aRecords . length > 0 ; } catch ( final Exception ex ) { // Do not log this message, as this method is potentially called very // often! if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Failed to check for MX record on host '" + sHostName + "': " + ex . getClass ( ) . getName ( ) + " - " + ex . getMessage ( ) ) ; return false ; } } | Check if the passed host name has an MX record . | 152 | 11 |
6,985 | public static boolean isValid ( @ Nullable final String sEmail ) { return s_aPerformMXRecordCheck . get ( ) ? isValidWithMXCheck ( sEmail ) : EmailAddressHelper . isValid ( sEmail ) ; } | Checks if a value is a valid e - mail address . Depending on the global value for the MX record check the check is performed incl . the MX record check or without . | 51 | 36 |
6,986 | public static boolean isValidWithMXCheck ( @ Nullable final String sEmail ) { // First check without MX if ( ! EmailAddressHelper . isValid ( sEmail ) ) return false ; final String sUnifiedEmail = EmailAddressHelper . getUnifiedEmailAddress ( sEmail ) ; // MX record checking final int i = sUnifiedEmail . indexOf ( ' ' ) ; final String sHostName = sUnifiedEmail . substring ( i + 1 ) ; return _hasMXRecord ( sHostName ) ; } | Checks if a value is a valid e - mail address according to a complex regular expression . Additionally an MX record lookup is performed to see whether this host provides SMTP services . | 112 | 36 |
6,987 | @ Nullable public String getResponseBodyAsString ( @ Nonnull final Charset aCharset ) { return m_aResponseBody == null ? null : new String ( m_aResponseBody , aCharset ) ; } | Get the response body as a string in the provided charset . | 51 | 13 |
6,988 | 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 . | 108 | 6 |
6,989 | 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 . | 104 | 6 |
6,990 | 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 . | 82 | 8 |
6,991 | 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 . | 171 | 9 |
6,992 | 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 | 65 | 34 |
6,993 | @ Nonnull public ICommonsList < String > getHeaders ( @ Nullable final String sName ) { return new CommonsArrayList <> ( m_aHeaders . get ( _unifyHeaderName ( sName ) ) ) ; } | Return all values for the given header as a List of value objects . | 53 | 14 |
6,994 | @ Nonnull public static EChange safeInvalidateSession ( @ Nullable 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 ) { // session already invalidated } } return EChange . UNCHANGED ; } | Invalidate the session if the session is still active . | 107 | 11 |
6,995 | @ Nonnull public static Enumeration < String > getAllAttributes ( @ Nonnull final HttpSession aSession ) { ValueEnforcer . notNull ( aSession , "Session" ) ; try { return GenericReflection . uncheckedCast ( aSession . getAttributeNames ( ) ) ; } catch ( final IllegalStateException ex ) { // Session no longer valid return new EmptyEnumeration <> ( ) ; } } | Get all attribute names present in the specified session . | 89 | 10 |
6,996 | @ Nonnull public IMicroDocument getAsDocument ( @ Nonnull @ Nonempty 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 ) ; // The location of the sub-sitemaps must be prefixed with the full server // and context path 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 . | 302 | 8 |
6,997 | @ Nonnull public static final < T extends AbstractSessionWebSingleton > T getSessionSingleton ( @ Nonnull 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 . | 51 | 31 |
6,998 | @ 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 . | 138 | 8 |
6,999 | public void registerServlet ( @ Nonnull final Class < ? extends Servlet > aServletClass , @ Nonnull @ Nonempty final String sServletPath , @ Nonnull @ Nonempty final String sServletName ) { registerServlet ( aServletClass , sServletPath , sServletName , ( Map < String , String > ) null ) ; } | Register a new servlet without servlet init parameters | 80 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.