_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q15400
Users.hasUser
train
public boolean hasUser(String userName) { boolean result = false; for (User item : getUsersList()) { if (item.getName().equals(userName)) { result = true; } } return result; }
java
{ "resource": "" }
q15401
Users.getUser
train
public User getUser(String userName) { User result = null; for (User item : getUsersList()) { if (item.getName().equals(userName)) { result = item; } } return result; }
java
{ "resource": "" }
q15402
CSP2SourceList.addScheme
train
@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; }
java
{ "resource": "" }
q15403
HttpClientFactory.setProxy
train
public final void setProxy (@Nullable final HttpHost aProxy, @Nullable final Credentials aProxyCredentials) { m_aProxy = aProxy; m_aProxyCredentials = aProxyCredentials; }
java
{ "resource": "" }
q15404
HttpClientFactory.setRetries
train
@Nonnull public final HttpClientFactory setRetries (@Nonnegative final int nRetries) { ValueEnforcer.isGE0 (nRetries, "Retries"); m_nRetries = nRetries; return this; }
java
{ "resource": "" }
q15405
HttpClientFactory.setRetryMode
train
@Nonnull public final HttpClientFactory setRetryMode (@Nonnull final ERetryMode eRetryMode) { ValueEnforcer.notNull (eRetryMode, "RetryMode"); m_eRetryMode = eRetryMode; return this; }
java
{ "resource": "" }
q15406
DNSResolver.dnsResolve
train
@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 (); }
java
{ "resource": "" }
q15407
AbstractXFilter.onFilterBefore
train
@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; }
java
{ "resource": "" }
q15408
AcceptMimeTypeList.supportsMimeType
train
public boolean supportsMimeType (@Nullable final IMimeType aMimeType) { if (aMimeType == null) return false; return getQValueOfMimeType (aMimeType).isAboveMinimumQuality (); }
java
{ "resource": "" }
q15409
GenomicsDataSourceFactory.configure
train
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; } }
java
{ "resource": "" }
q15410
GenomicsDataSourceFactory.get
train
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; }
java
{ "resource": "" }
q15411
SMTPSettings.setConnectionTimeoutMilliSecs
train
@Nonnull public EChange setConnectionTimeoutMilliSecs (final long nMilliSecs) { if (m_nConnectionTimeoutMilliSecs == nMilliSecs) return EChange.UNCHANGED; m_nConnectionTimeoutMilliSecs = nMilliSecs; return EChange.CHANGED; }
java
{ "resource": "" }
q15412
SMTPSettings.setTimeoutMilliSecs
train
@Nonnull public EChange setTimeoutMilliSecs (final long nMilliSecs) { if (m_nTimeoutMilliSecs == nMilliSecs) return EChange.UNCHANGED; m_nTimeoutMilliSecs = nMilliSecs; return EChange.CHANGED; }
java
{ "resource": "" }
q15413
ResponseHelper.getResponseHeaderMap
train
@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; }
java
{ "resource": "" }
q15414
UnifiedResponse.setContentAndCharset
train
@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; }
java
{ "resource": "" }
q15415
UnifiedResponse.setContent
train
@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; }
java
{ "resource": "" }
q15416
UnifiedResponse.setContentDispositionFilename
train
@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; }
java
{ "resource": "" }
q15417
UnifiedResponse.removeCaching
train
@Nonnull public final UnifiedResponse removeCaching () { // Remove any eventually set headers removeExpires (); removeCacheControl (); removeETag (); removeLastModified (); m_aResponseHeaderMap.removeHeaders (CHttpHeader.PRAGMA); return this; }
java
{ "resource": "" }
q15418
UnifiedResponse.disableCaching
train
@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; }
java
{ "resource": "" }
q15419
UnifiedResponse.enableCaching
train
@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; }
java
{ "resource": "" }
q15420
UnifiedResponse.setStatusUnauthorized
train
@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; }
java
{ "resource": "" }
q15421
UnifiedResponse.setCustomResponseHeaders
train
public final void setCustomResponseHeaders (@Nullable final HttpHeaderMap aOther) { m_aResponseHeaderMap.removeAll (); if (aOther != null) m_aResponseHeaderMap.setAllHeaders (aOther); }
java
{ "resource": "" }
q15422
JsonTransformerFactory.factory
train
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); }
java
{ "resource": "" }
q15423
MockHttpServletRequest.invalidate
train
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 (); }
java
{ "resource": "" }
q15424
AcceptEncodingList.getQValueOfEncoding
train
@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; }
java
{ "resource": "" }
q15425
Material.bind
train
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); } } }
java
{ "resource": "" }
q15426
Material.setProgram
train
public void setProgram(Program program) { if (program == null) { throw new IllegalStateException("Program cannot be null"); } program.checkCreated(); this.program = program; }
java
{ "resource": "" }
q15427
Material.addTexture
train
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); }
java
{ "resource": "" }
q15428
UnmappedReads.maybeAddRead
train
@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; }
java
{ "resource": "" }
q15429
UnmappedReads.getUnmappedMates
train
@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; }
java
{ "resource": "" }
q15430
WebScopeManager.setSessionPassivationAllowed
train
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); } } }
java
{ "resource": "" }
q15431
WebScopeManager.internalGetOrCreateSessionScope
train
@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); } }
java
{ "resource": "" }
q15432
WebScopeManager.internalGetSessionScope
train
@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); }
java
{ "resource": "" }
q15433
WebScopeManager.internalGetSessionScope
train
@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; }
java
{ "resource": "" }
q15434
VertexData.getIndicesBuffer
train
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; }
java
{ "resource": "" }
q15435
VertexData.addAttribute
train
public void addAttribute(int index, VertexAttribute attribute) { attributes.put(index, attribute); nameToIndex.put(attribute.getName(), index); }
java
{ "resource": "" }
q15436
VertexData.getAttributeSize
train
public int getAttributeSize(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return -1; } return attribute.getSize(); }
java
{ "resource": "" }
q15437
VertexData.getAttributeType
train
public DataType getAttributeType(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return null; } return attribute.getType(); }
java
{ "resource": "" }
q15438
VertexData.getAttributeName
train
public String getAttributeName(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return null; } return attribute.getName(); }
java
{ "resource": "" }
q15439
VertexData.getAttributeBuffer
train
public ByteBuffer getAttributeBuffer(int index) { final VertexAttribute attribute = getAttribute(index); if (attribute == null) { return null; } return attribute.getData(); }
java
{ "resource": "" }
q15440
VertexData.copy
train
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); }
java
{ "resource": "" }
q15441
AcceptLanguageList.getQValueOfLanguage
train
@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; }
java
{ "resource": "" }
q15442
Model.setVertexArray
train
public void setVertexArray(VertexArray vertexArray) { if (vertexArray == null) { throw new IllegalArgumentException("Vertex array cannot be null"); } vertexArray.checkCreated(); this.vertexArray = vertexArray; }
java
{ "resource": "" }
q15443
Model.getMatrix
train
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; }
java
{ "resource": "" }
q15444
Model.setParent
train
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; }
java
{ "resource": "" }
q15445
Aliases.hasAlias
train
public boolean hasAlias(String aliasName) { boolean result = false; for (Alias item : getAliasesList()) { if (item.getName().equals(aliasName)) { result = true; } } return result; }
java
{ "resource": "" }
q15446
RFC2047Helper.encode
train
@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; } }
java
{ "resource": "" }
q15447
RFC2047Helper.decode
train
@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; } }
java
{ "resource": "" }
q15448
RequestTracker.addRequest
train
public static void addRequest (@Nonnull @Nonempty final String sRequestID, @Nonnull final IRequestWebScope aRequestScope) { getInstance ().m_aRequestTrackingMgr.addRequest (sRequestID, aRequestScope, s_aParallelRunningCallbacks); }
java
{ "resource": "" }
q15449
RequestTracker.removeRequest
train
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); }
java
{ "resource": "" }
q15450
ScopedMailAPI.queueMail
train
@Nonnull public ESuccess queueMail (@Nonnull final ISMTPSettings aSMTPSettings, @Nonnull final IMutableEmailData aMailData) { return MailAPI.queueMail (aSMTPSettings, aMailData); }
java
{ "resource": "" }
q15451
ScopedMailAPI.queueMails
train
@Nonnegative public int queueMails (@Nonnull final ISMTPSettings aSMTPSettings, @Nonnull final Collection <? extends IMutableEmailData> aMailDataList) { return MailAPI.queueMails (aSMTPSettings, aMailDataList); }
java
{ "resource": "" }
q15452
EmailAddressValidator.setPerformMXRecordCheck
train
public static void setPerformMXRecordCheck (final boolean bPerformMXRecordCheck) { s_aPerformMXRecordCheck.set (bPerformMXRecordCheck); if (LOGGER.isInfoEnabled ()) LOGGER.info ("Email address record check is " + (bPerformMXRecordCheck ? "enabled" : "disabled")); }
java
{ "resource": "" }
q15453
EmailAddressValidator._hasMXRecord
train
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; } }
java
{ "resource": "" }
q15454
EmailAddressValidator.isValid
train
public static boolean isValid (@Nullable final String sEmail) { return s_aPerformMXRecordCheck.get () ? isValidWithMXCheck (sEmail) : EmailAddressHelper.isValid (sEmail); }
java
{ "resource": "" }
q15455
EmailAddressValidator.isValidWithMXCheck
train
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); }
java
{ "resource": "" }
q15456
ExtendedHttpResponseException.getResponseBodyAsString
train
@Nullable public String getResponseBodyAsString (@Nonnull final Charset aCharset) { return m_aResponseBody == null ? null : new String (m_aResponseBody, aCharset); }
java
{ "resource": "" }
q15457
SimpleCrypt.decode
train
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(); }
java
{ "resource": "" }
q15458
SimpleCrypt.encode
train
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(); }
java
{ "resource": "" }
q15459
PublicKeyReader.readPemPublicKey
train
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); }
java
{ "resource": "" }
q15460
PublicKeyExtensions.toPemFormat
train
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(); }
java
{ "resource": "" }
q15461
AbstractThresholdingOutputStream.checkThreshold
train
protected void checkThreshold (final int nCount) throws IOException { if (!m_bThresholdExceeded && (m_nWritten + nCount > m_nThreshold)) { m_bThresholdExceeded = true; onThresholdReached (); } }
java
{ "resource": "" }
q15462
MockHttpServletResponse.getHeaders
train
@Nonnull public ICommonsList <String> getHeaders (@Nullable final String sName) { return new CommonsArrayList <> (m_aHeaders.get (_unifyHeaderName (sName))); }
java
{ "resource": "" }
q15463
SessionHelper.safeInvalidateSession
train
@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; }
java
{ "resource": "" }
q15464
SessionHelper.getAllAttributes
train
@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 <> (); } }
java
{ "resource": "" }
q15465
XMLSitemapIndex.getAsDocument
train
@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; }
java
{ "resource": "" }
q15466
AbstractSessionWebSingleton.getSessionSingleton
train
@Nonnull public static final <T extends AbstractSessionWebSingleton> T getSessionSingleton (@Nonnull final Class <T> aClass) { return getSingleton (_getStaticScope (true), aClass); }
java
{ "resource": "" }
q15467
GLImplementation.load
train
@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; } }
java
{ "resource": "" }
q15468
MockServletPool.registerServlet
train
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); }
java
{ "resource": "" }
q15469
MockServletPool.registerServlet
train
public void registerServlet (@Nonnull final Class <? extends Servlet> aServletClass, @Nonnull @Nonempty final String sServletPath, @Nonnull @Nonempty final String sServletName, @Nullable final Map <String, String> aServletInitParams) { ValueEnforcer.notNull (aServletClass, "ServletClass"); ValueEnforcer.notEmpty (sServletPath, "ServletPath"); for (final ServletItem aItem : m_aServlets) { // Check path uniqueness if (aItem.getServletPath ().equals (sServletPath)) throw new IllegalArgumentException ("Another servlet with the path '" + sServletPath + "' is already registered: " + aItem); // Check name uniqueness if (aItem.getServletName ().equals (sServletName)) throw new IllegalArgumentException ("Another servlet with the name '" + sServletName + "' is already registered: " + aItem); } // Instantiate servlet 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)); }
java
{ "resource": "" }
q15470
MockServletPool.getServletOfPath
train
@Nullable public Servlet getServletOfPath (@Nullable 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 (); }
java
{ "resource": "" }
q15471
MockServletPool.invalidate
train
public void invalidate () { if (m_bInvalidated) throw new IllegalArgumentException ("Servlet pool already invalidated!"); m_bInvalidated = true; // Destroy all servlets 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 (); }
java
{ "resource": "" }
q15472
GA4GHSamRecordIterator.queryNextInterval
train
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; }
java
{ "resource": "" }
q15473
GA4GHSamRecordIterator.queryForInterval
train
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; }
java
{ "resource": "" }
q15474
GA4GHSamRecordIterator.seekMatchingRead
train
void seekMatchingRead() { while (!isAtEnd()) { if (iterator == null || !iterator.hasNext()) { LOG.info("Getting " + (iterator == null ? "first" : "next") + " interval from the API"); // We have hit an end (or this is first time) so we need to go fish // to 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; // Happy case, otherwise we keep spinning in the loop. } else { LOG.info("Skipping non matching read"); } } } }
java
{ "resource": "" }
q15475
CacheControlBuilder.setMaxAge
train
@Nonnull public CacheControlBuilder setMaxAge (@Nonnull final TimeUnit eTimeUnit, final long nDuration) { return setMaxAgeSeconds (eTimeUnit.toSeconds (nDuration)); }
java
{ "resource": "" }
q15476
Groups.hasGroup
train
public boolean hasGroup(String groupName) { boolean result = false; for (Group item : getGroupsList()) { if (item.getName().equals(groupName)) { result = true; } } return result; }
java
{ "resource": "" }
q15477
Groups.getGroup
train
public Group getGroup(String groupName) { Group result = null; for (Group item : getGroupsList()) { if (item.getName().equals(groupName)) { result = item; } } return result; }
java
{ "resource": "" }
q15478
ContextRuleProcessor.processDigits
train
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; // prevent length over limit 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) { // if this token is a number processRules(contextTokens, (HashMap) rule.get(num), matchBegin, currentPosition + 1, matches); } else { // thisToken is like "30-days" 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); } } } } } }
java
{ "resource": "" }
q15479
GA4GHQueryInterval.matches
train
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; }
java
{ "resource": "" }
q15480
ServletContextPathHolder.clearContextPath
train
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; } }
java
{ "resource": "" }
q15481
JdbcDaoSupport.setDataSource
train
public final void setDataSource(DataSource dataSource) { if (this.jdbcTemplate == null || dataSource != this.jdbcTemplate.getDataSource()) { this.jdbcTemplate = createJdbcTemplate(dataSource); initTemplateConfig(); } }
java
{ "resource": "" }
q15482
HttpDigestAuth.getDigestAuthClientCredentials
train
@Nullable public static DigestAuthClientCredentials getDigestAuthClientCredentials (@Nullable 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); }
java
{ "resource": "" }
q15483
HttpDigestAuth.createDigestAuthClientCredentials
train
@Nonnull public static DigestAuthClientCredentials createDigestAuthClientCredentials (@Nonnull final EHttpMethod eMethod, @Nonnull @Nonempty final String sDigestURI, @Nonnull @Nonempty final String sUserName, @Nonnull final String sPassword, @Nonnull @Nonempty final String sRealm, @Nonnull @Nonempty final String sServerNonce, @Nullable final String sAlgorithm, @Nullable final String sClientNonce, @Nullable final String sOpaque, @Nullable final String sMessageQOP, @CheckForSigned 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!"); // Nonce must always by 8 chars long final String sNonceCount = getNonceCountString (nNonceCount); // Create HA1 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); } // Create HA2 // Method name must be upper-case! final String sHA2 = _md5 (eMethod.getName () + SEPARATOR + sDigestURI); // Create the request digest - result must be all lowercase hex chars! String sRequestDigest; if (sMessageQOP == null) { // RFC 2069 backwards compatibility 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); }
java
{ "resource": "" }
q15484
UniformHolder.get
train
@SuppressWarnings("unchecked") public <U extends Uniform> U get(String name) { final Uniform uniform = uniforms.get(name); if (uniform == null) { return null; } return (U) uniform; }
java
{ "resource": "" }
q15485
AbstractFileUploadBase._getFilename
train
@Nullable private static String _getFilename (@Nullable 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)) { // Parameter parser can handle null input 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 { // Even if there is no value, the parameter is present, // so we return an empty file name rather than no file // name. sFilename = ""; } } } } return sFilename; }
java
{ "resource": "" }
q15486
AbstractFileUploadBase._getFieldName
train
@Nullable private static String _getFieldName (@Nullable final String sContentDisposition) { String sFieldName = null; if (sContentDisposition != null && sContentDisposition.toLowerCase (Locale.US).startsWith (RequestHelper.FORM_DATA)) { // Parameter parser can handle null input final ICommonsMap <String, String> aParams = new ParameterParser ().setLowerCaseNames (true) .parse (sContentDisposition, ';'); sFieldName = aParams.get ("name"); if (sFieldName != null) sFieldName = sFieldName.trim (); } return sFieldName; }
java
{ "resource": "" }
q15487
RequestWebScope.isForbiddenParamValueChar
train
public static boolean isForbiddenParamValueChar (final char c) { // INVALID_VALUE_CHAR_XML10 + 0x7f return (c >= 0x0 && c <= 0x8) || (c >= 0xb && c <= 0xc) || (c >= 0xe && c <= 0x1f) || (c == 0x7f) || (c >= 0xd800 && c <= 0xdfff) || (c >= 0xfffe && c <= 0xffff); }
java
{ "resource": "" }
q15488
RequestWebScope.getWithoutForbiddenChars
train
@Nullable public static String getWithoutForbiddenChars (@Nullable 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 "as-is" return s; } if (LOGGER.isWarnEnabled ()) LOGGER.warn ("Removed " + nForbidden + " forbidden character(s) from a request parameter value!"); return aCleanValue.toString (); }
java
{ "resource": "" }
q15489
StringModel.setString
train
public void setString(String string) { rawString = string; colorIndices.clear(); // Search for color codes 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; // Ignore escaped color codes if (index > 0 && stringBuilder.charAt(index - 1) == '\\') { // Remove the escape character stringBuilder.deleteCharAt(index - 1); removedCount++; continue; } // Add the color for the index and delete it from the string 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; } // Color code free string this.string = stringBuilder.toString(); }
java
{ "resource": "" }
q15490
PrivateKeyReader.readPrivateKey
train
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; }
java
{ "resource": "" }
q15491
AbstractCryptor.newAlgorithm
train
protected String newAlgorithm() { if (getModel().getAlgorithm() == null) { return SunJCEAlgorithm.PBEWithMD5AndDES.getAlgorithm(); } return getModel().getAlgorithm().getAlgorithm(); }
java
{ "resource": "" }
q15492
AbstractXServlet.init
train
@Override public final void init (@Nonnull final ServletConfig aSC) throws ServletException { super.init (aSC); m_aStatusMgr.onServletInit (getClass ()); try { // Build init parameter map 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)); } // Invoke each handler for potential initialization m_aHandlerRegistry.forEachHandlerThrowing (x -> x.onServletInit (aInitParams)); } catch (final ServletException ex) { m_aStatusMgr.onServletInitFailed (ex, getClass ()); throw ex; } }
java
{ "resource": "" }
q15493
AbstractXServlet.service
train
@Override public final void service (@Nonnull final ServletRequest req, @Nonnull final ServletResponse res) throws ServletException, IOException { super.service (req, res); }
java
{ "resource": "" }
q15494
HttpDebugger.beforeRequest
train
public static void beforeRequest (@Nonnull final HttpUriRequest aRequest, @Nullable final HttpContext aHttpContext) { if (isEnabled ()) if (LOGGER.isInfoEnabled ()) LOGGER.info ("Before HTTP call: " + aRequest.getMethod () + " " + aRequest.getURI () + (aHttpContext != null ? " (with special HTTP context)" : "")); }
java
{ "resource": "" }
q15495
HttpDebugger.afterRequest
train
public static void afterRequest (@Nonnull final HttpUriRequest aRequest, @Nullable final Object aResponse, @Nullable 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); } }
java
{ "resource": "" }
q15496
JsonRule.transform
train
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); } }
java
{ "resource": "" }
q15497
PasswordEncryptor.hashAndHexPassword
train
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); }
java
{ "resource": "" }
q15498
PasswordEncryptor.hashAndHexPassword
train
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; }
java
{ "resource": "" }
q15499
PasswordEncryptor.hashPassword
train
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; }
java
{ "resource": "" }