repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockEventListenerList.java | MockEventListenerList.addListener | @Nonnull
public EChange addListener (@Nonnull final EventListener aListener)
{
ValueEnforcer.notNull (aListener, "Listener");
// Small consistency check
if (!(aListener instanceof ServletContextListener) &&
!(aListener instanceof HttpSessionListener) &&
!(aListener instanceof ServletRequestListener))
{
LOGGER.warn ("Passed mock listener is none of ServletContextListener, HttpSessionListener or ServletRequestListener and therefore has no effect. The listener class is: " +
aListener.getClass ());
}
return m_aRWLock.writeLocked ( () -> EChange.valueOf (m_aListener.add (aListener)));
} | java | @Nonnull
public EChange addListener (@Nonnull final EventListener aListener)
{
ValueEnforcer.notNull (aListener, "Listener");
// Small consistency check
if (!(aListener instanceof ServletContextListener) &&
!(aListener instanceof HttpSessionListener) &&
!(aListener instanceof ServletRequestListener))
{
LOGGER.warn ("Passed mock listener is none of ServletContextListener, HttpSessionListener or ServletRequestListener and therefore has no effect. The listener class is: " +
aListener.getClass ());
}
return m_aRWLock.writeLocked ( () -> EChange.valueOf (m_aListener.add (aListener)));
} | [
"@",
"Nonnull",
"public",
"EChange",
"addListener",
"(",
"@",
"Nonnull",
"final",
"EventListener",
"aListener",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aListener",
",",
"\"Listener\"",
")",
";",
"// Small consistency check",
"if",
"(",
"!",
"(",
"aListe... | Add a new listener.
@param aListener
The listener to be added. May not be <code>null</code>.
@return {@link EChange}. | [
"Add",
"a",
"new",
"listener",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockEventListenerList.java#L95-L110 | train |
phax/ph-web | ph-sitemap/src/main/java/com/helger/sitemap/XMLSitemapProvider.java | XMLSitemapProvider.forEachURLSet | public static void forEachURLSet (@Nonnull final Consumer <? super XMLSitemapURLSet> aConsumer)
{
ValueEnforcer.notNull (aConsumer, "Consumer");
for (final IXMLSitemapProviderSPI aSPI : s_aProviders)
{
final XMLSitemapURLSet aURLSet = aSPI.createURLSet ();
aConsumer.accept (aURLSet);
}
} | java | public static void forEachURLSet (@Nonnull final Consumer <? super XMLSitemapURLSet> aConsumer)
{
ValueEnforcer.notNull (aConsumer, "Consumer");
for (final IXMLSitemapProviderSPI aSPI : s_aProviders)
{
final XMLSitemapURLSet aURLSet = aSPI.createURLSet ();
aConsumer.accept (aURLSet);
}
} | [
"public",
"static",
"void",
"forEachURLSet",
"(",
"@",
"Nonnull",
"final",
"Consumer",
"<",
"?",
"super",
"XMLSitemapURLSet",
">",
"aConsumer",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aConsumer",
",",
"\"Consumer\"",
")",
";",
"for",
"(",
"final",
"... | Create URL sets from every provider and invoke the provided consumer with
it.
@param aConsumer
The consumer to be invoked. Must be able to handle <code>null</code>
and empty values. May itself not be <code>null</code>. | [
"Create",
"URL",
"sets",
"from",
"every",
"provider",
"and",
"invoke",
"the",
"provided",
"consumer",
"with",
"it",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-sitemap/src/main/java/com/helger/sitemap/XMLSitemapProvider.java#L75-L83 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/Camera.java | Camera.getViewMatrix | public Matrix4f getViewMatrix() {
if (updateViewMatrix) {
rotationMatrixInverse = Matrix4f.createRotation(rotation);
final Matrix4f rotationMatrix = Matrix4f.createRotation(rotation.invert());
final Matrix4f positionMatrix = Matrix4f.createTranslation(position.negate());
viewMatrix = rotationMatrix.mul(positionMatrix);
updateViewMatrix = false;
}
return viewMatrix;
} | java | public Matrix4f getViewMatrix() {
if (updateViewMatrix) {
rotationMatrixInverse = Matrix4f.createRotation(rotation);
final Matrix4f rotationMatrix = Matrix4f.createRotation(rotation.invert());
final Matrix4f positionMatrix = Matrix4f.createTranslation(position.negate());
viewMatrix = rotationMatrix.mul(positionMatrix);
updateViewMatrix = false;
}
return viewMatrix;
} | [
"public",
"Matrix4f",
"getViewMatrix",
"(",
")",
"{",
"if",
"(",
"updateViewMatrix",
")",
"{",
"rotationMatrixInverse",
"=",
"Matrix4f",
".",
"createRotation",
"(",
"rotation",
")",
";",
"final",
"Matrix4f",
"rotationMatrix",
"=",
"Matrix4f",
".",
"createRotation"... | Returns the view matrix, which is the transformation matrix for the position and rotation.
@return The view matrix | [
"Returns",
"the",
"view",
"matrix",
"which",
"is",
"the",
"transformation",
"matrix",
"for",
"the",
"position",
"and",
"rotation",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/Camera.java#L73-L82 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/Camera.java | Camera.createPerspective | public static Camera createPerspective(float fieldOfView, int windowWidth, int windowHeight, float near, float far) {
return new Camera(Matrix4f.createPerspective(fieldOfView, (float) windowWidth / windowHeight, near, far));
} | java | public static Camera createPerspective(float fieldOfView, int windowWidth, int windowHeight, float near, float far) {
return new Camera(Matrix4f.createPerspective(fieldOfView, (float) windowWidth / windowHeight, near, far));
} | [
"public",
"static",
"Camera",
"createPerspective",
"(",
"float",
"fieldOfView",
",",
"int",
"windowWidth",
",",
"int",
"windowHeight",
",",
"float",
"near",
",",
"float",
"far",
")",
"{",
"return",
"new",
"Camera",
"(",
"Matrix4f",
".",
"createPerspective",
"(... | Creates a new camera with a standard perspective projection matrix.
@param fieldOfView The field of view, in degrees
@param windowWidth The window width
@param windowHeight The widow height
@param near The near plane
@param far The far plane
@return The camera | [
"Creates",
"a",
"new",
"camera",
"with",
"a",
"standard",
"perspective",
"projection",
"matrix",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/Camera.java#L166-L168 | train |
astrapi69/mystic-crypt | crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/CertificateReader.java | CertificateReader.readPemCertificate | public static X509Certificate readPemCertificate(final File file)
throws IOException, CertificateException
{
final String privateKeyAsString = readPemFileAsBase64(file);
final byte[] decoded = new Base64().decode(privateKeyAsString);
return readCertificate(decoded);
} | java | public static X509Certificate readPemCertificate(final File file)
throws IOException, CertificateException
{
final String privateKeyAsString = readPemFileAsBase64(file);
final byte[] decoded = new Base64().decode(privateKeyAsString);
return readCertificate(decoded);
} | [
"public",
"static",
"X509Certificate",
"readPemCertificate",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
",",
"CertificateException",
"{",
"final",
"String",
"privateKeyAsString",
"=",
"readPemFileAsBase64",
"(",
"file",
")",
";",
"final",
"byte",
"[... | Read pem certificate.
@param file
the file
@return the certificate
@throws IOException
Signals that an I/O exception has occurred.
@throws CertificateException
is thrown if no Provider supports a CertificateFactorySpi implementation for the
specified type. | [
"Read",
"pem",
"certificate",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/CertificateReader.java#L66-L72 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/logging/LoggingFilter.java | LoggingFilter.isLogRequest | @OverrideOnDemand
protected boolean isLogRequest (@Nonnull final HttpServletRequest aHttpRequest,
@Nonnull final HttpServletResponse aHttpResponse)
{
boolean bLog = isGloballyEnabled () && m_aLogger.isInfoEnabled ();
if (bLog)
{
// Check for excluded path
final String sRequestURI = ServletHelper.getRequestRequestURI (aHttpRequest);
for (final String sExcludedPath : m_aExcludedPaths)
if (sRequestURI.startsWith (sExcludedPath))
{
bLog = false;
break;
}
}
return bLog;
} | java | @OverrideOnDemand
protected boolean isLogRequest (@Nonnull final HttpServletRequest aHttpRequest,
@Nonnull final HttpServletResponse aHttpResponse)
{
boolean bLog = isGloballyEnabled () && m_aLogger.isInfoEnabled ();
if (bLog)
{
// Check for excluded path
final String sRequestURI = ServletHelper.getRequestRequestURI (aHttpRequest);
for (final String sExcludedPath : m_aExcludedPaths)
if (sRequestURI.startsWith (sExcludedPath))
{
bLog = false;
break;
}
}
return bLog;
} | [
"@",
"OverrideOnDemand",
"protected",
"boolean",
"isLogRequest",
"(",
"@",
"Nonnull",
"final",
"HttpServletRequest",
"aHttpRequest",
",",
"@",
"Nonnull",
"final",
"HttpServletResponse",
"aHttpResponse",
")",
"{",
"boolean",
"bLog",
"=",
"isGloballyEnabled",
"(",
")",
... | Check if this request should be logged or not.
@param aHttpRequest
Current HTTP servlet request. Never <code>null</code>.
@param aHttpResponse
Current HTTP servlet response. Never <code>null</code>.
@return <code>true</code> to log, <code>false</code> to not log the request | [
"Check",
"if",
"this",
"request",
"should",
"be",
"logged",
"or",
"not",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/logging/LoggingFilter.java#L145-L162 | train |
phax/ph-web | ph-httpclient/src/main/java/com/helger/httpclient/HttpClientManager.java | HttpClientManager.execute | @Nonnull
public CloseableHttpResponse execute (@Nonnull final HttpUriRequest aRequest) throws IOException
{
return execute (aRequest, (HttpContext) null);
} | java | @Nonnull
public CloseableHttpResponse execute (@Nonnull final HttpUriRequest aRequest) throws IOException
{
return execute (aRequest, (HttpContext) null);
} | [
"@",
"Nonnull",
"public",
"CloseableHttpResponse",
"execute",
"(",
"@",
"Nonnull",
"final",
"HttpUriRequest",
"aRequest",
")",
"throws",
"IOException",
"{",
"return",
"execute",
"(",
"aRequest",
",",
"(",
"HttpContext",
")",
"null",
")",
";",
"}"
] | Execute the provided request without any special context. Caller is
responsible for consuming the response correctly!
@param aRequest
The request to be executed. May not be <code>null</code>.
@return The response to be evaluated. Never <code>null</code>.
@throws IOException
In case of error
@throws IllegalStateException
If this manager was already closed! | [
"Execute",
"the",
"provided",
"request",
"without",
"any",
"special",
"context",
".",
"Caller",
"is",
"responsible",
"for",
"consuming",
"the",
"response",
"correctly!"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-httpclient/src/main/java/com/helger/httpclient/HttpClientManager.java#L90-L94 | train |
phax/ph-web | ph-httpclient/src/main/java/com/helger/httpclient/HttpClientManager.java | HttpClientManager.execute | @Nonnull
public CloseableHttpResponse execute (@Nonnull final HttpUriRequest aRequest,
@Nullable final HttpContext aHttpContext) throws IOException
{
checkIfClosed ();
HttpDebugger.beforeRequest (aRequest, aHttpContext);
CloseableHttpResponse ret = null;
Throwable aCaughtException = null;
try
{
ret = m_aHttpClient.execute (aRequest, aHttpContext);
return ret;
}
catch (final IOException ex)
{
aCaughtException = ex;
throw ex;
}
finally
{
HttpDebugger.afterRequest (aRequest, ret, aCaughtException);
}
} | java | @Nonnull
public CloseableHttpResponse execute (@Nonnull final HttpUriRequest aRequest,
@Nullable final HttpContext aHttpContext) throws IOException
{
checkIfClosed ();
HttpDebugger.beforeRequest (aRequest, aHttpContext);
CloseableHttpResponse ret = null;
Throwable aCaughtException = null;
try
{
ret = m_aHttpClient.execute (aRequest, aHttpContext);
return ret;
}
catch (final IOException ex)
{
aCaughtException = ex;
throw ex;
}
finally
{
HttpDebugger.afterRequest (aRequest, ret, aCaughtException);
}
} | [
"@",
"Nonnull",
"public",
"CloseableHttpResponse",
"execute",
"(",
"@",
"Nonnull",
"final",
"HttpUriRequest",
"aRequest",
",",
"@",
"Nullable",
"final",
"HttpContext",
"aHttpContext",
")",
"throws",
"IOException",
"{",
"checkIfClosed",
"(",
")",
";",
"HttpDebugger",... | Execute the provided request with an optional special context. Caller is
responsible for consuming the response correctly!
@param aRequest
The request to be executed. May not be <code>null</code>.
@param aHttpContext
The optional context to be used. May be <code>null</code> to
@return The response to be evaluated. Never <code>null</code>.
@throws IOException
In case of error
@throws IllegalStateException
If this manager was already closed! | [
"Execute",
"the",
"provided",
"request",
"with",
"an",
"optional",
"special",
"context",
".",
"Caller",
"is",
"responsible",
"for",
"consuming",
"the",
"response",
"correctly!"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-httpclient/src/main/java/com/helger/httpclient/HttpClientManager.java#L110-L132 | train |
phax/ph-web | ph-httpclient/src/main/java/com/helger/httpclient/HttpClientManager.java | HttpClientManager.execute | @Nullable
public <T> T execute (@Nonnull final HttpUriRequest aRequest,
@Nonnull final ResponseHandler <T> aResponseHandler) throws IOException
{
return execute (aRequest, (HttpContext) null, aResponseHandler);
} | java | @Nullable
public <T> T execute (@Nonnull final HttpUriRequest aRequest,
@Nonnull final ResponseHandler <T> aResponseHandler) throws IOException
{
return execute (aRequest, (HttpContext) null, aResponseHandler);
} | [
"@",
"Nullable",
"public",
"<",
"T",
">",
"T",
"execute",
"(",
"@",
"Nonnull",
"final",
"HttpUriRequest",
"aRequest",
",",
"@",
"Nonnull",
"final",
"ResponseHandler",
"<",
"T",
">",
"aResponseHandler",
")",
"throws",
"IOException",
"{",
"return",
"execute",
... | Execute the provided request without any special context. The response
handler is invoked as a callback. This method automatically cleans up all
used resources and as such is preferred over the execute methods returning
the CloseableHttpResponse.
@param aRequest
The request to be executed. May not be <code>null</code>.
@param aResponseHandler
The response handler to be executed. May not be <code>null</code>.
@return The evaluated response of the response handler. May be
<code>null</code>.
@throws IOException
In case of error
@throws IllegalStateException
If this manager was already closed!
@param <T>
return type | [
"Execute",
"the",
"provided",
"request",
"without",
"any",
"special",
"context",
".",
"The",
"response",
"handler",
"is",
"invoked",
"as",
"a",
"callback",
".",
"This",
"method",
"automatically",
"cleans",
"up",
"all",
"used",
"resources",
"and",
"as",
"such",... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-httpclient/src/main/java/com/helger/httpclient/HttpClientManager.java#L153-L158 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.setMailQueueSize | @Nonnull
public static EChange setMailQueueSize (@Nonnegative final int nMaxMailQueueLen,
@Nonnegative final int nMaxMailSendCount)
{
ValueEnforcer.isGT0 (nMaxMailQueueLen, "MaxMailQueueLen");
ValueEnforcer.isGT0 (nMaxMailSendCount, "MaxMailSendCount");
ValueEnforcer.isTrue (nMaxMailQueueLen >= nMaxMailSendCount,
() -> "MaxMailQueueLen (" +
nMaxMailQueueLen +
") must be >= than MaxMailSendCount (" +
nMaxMailSendCount +
")");
return s_aRWLock.writeLocked ( () -> {
if (nMaxMailQueueLen == s_nMaxMailQueueLen && nMaxMailSendCount == s_nMaxMailSendCount)
return EChange.UNCHANGED;
s_nMaxMailQueueLen = nMaxMailQueueLen;
s_nMaxMailSendCount = nMaxMailSendCount;
return EChange.CHANGED;
});
} | java | @Nonnull
public static EChange setMailQueueSize (@Nonnegative final int nMaxMailQueueLen,
@Nonnegative final int nMaxMailSendCount)
{
ValueEnforcer.isGT0 (nMaxMailQueueLen, "MaxMailQueueLen");
ValueEnforcer.isGT0 (nMaxMailSendCount, "MaxMailSendCount");
ValueEnforcer.isTrue (nMaxMailQueueLen >= nMaxMailSendCount,
() -> "MaxMailQueueLen (" +
nMaxMailQueueLen +
") must be >= than MaxMailSendCount (" +
nMaxMailSendCount +
")");
return s_aRWLock.writeLocked ( () -> {
if (nMaxMailQueueLen == s_nMaxMailQueueLen && nMaxMailSendCount == s_nMaxMailSendCount)
return EChange.UNCHANGED;
s_nMaxMailQueueLen = nMaxMailQueueLen;
s_nMaxMailSendCount = nMaxMailSendCount;
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"setMailQueueSize",
"(",
"@",
"Nonnegative",
"final",
"int",
"nMaxMailQueueLen",
",",
"@",
"Nonnegative",
"final",
"int",
"nMaxMailSendCount",
")",
"{",
"ValueEnforcer",
".",
"isGT0",
"(",
"nMaxMailQueueLen",
",",
"\"... | Set mail queue settings. Changing these settings has no effect on existing
mail queues!
@param nMaxMailQueueLen
The maximum number of mails that can be queued. Must be > 0.
@param nMaxMailSendCount
The maximum number of mails that are send out in one mail session.
Must be > 0 but ≤ than {@link #getMaxMailQueueLength()}.
@return {@link EChange}. | [
"Set",
"mail",
"queue",
"settings",
".",
"Changing",
"these",
"settings",
"has",
"no",
"effect",
"on",
"existing",
"mail",
"queues!"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L103-L123 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.setUseSSL | @Nonnull
public static EChange setUseSSL (final boolean bUseSSL)
{
return s_aRWLock.writeLocked ( () -> {
if (s_bUseSSL == bUseSSL)
return EChange.UNCHANGED;
s_bUseSSL = bUseSSL;
return EChange.CHANGED;
});
} | java | @Nonnull
public static EChange setUseSSL (final boolean bUseSSL)
{
return s_aRWLock.writeLocked ( () -> {
if (s_bUseSSL == bUseSSL)
return EChange.UNCHANGED;
s_bUseSSL = bUseSSL;
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"setUseSSL",
"(",
"final",
"boolean",
"bUseSSL",
")",
"{",
"return",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"s_bUseSSL",
"==",
"bUseSSL",
")",
"return",
"EChange",
".",
"UNCHANGE... | Use SSL by default?
@param bUseSSL
<code>true</code> to use it by default, <code>false</code> if not.
@return {@link EChange} | [
"Use",
"SSL",
"by",
"default?"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L151-L160 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.setUseSTARTTLS | @Nonnull
public static EChange setUseSTARTTLS (final boolean bUseSTARTTLS)
{
return s_aRWLock.writeLocked ( () -> {
if (s_bUseSTARTTLS == bUseSTARTTLS)
return EChange.UNCHANGED;
s_bUseSTARTTLS = bUseSTARTTLS;
return EChange.CHANGED;
});
} | java | @Nonnull
public static EChange setUseSTARTTLS (final boolean bUseSTARTTLS)
{
return s_aRWLock.writeLocked ( () -> {
if (s_bUseSTARTTLS == bUseSTARTTLS)
return EChange.UNCHANGED;
s_bUseSTARTTLS = bUseSTARTTLS;
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"setUseSTARTTLS",
"(",
"final",
"boolean",
"bUseSTARTTLS",
")",
"{",
"return",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"s_bUseSTARTTLS",
"==",
"bUseSTARTTLS",
")",
"return",
"EChange"... | Use STARTTLS by default?
@param bUseSTARTTLS
<code>true</code> to use it by default, <code>false</code> if not.
@return {@link EChange} | [
"Use",
"STARTTLS",
"by",
"default?"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L177-L186 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.setConnectionTimeoutMilliSecs | @Nonnull
public static EChange setConnectionTimeoutMilliSecs (final long nMilliSecs)
{
return s_aRWLock.writeLocked ( () -> {
if (s_nConnectionTimeoutMilliSecs == nMilliSecs)
return EChange.UNCHANGED;
if (nMilliSecs <= 0)
LOGGER.warn ("You are setting an indefinite connection timeout for the mail transport api: " + nMilliSecs);
s_nConnectionTimeoutMilliSecs = nMilliSecs;
return EChange.CHANGED;
});
} | java | @Nonnull
public static EChange setConnectionTimeoutMilliSecs (final long nMilliSecs)
{
return s_aRWLock.writeLocked ( () -> {
if (s_nConnectionTimeoutMilliSecs == nMilliSecs)
return EChange.UNCHANGED;
if (nMilliSecs <= 0)
LOGGER.warn ("You are setting an indefinite connection timeout for the mail transport api: " + nMilliSecs);
s_nConnectionTimeoutMilliSecs = nMilliSecs;
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"setConnectionTimeoutMilliSecs",
"(",
"final",
"long",
"nMilliSecs",
")",
"{",
"return",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"s_nConnectionTimeoutMilliSecs",
"==",
"nMilliSecs",
")",
... | Set the connection timeout in milliseconds. Values ≤ 0 are interpreted
as indefinite timeout which is not recommended! Changing these settings has
no effect on existing mail queues!
@param nMilliSecs
The milliseconds timeout
@return {@link EChange} | [
"Set",
"the",
"connection",
"timeout",
"in",
"milliseconds",
".",
"Values",
"&le",
";",
"0",
"are",
"interpreted",
"as",
"indefinite",
"timeout",
"which",
"is",
"not",
"recommended!",
"Changing",
"these",
"settings",
"has",
"no",
"effect",
"on",
"existing",
"m... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L205-L216 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.setTimeoutMilliSecs | @Nonnull
public static EChange setTimeoutMilliSecs (final long nMilliSecs)
{
return s_aRWLock.writeLocked ( () -> {
if (s_nTimeoutMilliSecs == nMilliSecs)
return EChange.UNCHANGED;
if (nMilliSecs <= 0)
LOGGER.warn ("You are setting an indefinite socket timeout for the mail transport api: " + nMilliSecs);
s_nTimeoutMilliSecs = nMilliSecs;
return EChange.CHANGED;
});
} | java | @Nonnull
public static EChange setTimeoutMilliSecs (final long nMilliSecs)
{
return s_aRWLock.writeLocked ( () -> {
if (s_nTimeoutMilliSecs == nMilliSecs)
return EChange.UNCHANGED;
if (nMilliSecs <= 0)
LOGGER.warn ("You are setting an indefinite socket timeout for the mail transport api: " + nMilliSecs);
s_nTimeoutMilliSecs = nMilliSecs;
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"setTimeoutMilliSecs",
"(",
"final",
"long",
"nMilliSecs",
")",
"{",
"return",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"s_nTimeoutMilliSecs",
"==",
"nMilliSecs",
")",
"return",
"EChan... | Set the socket timeout in milliseconds. Values ≤ 0 are interpreted as
indefinite timeout which is not recommended! Changing these settings has no
effect on existing mail queues!
@param nMilliSecs
The milliseconds timeout
@return {@link EChange} | [
"Set",
"the",
"socket",
"timeout",
"in",
"milliseconds",
".",
"Values",
"&le",
";",
"0",
"are",
"interpreted",
"as",
"indefinite",
"timeout",
"which",
"is",
"not",
"recommended!",
"Changing",
"these",
"settings",
"has",
"no",
"effect",
"on",
"existing",
"mail"... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L238-L249 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.addConnectionListener | public static void addConnectionListener (@Nonnull final ConnectionListener aConnectionListener)
{
ValueEnforcer.notNull (aConnectionListener, "ConnectionListener");
s_aRWLock.writeLocked ( () -> s_aConnectionListeners.add (aConnectionListener));
} | java | public static void addConnectionListener (@Nonnull final ConnectionListener aConnectionListener)
{
ValueEnforcer.notNull (aConnectionListener, "ConnectionListener");
s_aRWLock.writeLocked ( () -> s_aConnectionListeners.add (aConnectionListener));
} | [
"public",
"static",
"void",
"addConnectionListener",
"(",
"@",
"Nonnull",
"final",
"ConnectionListener",
"aConnectionListener",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aConnectionListener",
",",
"\"ConnectionListener\"",
")",
";",
"s_aRWLock",
".",
"writeLocked... | Add a new mail connection listener.
@param aConnectionListener
The new connection listener to add. May not be <code>null</code>.
@since 1.1.0 | [
"Add",
"a",
"new",
"mail",
"connection",
"listener",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L297-L301 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.removeConnectionListener | @Nonnull
public static EChange removeConnectionListener (@Nullable final ConnectionListener aConnectionListener)
{
if (aConnectionListener == null)
return EChange.UNCHANGED;
return s_aRWLock.writeLocked ( () -> s_aConnectionListeners.removeObject (aConnectionListener));
} | java | @Nonnull
public static EChange removeConnectionListener (@Nullable final ConnectionListener aConnectionListener)
{
if (aConnectionListener == null)
return EChange.UNCHANGED;
return s_aRWLock.writeLocked ( () -> s_aConnectionListeners.removeObject (aConnectionListener));
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"removeConnectionListener",
"(",
"@",
"Nullable",
"final",
"ConnectionListener",
"aConnectionListener",
")",
"{",
"if",
"(",
"aConnectionListener",
"==",
"null",
")",
"return",
"EChange",
".",
"UNCHANGED",
";",
"return"... | Remove an existing mail connection listener.
@param aConnectionListener
The new connection listener to set. May not be <code>null</code>.
@return {@link EChange}
@since 1.1.0 | [
"Remove",
"an",
"existing",
"mail",
"connection",
"listener",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L311-L318 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.addEmailDataTransportListener | public static void addEmailDataTransportListener (@Nonnull final IEmailDataTransportListener aEmailDataTransportListener)
{
ValueEnforcer.notNull (aEmailDataTransportListener, "EmailDataTransportListener");
s_aRWLock.writeLocked ( () -> s_aEmailDataTransportListeners.add (aEmailDataTransportListener));
} | java | public static void addEmailDataTransportListener (@Nonnull final IEmailDataTransportListener aEmailDataTransportListener)
{
ValueEnforcer.notNull (aEmailDataTransportListener, "EmailDataTransportListener");
s_aRWLock.writeLocked ( () -> s_aEmailDataTransportListeners.add (aEmailDataTransportListener));
} | [
"public",
"static",
"void",
"addEmailDataTransportListener",
"(",
"@",
"Nonnull",
"final",
"IEmailDataTransportListener",
"aEmailDataTransportListener",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aEmailDataTransportListener",
",",
"\"EmailDataTransportListener\"",
")",
... | Add a new mail transport listener.
@param aEmailDataTransportListener
The new transport listener to add. May not be <code>null</code>.
@since 1.1.0 | [
"Add",
"a",
"new",
"mail",
"transport",
"listener",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L360-L364 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.removeEmailDataTransportListener | @Nonnull
public static EChange removeEmailDataTransportListener (@Nullable final IEmailDataTransportListener aEmailDataTransportListener)
{
if (aEmailDataTransportListener == null)
return EChange.UNCHANGED;
return s_aRWLock.writeLocked ( () -> s_aEmailDataTransportListeners.removeObject (aEmailDataTransportListener));
} | java | @Nonnull
public static EChange removeEmailDataTransportListener (@Nullable final IEmailDataTransportListener aEmailDataTransportListener)
{
if (aEmailDataTransportListener == null)
return EChange.UNCHANGED;
return s_aRWLock.writeLocked ( () -> s_aEmailDataTransportListeners.removeObject (aEmailDataTransportListener));
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"removeEmailDataTransportListener",
"(",
"@",
"Nullable",
"final",
"IEmailDataTransportListener",
"aEmailDataTransportListener",
")",
"{",
"if",
"(",
"aEmailDataTransportListener",
"==",
"null",
")",
"return",
"EChange",
".",... | Remove an existing mail transport listener.
@param aEmailDataTransportListener
The new transport listener to set. May not be <code>null</code>.
@return {@link EChange}
@since 1.1.0 | [
"Remove",
"an",
"existing",
"mail",
"transport",
"listener",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L374-L381 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.enableJavaxMailDebugging | @SuppressFBWarnings ("LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE")
public static void enableJavaxMailDebugging (final boolean bDebug)
{
java.util.logging.Logger.getLogger ("com.sun.mail.smtp").setLevel (bDebug ? Level.FINEST : Level.INFO);
java.util.logging.Logger.getLogger ("com.sun.mail.smtp.protocol").setLevel (bDebug ? Level.FINEST : Level.INFO);
SystemProperties.setPropertyValue ("mail.socket.debug", bDebug);
SystemProperties.setPropertyValue ("java.security.debug", bDebug ? "certpath" : null);
SystemProperties.setPropertyValue ("javax.net.debug", bDebug ? "trustmanager" : null);
} | java | @SuppressFBWarnings ("LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE")
public static void enableJavaxMailDebugging (final boolean bDebug)
{
java.util.logging.Logger.getLogger ("com.sun.mail.smtp").setLevel (bDebug ? Level.FINEST : Level.INFO);
java.util.logging.Logger.getLogger ("com.sun.mail.smtp.protocol").setLevel (bDebug ? Level.FINEST : Level.INFO);
SystemProperties.setPropertyValue ("mail.socket.debug", bDebug);
SystemProperties.setPropertyValue ("java.security.debug", bDebug ? "certpath" : null);
SystemProperties.setPropertyValue ("javax.net.debug", bDebug ? "trustmanager" : null);
} | [
"@",
"SuppressFBWarnings",
"(",
"\"LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE\"",
")",
"public",
"static",
"void",
"enableJavaxMailDebugging",
"(",
"final",
"boolean",
"bDebug",
")",
"{",
"java",
".",
"util",
".",
"logging",
".",
"Logger",
".",
"getLogger",
"(",
"\"com.su... | Enable or disable javax.mail debugging. By default debugging is disabled.
@param bDebug
<code>true</code> to enabled debugging, <code>false</code> to
disable it. | [
"Enable",
"or",
"disable",
"javax",
".",
"mail",
"debugging",
".",
"By",
"default",
"debugging",
"is",
"disabled",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L423-L431 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java | EmailGlobalSettings.setToDefault | public static void setToDefault ()
{
s_aRWLock.writeLocked ( () -> {
s_nMaxMailQueueLen = DEFAULT_MAX_QUEUE_LENGTH;
s_nMaxMailSendCount = DEFAULT_MAX_SEND_COUNT;
s_bUseSSL = DEFAULT_USE_SSL;
s_bUseSTARTTLS = DEFAULT_USE_STARTTLS;
s_nConnectionTimeoutMilliSecs = DEFAULT_CONNECT_TIMEOUT_MILLISECS;
s_nTimeoutMilliSecs = DEFAULT_TIMEOUT_MILLISECS;
s_bDebugSMTP = GlobalDebug.isDebugMode ();
s_aConnectionListeners.clear ();
s_aEmailDataTransportListeners.clear ();
});
} | java | public static void setToDefault ()
{
s_aRWLock.writeLocked ( () -> {
s_nMaxMailQueueLen = DEFAULT_MAX_QUEUE_LENGTH;
s_nMaxMailSendCount = DEFAULT_MAX_SEND_COUNT;
s_bUseSSL = DEFAULT_USE_SSL;
s_bUseSTARTTLS = DEFAULT_USE_STARTTLS;
s_nConnectionTimeoutMilliSecs = DEFAULT_CONNECT_TIMEOUT_MILLISECS;
s_nTimeoutMilliSecs = DEFAULT_TIMEOUT_MILLISECS;
s_bDebugSMTP = GlobalDebug.isDebugMode ();
s_aConnectionListeners.clear ();
s_aEmailDataTransportListeners.clear ();
});
} | [
"public",
"static",
"void",
"setToDefault",
"(",
")",
"{",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"s_nMaxMailQueueLen",
"=",
"DEFAULT_MAX_QUEUE_LENGTH",
";",
"s_nMaxMailSendCount",
"=",
"DEFAULT_MAX_SEND_COUNT",
";",
"s_bUseSSL",
"=",
"DEFAULT_US... | Set all settings to the default. This is helpful for testing.
@since 3.0.0 | [
"Set",
"all",
"settings",
"to",
"the",
"default",
".",
"This",
"is",
"helpful",
"for",
"testing",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/EmailGlobalSettings.java#L447-L460 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/gm/GoogleMapsUrlSigner.java | GoogleMapsUrlSigner.convertToKeyByteArray | public static byte[] convertToKeyByteArray(String yourGooglePrivateKeyString)
{
yourGooglePrivateKeyString = yourGooglePrivateKeyString.replace('-', '+');
yourGooglePrivateKeyString = yourGooglePrivateKeyString.replace('_', '/');
return Base64.getDecoder().decode(yourGooglePrivateKeyString);
} | java | public static byte[] convertToKeyByteArray(String yourGooglePrivateKeyString)
{
yourGooglePrivateKeyString = yourGooglePrivateKeyString.replace('-', '+');
yourGooglePrivateKeyString = yourGooglePrivateKeyString.replace('_', '/');
return Base64.getDecoder().decode(yourGooglePrivateKeyString);
} | [
"public",
"static",
"byte",
"[",
"]",
"convertToKeyByteArray",
"(",
"String",
"yourGooglePrivateKeyString",
")",
"{",
"yourGooglePrivateKeyString",
"=",
"yourGooglePrivateKeyString",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"yourGooglePrivateKeyString",... | Converts the given private key as String to an base 64 encoded byte array.
@param yourGooglePrivateKeyString
the google private key as String
@return the base 64 encoded byte array. | [
"Converts",
"the",
"given",
"private",
"key",
"as",
"String",
"to",
"an",
"base",
"64",
"encoded",
"byte",
"array",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/gm/GoogleMapsUrlSigner.java#L55-L60 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/gm/GoogleMapsUrlSigner.java | GoogleMapsUrlSigner.signRequest | public static String signRequest(final String yourGooglePrivateKeyString, final String path,
final String query) throws NoSuchAlgorithmException, InvalidKeyException,
UnsupportedEncodingException, URISyntaxException
{
// Retrieve the proper URL components to sign
final String resource = path + '?' + query;
// Get an HMAC-SHA1 signing key from the raw key bytes
final SecretKeySpec sha1Key = new SecretKeySpec(
convertToKeyByteArray(yourGooglePrivateKeyString), "HmacSHA1");
// Get an HMAC-SHA1 Mac instance and initialize it with the HMAC-SHA1
// key
final Mac mac = Mac.getInstance("HmacSHA1");
mac.init(sha1Key);
// compute the binary signature for the request
final byte[] sigBytes = mac.doFinal(resource.getBytes());
// base 64 encode the binary signature
// Base64 is JDK 1.8 only - older versions may need to use Apache
// Commons or similar.
String signature = Base64.getEncoder().encodeToString(sigBytes);
// convert the signature to 'web safe' base 64
signature = signature.replace('+', '-');
signature = signature.replace('/', '_');
return resource + "&signature=" + signature;
} | java | public static String signRequest(final String yourGooglePrivateKeyString, final String path,
final String query) throws NoSuchAlgorithmException, InvalidKeyException,
UnsupportedEncodingException, URISyntaxException
{
// Retrieve the proper URL components to sign
final String resource = path + '?' + query;
// Get an HMAC-SHA1 signing key from the raw key bytes
final SecretKeySpec sha1Key = new SecretKeySpec(
convertToKeyByteArray(yourGooglePrivateKeyString), "HmacSHA1");
// Get an HMAC-SHA1 Mac instance and initialize it with the HMAC-SHA1
// key
final Mac mac = Mac.getInstance("HmacSHA1");
mac.init(sha1Key);
// compute the binary signature for the request
final byte[] sigBytes = mac.doFinal(resource.getBytes());
// base 64 encode the binary signature
// Base64 is JDK 1.8 only - older versions may need to use Apache
// Commons or similar.
String signature = Base64.getEncoder().encodeToString(sigBytes);
// convert the signature to 'web safe' base 64
signature = signature.replace('+', '-');
signature = signature.replace('/', '_');
return resource + "&signature=" + signature;
} | [
"public",
"static",
"String",
"signRequest",
"(",
"final",
"String",
"yourGooglePrivateKeyString",
",",
"final",
"String",
"path",
",",
"final",
"String",
"query",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
",",
"UnsupportedEncodingException",
... | Returns the context path with the signature as parameter.
@param yourGooglePrivateKeyString
your private key from google as byte array in Base64 format
@param path
the path
@param query
the query
@return the signed context path as string
@throws NoSuchAlgorithmException
the no such algorithm exception
@throws InvalidKeyException
the invalid key exception
@throws UnsupportedEncodingException
the unsupported encoding exception
@throws URISyntaxException
the URI syntax exception | [
"Returns",
"the",
"context",
"path",
"with",
"the",
"signature",
"as",
"parameter",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/gm/GoogleMapsUrlSigner.java#L81-L111 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/gm/GoogleMapsUrlSigner.java | GoogleMapsUrlSigner.signRequest | public static String signRequest(final URL url, final String yourGooglePrivateKeyString)
throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException,
URISyntaxException
{
// Retrieve the proper URL components to sign
final String resource = url.getPath() + '?' + url.getQuery();
// Get an HMAC-SHA1 signing key from the raw key bytes
final SecretKeySpec sha1Key = new SecretKeySpec(
convertToKeyByteArray(yourGooglePrivateKeyString), "HmacSHA1");
// Get an HMAC-SHA1 Mac instance and initialize it with the HMAC-SHA1
// key
final Mac mac = Mac.getInstance("HmacSHA1");
mac.init(sha1Key);
// compute the binary signature for the request
final byte[] sigBytes = mac.doFinal(resource.getBytes());
// base 64 encode the binary signature
// Base64 is JDK 1.8 only - older versions may need to use Apache
// Commons or similar.
String signature = Base64.getEncoder().encodeToString(sigBytes);
// convert the signature to 'web safe' base 64
signature = signature.replace('+', '-');
signature = signature.replace('/', '_');
final String signedRequestPath = resource + "&signature=" + signature;
final String urlGoogleMapSignedRequest = url.getProtocol() + "://" + url.getHost()
+ signedRequestPath;
return urlGoogleMapSignedRequest;
} | java | public static String signRequest(final URL url, final String yourGooglePrivateKeyString)
throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException,
URISyntaxException
{
// Retrieve the proper URL components to sign
final String resource = url.getPath() + '?' + url.getQuery();
// Get an HMAC-SHA1 signing key from the raw key bytes
final SecretKeySpec sha1Key = new SecretKeySpec(
convertToKeyByteArray(yourGooglePrivateKeyString), "HmacSHA1");
// Get an HMAC-SHA1 Mac instance and initialize it with the HMAC-SHA1
// key
final Mac mac = Mac.getInstance("HmacSHA1");
mac.init(sha1Key);
// compute the binary signature for the request
final byte[] sigBytes = mac.doFinal(resource.getBytes());
// base 64 encode the binary signature
// Base64 is JDK 1.8 only - older versions may need to use Apache
// Commons or similar.
String signature = Base64.getEncoder().encodeToString(sigBytes);
// convert the signature to 'web safe' base 64
signature = signature.replace('+', '-');
signature = signature.replace('/', '_');
final String signedRequestPath = resource + "&signature=" + signature;
final String urlGoogleMapSignedRequest = url.getProtocol() + "://" + url.getHost()
+ signedRequestPath;
return urlGoogleMapSignedRequest;
} | [
"public",
"static",
"String",
"signRequest",
"(",
"final",
"URL",
"url",
",",
"final",
"String",
"yourGooglePrivateKeyString",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
",",
"UnsupportedEncodingException",
",",
"URISyntaxException",
"{",
"// R... | Returns the full url as String object with the signature as parameter.
@param url
the url
@param yourGooglePrivateKeyString
the your google private key string
@return the string
@throws NoSuchAlgorithmException
the no such algorithm exception
@throws InvalidKeyException
the invalid key exception
@throws UnsupportedEncodingException
the unsupported encoding exception
@throws URISyntaxException
the URI syntax exception | [
"Returns",
"the",
"full",
"url",
"as",
"String",
"object",
"with",
"the",
"signature",
"as",
"parameter",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/gm/GoogleMapsUrlSigner.java#L130-L162 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/response/UnifiedResponseDefaultSettings.java | UnifiedResponseDefaultSettings.setResponseHeader | public static void setResponseHeader (@Nonnull @Nonempty final String sName, @Nonnull @Nonempty final String sValue)
{
ValueEnforcer.notEmpty (sName, "Name");
ValueEnforcer.notEmpty (sValue, "Value");
s_aRWLock.writeLocked ( () -> s_aResponseHeaderMap.setHeader (sName, sValue));
} | java | public static void setResponseHeader (@Nonnull @Nonempty final String sName, @Nonnull @Nonempty final String sValue)
{
ValueEnforcer.notEmpty (sName, "Name");
ValueEnforcer.notEmpty (sValue, "Value");
s_aRWLock.writeLocked ( () -> s_aResponseHeaderMap.setHeader (sName, sValue));
} | [
"public",
"static",
"void",
"setResponseHeader",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sName",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sValue",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sName",
",",
"\"Name\"",
"... | Sets a response header to the response according to the passed name and
value. An existing header entry with the same name is overridden.
@param sName
Name of the header. May neither be <code>null</code> nor empty.
@param sValue
Value of the header. May neither be <code>null</code> nor empty. | [
"Sets",
"a",
"response",
"header",
"to",
"the",
"response",
"according",
"to",
"the",
"passed",
"name",
"and",
"value",
".",
"An",
"existing",
"header",
"entry",
"with",
"the",
"same",
"name",
"is",
"overridden",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/response/UnifiedResponseDefaultSettings.java#L217-L224 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/response/UnifiedResponseDefaultSettings.java | UnifiedResponseDefaultSettings.addResponseHeader | public static void addResponseHeader (@Nonnull @Nonempty final String sName, @Nonnull @Nonempty final String sValue)
{
ValueEnforcer.notEmpty (sName, "Name");
ValueEnforcer.notEmpty (sValue, "Value");
s_aRWLock.writeLocked ( () -> s_aResponseHeaderMap.addHeader (sName, sValue));
} | java | public static void addResponseHeader (@Nonnull @Nonempty final String sName, @Nonnull @Nonempty final String sValue)
{
ValueEnforcer.notEmpty (sName, "Name");
ValueEnforcer.notEmpty (sValue, "Value");
s_aRWLock.writeLocked ( () -> s_aResponseHeaderMap.addHeader (sName, sValue));
} | [
"public",
"static",
"void",
"addResponseHeader",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sName",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sValue",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sName",
",",
"\"Name\"",
"... | Adds a response header to the response according to the passed name and
value. If an existing header with the same is present, the value is added to
the list so that the header is emitted more than once.
@param sName
Name of the header. May neither be <code>null</code> nor empty.
@param sValue
Value of the header. May neither be <code>null</code> nor empty. | [
"Adds",
"a",
"response",
"header",
"to",
"the",
"response",
"according",
"to",
"the",
"passed",
"name",
"and",
"value",
".",
"If",
"an",
"existing",
"header",
"with",
"the",
"same",
"is",
"present",
"the",
"value",
"is",
"added",
"to",
"the",
"list",
"so... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/response/UnifiedResponseDefaultSettings.java#L236-L242 | train |
sigopt/sigopt-java | src/main/java/com/sigopt/net/MapHelper.java | MapHelper.merge | public static <S, T> Map<S, T> merge(Map<S, T> map, Map<S, T> toMerge) {
Map<S, T> ret = new HashMap<S, T>();
ret.putAll(ensure(map));
ret.putAll(ensure(toMerge));
return ret;
} | java | public static <S, T> Map<S, T> merge(Map<S, T> map, Map<S, T> toMerge) {
Map<S, T> ret = new HashMap<S, T>();
ret.putAll(ensure(map));
ret.putAll(ensure(toMerge));
return ret;
} | [
"public",
"static",
"<",
"S",
",",
"T",
">",
"Map",
"<",
"S",
",",
"T",
">",
"merge",
"(",
"Map",
"<",
"S",
",",
"T",
">",
"map",
",",
"Map",
"<",
"S",
",",
"T",
">",
"toMerge",
")",
"{",
"Map",
"<",
"S",
",",
"T",
">",
"ret",
"=",
"new... | toMerge will overwrite map values. | [
"toMerge",
"will",
"overwrite",
"map",
"values",
"."
] | fc27065a8c1c5661576874b094e243e88ccaafb1 | https://github.com/sigopt/sigopt-java/blob/fc27065a8c1c5661576874b094e243e88ccaafb1/src/main/java/com/sigopt/net/MapHelper.java#L8-L13 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/FileItemHeaders.java | FileItemHeaders.addHeader | public void addHeader (@Nonnull final String sName, @Nullable final String sValue)
{
ValueEnforcer.notNull (sName, "HeaderName");
final String sNameLower = sName.toLowerCase (Locale.US);
m_aRWLock.writeLocked ( () -> {
ICommonsList <String> aHeaderValueList = m_aHeaderNameToValueListMap.get (sNameLower);
if (aHeaderValueList == null)
{
aHeaderValueList = new CommonsArrayList <> ();
m_aHeaderNameToValueListMap.put (sNameLower, aHeaderValueList);
m_aHeaderNameList.add (sNameLower);
}
aHeaderValueList.add (sValue);
});
} | java | public void addHeader (@Nonnull final String sName, @Nullable final String sValue)
{
ValueEnforcer.notNull (sName, "HeaderName");
final String sNameLower = sName.toLowerCase (Locale.US);
m_aRWLock.writeLocked ( () -> {
ICommonsList <String> aHeaderValueList = m_aHeaderNameToValueListMap.get (sNameLower);
if (aHeaderValueList == null)
{
aHeaderValueList = new CommonsArrayList <> ();
m_aHeaderNameToValueListMap.put (sNameLower, aHeaderValueList);
m_aHeaderNameList.add (sNameLower);
}
aHeaderValueList.add (sValue);
});
} | [
"public",
"void",
"addHeader",
"(",
"@",
"Nonnull",
"final",
"String",
"sName",
",",
"@",
"Nullable",
"final",
"String",
"sValue",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"sName",
",",
"\"HeaderName\"",
")",
";",
"final",
"String",
"sNameLower",
"=",... | Method to add header values to this instance.
@param sName
name of this header
@param sValue
value of this header | [
"Method",
"to",
"add",
"header",
"values",
"to",
"this",
"instance",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/FileItemHeaders.java#L123-L139 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java | CausticUtil.checkVersion | public static void checkVersion(GLVersioned required, GLVersioned object) {
if (!debug) {
return;
}
final GLVersion requiredVersion = required.getGLVersion();
final GLVersion objectVersion = object.getGLVersion();
if (objectVersion.getMajor() > requiredVersion.getMajor() && objectVersion.getMinor() > requiredVersion.getMinor()) {
throw new IllegalStateException("Versions not compatible: expected " + requiredVersion + " or lower, got " + objectVersion);
}
} | java | public static void checkVersion(GLVersioned required, GLVersioned object) {
if (!debug) {
return;
}
final GLVersion requiredVersion = required.getGLVersion();
final GLVersion objectVersion = object.getGLVersion();
if (objectVersion.getMajor() > requiredVersion.getMajor() && objectVersion.getMinor() > requiredVersion.getMinor()) {
throw new IllegalStateException("Versions not compatible: expected " + requiredVersion + " or lower, got " + objectVersion);
}
} | [
"public",
"static",
"void",
"checkVersion",
"(",
"GLVersioned",
"required",
",",
"GLVersioned",
"object",
")",
"{",
"if",
"(",
"!",
"debug",
")",
"{",
"return",
";",
"}",
"final",
"GLVersion",
"requiredVersion",
"=",
"required",
".",
"getGLVersion",
"(",
")"... | Checks if two OpenGL versioned object have compatible version. Throws an exception if that's not the case. A version is determined to be compatible with another is it's lower than the said
version. This isn't always true when deprecation is involved, but it's an acceptable way of doing this in most implementations.
@param required The required version
@param object The object to check the version of
@throws IllegalStateException If the object versions are not compatible | [
"Checks",
"if",
"two",
"OpenGL",
"versioned",
"object",
"have",
"compatible",
"version",
".",
"Throws",
"an",
"exception",
"if",
"that",
"s",
"not",
"the",
"case",
".",
"A",
"version",
"is",
"determined",
"to",
"be",
"compatible",
"with",
"another",
"is",
... | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L106-L115 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java | CausticUtil.getPackedPixels | public static int[] getPackedPixels(ByteBuffer imageData, Format format, Rectangle size) {
final int[] pixels = new int[size.getArea()];
final int width = size.getWidth();
final int height = size.getHeight();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
final int srcIndex = (x + y * width) * format.getComponentCount();
final int destIndex = x + (height - y - 1) * width;
if (format.hasRed()) {
pixels[destIndex] |= (imageData.get(srcIndex) & 0xff) << 16;
}
if (format.hasGreen()) {
pixels[destIndex] |= (imageData.get(srcIndex + 1) & 0xff) << 8;
}
if (format.hasBlue()) {
pixels[destIndex] |= imageData.get(srcIndex + 2) & 0xff;
}
if (format.hasAlpha()) {
pixels[destIndex] |= (imageData.get(srcIndex + 3) & 0xff) << 24;
} else {
pixels[destIndex] |= 0xff000000;
}
}
}
return pixels;
} | java | public static int[] getPackedPixels(ByteBuffer imageData, Format format, Rectangle size) {
final int[] pixels = new int[size.getArea()];
final int width = size.getWidth();
final int height = size.getHeight();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
final int srcIndex = (x + y * width) * format.getComponentCount();
final int destIndex = x + (height - y - 1) * width;
if (format.hasRed()) {
pixels[destIndex] |= (imageData.get(srcIndex) & 0xff) << 16;
}
if (format.hasGreen()) {
pixels[destIndex] |= (imageData.get(srcIndex + 1) & 0xff) << 8;
}
if (format.hasBlue()) {
pixels[destIndex] |= imageData.get(srcIndex + 2) & 0xff;
}
if (format.hasAlpha()) {
pixels[destIndex] |= (imageData.get(srcIndex + 3) & 0xff) << 24;
} else {
pixels[destIndex] |= 0xff000000;
}
}
}
return pixels;
} | [
"public",
"static",
"int",
"[",
"]",
"getPackedPixels",
"(",
"ByteBuffer",
"imageData",
",",
"Format",
"format",
",",
"Rectangle",
"size",
")",
"{",
"final",
"int",
"[",
"]",
"pixels",
"=",
"new",
"int",
"[",
"size",
".",
"getArea",
"(",
")",
"]",
";",... | Converts a byte buffer of image data to a flat integer array integer where each pixel is and integer in the ARGB format. Input data is expected to be 8 bits per component. If the format has no
alpha, 0xFF is written as the value.
@param imageData The source image data
@param format The format of the image data, 8 bits per component
@param size The size of the image
@return The packed pixel array | [
"Converts",
"a",
"byte",
"buffer",
"of",
"image",
"data",
"to",
"a",
"flat",
"integer",
"array",
"integer",
"where",
"each",
"pixel",
"is",
"and",
"integer",
"in",
"the",
"ARGB",
"format",
".",
"Input",
"data",
"is",
"expected",
"to",
"be",
"8",
"bits",
... | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L198-L223 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java | CausticUtil.getImage | public static BufferedImage getImage(ByteBuffer imageData, Format format, Rectangle size) {
final int width = size.getWidth();
final int height = size.getHeight();
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
final int srcIndex = (x + y * width) * format.getComponentCount();
final int destIndex = x + (height - y - 1) * width;
if (format.hasRed()) {
pixels[destIndex] |= (imageData.get(srcIndex) & 0xff) << 16;
}
if (format.hasGreen()) {
pixels[destIndex] |= (imageData.get(srcIndex + 1) & 0xff) << 8;
}
if (format.hasBlue()) {
pixels[destIndex] |= imageData.get(srcIndex + 2) & 0xff;
}
if (format.hasAlpha()) {
pixels[destIndex] |= (imageData.get(srcIndex + 3) & 0xff) << 24;
} else {
pixels[destIndex] |= 0xff000000;
}
}
}
return image;
} | java | public static BufferedImage getImage(ByteBuffer imageData, Format format, Rectangle size) {
final int width = size.getWidth();
final int height = size.getHeight();
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
final int srcIndex = (x + y * width) * format.getComponentCount();
final int destIndex = x + (height - y - 1) * width;
if (format.hasRed()) {
pixels[destIndex] |= (imageData.get(srcIndex) & 0xff) << 16;
}
if (format.hasGreen()) {
pixels[destIndex] |= (imageData.get(srcIndex + 1) & 0xff) << 8;
}
if (format.hasBlue()) {
pixels[destIndex] |= imageData.get(srcIndex + 2) & 0xff;
}
if (format.hasAlpha()) {
pixels[destIndex] |= (imageData.get(srcIndex + 3) & 0xff) << 24;
} else {
pixels[destIndex] |= 0xff000000;
}
}
}
return image;
} | [
"public",
"static",
"BufferedImage",
"getImage",
"(",
"ByteBuffer",
"imageData",
",",
"Format",
"format",
",",
"Rectangle",
"size",
")",
"{",
"final",
"int",
"width",
"=",
"size",
".",
"getWidth",
"(",
")",
";",
"final",
"int",
"height",
"=",
"size",
".",
... | Converts a byte buffer of image data to a buffered image in the ARGB format. Input data is expected to be 8 bits per component. If the format has no alpha, 0xFF is written as the value.
@param imageData The source image data
@param format The format of the image data, 8 bits per component
@param size The size of the image
@return The buffered image | [
"Converts",
"a",
"byte",
"buffer",
"of",
"image",
"data",
"to",
"a",
"buffered",
"image",
"in",
"the",
"ARGB",
"format",
".",
"Input",
"data",
"is",
"expected",
"to",
"be",
"8",
"bits",
"per",
"component",
".",
"If",
"the",
"format",
"has",
"no",
"alph... | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L233-L259 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java | CausticUtil.fromIntRGBA | public static Vector4f fromIntRGBA(int r, int g, int b, int a) {
return new Vector4f((r & 0xff) / 255f, (g & 0xff) / 255f, (b & 0xff) / 255f, (a & 0xff) / 255f);
} | java | public static Vector4f fromIntRGBA(int r, int g, int b, int a) {
return new Vector4f((r & 0xff) / 255f, (g & 0xff) / 255f, (b & 0xff) / 255f, (a & 0xff) / 255f);
} | [
"public",
"static",
"Vector4f",
"fromIntRGBA",
"(",
"int",
"r",
",",
"int",
"g",
",",
"int",
"b",
",",
"int",
"a",
")",
"{",
"return",
"new",
"Vector4f",
"(",
"(",
"r",
"&",
"0xff",
")",
"/",
"255f",
",",
"(",
"g",
"&",
"0xff",
")",
"/",
"255f"... | Converts 4 byte color components to a normalized float color.
@param r The red component
@param b The blue component
@param g The green component
@param a The alpha component
@return The color as a 4 float vector | [
"Converts",
"4",
"byte",
"color",
"components",
"to",
"a",
"normalized",
"float",
"color",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L280-L282 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java | CausticUtil.createByteBuffer | public static ByteBuffer createByteBuffer(int capacity) {
return ByteBuffer.allocateDirect(capacity * DataType.BYTE.getByteSize()).order(ByteOrder.nativeOrder());
} | java | public static ByteBuffer createByteBuffer(int capacity) {
return ByteBuffer.allocateDirect(capacity * DataType.BYTE.getByteSize()).order(ByteOrder.nativeOrder());
} | [
"public",
"static",
"ByteBuffer",
"createByteBuffer",
"(",
"int",
"capacity",
")",
"{",
"return",
"ByteBuffer",
".",
"allocateDirect",
"(",
"capacity",
"*",
"DataType",
".",
"BYTE",
".",
"getByteSize",
"(",
")",
")",
".",
"order",
"(",
"ByteOrder",
".",
"nat... | Creates a byte buffer of the desired capacity.
@param capacity The capacity
@return The byte buffer | [
"Creates",
"a",
"byte",
"buffer",
"of",
"the",
"desired",
"capacity",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/CausticUtil.java#L367-L369 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/common/GenomicsDataSourceBase.java | GenomicsDataSourceBase.getUnmappedMatesOfMappedReads | protected UnmappedReads<Read> getUnmappedMatesOfMappedReads(String readsetId)
throws GeneralSecurityException, IOException {
LOG.info("Collecting unmapped mates of mapped reads for injection");
final Iterable<Read> unmappedReadsIterable = getUnmappedReadsIterator(readsetId);
final UnmappedReads<Read> unmappedReads = createUnmappedReads();
for (Read read : unmappedReadsIterable) {
unmappedReads.maybeAddRead(read);
}
LOG.info("Finished collecting unmapped mates of mapped reads: " +
unmappedReads.getReadCount() + " found.");
return unmappedReads;
} | java | protected UnmappedReads<Read> getUnmappedMatesOfMappedReads(String readsetId)
throws GeneralSecurityException, IOException {
LOG.info("Collecting unmapped mates of mapped reads for injection");
final Iterable<Read> unmappedReadsIterable = getUnmappedReadsIterator(readsetId);
final UnmappedReads<Read> unmappedReads = createUnmappedReads();
for (Read read : unmappedReadsIterable) {
unmappedReads.maybeAddRead(read);
}
LOG.info("Finished collecting unmapped mates of mapped reads: " +
unmappedReads.getReadCount() + " found.");
return unmappedReads;
} | [
"protected",
"UnmappedReads",
"<",
"Read",
">",
"getUnmappedMatesOfMappedReads",
"(",
"String",
"readsetId",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"LOG",
".",
"info",
"(",
"\"Collecting unmapped mates of mapped reads for injection\"",
")",
";",... | Gets unmapped mates so we can inject them besides their mapped pairs.
@throws GeneralSecurityException
@throws IOException | [
"Gets",
"unmapped",
"mates",
"so",
"we",
"can",
"inject",
"them",
"besides",
"their",
"mapped",
"pairs",
"."
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/common/GenomicsDataSourceBase.java#L135-L146 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/Rectangle.java | Rectangle.set | public void set(Rectangle rectangle) {
set(rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight());
} | java | public void set(Rectangle rectangle) {
set(rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight());
} | [
"public",
"void",
"set",
"(",
"Rectangle",
"rectangle",
")",
"{",
"set",
"(",
"rectangle",
".",
"getX",
"(",
")",
",",
"rectangle",
".",
"getY",
"(",
")",
",",
"rectangle",
".",
"getWidth",
"(",
")",
",",
"rectangle",
".",
"getHeight",
"(",
")",
")",... | Sets the rectangle to be an exact copy of the provided one.
@param rectangle The rectangle to copy | [
"Sets",
"the",
"rectangle",
"to",
"be",
"an",
"exact",
"copy",
"of",
"the",
"provided",
"one",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/Rectangle.java#L244-L246 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/scope/mgr/WebScopeSessionManager.java | WebScopeSessionManager.getSessionWebScopeOfSession | @Nullable
public static ISessionWebScope getSessionWebScopeOfSession (@Nullable final HttpSession aHttpSession)
{
return aHttpSession == null ? null : getSessionWebScopeOfID (aHttpSession.getId ());
} | java | @Nullable
public static ISessionWebScope getSessionWebScopeOfSession (@Nullable final HttpSession aHttpSession)
{
return aHttpSession == null ? null : getSessionWebScopeOfID (aHttpSession.getId ());
} | [
"@",
"Nullable",
"public",
"static",
"ISessionWebScope",
"getSessionWebScopeOfSession",
"(",
"@",
"Nullable",
"final",
"HttpSession",
"aHttpSession",
")",
"{",
"return",
"aHttpSession",
"==",
"null",
"?",
"null",
":",
"getSessionWebScopeOfID",
"(",
"aHttpSession",
"."... | Get the session web scope of the passed HTTP session.
@param aHttpSession
The HTTP session to get the scope from. May be <code>null</code>.
@return <code>null</code> if either the HTTP session is <code>null</code>
or if no such scope exists. | [
"Get",
"the",
"session",
"web",
"scope",
"of",
"the",
"passed",
"HTTP",
"session",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/scope/mgr/WebScopeSessionManager.java#L85-L89 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/scope/mgr/WebScopeSessionManager.java | WebScopeSessionManager.destroyAllWebSessions | public static void destroyAllWebSessions ()
{
// destroy all session web scopes (make a copy, because we're invalidating
// the sessions!)
for (final ISessionWebScope aSessionScope : getAllSessionWebScopes ())
{
// Unfortunately we need a special handling here
if (aSessionScope.selfDestruct ().isContinue ())
{
// Remove from map
ScopeSessionManager.getInstance ().onScopeEnd (aSessionScope);
}
// Else the destruction was already started!
}
} | java | public static void destroyAllWebSessions ()
{
// destroy all session web scopes (make a copy, because we're invalidating
// the sessions!)
for (final ISessionWebScope aSessionScope : getAllSessionWebScopes ())
{
// Unfortunately we need a special handling here
if (aSessionScope.selfDestruct ().isContinue ())
{
// Remove from map
ScopeSessionManager.getInstance ().onScopeEnd (aSessionScope);
}
// Else the destruction was already started!
}
} | [
"public",
"static",
"void",
"destroyAllWebSessions",
"(",
")",
"{",
"// destroy all session web scopes (make a copy, because we're invalidating",
"// the sessions!)",
"for",
"(",
"final",
"ISessionWebScope",
"aSessionScope",
":",
"getAllSessionWebScopes",
"(",
")",
")",
"{",
... | Destroy all available web scopes. | [
"Destroy",
"all",
"available",
"web",
"scopes",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/scope/mgr/WebScopeSessionManager.java#L105-L119 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java | DiskFileItem.writeObject | private void writeObject (final ObjectOutputStream aOS) throws IOException
{
// Read the data
if (m_aDFOS.isInMemory ())
{
_ensureCachedContentIsPresent ();
}
else
{
m_aCachedContent = null;
m_aDFOSFile = m_aDFOS.getFile ();
}
// write out values
aOS.defaultWriteObject ();
} | java | private void writeObject (final ObjectOutputStream aOS) throws IOException
{
// Read the data
if (m_aDFOS.isInMemory ())
{
_ensureCachedContentIsPresent ();
}
else
{
m_aCachedContent = null;
m_aDFOSFile = m_aDFOS.getFile ();
}
// write out values
aOS.defaultWriteObject ();
} | [
"private",
"void",
"writeObject",
"(",
"final",
"ObjectOutputStream",
"aOS",
")",
"throws",
"IOException",
"{",
"// Read the data",
"if",
"(",
"m_aDFOS",
".",
"isInMemory",
"(",
")",
")",
"{",
"_ensureCachedContentIsPresent",
"(",
")",
";",
"}",
"else",
"{",
"... | Writes the state of this object during serialization.
@param aOS
The stream to which the state should be written.
@throws IOException
if an error occurs. | [
"Writes",
"the",
"state",
"of",
"this",
"object",
"during",
"serialization",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java#L236-L251 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java | DiskFileItem.getSize | @Nonnegative
public long getSize ()
{
if (m_nSize >= 0)
return m_nSize;
if (m_aCachedContent != null)
return m_aCachedContent.length;
if (m_aDFOS.isInMemory ())
return m_aDFOS.getDataLength ();
return m_aDFOS.getFile ().length ();
} | java | @Nonnegative
public long getSize ()
{
if (m_nSize >= 0)
return m_nSize;
if (m_aCachedContent != null)
return m_aCachedContent.length;
if (m_aDFOS.isInMemory ())
return m_aDFOS.getDataLength ();
return m_aDFOS.getFile ().length ();
} | [
"@",
"Nonnegative",
"public",
"long",
"getSize",
"(",
")",
"{",
"if",
"(",
"m_nSize",
">=",
"0",
")",
"return",
"m_nSize",
";",
"if",
"(",
"m_aCachedContent",
"!=",
"null",
")",
"return",
"m_aCachedContent",
".",
"length",
";",
"if",
"(",
"m_aDFOS",
".",... | Returns the size of the file.
@return The size of the file, in bytes. | [
"Returns",
"the",
"size",
"of",
"the",
"file",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java#L405-L415 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java | DiskFileItem.directGet | @ReturnsMutableObject ("Speed")
@SuppressFBWarnings ("EI_EXPOSE_REP")
@Nullable
public byte [] directGet ()
{
if (isInMemory ())
{
_ensureCachedContentIsPresent ();
return m_aCachedContent;
}
return SimpleFileIO.getAllFileBytes (m_aDFOS.getFile ());
} | java | @ReturnsMutableObject ("Speed")
@SuppressFBWarnings ("EI_EXPOSE_REP")
@Nullable
public byte [] directGet ()
{
if (isInMemory ())
{
_ensureCachedContentIsPresent ();
return m_aCachedContent;
}
return SimpleFileIO.getAllFileBytes (m_aDFOS.getFile ());
} | [
"@",
"ReturnsMutableObject",
"(",
"\"Speed\"",
")",
"@",
"SuppressFBWarnings",
"(",
"\"EI_EXPOSE_REP\"",
")",
"@",
"Nullable",
"public",
"byte",
"[",
"]",
"directGet",
"(",
")",
"{",
"if",
"(",
"isInMemory",
"(",
")",
")",
"{",
"_ensureCachedContentIsPresent",
... | Returns the contents of the file as an array of bytes. If the contents of
the file were not yet cached in memory, they will be loaded from the disk
storage and cached.
@return The contents of the file as an array of bytes. | [
"Returns",
"the",
"contents",
"of",
"the",
"file",
"as",
"an",
"array",
"of",
"bytes",
".",
"If",
"the",
"contents",
"of",
"the",
"file",
"were",
"not",
"yet",
"cached",
"in",
"memory",
"they",
"will",
"be",
"loaded",
"from",
"the",
"disk",
"storage",
... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java#L424-L436 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java | DiskFileItem.getStringWithFallback | @Nonnull
public String getStringWithFallback (@Nonnull final Charset aFallbackCharset)
{
final String sCharset = getCharSet ();
final Charset aCharset = CharsetHelper.getCharsetFromNameOrDefault (sCharset, aFallbackCharset);
return getString (aCharset);
} | java | @Nonnull
public String getStringWithFallback (@Nonnull final Charset aFallbackCharset)
{
final String sCharset = getCharSet ();
final Charset aCharset = CharsetHelper.getCharsetFromNameOrDefault (sCharset, aFallbackCharset);
return getString (aCharset);
} | [
"@",
"Nonnull",
"public",
"String",
"getStringWithFallback",
"(",
"@",
"Nonnull",
"final",
"Charset",
"aFallbackCharset",
")",
"{",
"final",
"String",
"sCharset",
"=",
"getCharSet",
"(",
")",
";",
"final",
"Charset",
"aCharset",
"=",
"CharsetHelper",
".",
"getCh... | Get the string with the charset defined in the content type.
@param aFallbackCharset
The fallback charset to be used if the content type does not include
a charset. May not be <code>null</code>.
@return The string representation of the item. | [
"Get",
"the",
"string",
"with",
"the",
"charset",
"defined",
"in",
"the",
"content",
"type",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/DiskFileItem.java#L465-L471 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java | GA4GHPicardRunner.run | public void run(String[] args) {
LOG.info("Starting GA4GHPicardRunner");
try {
parseCmdLine(args);
buildPicardCommand();
startProcess();
pumpInputData();
waitForProcessEnd();
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
} | java | public void run(String[] args) {
LOG.info("Starting GA4GHPicardRunner");
try {
parseCmdLine(args);
buildPicardCommand();
startProcess();
pumpInputData();
waitForProcessEnd();
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
} | [
"public",
"void",
"run",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Starting GA4GHPicardRunner\"",
")",
";",
"try",
"{",
"parseCmdLine",
"(",
"args",
")",
";",
"buildPicardCommand",
"(",
")",
";",
"startProcess",
"(",
")",
";"... | Sets up required streams and pipes and then spawns the Picard tool | [
"Sets",
"up",
"required",
"streams",
"and",
"pipes",
"and",
"then",
"spawns",
"the",
"Picard",
"tool"
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java#L151-L163 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java | GA4GHPicardRunner.parseCmdLine | void parseCmdLine(String[] args) {
JCommander parser = new JCommander(this, args);
parser.setProgramName("GA4GHPicardRunner");
LOG.info("Cmd line parsed");
} | java | void parseCmdLine(String[] args) {
JCommander parser = new JCommander(this, args);
parser.setProgramName("GA4GHPicardRunner");
LOG.info("Cmd line parsed");
} | [
"void",
"parseCmdLine",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"JCommander",
"parser",
"=",
"new",
"JCommander",
"(",
"this",
",",
"args",
")",
";",
"parser",
".",
"setProgramName",
"(",
"\"GA4GHPicardRunner\"",
")",
";",
"LOG",
".",
"info",
"(",
"\"... | Parses cmd line with JCommander | [
"Parses",
"cmd",
"line",
"with",
"JCommander"
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java#L166-L170 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java | GA4GHPicardRunner.buildPicardCommand | private void buildPicardCommand()
throws IOException, GeneralSecurityException, URISyntaxException {
File picardJarPath = new File(picardPath, "picard.jar");
if (!picardJarPath.exists()) {
throw new IOException("Picard tool not found at " +
picardJarPath.getAbsolutePath());
}
command.add("java");
command.add(picardJVMArgs);
command.add("-jar");
command.add(picardJarPath.getAbsolutePath());
command.add(picardTool);
for (String picardArg : picardArgs) {
if (picardArg.startsWith(INPUT_PREFIX)) {
String inputPath = picardArg.substring(INPUT_PREFIX.length());
inputs.add(processInput(inputPath));
} else {
command.add(picardArg);
}
}
for (Input input : inputs) {
command.add("INPUT=" + input.pipeName);
}
} | java | private void buildPicardCommand()
throws IOException, GeneralSecurityException, URISyntaxException {
File picardJarPath = new File(picardPath, "picard.jar");
if (!picardJarPath.exists()) {
throw new IOException("Picard tool not found at " +
picardJarPath.getAbsolutePath());
}
command.add("java");
command.add(picardJVMArgs);
command.add("-jar");
command.add(picardJarPath.getAbsolutePath());
command.add(picardTool);
for (String picardArg : picardArgs) {
if (picardArg.startsWith(INPUT_PREFIX)) {
String inputPath = picardArg.substring(INPUT_PREFIX.length());
inputs.add(processInput(inputPath));
} else {
command.add(picardArg);
}
}
for (Input input : inputs) {
command.add("INPUT=" + input.pipeName);
}
} | [
"private",
"void",
"buildPicardCommand",
"(",
")",
"throws",
"IOException",
",",
"GeneralSecurityException",
",",
"URISyntaxException",
"{",
"File",
"picardJarPath",
"=",
"new",
"File",
"(",
"picardPath",
",",
"\"picard.jar\"",
")",
";",
"if",
"(",
"!",
"picardJar... | Adds relevant parts to the cmd line for Picard tool, finds and extracts
"INPUT=" arguments and processes them by creating appropriate data pumps. | [
"Adds",
"relevant",
"parts",
"to",
"the",
"cmd",
"line",
"for",
"Picard",
"tool",
"finds",
"and",
"extracts",
"INPUT",
"=",
"arguments",
"and",
"processes",
"them",
"by",
"creating",
"appropriate",
"data",
"pumps",
"."
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java#L176-L201 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java | GA4GHPicardRunner.processGA4GHInput | private Input processGA4GHInput(String input) throws IOException, GeneralSecurityException, URISyntaxException {
GA4GHUrl url = new GA4GHUrl(input);
SAMFilePump pump;
if (usingGrpc) {
factoryGrpc.configure(url.getRootUrl(),
new Settings(clientSecretsFilename, apiKey, noLocalServer));
pump = new ReadIteratorToSAMFilePump<
com.google.genomics.v1.Read,
com.google.genomics.v1.ReadGroupSet,
com.google.genomics.v1.Reference>(
factoryGrpc
.get(url.getRootUrl())
.getReads(url));
} else {
factoryRest.configure(url.getRootUrl(),
new Settings(clientSecretsFilename, apiKey, noLocalServer));
pump = new ReadIteratorToSAMFilePump<
com.google.api.services.genomics.model.Read,
com.google.api.services.genomics.model.ReadGroupSet,
com.google.api.services.genomics.model.Reference>(
factoryRest
.get(url.getRootUrl())
.getReads(url));
}
return new Input(input, STDIN_FILE_NAME, pump);
} | java | private Input processGA4GHInput(String input) throws IOException, GeneralSecurityException, URISyntaxException {
GA4GHUrl url = new GA4GHUrl(input);
SAMFilePump pump;
if (usingGrpc) {
factoryGrpc.configure(url.getRootUrl(),
new Settings(clientSecretsFilename, apiKey, noLocalServer));
pump = new ReadIteratorToSAMFilePump<
com.google.genomics.v1.Read,
com.google.genomics.v1.ReadGroupSet,
com.google.genomics.v1.Reference>(
factoryGrpc
.get(url.getRootUrl())
.getReads(url));
} else {
factoryRest.configure(url.getRootUrl(),
new Settings(clientSecretsFilename, apiKey, noLocalServer));
pump = new ReadIteratorToSAMFilePump<
com.google.api.services.genomics.model.Read,
com.google.api.services.genomics.model.ReadGroupSet,
com.google.api.services.genomics.model.Reference>(
factoryRest
.get(url.getRootUrl())
.getReads(url));
}
return new Input(input, STDIN_FILE_NAME, pump);
} | [
"private",
"Input",
"processGA4GHInput",
"(",
"String",
"input",
")",
"throws",
"IOException",
",",
"GeneralSecurityException",
",",
"URISyntaxException",
"{",
"GA4GHUrl",
"url",
"=",
"new",
"GA4GHUrl",
"(",
"input",
")",
";",
"SAMFilePump",
"pump",
";",
"if",
"... | Processes GA4GH based input, creates required API connections and data pump | [
"Processes",
"GA4GH",
"based",
"input",
"creates",
"required",
"API",
"connections",
"and",
"data",
"pump"
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java#L212-L237 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java | GA4GHPicardRunner.processRegularFileInput | private Input processRegularFileInput(String input) throws IOException {
File inputFile = new File(input);
if (!inputFile.exists()) {
throw new IOException("Input does not exist: " + input);
}
if (pipeFiles) {
SamReader samReader = SamReaderFactory.makeDefault().open(inputFile);
return new Input(input, STDIN_FILE_NAME,
new SamReaderToSAMFilePump(samReader));
} else {
return new Input(input, input, null);
}
} | java | private Input processRegularFileInput(String input) throws IOException {
File inputFile = new File(input);
if (!inputFile.exists()) {
throw new IOException("Input does not exist: " + input);
}
if (pipeFiles) {
SamReader samReader = SamReaderFactory.makeDefault().open(inputFile);
return new Input(input, STDIN_FILE_NAME,
new SamReaderToSAMFilePump(samReader));
} else {
return new Input(input, input, null);
}
} | [
"private",
"Input",
"processRegularFileInput",
"(",
"String",
"input",
")",
"throws",
"IOException",
"{",
"File",
"inputFile",
"=",
"new",
"File",
"(",
"input",
")",
";",
"if",
"(",
"!",
"inputFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"IO... | Processes regular, non GA4GH based file input | [
"Processes",
"regular",
"non",
"GA4GH",
"based",
"file",
"input"
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java#L240-L252 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java | GA4GHPicardRunner.startProcess | private void startProcess() throws IOException {
LOG.info("Building process");
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
LOG.info("Starting process");
process = processBuilder.start();
LOG.info("Process started");
} | java | private void startProcess() throws IOException {
LOG.info("Building process");
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
LOG.info("Starting process");
process = processBuilder.start();
LOG.info("Process started");
} | [
"private",
"void",
"startProcess",
"(",
")",
"throws",
"IOException",
"{",
"LOG",
".",
"info",
"(",
"\"Building process\"",
")",
";",
"ProcessBuilder",
"processBuilder",
"=",
"new",
"ProcessBuilder",
"(",
"command",
")",
";",
"processBuilder",
".",
"redirectError"... | Starts the Picard tool process based on constructed command.
@throws IOException | [
"Starts",
"the",
"Picard",
"tool",
"process",
"based",
"on",
"constructed",
"command",
"."
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java#L258-L267 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java | GA4GHPicardRunner.pumpInputData | private void pumpInputData() throws IOException {
for (Input input : inputs) {
if (input.pump == null) {
continue;
}
OutputStream os;
if (input.pipeName.equals(STDIN_FILE_NAME)) {
os = process.getOutputStream();
} else {
throw new IOException("Only stdin piping is supported so far.");
}
input.pump.pump(os);
}
} | java | private void pumpInputData() throws IOException {
for (Input input : inputs) {
if (input.pump == null) {
continue;
}
OutputStream os;
if (input.pipeName.equals(STDIN_FILE_NAME)) {
os = process.getOutputStream();
} else {
throw new IOException("Only stdin piping is supported so far.");
}
input.pump.pump(os);
}
} | [
"private",
"void",
"pumpInputData",
"(",
")",
"throws",
"IOException",
"{",
"for",
"(",
"Input",
"input",
":",
"inputs",
")",
"{",
"if",
"(",
"input",
".",
"pump",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"OutputStream",
"os",
";",
"if",
"(",
"i... | Loops through inputs and for each, pumps the data into the proper pipe
stream connected to the executing process.
@throws IOException | [
"Loops",
"through",
"inputs",
"and",
"for",
"each",
"pumps",
"the",
"data",
"into",
"the",
"proper",
"pipe",
"stream",
"connected",
"to",
"the",
"executing",
"process",
"."
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/picard/runner/GA4GHPicardRunner.java#L274-L287 | train |
phax/ph-oton | ph-oton-bootstrap3-pages/src/main/java/com/helger/photon/bootstrap3/pages/sysinfo/NetworkInterfaceHelper.java | NetworkInterfaceHelper.createNetworkInterfaceTree | @Nonnull
public static DefaultTreeWithGlobalUniqueID <String, NetworkInterface> createNetworkInterfaceTree ()
{
final DefaultTreeWithGlobalUniqueID <String, NetworkInterface> ret = new DefaultTreeWithGlobalUniqueID <> ();
// Build basic level - all IFs without a parent
final ICommonsList <NetworkInterface> aNonRootNIs = new CommonsArrayList <> ();
try
{
for (final NetworkInterface aNI : IteratorHelper.getIterator (NetworkInterface.getNetworkInterfaces ()))
if (aNI.getParent () == null)
ret.getRootItem ().createChildItem (aNI.getName (), aNI);
else
aNonRootNIs.add (aNI);
}
catch (final Throwable t)
{
throw new IllegalStateException ("Failed to get all network interfaces", t);
}
int nNotFound = 0;
while (aNonRootNIs.isNotEmpty ())
{
final NetworkInterface aNI = aNonRootNIs.removeFirst ();
final DefaultTreeItemWithID <String, NetworkInterface> aParentItem = ret.getItemWithID (aNI.getParent ()
.getName ());
if (aParentItem != null)
{
// We found the parent
aParentItem.createChildItem (aNI.getName (), aNI);
// Reset counter
nNotFound = 0;
}
else
{
// Add again at the end
aNonRootNIs.add (aNI);
// Parent not found
nNotFound++;
// We tried too many times without success - we iterated the whole
// remaining list and found no parent tree item
if (nNotFound > aNonRootNIs.size ())
throw new IllegalStateException ("Seems like we have a data structure inconsistency! Remaining are: " +
aNonRootNIs);
}
}
return ret;
} | java | @Nonnull
public static DefaultTreeWithGlobalUniqueID <String, NetworkInterface> createNetworkInterfaceTree ()
{
final DefaultTreeWithGlobalUniqueID <String, NetworkInterface> ret = new DefaultTreeWithGlobalUniqueID <> ();
// Build basic level - all IFs without a parent
final ICommonsList <NetworkInterface> aNonRootNIs = new CommonsArrayList <> ();
try
{
for (final NetworkInterface aNI : IteratorHelper.getIterator (NetworkInterface.getNetworkInterfaces ()))
if (aNI.getParent () == null)
ret.getRootItem ().createChildItem (aNI.getName (), aNI);
else
aNonRootNIs.add (aNI);
}
catch (final Throwable t)
{
throw new IllegalStateException ("Failed to get all network interfaces", t);
}
int nNotFound = 0;
while (aNonRootNIs.isNotEmpty ())
{
final NetworkInterface aNI = aNonRootNIs.removeFirst ();
final DefaultTreeItemWithID <String, NetworkInterface> aParentItem = ret.getItemWithID (aNI.getParent ()
.getName ());
if (aParentItem != null)
{
// We found the parent
aParentItem.createChildItem (aNI.getName (), aNI);
// Reset counter
nNotFound = 0;
}
else
{
// Add again at the end
aNonRootNIs.add (aNI);
// Parent not found
nNotFound++;
// We tried too many times without success - we iterated the whole
// remaining list and found no parent tree item
if (nNotFound > aNonRootNIs.size ())
throw new IllegalStateException ("Seems like we have a data structure inconsistency! Remaining are: " +
aNonRootNIs);
}
}
return ret;
} | [
"@",
"Nonnull",
"public",
"static",
"DefaultTreeWithGlobalUniqueID",
"<",
"String",
",",
"NetworkInterface",
">",
"createNetworkInterfaceTree",
"(",
")",
"{",
"final",
"DefaultTreeWithGlobalUniqueID",
"<",
"String",
",",
"NetworkInterface",
">",
"ret",
"=",
"new",
"De... | Create a hierarchical tree of the network interfaces.
@return The created tree and never <code>null</code>.
@throws IllegalStateException
In case an internal error occurred. | [
"Create",
"a",
"hierarchical",
"tree",
"of",
"the",
"network",
"interfaces",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-bootstrap3-pages/src/main/java/com/helger/photon/bootstrap3/pages/sysinfo/NetworkInterfaceHelper.java#L53-L103 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/junit/JUnit4Monitor.java | JUnit4Monitor.runnerForClass0 | public static Runner runnerForClass0(RunnerBuilder builder, Class<?> testClass) throws Throwable {
if (recursiveDepth > 1 ||
isOnStack(0, CoverageRunner.class.getCanonicalName())) {
return builder.runnerForClass(testClass);
}
AffectingBuilder affectingBuilder = new AffectingBuilder();
Runner runner = affectingBuilder.runnerForClass(testClass);
if (runner != null) {
return runner;
}
CoverageMonitor.clean();
Runner wrapped = builder.runnerForClass(testClass);
return new CoverageRunner(testClass, wrapped, CoverageMonitor.getURLs());
} | java | public static Runner runnerForClass0(RunnerBuilder builder, Class<?> testClass) throws Throwable {
if (recursiveDepth > 1 ||
isOnStack(0, CoverageRunner.class.getCanonicalName())) {
return builder.runnerForClass(testClass);
}
AffectingBuilder affectingBuilder = new AffectingBuilder();
Runner runner = affectingBuilder.runnerForClass(testClass);
if (runner != null) {
return runner;
}
CoverageMonitor.clean();
Runner wrapped = builder.runnerForClass(testClass);
return new CoverageRunner(testClass, wrapped, CoverageMonitor.getURLs());
} | [
"public",
"static",
"Runner",
"runnerForClass0",
"(",
"RunnerBuilder",
"builder",
",",
"Class",
"<",
"?",
">",
"testClass",
")",
"throws",
"Throwable",
"{",
"if",
"(",
"recursiveDepth",
">",
"1",
"||",
"isOnStack",
"(",
"0",
",",
"CoverageRunner",
".",
"clas... | JUnit4 support. | [
"JUnit4",
"support",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/junit/JUnit4Monitor.java#L50-L63 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/junit/JUnit4Monitor.java | JUnit4Monitor.isOnStack | private static boolean isOnStack(int moreThan, String canonicalName) {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
int count = 0;
for (StackTraceElement element : stackTrace) {
if (element.getClassName().startsWith(canonicalName)) {
count++;
}
}
return count > moreThan;
} | java | private static boolean isOnStack(int moreThan, String canonicalName) {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
int count = 0;
for (StackTraceElement element : stackTrace) {
if (element.getClassName().startsWith(canonicalName)) {
count++;
}
}
return count > moreThan;
} | [
"private",
"static",
"boolean",
"isOnStack",
"(",
"int",
"moreThan",
",",
"String",
"canonicalName",
")",
"{",
"StackTraceElement",
"[",
"]",
"stackTrace",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getStackTrace",
"(",
")",
";",
"int",
"count",
"=... | Checks if the given name is on stack more than the given number of times.
This method uses startsWith to check if the given name is on stack, so
one can pass a package name too.
Intentionally duplicate. | [
"Checks",
"if",
"the",
"given",
"name",
"is",
"on",
"stack",
"more",
"than",
"the",
"given",
"number",
"of",
"times",
".",
"This",
"method",
"uses",
"startsWith",
"to",
"check",
"if",
"the",
"given",
"name",
"is",
"on",
"stack",
"so",
"one",
"can",
"pa... | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/junit/JUnit4Monitor.java#L72-L81 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/mock/PhotonCoreValidator.java | PhotonCoreValidator.validateHTMLConfiguration | public static void validateHTMLConfiguration () throws IllegalStateException
{
// This will throw an IllegalStateException for wrong files in html/js.xml
// and html/css.xml
PhotonCSS.readCSSIncludesForGlobal (new ClassPathResource (PhotonCSS.DEFAULT_FILENAME));
PhotonJS.readJSIncludesForGlobal (new ClassPathResource (PhotonJS.DEFAULT_FILENAME));
} | java | public static void validateHTMLConfiguration () throws IllegalStateException
{
// This will throw an IllegalStateException for wrong files in html/js.xml
// and html/css.xml
PhotonCSS.readCSSIncludesForGlobal (new ClassPathResource (PhotonCSS.DEFAULT_FILENAME));
PhotonJS.readJSIncludesForGlobal (new ClassPathResource (PhotonJS.DEFAULT_FILENAME));
} | [
"public",
"static",
"void",
"validateHTMLConfiguration",
"(",
")",
"throws",
"IllegalStateException",
"{",
"// This will throw an IllegalStateException for wrong files in html/js.xml",
"// and html/css.xml",
"PhotonCSS",
".",
"readCSSIncludesForGlobal",
"(",
"new",
"ClassPathResource... | Check if the referenced JS and CSS files exist
@throws IllegalStateException
if not | [
"Check",
"if",
"the",
"referenced",
"JS",
"and",
"CSS",
"files",
"exist"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/mock/PhotonCoreValidator.java#L80-L86 | train |
phax/ph-oton | ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Form.java | FineUploader5Form.setElementID | @Nonnull
public FineUploader5Form setElementID (@Nonnull @Nonempty final String sElementID)
{
ValueEnforcer.notEmpty (sElementID, "ElementID");
m_sFormElementID = sElementID;
return this;
} | java | @Nonnull
public FineUploader5Form setElementID (@Nonnull @Nonempty final String sElementID)
{
ValueEnforcer.notEmpty (sElementID, "ElementID");
m_sFormElementID = sElementID;
return this;
} | [
"@",
"Nonnull",
"public",
"FineUploader5Form",
"setElementID",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sElementID",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sElementID",
",",
"\"ElementID\"",
")",
";",
"m_sFormElementID",
"=",
"sElementI... | This can be the ID of the <form> or a reference to the <form>
element.
@param sElementID
New value. May neither be <code>null</code> nor empty.
@return this for chaining | [
"This",
"can",
"be",
"the",
"ID",
"of",
"the",
"<",
";",
"form>",
";",
"or",
"a",
"reference",
"to",
"the",
"<",
";",
"form>",
";",
"element",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-uictrls/src/main/java/com/helger/photon/uictrls/fineupload5/FineUploader5Form.java#L59-L65 | train |
phax/ph-oton | ph-oton-audit/src/main/java/com/helger/photon/audit/AuditHelper.java | AuditHelper.setAuditor | public static void setAuditor (@Nonnull final IAuditor aAuditor)
{
ValueEnforcer.notNull (aAuditor, "Auditor");
s_aRWLock.writeLocked ( () -> s_aAuditor = aAuditor);
} | java | public static void setAuditor (@Nonnull final IAuditor aAuditor)
{
ValueEnforcer.notNull (aAuditor, "Auditor");
s_aRWLock.writeLocked ( () -> s_aAuditor = aAuditor);
} | [
"public",
"static",
"void",
"setAuditor",
"(",
"@",
"Nonnull",
"final",
"IAuditor",
"aAuditor",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aAuditor",
",",
"\"Auditor\"",
")",
";",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"s_aAuditor",
"=",... | Set the global auditor to use.
@param aAuditor
The auditor to be set. May not be <code>null</code>. | [
"Set",
"the",
"global",
"auditor",
"to",
"use",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-audit/src/main/java/com/helger/photon/audit/AuditHelper.java#L62-L67 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/dynamic/JarXtractor.java | JarXtractor.startsWith | private static boolean startsWith(String str, String... prefixes) {
for (String prefix : prefixes) {
if (str.startsWith(prefix)) return true;
}
return false;
} | java | private static boolean startsWith(String str, String... prefixes) {
for (String prefix : prefixes) {
if (str.startsWith(prefix)) return true;
}
return false;
} | [
"private",
"static",
"boolean",
"startsWith",
"(",
"String",
"str",
",",
"String",
"...",
"prefixes",
")",
"{",
"for",
"(",
"String",
"prefix",
":",
"prefixes",
")",
"{",
"if",
"(",
"str",
".",
"startsWith",
"(",
"prefix",
")",
")",
"return",
"true",
"... | Checks if the given string starts with any of the given prefixes.
@param str
String to check for prefix.
@param prefixes
Potential prefixes of the string.
@return True if the string starts with any of the prefixes. | [
"Checks",
"if",
"the",
"given",
"string",
"starts",
"with",
"any",
"of",
"the",
"given",
"prefixes",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/dynamic/JarXtractor.java#L99-L104 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/dynamic/JarXtractor.java | JarXtractor.extractClassNames | private static List<String> extractClassNames(String jarName) throws IOException {
List<String> classes = new LinkedList<String>();
ZipInputStream orig = new ZipInputStream(new FileInputStream(jarName));
for (ZipEntry entry = orig.getNextEntry(); entry != null; entry = orig.getNextEntry()) {
String fullName = entry.getName().replaceAll("/", ".").replace(".class", "");
classes.add(fullName);
}
orig.close();
return classes;
} | java | private static List<String> extractClassNames(String jarName) throws IOException {
List<String> classes = new LinkedList<String>();
ZipInputStream orig = new ZipInputStream(new FileInputStream(jarName));
for (ZipEntry entry = orig.getNextEntry(); entry != null; entry = orig.getNextEntry()) {
String fullName = entry.getName().replaceAll("/", ".").replace(".class", "");
classes.add(fullName);
}
orig.close();
return classes;
} | [
"private",
"static",
"List",
"<",
"String",
">",
"extractClassNames",
"(",
"String",
"jarName",
")",
"throws",
"IOException",
"{",
"List",
"<",
"String",
">",
"classes",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"ZipInputStream",
"orig",
... | Extract class names from the given jar. This method is for debugging
purpose.
@param jarName
path to jar file
@throws IOException
in case file is not found | [
"Extract",
"class",
"names",
"from",
"the",
"given",
"jar",
".",
"This",
"method",
"is",
"for",
"debugging",
"purpose",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/dynamic/JarXtractor.java#L115-L124 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/dynamic/JarXtractor.java | JarXtractor.main | public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.out.println("There should be an argument: path to a jar.");
System.exit(0);
}
String jarInput = args[0];
extract(new File(jarInput), new File("/tmp/junit-ekstazi-agent.jar"),
new String[] { Names.EKSTAZI_PACKAGE_BIN }, new String[] {});
for (String name : extractClassNames("/tmp/junit-ekstazi-agent.jar")) {
System.out.println(name);
}
} | java | public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.out.println("There should be an argument: path to a jar.");
System.exit(0);
}
String jarInput = args[0];
extract(new File(jarInput), new File("/tmp/junit-ekstazi-agent.jar"),
new String[] { Names.EKSTAZI_PACKAGE_BIN }, new String[] {});
for (String name : extractClassNames("/tmp/junit-ekstazi-agent.jar")) {
System.out.println(name);
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"1",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"There should be an argument: path to a jar.\"",
")",
... | Simple test to print all classes in the given jar. | [
"Simple",
"test",
"to",
"print",
"all",
"classes",
"in",
"the",
"given",
"jar",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/dynamic/JarXtractor.java#L131-L142 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/script/HCJSNodeDetector.java | HCJSNodeDetector.isJSNode | public static boolean isJSNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSNode (aUnwrappedNode);
} | java | public static boolean isJSNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSNode (aUnwrappedNode);
} | [
"public",
"static",
"boolean",
"isJSNode",
"(",
"@",
"Nullable",
"final",
"IHCNode",
"aNode",
")",
"{",
"final",
"IHCNode",
"aUnwrappedNode",
"=",
"HCHelper",
".",
"getUnwrappedNode",
"(",
"aNode",
")",
";",
"return",
"isDirectJSNode",
"(",
"aUnwrappedNode",
")"... | Check if the passed node is a JS node after unwrapping.
@param aNode
The node to be checked - may be <code>null</code>.
@return <code>true</code> if the node implements {@link IHCScript}. | [
"Check",
"if",
"the",
"passed",
"node",
"is",
"a",
"JS",
"node",
"after",
"unwrapping",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/script/HCJSNodeDetector.java#L48-L52 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/script/HCJSNodeDetector.java | HCJSNodeDetector.isJSInlineNode | public static boolean isJSInlineNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSInlineNode (aUnwrappedNode);
} | java | public static boolean isJSInlineNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSInlineNode (aUnwrappedNode);
} | [
"public",
"static",
"boolean",
"isJSInlineNode",
"(",
"@",
"Nullable",
"final",
"IHCNode",
"aNode",
")",
"{",
"final",
"IHCNode",
"aUnwrappedNode",
"=",
"HCHelper",
".",
"getUnwrappedNode",
"(",
"aNode",
")",
";",
"return",
"isDirectJSInlineNode",
"(",
"aUnwrapped... | Check if the passed node is an inline JS node after unwrapping.
@param aNode
The node to be checked - may be <code>null</code>.
@return <code>true</code> if the node implements {@link HCScriptInline}. | [
"Check",
"if",
"the",
"passed",
"node",
"is",
"an",
"inline",
"JS",
"node",
"after",
"unwrapping",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/script/HCJSNodeDetector.java#L74-L78 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/script/HCJSNodeDetector.java | HCJSNodeDetector.isJSFileNode | public static boolean isJSFileNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSFileNode (aUnwrappedNode);
} | java | public static boolean isJSFileNode (@Nullable final IHCNode aNode)
{
final IHCNode aUnwrappedNode = HCHelper.getUnwrappedNode (aNode);
return isDirectJSFileNode (aUnwrappedNode);
} | [
"public",
"static",
"boolean",
"isJSFileNode",
"(",
"@",
"Nullable",
"final",
"IHCNode",
"aNode",
")",
"{",
"final",
"IHCNode",
"aUnwrappedNode",
"=",
"HCHelper",
".",
"getUnwrappedNode",
"(",
"aNode",
")",
";",
"return",
"isDirectJSFileNode",
"(",
"aUnwrappedNode... | Check if the passed node is a file JS node after unwrapping.
@param aNode
The node to be checked - may be <code>null</code>.
@return <code>true</code> if the node implements {@link HCScriptFile}. | [
"Check",
"if",
"the",
"passed",
"node",
"is",
"a",
"file",
"JS",
"node",
"after",
"unwrapping",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/script/HCJSNodeDetector.java#L100-L104 | train |
phax/ph-oton | ph-oton-jscode/src/main/java/com/helger/html/jscode/JSAnonymousFunction.java | JSAnonymousFunction.param | @Nonnull
public JSVar param (@Nonnull @Nonempty final String sName)
{
final JSVar aVar = new JSVar (sName, null);
m_aParams.add (aVar);
return aVar;
} | java | @Nonnull
public JSVar param (@Nonnull @Nonempty final String sName)
{
final JSVar aVar = new JSVar (sName, null);
m_aParams.add (aVar);
return aVar;
} | [
"@",
"Nonnull",
"public",
"JSVar",
"param",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sName",
")",
"{",
"final",
"JSVar",
"aVar",
"=",
"new",
"JSVar",
"(",
"sName",
",",
"null",
")",
";",
"m_aParams",
".",
"add",
"(",
"aVar",
")",
";"... | Add the specified variable to the list of parameters for this function
signature.
@param sName
Name of the parameter being added
@return New parameter variable | [
"Add",
"the",
"specified",
"variable",
"to",
"the",
"list",
"of",
"parameters",
"for",
"this",
"function",
"signature",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-jscode/src/main/java/com/helger/html/jscode/JSAnonymousFunction.java#L122-L128 | train |
phax/ph-oton | ph-oton-jscode/src/main/java/com/helger/html/jscode/JSAnonymousFunction.java | JSAnonymousFunction.body | @Nonnull
public JSBlock body ()
{
if (m_aBody == null)
m_aBody = new JSBlock ().newlineAtEnd (false);
return m_aBody;
} | java | @Nonnull
public JSBlock body ()
{
if (m_aBody == null)
m_aBody = new JSBlock ().newlineAtEnd (false);
return m_aBody;
} | [
"@",
"Nonnull",
"public",
"JSBlock",
"body",
"(",
")",
"{",
"if",
"(",
"m_aBody",
"==",
"null",
")",
"m_aBody",
"=",
"new",
"JSBlock",
"(",
")",
".",
"newlineAtEnd",
"(",
"false",
")",
";",
"return",
"m_aBody",
";",
"}"
] | Get the block that makes up body of this function
@return Body of function | [
"Get",
"the",
"block",
"that",
"makes",
"up",
"body",
"of",
"this",
"function"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-jscode/src/main/java/com/helger/html/jscode/JSAnonymousFunction.java#L161-L167 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/tabular/HCCol.java | HCCol.perc | @Nonnull
public static HCCol perc (@Nonnegative final int nPerc)
{
return new HCCol ().setWidth (ECSSUnit.perc (nPerc));
} | java | @Nonnull
public static HCCol perc (@Nonnegative final int nPerc)
{
return new HCCol ().setWidth (ECSSUnit.perc (nPerc));
} | [
"@",
"Nonnull",
"public",
"static",
"HCCol",
"perc",
"(",
"@",
"Nonnegative",
"final",
"int",
"nPerc",
")",
"{",
"return",
"new",
"HCCol",
"(",
")",
".",
"setWidth",
"(",
"ECSSUnit",
".",
"perc",
"(",
"nPerc",
")",
")",
";",
"}"
] | Create a new column with a certain percentage.
@param nPerc
The percentage to be used. Should ideally be between 0 and 100.
@return Never <code>null</code>. | [
"Create",
"a",
"new",
"column",
"with",
"a",
"certain",
"percentage",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/tabular/HCCol.java#L60-L64 | train |
NICTA/t3as-snomedct-service | snomedct-lookup/src/main/java/org/t3as/snomedct/lookup/SnomedLookup.java | SnomedLookup.enrichXml | public int enrichXml(final MMOs root) throws SQLException {
int count = 0;
// TODO: take out the print statements
for (final MMO mmo : root.getMMO()) {
for (final Utterance utterance : mmo.getUtterances().getUtterance()) {
for (final Phrase phrase : utterance.getPhrases().getPhrase()) {
System.out.printf("Phrase: %s\n", phrase.getPhraseText());
for (final Mapping mapping : phrase.getMappings().getMapping()) {
System.out.printf("Score: %s\n", mapping.getMappingScore());
for (final Candidate candidate : mapping.getMappingCandidates().getCandidate()) {
final Collection<String> semTypes = new ArrayList<>();
for (final SemType st : candidate.getSemTypes().getSemType()) {
semTypes.add(st.getvalue());
}
// the actual line of work
count += addSnomedId(candidate) ? 1 : 0;
System.out.printf(" %-5s %-9s %s %s %s %s\n",
candidate.getCandidateScore(),
candidate.getCandidateCUI(),
candidate.getSnomedId(),
candidate.getCandidatePreferred(),
semTypes,
candidate.getSources().getSource());
}
}
System.out.println();
}
}
}
return count;
} | java | public int enrichXml(final MMOs root) throws SQLException {
int count = 0;
// TODO: take out the print statements
for (final MMO mmo : root.getMMO()) {
for (final Utterance utterance : mmo.getUtterances().getUtterance()) {
for (final Phrase phrase : utterance.getPhrases().getPhrase()) {
System.out.printf("Phrase: %s\n", phrase.getPhraseText());
for (final Mapping mapping : phrase.getMappings().getMapping()) {
System.out.printf("Score: %s\n", mapping.getMappingScore());
for (final Candidate candidate : mapping.getMappingCandidates().getCandidate()) {
final Collection<String> semTypes = new ArrayList<>();
for (final SemType st : candidate.getSemTypes().getSemType()) {
semTypes.add(st.getvalue());
}
// the actual line of work
count += addSnomedId(candidate) ? 1 : 0;
System.out.printf(" %-5s %-9s %s %s %s %s\n",
candidate.getCandidateScore(),
candidate.getCandidateCUI(),
candidate.getSnomedId(),
candidate.getCandidatePreferred(),
semTypes,
candidate.getSources().getSource());
}
}
System.out.println();
}
}
}
return count;
} | [
"public",
"int",
"enrichXml",
"(",
"final",
"MMOs",
"root",
")",
"throws",
"SQLException",
"{",
"int",
"count",
"=",
"0",
";",
"// TODO: take out the print statements",
"for",
"(",
"final",
"MMO",
"mmo",
":",
"root",
".",
"getMMO",
"(",
")",
")",
"{",
"for... | Tries to look up each Mapping Candidate in the SNOMED CT db to add more data.
@return the number of Candidates that were enriched | [
"Tries",
"to",
"look",
"up",
"each",
"Mapping",
"Candidate",
"in",
"the",
"SNOMED",
"CT",
"db",
"to",
"add",
"more",
"data",
"."
] | 70a82d5c889f97eef2d17a648970575c152983e9 | https://github.com/NICTA/t3as-snomedct-service/blob/70a82d5c889f97eef2d17a648970575c152983e9/snomedct-lookup/src/main/java/org/t3as/snomedct/lookup/SnomedLookup.java#L81-L113 | train |
NICTA/t3as-snomedct-service | snomedct-lookup/src/main/java/org/t3as/snomedct/lookup/SnomedLookup.java | SnomedLookup.addSnomedId | public boolean addSnomedId(final Candidate candidate) throws SQLException {
final SnomedTerm result = findFromCuiAndDesc(candidate.getCandidateCUI(), candidate.getCandidatePreferred());
if (result != null) {
candidate.setSnomedId(result.snomedId);
candidate.setTermType(result.termType);
return true;
}
else {
// TODO: log this somewhere?
System.err.printf("WARNING! Could not find the SNOMED CT concept id for UMLS CUI: %s: '%s'\n",
candidate.getCandidateCUI(), candidate.getCandidatePreferred());
return false;
}
} | java | public boolean addSnomedId(final Candidate candidate) throws SQLException {
final SnomedTerm result = findFromCuiAndDesc(candidate.getCandidateCUI(), candidate.getCandidatePreferred());
if (result != null) {
candidate.setSnomedId(result.snomedId);
candidate.setTermType(result.termType);
return true;
}
else {
// TODO: log this somewhere?
System.err.printf("WARNING! Could not find the SNOMED CT concept id for UMLS CUI: %s: '%s'\n",
candidate.getCandidateCUI(), candidate.getCandidatePreferred());
return false;
}
} | [
"public",
"boolean",
"addSnomedId",
"(",
"final",
"Candidate",
"candidate",
")",
"throws",
"SQLException",
"{",
"final",
"SnomedTerm",
"result",
"=",
"findFromCuiAndDesc",
"(",
"candidate",
".",
"getCandidateCUI",
"(",
")",
",",
"candidate",
".",
"getCandidatePrefer... | Tries to find this candidate in the SNOMED CT database, and if found adds the SNOMED id and term type to the
instance. | [
"Tries",
"to",
"find",
"this",
"candidate",
"in",
"the",
"SNOMED",
"CT",
"database",
"and",
"if",
"found",
"adds",
"the",
"SNOMED",
"id",
"and",
"term",
"type",
"to",
"the",
"instance",
"."
] | 70a82d5c889f97eef2d17a648970575c152983e9 | https://github.com/NICTA/t3as-snomedct-service/blob/70a82d5c889f97eef2d17a648970575c152983e9/snomedct-lookup/src/main/java/org/t3as/snomedct/lookup/SnomedLookup.java#L119-L132 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/parser/XHTMLParser.java | XHTMLParser.looksLikeXHTML | public static boolean looksLikeXHTML (@Nullable final String sText)
{
// If the text contains an open angle bracket followed by a character that
// we think of it as HTML
// (?s) enables the "dotall" mode - see Pattern.DOTALL
return StringHelper.hasText (sText) && RegExHelper.stringMatchesPattern ("(?s).*<[a-zA-Z].+", sText);
} | java | public static boolean looksLikeXHTML (@Nullable final String sText)
{
// If the text contains an open angle bracket followed by a character that
// we think of it as HTML
// (?s) enables the "dotall" mode - see Pattern.DOTALL
return StringHelper.hasText (sText) && RegExHelper.stringMatchesPattern ("(?s).*<[a-zA-Z].+", sText);
} | [
"public",
"static",
"boolean",
"looksLikeXHTML",
"(",
"@",
"Nullable",
"final",
"String",
"sText",
")",
"{",
"// If the text contains an open angle bracket followed by a character that",
"// we think of it as HTML",
"// (?s) enables the \"dotall\" mode - see Pattern.DOTALL",
"return",
... | Check whether the passed text looks like it contains XHTML code. This is a
heuristic check only and does not perform actual parsing!
@param sText
The text to check.
@return <code>true</code> if the text looks like HTML | [
"Check",
"whether",
"the",
"passed",
"text",
"looks",
"like",
"it",
"contains",
"XHTML",
"code",
".",
"This",
"is",
"a",
"heuristic",
"check",
"only",
"and",
"does",
"not",
"perform",
"actual",
"parsing!"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/parser/XHTMLParser.java#L114-L120 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/parser/XHTMLParser.java | XHTMLParser.isValidXHTMLFragment | public boolean isValidXHTMLFragment (@Nullable final String sXHTMLFragment)
{
return StringHelper.hasNoText (sXHTMLFragment) || parseXHTMLFragment (sXHTMLFragment) != null;
} | java | public boolean isValidXHTMLFragment (@Nullable final String sXHTMLFragment)
{
return StringHelper.hasNoText (sXHTMLFragment) || parseXHTMLFragment (sXHTMLFragment) != null;
} | [
"public",
"boolean",
"isValidXHTMLFragment",
"(",
"@",
"Nullable",
"final",
"String",
"sXHTMLFragment",
")",
"{",
"return",
"StringHelper",
".",
"hasNoText",
"(",
"sXHTMLFragment",
")",
"||",
"parseXHTMLFragment",
"(",
"sXHTMLFragment",
")",
"!=",
"null",
";",
"}"... | Check if the given fragment is valid XHTML 1.1 mark-up. This method tries
to parse the XHTML fragment, so it is potentially slow!
@param sXHTMLFragment
The XHTML fragment to parse. It is not checked, whether the value
looks like HTML or not.
@return <code>true</code> if the fragment is valid, <code>false</code>
otherwise. | [
"Check",
"if",
"the",
"given",
"fragment",
"is",
"valid",
"XHTML",
"1",
".",
"1",
"mark",
"-",
"up",
".",
"This",
"method",
"tries",
"to",
"parse",
"the",
"XHTML",
"fragment",
"so",
"it",
"is",
"potentially",
"slow!"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/parser/XHTMLParser.java#L132-L135 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/parser/XHTMLParser.java | XHTMLParser.unescapeXHTMLFragment | @Nullable
public IMicroContainer unescapeXHTMLFragment (@Nullable final String sXHTML)
{
// Ensure that the content is surrounded by a single tag
final IMicroDocument aDoc = parseXHTMLFragment (sXHTML);
if (aDoc != null && aDoc.getDocumentElement () != null)
{
// Find "body" case insensitive
final IMicroElement eBody = aDoc.getDocumentElement ().getFirstChildElement (EHTMLElement.BODY.getElementName ());
if (eBody != null)
{
final IMicroContainer ret = new MicroContainer ();
if (eBody.hasChildren ())
{
// We need a copy because detachFromParent is modifying
for (final IMicroNode aChildNode : eBody.getAllChildren ())
ret.appendChild (aChildNode.detachFromParent ());
}
return ret;
}
}
return null;
} | java | @Nullable
public IMicroContainer unescapeXHTMLFragment (@Nullable final String sXHTML)
{
// Ensure that the content is surrounded by a single tag
final IMicroDocument aDoc = parseXHTMLFragment (sXHTML);
if (aDoc != null && aDoc.getDocumentElement () != null)
{
// Find "body" case insensitive
final IMicroElement eBody = aDoc.getDocumentElement ().getFirstChildElement (EHTMLElement.BODY.getElementName ());
if (eBody != null)
{
final IMicroContainer ret = new MicroContainer ();
if (eBody.hasChildren ())
{
// We need a copy because detachFromParent is modifying
for (final IMicroNode aChildNode : eBody.getAllChildren ())
ret.appendChild (aChildNode.detachFromParent ());
}
return ret;
}
}
return null;
} | [
"@",
"Nullable",
"public",
"IMicroContainer",
"unescapeXHTMLFragment",
"(",
"@",
"Nullable",
"final",
"String",
"sXHTML",
")",
"{",
"// Ensure that the content is surrounded by a single tag",
"final",
"IMicroDocument",
"aDoc",
"=",
"parseXHTMLFragment",
"(",
"sXHTML",
")",
... | Interpret the passed XHTML fragment as HTML and retrieve a result container
with all body elements.
@param sXHTML
The XHTML text fragment. This fragment is parsed as an HTML body and
may therefore not contain the <body> tag.
@return <code>null</code> if the passed text could not be interpreted as
XHTML or if no body element was found, an {@link IMicroContainer}
with all body children otherwise. | [
"Interpret",
"the",
"passed",
"XHTML",
"fragment",
"as",
"HTML",
"and",
"retrieve",
"a",
"result",
"container",
"with",
"all",
"body",
"elements",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/parser/XHTMLParser.java#L196-L218 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/object/AbstractBusinessObjectMicroTypeConverter.java | AbstractBusinessObjectMicroTypeConverter.readAsLocalDateTime | @Nullable
@ContainsSoftMigration
public static LocalDateTime readAsLocalDateTime (@Nonnull final IMicroElement aElement,
@Nonnull final IMicroQName aLDTName,
@Nonnull final String aDTName)
{
LocalDateTime aLDT = aElement.getAttributeValueWithConversion (aLDTName, LocalDateTime.class);
if (aLDT == null)
{
final ZonedDateTime aDT = aElement.getAttributeValueWithConversion (aDTName, ZonedDateTime.class);
if (aDT != null)
aLDT = aDT.toLocalDateTime ();
}
return aLDT;
} | java | @Nullable
@ContainsSoftMigration
public static LocalDateTime readAsLocalDateTime (@Nonnull final IMicroElement aElement,
@Nonnull final IMicroQName aLDTName,
@Nonnull final String aDTName)
{
LocalDateTime aLDT = aElement.getAttributeValueWithConversion (aLDTName, LocalDateTime.class);
if (aLDT == null)
{
final ZonedDateTime aDT = aElement.getAttributeValueWithConversion (aDTName, ZonedDateTime.class);
if (aDT != null)
aLDT = aDT.toLocalDateTime ();
}
return aLDT;
} | [
"@",
"Nullable",
"@",
"ContainsSoftMigration",
"public",
"static",
"LocalDateTime",
"readAsLocalDateTime",
"(",
"@",
"Nonnull",
"final",
"IMicroElement",
"aElement",
",",
"@",
"Nonnull",
"final",
"IMicroQName",
"aLDTName",
",",
"@",
"Nonnull",
"final",
"String",
"aD... | For migration purposes - read LocalDateTime - if no present fall back to
DateTime
@param aElement
Element
@param aLDTName
new local date time element name
@param aDTName
old date time element name
@return May be <code>null</code>. | [
"For",
"migration",
"purposes",
"-",
"read",
"LocalDateTime",
"-",
"if",
"no",
"present",
"fall",
"back",
"to",
"DateTime"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/object/AbstractBusinessObjectMicroTypeConverter.java#L85-L99 | train |
phax/ph-oton | ph-oton-bootstrap4/src/main/java/com/helger/photon/bootstrap4/utils/BootstrapDisplayBuilder.java | BootstrapDisplayBuilder.display | @Nonnull
public BootstrapDisplayBuilder display (@Nonnull final EBootstrapDisplayType eDisplay)
{
ValueEnforcer.notNull (eDisplay, "eDisplay");
m_eDisplay = eDisplay;
return this;
} | java | @Nonnull
public BootstrapDisplayBuilder display (@Nonnull final EBootstrapDisplayType eDisplay)
{
ValueEnforcer.notNull (eDisplay, "eDisplay");
m_eDisplay = eDisplay;
return this;
} | [
"@",
"Nonnull",
"public",
"BootstrapDisplayBuilder",
"display",
"(",
"@",
"Nonnull",
"final",
"EBootstrapDisplayType",
"eDisplay",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"eDisplay",
",",
"\"eDisplay\"",
")",
";",
"m_eDisplay",
"=",
"eDisplay",
";",
"retur... | Set the display type. Default is "block".
@param eDisplay
Display type. May not be <code>null</code>.
@return this for chaining | [
"Set",
"the",
"display",
"type",
".",
"Default",
"is",
"block",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-bootstrap4/src/main/java/com/helger/photon/bootstrap4/utils/BootstrapDisplayBuilder.java#L63-L69 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/metadata/HCHead.java | HCHead.addCSSAt | @Nonnull
public final HCHead addCSSAt (@Nonnegative final int nIndex, @Nonnull final IHCNode aCSS)
{
ValueEnforcer.notNull (aCSS, "CSS");
if (!HCCSSNodeDetector.isCSSNode (aCSS))
throw new IllegalArgumentException (aCSS + " is not a valid CSS node!");
m_aCSS.add (nIndex, aCSS);
return this;
} | java | @Nonnull
public final HCHead addCSSAt (@Nonnegative final int nIndex, @Nonnull final IHCNode aCSS)
{
ValueEnforcer.notNull (aCSS, "CSS");
if (!HCCSSNodeDetector.isCSSNode (aCSS))
throw new IllegalArgumentException (aCSS + " is not a valid CSS node!");
m_aCSS.add (nIndex, aCSS);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"HCHead",
"addCSSAt",
"(",
"@",
"Nonnegative",
"final",
"int",
"nIndex",
",",
"@",
"Nonnull",
"final",
"IHCNode",
"aCSS",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aCSS",
",",
"\"CSS\"",
")",
";",
"if",
"(",
"!",... | Add a CSS node at the specified index.
@param nIndex
The index to add. Should be ≥ 0.
@param aCSS
The CSS node to be added. May not be <code>null</code>.
@return this for chaining | [
"Add",
"a",
"CSS",
"node",
"at",
"the",
"specified",
"index",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/metadata/HCHead.java#L200-L208 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/metadata/HCHead.java | HCHead.addJS | @Nonnull
public final HCHead addJS (@Nonnull final IHCNode aJS)
{
ValueEnforcer.notNull (aJS, "JS");
if (!HCJSNodeDetector.isJSNode (aJS))
throw new IllegalArgumentException (aJS + " is not a valid JS node!");
m_aJS.add (aJS);
return this;
} | java | @Nonnull
public final HCHead addJS (@Nonnull final IHCNode aJS)
{
ValueEnforcer.notNull (aJS, "JS");
if (!HCJSNodeDetector.isJSNode (aJS))
throw new IllegalArgumentException (aJS + " is not a valid JS node!");
m_aJS.add (aJS);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"HCHead",
"addJS",
"(",
"@",
"Nonnull",
"final",
"IHCNode",
"aJS",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aJS",
",",
"\"JS\"",
")",
";",
"if",
"(",
"!",
"HCJSNodeDetector",
".",
"isJSNode",
"(",
"aJS",
")",
... | Append some JavaScript code
@param aJS
The JS to be added. May not be <code>null</code>.
@return this | [
"Append",
"some",
"JavaScript",
"code"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/metadata/HCHead.java#L262-L270 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/html/metadata/HCHead.java | HCHead.addJSAt | @Nonnull
public final HCHead addJSAt (@Nonnegative final int nIndex, @Nonnull final IHCNode aJS)
{
ValueEnforcer.notNull (aJS, "JS");
if (!HCJSNodeDetector.isJSNode (aJS))
throw new IllegalArgumentException (aJS + " is not a valid JS node!");
m_aJS.add (nIndex, aJS);
return this;
} | java | @Nonnull
public final HCHead addJSAt (@Nonnegative final int nIndex, @Nonnull final IHCNode aJS)
{
ValueEnforcer.notNull (aJS, "JS");
if (!HCJSNodeDetector.isJSNode (aJS))
throw new IllegalArgumentException (aJS + " is not a valid JS node!");
m_aJS.add (nIndex, aJS);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"HCHead",
"addJSAt",
"(",
"@",
"Nonnegative",
"final",
"int",
"nIndex",
",",
"@",
"Nonnull",
"final",
"IHCNode",
"aJS",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aJS",
",",
"\"JS\"",
")",
";",
"if",
"(",
"!",
"... | Append some JavaScript code at the specified index
@param nIndex
The index where the JS should be added (counting only JS elements)
@param aJS
The JS to be added. May not be <code>null</code>.
@return this | [
"Append",
"some",
"JavaScript",
"code",
"at",
"the",
"specified",
"index"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/html/metadata/HCHead.java#L281-L289 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/Ekstazi.java | Ekstazi.inst | public static Ekstazi inst() {
if (inst != null) return inst;
synchronized (Ekstazi.class) {
if (inst == null) {
inst = new Ekstazi();
}
}
return inst;
} | java | public static Ekstazi inst() {
if (inst != null) return inst;
synchronized (Ekstazi.class) {
if (inst == null) {
inst = new Ekstazi();
}
}
return inst;
} | [
"public",
"static",
"Ekstazi",
"inst",
"(",
")",
"{",
"if",
"(",
"inst",
"!=",
"null",
")",
"return",
"inst",
";",
"synchronized",
"(",
"Ekstazi",
".",
"class",
")",
"{",
"if",
"(",
"inst",
"==",
"null",
")",
"{",
"inst",
"=",
"new",
"Ekstazi",
"("... | Returns the only instance of this class. This method will construct
and initialize the instance if it was not previously constructed. | [
"Returns",
"the",
"only",
"instance",
"of",
"this",
"class",
".",
"This",
"method",
"will",
"construct",
"and",
"initialize",
"the",
"instance",
"if",
"it",
"was",
"not",
"previously",
"constructed",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/Ekstazi.java#L77-L85 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/Ekstazi.java | Ekstazi.endClassCoverage | public void endClassCoverage(String className, boolean isFailOrError) {
File testResultsDir = new File(Config.ROOT_DIR_V, Names.TEST_RESULTS_DIR_NAME);
File outcomeFile = new File(testResultsDir, className);
if (isFailOrError) {
// TODO: long names.
testResultsDir.mkdirs();
try {
outcomeFile.createNewFile();
} catch (IOException e) {
Log.e("Unable to create file for a failing test: " + className, e);
}
} else {
outcomeFile.delete();
}
endClassCoverage(className);
} | java | public void endClassCoverage(String className, boolean isFailOrError) {
File testResultsDir = new File(Config.ROOT_DIR_V, Names.TEST_RESULTS_DIR_NAME);
File outcomeFile = new File(testResultsDir, className);
if (isFailOrError) {
// TODO: long names.
testResultsDir.mkdirs();
try {
outcomeFile.createNewFile();
} catch (IOException e) {
Log.e("Unable to create file for a failing test: " + className, e);
}
} else {
outcomeFile.delete();
}
endClassCoverage(className);
} | [
"public",
"void",
"endClassCoverage",
"(",
"String",
"className",
",",
"boolean",
"isFailOrError",
")",
"{",
"File",
"testResultsDir",
"=",
"new",
"File",
"(",
"Config",
".",
"ROOT_DIR_V",
",",
"Names",
".",
"TEST_RESULTS_DIR_NAME",
")",
";",
"File",
"outcomeFil... | Saves info about the results of running the given test class. | [
"Saves",
"info",
"about",
"the",
"results",
"of",
"running",
"the",
"given",
"test",
"class",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/Ekstazi.java#L144-L159 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/Ekstazi.java | Ekstazi.initAndReportSuccess | private boolean initAndReportSuccess() {
// Load configuration.
Config.loadConfig();
// Initialize storer, hashes, and analyzer.
mDependencyAnalyzer = Config.createDepenencyAnalyzer();
// Establish if Tool is enabled.
boolean isEnabled = establishIfEnabled();
// Return if not enabled or code should not be instrumented.
if (!isEnabled || !Config.X_INSTRUMENT_CODE_V || isEkstaziSystemClassLoader()) {
return isEnabled;
}
// Set the agent at runtime if not already set.
Instrumentation instrumentation = EkstaziAgent.getInstrumentation();
if (instrumentation == null) {
Log.d("Agent has not been set previously");
instrumentation = DynamicEkstazi.initAgentAtRuntimeAndReportSuccess();
if (instrumentation == null) {
Log.d("No Instrumentation object found; enabling Ekstazi without using any instrumentation");
return true;
}
} else {
Log.d("Agent has been set previously");
}
return true;
} | java | private boolean initAndReportSuccess() {
// Load configuration.
Config.loadConfig();
// Initialize storer, hashes, and analyzer.
mDependencyAnalyzer = Config.createDepenencyAnalyzer();
// Establish if Tool is enabled.
boolean isEnabled = establishIfEnabled();
// Return if not enabled or code should not be instrumented.
if (!isEnabled || !Config.X_INSTRUMENT_CODE_V || isEkstaziSystemClassLoader()) {
return isEnabled;
}
// Set the agent at runtime if not already set.
Instrumentation instrumentation = EkstaziAgent.getInstrumentation();
if (instrumentation == null) {
Log.d("Agent has not been set previously");
instrumentation = DynamicEkstazi.initAgentAtRuntimeAndReportSuccess();
if (instrumentation == null) {
Log.d("No Instrumentation object found; enabling Ekstazi without using any instrumentation");
return true;
}
} else {
Log.d("Agent has been set previously");
}
return true;
} | [
"private",
"boolean",
"initAndReportSuccess",
"(",
")",
"{",
"// Load configuration.",
"Config",
".",
"loadConfig",
"(",
")",
";",
"// Initialize storer, hashes, and analyzer.",
"mDependencyAnalyzer",
"=",
"Config",
".",
"createDepenencyAnalyzer",
"(",
")",
";",
"// Estab... | Initializes this facade. This method should be invoked only once.
The following steps are performed: 1) load configuration, 2) establish if
this Tool is enabled, 3) set paths needed for instrumentation (if
instrumentation is enabled and agent is not already present).
@return true if Tool is enabled, false otherwise. | [
"Initializes",
"this",
"facade",
".",
"This",
"method",
"should",
"be",
"invoked",
"only",
"once",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/Ekstazi.java#L172-L199 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/markdown/Emitter.java | Emitter.emitPluginLines | protected void emitPluginLines (final MarkdownHCStack aOut, final Line aLines, @Nonnull final String sMeta)
{
Line aLine = aLines;
String sIDPlugin = sMeta;
String sParams = null;
ICommonsMap <String, String> aParams = null;
final int nIdxOfSpace = sMeta.indexOf (' ');
if (nIdxOfSpace != -1)
{
sIDPlugin = sMeta.substring (0, nIdxOfSpace);
sParams = sMeta.substring (nIdxOfSpace + 1);
if (sParams != null)
{
aParams = parsePluginParams (sParams);
}
}
if (aParams == null)
{
aParams = new CommonsHashMap <> ();
}
final ICommonsList <String> aList = new CommonsArrayList <> ();
while (aLine != null)
{
if (aLine.m_bIsEmpty)
aList.add ("");
else
aList.add (aLine.m_sValue);
aLine = aLine.m_aNext;
}
final AbstractMarkdownPlugin aPlugin = m_aPlugins.get (sIDPlugin);
if (aPlugin != null)
{
aPlugin.emit (aOut, aList, aParams);
}
} | java | protected void emitPluginLines (final MarkdownHCStack aOut, final Line aLines, @Nonnull final String sMeta)
{
Line aLine = aLines;
String sIDPlugin = sMeta;
String sParams = null;
ICommonsMap <String, String> aParams = null;
final int nIdxOfSpace = sMeta.indexOf (' ');
if (nIdxOfSpace != -1)
{
sIDPlugin = sMeta.substring (0, nIdxOfSpace);
sParams = sMeta.substring (nIdxOfSpace + 1);
if (sParams != null)
{
aParams = parsePluginParams (sParams);
}
}
if (aParams == null)
{
aParams = new CommonsHashMap <> ();
}
final ICommonsList <String> aList = new CommonsArrayList <> ();
while (aLine != null)
{
if (aLine.m_bIsEmpty)
aList.add ("");
else
aList.add (aLine.m_sValue);
aLine = aLine.m_aNext;
}
final AbstractMarkdownPlugin aPlugin = m_aPlugins.get (sIDPlugin);
if (aPlugin != null)
{
aPlugin.emit (aOut, aList, aParams);
}
} | [
"protected",
"void",
"emitPluginLines",
"(",
"final",
"MarkdownHCStack",
"aOut",
",",
"final",
"Line",
"aLines",
",",
"@",
"Nonnull",
"final",
"String",
"sMeta",
")",
"{",
"Line",
"aLine",
"=",
"aLines",
";",
"String",
"sIDPlugin",
"=",
"sMeta",
";",
"String... | interprets a plugin block into the StringBuilder.
@param aOut
The StringBuilder to write to.
@param aLines
The lines to write.
@param sMeta
Meta information. | [
"interprets",
"a",
"plugin",
"block",
"into",
"the",
"StringBuilder",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/markdown/Emitter.java#L1127-L1164 | train |
rometools/rome-utils | src/main/java/com/rometools/utils/Dates.java | Dates.copy | public static Date copy(final Date d) {
if (d == null) {
return null;
} else {
return new Date(d.getTime());
}
} | java | public static Date copy(final Date d) {
if (d == null) {
return null;
} else {
return new Date(d.getTime());
}
} | [
"public",
"static",
"Date",
"copy",
"(",
"final",
"Date",
"d",
")",
"{",
"if",
"(",
"d",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"new",
"Date",
"(",
"d",
".",
"getTime",
"(",
")",
")",
";",
"}",
"}"
] | Creates a copy on a Date.
@param d The Date to copy, can be null
@return null when the input Date was null, a copy of the Date otherwise | [
"Creates",
"a",
"copy",
"on",
"a",
"Date",
"."
] | 96ed1d1d10144886cadcf924d0e304459f4edefc | https://github.com/rometools/rome-utils/blob/96ed1d1d10144886cadcf924d0e304459f4edefc/src/main/java/com/rometools/utils/Dates.java#L30-L36 | train |
JamesIry/jADT | jADT-core/src/main/java/com/pogofish/jadt/util/Util.java | Util.list | public static <A> List<A> list(A... elements) {
final List<A> list = new ArrayList<A>(elements.length);
for (A element : elements) {
list.add(element);
}
return list;
} | java | public static <A> List<A> list(A... elements) {
final List<A> list = new ArrayList<A>(elements.length);
for (A element : elements) {
list.add(element);
}
return list;
} | [
"public",
"static",
"<",
"A",
">",
"List",
"<",
"A",
">",
"list",
"(",
"A",
"...",
"elements",
")",
"{",
"final",
"List",
"<",
"A",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"A",
">",
"(",
"elements",
".",
"length",
")",
";",
"for",
"(",
"A",
... | Returns an array list of elements | [
"Returns",
"an",
"array",
"list",
"of",
"elements"
] | 92ee94b6624cd673851497d78c218837dcf02b8a | https://github.com/JamesIry/jADT/blob/92ee94b6624cd673851497d78c218837dcf02b8a/jADT-core/src/main/java/com/pogofish/jadt/util/Util.java#L32-L38 | train |
JamesIry/jADT | jADT-core/src/main/java/com/pogofish/jadt/util/Util.java | Util.set | public static <A> Set<A> set(A... elements) {
final Set<A> set = new HashSet<A>(elements.length);
for (A element : elements) {
set.add(element);
}
return set;
} | java | public static <A> Set<A> set(A... elements) {
final Set<A> set = new HashSet<A>(elements.length);
for (A element : elements) {
set.add(element);
}
return set;
} | [
"public",
"static",
"<",
"A",
">",
"Set",
"<",
"A",
">",
"set",
"(",
"A",
"...",
"elements",
")",
"{",
"final",
"Set",
"<",
"A",
">",
"set",
"=",
"new",
"HashSet",
"<",
"A",
">",
"(",
"elements",
".",
"length",
")",
";",
"for",
"(",
"A",
"ele... | Returns a hash set of elements | [
"Returns",
"a",
"hash",
"set",
"of",
"elements"
] | 92ee94b6624cd673851497d78c218837dcf02b8a | https://github.com/JamesIry/jADT/blob/92ee94b6624cd673851497d78c218837dcf02b8a/jADT-core/src/main/java/com/pogofish/jadt/util/Util.java#L43-L49 | train |
JamesIry/jADT | jADT-core/src/main/java/com/pogofish/jadt/util/Util.java | Util.execute | public static <A> A execute(ExceptionAction<A> action) {
try {
return action.doAction();
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable e) {
throw new RuntimeException(e);
}
} | java | public static <A> A execute(ExceptionAction<A> action) {
try {
return action.doAction();
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"<",
"A",
">",
"A",
"execute",
"(",
"ExceptionAction",
"<",
"A",
">",
"action",
")",
"{",
"try",
"{",
"return",
"action",
".",
"doAction",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
"e",
";",
"... | delegate to your to an ExceptionAction and wraps checked exceptions in RuntimExceptions, leaving unchecked exceptions alone.
@return A
@throws Either Error or RuntimeException. Error on Errors in doAction and RuntimeException if doError throws a RuntimeException or an Exception. In the latter case
the RuntimeException will contain the original Exception as its cause | [
"delegate",
"to",
"your",
"to",
"an",
"ExceptionAction",
"and",
"wraps",
"checked",
"exceptions",
"in",
"RuntimExceptions",
"leaving",
"unchecked",
"exceptions",
"alone",
"."
] | 92ee94b6624cd673851497d78c218837dcf02b8a | https://github.com/JamesIry/jADT/blob/92ee94b6624cd673851497d78c218837dcf02b8a/jADT-core/src/main/java/com/pogofish/jadt/util/Util.java#L58-L68 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/form/FormErrorList.java | FormErrorList.addFieldInfo | public void addFieldInfo (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderInfo ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | java | public void addFieldInfo (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderInfo ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | [
"public",
"void",
"addFieldInfo",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sFieldName",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sText",
")",
"{",
"add",
"(",
"SingleError",
".",
"builderInfo",
"(",
")",
".",
"setErrorFieldN... | Add a field specific information message.
@param sFieldName
The field name for which the message is to be recorded. May neither
be <code>null</code> nor empty.
@param sText
The text to use. May neither be <code>null</code> nor empty. | [
"Add",
"a",
"field",
"specific",
"information",
"message",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/form/FormErrorList.java#L52-L55 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/form/FormErrorList.java | FormErrorList.addFieldWarning | public void addFieldWarning (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderWarn ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | java | public void addFieldWarning (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderWarn ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | [
"public",
"void",
"addFieldWarning",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sFieldName",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sText",
")",
"{",
"add",
"(",
"SingleError",
".",
"builderWarn",
"(",
")",
".",
"setErrorFie... | Add a field specific warning message.
@param sFieldName
The field name for which the message is to be recorded. May neither
be <code>null</code> nor empty.
@param sText
The text to use. May neither be <code>null</code> nor empty. | [
"Add",
"a",
"field",
"specific",
"warning",
"message",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/form/FormErrorList.java#L66-L69 | train |
phax/ph-oton | ph-oton-core/src/main/java/com/helger/photon/core/form/FormErrorList.java | FormErrorList.addFieldError | public void addFieldError (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderError ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | java | public void addFieldError (@Nonnull @Nonempty final String sFieldName, @Nonnull @Nonempty final String sText)
{
add (SingleError.builderError ().setErrorFieldName (sFieldName).setErrorText (sText).build ());
} | [
"public",
"void",
"addFieldError",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sFieldName",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sText",
")",
"{",
"add",
"(",
"SingleError",
".",
"builderError",
"(",
")",
".",
"setErrorFiel... | Add a field specific error message.
@param sFieldName
The field name for which the message is to be recorded. May neither
be <code>null</code> nor empty.
@param sText
The text to use. May neither be <code>null</code> nor empty. | [
"Add",
"a",
"field",
"specific",
"error",
"message",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-core/src/main/java/com/helger/photon/core/form/FormErrorList.java#L80-L83 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.createNewUserGroup | @Nonnull
public IUserGroup createNewUserGroup (@Nonnull @Nonempty final String sName,
@Nullable final String sDescription,
@Nullable final Map <String, String> aCustomAttrs)
{
// Create user group
final UserGroup aUserGroup = new UserGroup (sName, sDescription, aCustomAttrs);
m_aRWLock.writeLocked ( () -> {
// Store
internalCreateItem (aUserGroup);
});
AuditHelper.onAuditCreateSuccess (UserGroup.OT, aUserGroup.getID (), sName, sDescription, aCustomAttrs);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupCreated (aUserGroup, false));
return aUserGroup;
} | java | @Nonnull
public IUserGroup createNewUserGroup (@Nonnull @Nonempty final String sName,
@Nullable final String sDescription,
@Nullable final Map <String, String> aCustomAttrs)
{
// Create user group
final UserGroup aUserGroup = new UserGroup (sName, sDescription, aCustomAttrs);
m_aRWLock.writeLocked ( () -> {
// Store
internalCreateItem (aUserGroup);
});
AuditHelper.onAuditCreateSuccess (UserGroup.OT, aUserGroup.getID (), sName, sDescription, aCustomAttrs);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupCreated (aUserGroup, false));
return aUserGroup;
} | [
"@",
"Nonnull",
"public",
"IUserGroup",
"createNewUserGroup",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sName",
",",
"@",
"Nullable",
"final",
"String",
"sDescription",
",",
"@",
"Nullable",
"final",
"Map",
"<",
"String",
",",
"String",
">",
... | Create a new user group.
@param sName
The name of the user group to create. May neither be
<code>null</code> nor empty.
@param sDescription
The optional description of the user group. May be <code>null</code>
.
@param aCustomAttrs
A set of custom attributes. May be <code>null</code>.
@return The created user group. | [
"Create",
"a",
"new",
"user",
"group",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L135-L154 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.createPredefinedUserGroup | @Nonnull
public IUserGroup createPredefinedUserGroup (@Nonnull @Nonempty final String sID,
@Nonnull @Nonempty final String sName,
@Nullable final String sDescription,
@Nullable final Map <String, String> aCustomAttrs)
{
// Create user group
final UserGroup aUserGroup = new UserGroup (StubObject.createForCurrentUserAndID (sID, aCustomAttrs),
sName,
sDescription);
m_aRWLock.writeLocked ( () -> {
// Store
internalCreateItem (aUserGroup);
});
AuditHelper.onAuditCreateSuccess (UserGroup.OT,
aUserGroup.getID (),
"predefined-usergroup",
sName,
sDescription,
aCustomAttrs);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupCreated (aUserGroup, true));
return aUserGroup;
} | java | @Nonnull
public IUserGroup createPredefinedUserGroup (@Nonnull @Nonempty final String sID,
@Nonnull @Nonempty final String sName,
@Nullable final String sDescription,
@Nullable final Map <String, String> aCustomAttrs)
{
// Create user group
final UserGroup aUserGroup = new UserGroup (StubObject.createForCurrentUserAndID (sID, aCustomAttrs),
sName,
sDescription);
m_aRWLock.writeLocked ( () -> {
// Store
internalCreateItem (aUserGroup);
});
AuditHelper.onAuditCreateSuccess (UserGroup.OT,
aUserGroup.getID (),
"predefined-usergroup",
sName,
sDescription,
aCustomAttrs);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupCreated (aUserGroup, true));
return aUserGroup;
} | [
"@",
"Nonnull",
"public",
"IUserGroup",
"createPredefinedUserGroup",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sID",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sName",
",",
"@",
"Nullable",
"final",
"String",
"sDescription",
",",
... | Create a predefined user group.
@param sID
The ID to use
@param sName
The name of the user group to create. May neither be
<code>null</code> nor empty.
@param sDescription
The optional description of the user group. May be <code>null</code>
.
@param aCustomAttrs
A set of custom attributes. May be <code>null</code>.
@return The created user group. | [
"Create",
"a",
"predefined",
"user",
"group",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L171-L197 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.deleteUserGroup | @Nonnull
public EChange deleteUserGroup (@Nullable final String sUserGroupID)
{
if (StringHelper.hasNoText (sUserGroupID))
return EChange.UNCHANGED;
final UserGroup aDeletedUserGroup = getOfID (sUserGroupID);
if (aDeletedUserGroup == null)
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "no-such-usergroup-id", sUserGroupID);
return EChange.UNCHANGED;
}
if (aDeletedUserGroup.isDeleted ())
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "already-deleted", sUserGroupID);
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (BusinessObjectHelper.setDeletionNow (aDeletedUserGroup).isUnchanged ())
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "already-deleted", sUserGroupID);
return EChange.UNCHANGED;
}
internalMarkItemDeleted (aDeletedUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditDeleteSuccess (UserGroup.OT, sUserGroupID);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupDeleted (aDeletedUserGroup));
return EChange.CHANGED;
} | java | @Nonnull
public EChange deleteUserGroup (@Nullable final String sUserGroupID)
{
if (StringHelper.hasNoText (sUserGroupID))
return EChange.UNCHANGED;
final UserGroup aDeletedUserGroup = getOfID (sUserGroupID);
if (aDeletedUserGroup == null)
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "no-such-usergroup-id", sUserGroupID);
return EChange.UNCHANGED;
}
if (aDeletedUserGroup.isDeleted ())
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "already-deleted", sUserGroupID);
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (BusinessObjectHelper.setDeletionNow (aDeletedUserGroup).isUnchanged ())
{
AuditHelper.onAuditDeleteFailure (UserGroup.OT, "already-deleted", sUserGroupID);
return EChange.UNCHANGED;
}
internalMarkItemDeleted (aDeletedUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditDeleteSuccess (UserGroup.OT, sUserGroupID);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupDeleted (aDeletedUserGroup));
return EChange.CHANGED;
} | [
"@",
"Nonnull",
"public",
"EChange",
"deleteUserGroup",
"(",
"@",
"Nullable",
"final",
"String",
"sUserGroupID",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sUserGroupID",
")",
")",
"return",
"EChange",
".",
"UNCHANGED",
";",
"final",
"UserGro... | Delete the user group with the specified ID
@param sUserGroupID
The ID of the user group to be deleted. May be <code>null</code>.
@return {@link EChange#CHANGED} if the user group was deleted,
{@link EChange#UNCHANGED} otherwise | [
"Delete",
"the",
"user",
"group",
"with",
"the",
"specified",
"ID"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L207-L245 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.undeleteUserGroup | @Nonnull
public EChange undeleteUserGroup (@Nullable final String sUserGroupID)
{
final UserGroup aUserGroup = getOfID (sUserGroupID);
if (aUserGroup == null)
{
AuditHelper.onAuditUndeleteFailure (UserGroup.OT, sUserGroupID, "no-such-id");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (BusinessObjectHelper.setUndeletionNow (aUserGroup).isUnchanged ())
return EChange.UNCHANGED;
internalMarkItemUndeleted (aUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditUndeleteSuccess (UserGroup.OT, sUserGroupID);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupUndeleted (aUserGroup));
return EChange.CHANGED;
} | java | @Nonnull
public EChange undeleteUserGroup (@Nullable final String sUserGroupID)
{
final UserGroup aUserGroup = getOfID (sUserGroupID);
if (aUserGroup == null)
{
AuditHelper.onAuditUndeleteFailure (UserGroup.OT, sUserGroupID, "no-such-id");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (BusinessObjectHelper.setUndeletionNow (aUserGroup).isUnchanged ())
return EChange.UNCHANGED;
internalMarkItemUndeleted (aUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditUndeleteSuccess (UserGroup.OT, sUserGroupID);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupUndeleted (aUserGroup));
return EChange.CHANGED;
} | [
"@",
"Nonnull",
"public",
"EChange",
"undeleteUserGroup",
"(",
"@",
"Nullable",
"final",
"String",
"sUserGroupID",
")",
"{",
"final",
"UserGroup",
"aUserGroup",
"=",
"getOfID",
"(",
"sUserGroupID",
")",
";",
"if",
"(",
"aUserGroup",
"==",
"null",
")",
"{",
"... | Undelete the user group with the specified ID.
@param sUserGroupID
The ID of the user group to undelete
@return {@link EChange#CHANGED} if the user group was undeleted,
{@link EChange#UNCHANGED} otherwise. | [
"Undelete",
"the",
"user",
"group",
"with",
"the",
"specified",
"ID",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L255-L282 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.renameUserGroup | @Nonnull
public EChange renameUserGroup (@Nullable final String sUserGroupID, @Nonnull @Nonempty final String sNewName)
{
// Resolve user group
final UserGroup aUserGroup = getOfID (sUserGroupID);
if (aUserGroup == null)
{
AuditHelper.onAuditModifyFailure (UserGroup.OT, sUserGroupID, "no-such-usergroup-id", "name");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (aUserGroup.setName (sNewName).isUnchanged ())
return EChange.UNCHANGED;
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "name", sUserGroupID, sNewName);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupRenamed (aUserGroup));
return EChange.CHANGED;
} | java | @Nonnull
public EChange renameUserGroup (@Nullable final String sUserGroupID, @Nonnull @Nonempty final String sNewName)
{
// Resolve user group
final UserGroup aUserGroup = getOfID (sUserGroupID);
if (aUserGroup == null)
{
AuditHelper.onAuditModifyFailure (UserGroup.OT, sUserGroupID, "no-such-usergroup-id", "name");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (aUserGroup.setName (sNewName).isUnchanged ())
return EChange.UNCHANGED;
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "name", sUserGroupID, sNewName);
// Execute callback as the very last action
m_aCallbacks.forEach (aCB -> aCB.onUserGroupRenamed (aUserGroup));
return EChange.CHANGED;
} | [
"@",
"Nonnull",
"public",
"EChange",
"renameUserGroup",
"(",
"@",
"Nullable",
"final",
"String",
"sUserGroupID",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sNewName",
")",
"{",
"// Resolve user group",
"final",
"UserGroup",
"aUserGroup",
"=",
"getOf... | Rename the user group with the specified ID
@param sUserGroupID
The ID of the user group. May be <code>null</code>.
@param sNewName
The new name of the user group. May neither be <code>null</code> nor
empty.
@return {@link EChange#CHANGED} if the user group ID was valid, and the new
name was different from the old name | [
"Rename",
"the",
"user",
"group",
"with",
"the",
"specified",
"ID"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L329-L359 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.unassignUserFromAllUserGroups | @Nonnull
public EChange unassignUserFromAllUserGroups (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return EChange.UNCHANGED;
final ICommonsList <IUserGroup> aAffectedUserGroups = new CommonsArrayList <> ();
m_aRWLock.writeLock ().lock ();
try
{
EChange eChange = EChange.UNCHANGED;
for (final UserGroup aUserGroup : internalDirectGetAll ())
if (aUserGroup.unassignUser (sUserID).isChanged ())
{
aAffectedUserGroups.add (aUserGroup);
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
eChange = EChange.CHANGED;
}
if (eChange.isUnchanged ())
return EChange.UNCHANGED;
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "unassign-user-from-all-usergroups", sUserID);
// Execute callback as the very last action
for (final IUserGroup aUserGroup : aAffectedUserGroups)
m_aCallbacks.forEach (aCB -> aCB.onUserGroupUserAssignment (aUserGroup, sUserID, false));
return EChange.CHANGED;
}
/**
* Check if the passed user is assigned to the specified user group
*
* @param sUserGroupID
* ID of the user group to check
* @param sUserID
* ID of the user to be checked.
* @return <code>true</code> if the specified user is assigned to the
* specified user group.
*/
public boolean isUserAssignedToUserGroup (@Nullable final String sUserGroupID, @Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return false;
final IUserGroup aUserGroup = getOfID (sUserGroupID);
return aUserGroup == null ? false : aUserGroup.containsUserID (sUserID);
} | java | @Nonnull
public EChange unassignUserFromAllUserGroups (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return EChange.UNCHANGED;
final ICommonsList <IUserGroup> aAffectedUserGroups = new CommonsArrayList <> ();
m_aRWLock.writeLock ().lock ();
try
{
EChange eChange = EChange.UNCHANGED;
for (final UserGroup aUserGroup : internalDirectGetAll ())
if (aUserGroup.unassignUser (sUserID).isChanged ())
{
aAffectedUserGroups.add (aUserGroup);
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
eChange = EChange.CHANGED;
}
if (eChange.isUnchanged ())
return EChange.UNCHANGED;
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "unassign-user-from-all-usergroups", sUserID);
// Execute callback as the very last action
for (final IUserGroup aUserGroup : aAffectedUserGroups)
m_aCallbacks.forEach (aCB -> aCB.onUserGroupUserAssignment (aUserGroup, sUserID, false));
return EChange.CHANGED;
}
/**
* Check if the passed user is assigned to the specified user group
*
* @param sUserGroupID
* ID of the user group to check
* @param sUserID
* ID of the user to be checked.
* @return <code>true</code> if the specified user is assigned to the
* specified user group.
*/
public boolean isUserAssignedToUserGroup (@Nullable final String sUserGroupID, @Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return false;
final IUserGroup aUserGroup = getOfID (sUserGroupID);
return aUserGroup == null ? false : aUserGroup.containsUserID (sUserID);
} | [
"@",
"Nonnull",
"public",
"EChange",
"unassignUserFromAllUserGroups",
"(",
"@",
"Nullable",
"final",
"String",
"sUserID",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sUserID",
")",
")",
"return",
"EChange",
".",
"UNCHANGED",
";",
"final",
"ICo... | Unassign the passed user ID from all user groups.
@param sUserID
ID of the user to be unassigned.
@return {@link EChange#CHANGED} if the passed user ID was at least assigned
to one user group. | [
"Unassign",
"the",
"passed",
"user",
"ID",
"from",
"all",
"user",
"groups",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L512-L565 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.getAllUserGroupsWithAssignedUser | @Nonnull
@ReturnsMutableCopy
public ICommonsList <IUserGroup> getAllUserGroupsWithAssignedUser (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return new CommonsArrayList <> ();
return getAll (aUserGroup -> aUserGroup.containsUserID (sUserID));
} | java | @Nonnull
@ReturnsMutableCopy
public ICommonsList <IUserGroup> getAllUserGroupsWithAssignedUser (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return new CommonsArrayList <> ();
return getAll (aUserGroup -> aUserGroup.containsUserID (sUserID));
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"ICommonsList",
"<",
"IUserGroup",
">",
"getAllUserGroupsWithAssignedUser",
"(",
"@",
"Nullable",
"final",
"String",
"sUserID",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sUserID",
")",
")",
... | Get a collection of all user groups to which a certain user is assigned to.
@param sUserID
The user ID to search
@return A non-<code>null</code>but may be empty collection with all
matching user groups. | [
"Get",
"a",
"collection",
"of",
"all",
"user",
"groups",
"to",
"which",
"a",
"certain",
"user",
"is",
"assigned",
"to",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L575-L583 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.getAllUserGroupIDsWithAssignedUser | @Nonnull
@ReturnsMutableCopy
public ICommonsList <String> getAllUserGroupIDsWithAssignedUser (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return new CommonsArrayList <> ();
return getAllMapped (aUserGroup -> aUserGroup.containsUserID (sUserID), aUserGroup -> aUserGroup.getID ());
} | java | @Nonnull
@ReturnsMutableCopy
public ICommonsList <String> getAllUserGroupIDsWithAssignedUser (@Nullable final String sUserID)
{
if (StringHelper.hasNoText (sUserID))
return new CommonsArrayList <> ();
return getAllMapped (aUserGroup -> aUserGroup.containsUserID (sUserID), aUserGroup -> aUserGroup.getID ());
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"ICommonsList",
"<",
"String",
">",
"getAllUserGroupIDsWithAssignedUser",
"(",
"@",
"Nullable",
"final",
"String",
"sUserID",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sUserID",
")",
")",
"r... | Get a collection of all user group IDs to which a certain user is assigned
to.
@param sUserID
The user ID to search
@return A non-<code>null</code>but may be empty collection with all
matching user group IDs. | [
"Get",
"a",
"collection",
"of",
"all",
"user",
"group",
"IDs",
"to",
"which",
"a",
"certain",
"user",
"is",
"assigned",
"to",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L605-L613 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.unassignRoleFromAllUserGroups | @Nonnull
public EChange unassignRoleFromAllUserGroups (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return EChange.UNCHANGED;
final ICommonsList <IUserGroup> aAffectedUserGroups = new CommonsArrayList <> ();
m_aRWLock.writeLock ().lock ();
try
{
EChange eChange = EChange.UNCHANGED;
for (final UserGroup aUserGroup : internalDirectGetAll ())
if (aUserGroup.unassignRole (sRoleID).isChanged ())
{
aAffectedUserGroups.add (aUserGroup);
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
eChange = EChange.CHANGED;
}
if (eChange.isUnchanged ())
return EChange.UNCHANGED;
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "unassign-role-from-all-usergroups", sRoleID);
// Execute callback as the very last action
for (final IUserGroup aUserGroup : aAffectedUserGroups)
m_aCallbacks.forEach (aCB -> aCB.onUserGroupRoleAssignment (aUserGroup, sRoleID, false));
return EChange.CHANGED;
}
/**
* Get a collection of all user groups to which a certain role is assigned to.
*
* @param sRoleID
* The role ID to search
* @return A non-<code>null</code>but may be empty collection with all
* matching user groups.
*/
@Nonnull
@ReturnsMutableCopy
public ICommonsList <IUserGroup> getAllUserGroupsWithAssignedRole (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return getNone ();
return getAll (aUserGroup -> aUserGroup.containsRoleID (sRoleID));
} | java | @Nonnull
public EChange unassignRoleFromAllUserGroups (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return EChange.UNCHANGED;
final ICommonsList <IUserGroup> aAffectedUserGroups = new CommonsArrayList <> ();
m_aRWLock.writeLock ().lock ();
try
{
EChange eChange = EChange.UNCHANGED;
for (final UserGroup aUserGroup : internalDirectGetAll ())
if (aUserGroup.unassignRole (sRoleID).isChanged ())
{
aAffectedUserGroups.add (aUserGroup);
BusinessObjectHelper.setLastModificationNow (aUserGroup);
internalUpdateItem (aUserGroup);
eChange = EChange.CHANGED;
}
if (eChange.isUnchanged ())
return EChange.UNCHANGED;
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (UserGroup.OT, "unassign-role-from-all-usergroups", sRoleID);
// Execute callback as the very last action
for (final IUserGroup aUserGroup : aAffectedUserGroups)
m_aCallbacks.forEach (aCB -> aCB.onUserGroupRoleAssignment (aUserGroup, sRoleID, false));
return EChange.CHANGED;
}
/**
* Get a collection of all user groups to which a certain role is assigned to.
*
* @param sRoleID
* The role ID to search
* @return A non-<code>null</code>but may be empty collection with all
* matching user groups.
*/
@Nonnull
@ReturnsMutableCopy
public ICommonsList <IUserGroup> getAllUserGroupsWithAssignedRole (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return getNone ();
return getAll (aUserGroup -> aUserGroup.containsRoleID (sRoleID));
} | [
"@",
"Nonnull",
"public",
"EChange",
"unassignRoleFromAllUserGroups",
"(",
"@",
"Nullable",
"final",
"String",
"sRoleID",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sRoleID",
")",
")",
"return",
"EChange",
".",
"UNCHANGED",
";",
"final",
"ICo... | Unassign the passed role ID from existing user groups.
@param sRoleID
The role ID to be unassigned
@return {@link EChange#CHANGED} if the passed role ID was contained in at
least one user group | [
"Unassign",
"the",
"passed",
"role",
"ID",
"from",
"existing",
"user",
"groups",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L708-L759 | train |
phax/ph-oton | ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java | UserGroupManager.getAllUserGroupIDsWithAssignedRole | @Nonnull
@ReturnsMutableCopy
public ICommonsList <String> getAllUserGroupIDsWithAssignedRole (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return getNone ();
return getAllMapped (aUserGroup -> aUserGroup.containsRoleID (sRoleID), IUserGroup::getID);
} | java | @Nonnull
@ReturnsMutableCopy
public ICommonsList <String> getAllUserGroupIDsWithAssignedRole (@Nullable final String sRoleID)
{
if (StringHelper.hasNoText (sRoleID))
return getNone ();
return getAllMapped (aUserGroup -> aUserGroup.containsRoleID (sRoleID), IUserGroup::getID);
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"ICommonsList",
"<",
"String",
">",
"getAllUserGroupIDsWithAssignedRole",
"(",
"@",
"Nullable",
"final",
"String",
"sRoleID",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sRoleID",
")",
")",
"r... | Get a collection of all user group IDs to which a certain role is assigned
to.
@param sRoleID
The role ID to search
@return A non-<code>null</code>but may be empty collection with all
matching user group IDs. | [
"Get",
"a",
"collection",
"of",
"all",
"user",
"group",
"IDs",
"to",
"which",
"a",
"certain",
"role",
"is",
"assigned",
"to",
"."
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-security/src/main/java/com/helger/photon/security/usergroup/UserGroupManager.java#L770-L778 | train |
phax/ph-oton | ph-oton-html/src/main/java/com/helger/html/hc/impl/AbstractHCNode.java | AbstractHCNode.internalSetNodeState | public final void internalSetNodeState (@Nonnull final EHCNodeState eNodeState)
{
if (DEBUG_NODE_STATE)
{
ValueEnforcer.notNull (eNodeState, "NodeState");
if (m_eNodeState.isAfter (eNodeState))
HCConsistencyChecker.consistencyError ("The new node state is invalid. Got " +
eNodeState +
" but having " +
m_eNodeState);
}
m_eNodeState = eNodeState;
} | java | public final void internalSetNodeState (@Nonnull final EHCNodeState eNodeState)
{
if (DEBUG_NODE_STATE)
{
ValueEnforcer.notNull (eNodeState, "NodeState");
if (m_eNodeState.isAfter (eNodeState))
HCConsistencyChecker.consistencyError ("The new node state is invalid. Got " +
eNodeState +
" but having " +
m_eNodeState);
}
m_eNodeState = eNodeState;
} | [
"public",
"final",
"void",
"internalSetNodeState",
"(",
"@",
"Nonnull",
"final",
"EHCNodeState",
"eNodeState",
")",
"{",
"if",
"(",
"DEBUG_NODE_STATE",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"eNodeState",
",",
"\"NodeState\"",
")",
";",
"if",
"(",
"m_... | Change the node state internally. Handle with care!
@param eNodeState
The new node state. May not be <code>null</code>. | [
"Change",
"the",
"node",
"state",
"internally",
".",
"Handle",
"with",
"care!"
] | f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef | https://github.com/phax/ph-oton/blob/f3aaacbbc02a9f3e4f32fe8db8e4adf7b9c1d3ef/ph-oton-html/src/main/java/com/helger/html/hc/impl/AbstractHCNode.java#L168-L180 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/monitor/ClassesCache.java | ClassesCache.check | public static boolean check(Class<?> clz) {
if (Config.CACHE_SEEN_CLASSES_V) {
int index = hash(clz);
if (CACHE[index] == clz) {
return true;
}
CACHE[index] = clz;
}
return false;
} | java | public static boolean check(Class<?> clz) {
if (Config.CACHE_SEEN_CLASSES_V) {
int index = hash(clz);
if (CACHE[index] == clz) {
return true;
}
CACHE[index] = clz;
}
return false;
} | [
"public",
"static",
"boolean",
"check",
"(",
"Class",
"<",
"?",
">",
"clz",
")",
"{",
"if",
"(",
"Config",
".",
"CACHE_SEEN_CLASSES_V",
")",
"{",
"int",
"index",
"=",
"hash",
"(",
"clz",
")",
";",
"if",
"(",
"CACHE",
"[",
"index",
"]",
"==",
"clz",... | Checks if the given class is in cache. If not, puts the class in the
cache and returns false; otherwise it returns true.
@param clz
Class object to search for in cache.
@return true if the given argument is in cache, false otherwise. | [
"Checks",
"if",
"the",
"given",
"class",
"is",
"in",
"cache",
".",
"If",
"not",
"puts",
"the",
"class",
"in",
"the",
"cache",
"and",
"returns",
"false",
";",
"otherwise",
"it",
"returns",
"true",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/monitor/ClassesCache.java#L48-L57 | train |
JamesIry/jADT | jADT-core/src/main/java/com/pogofish/jadt/sink/StringSinkFactory.java | StringSinkFactory.getResults | public Map<String, String> getResults() {
final Map<String, String> results = new HashMap<String, String>(sinks.size());
for (Map.Entry<String, StringSink> entry : sinks.entrySet()) {
results.put(entry.getKey(), entry.getValue().result());
}
return Collections.unmodifiableMap(results);
} | java | public Map<String, String> getResults() {
final Map<String, String> results = new HashMap<String, String>(sinks.size());
for (Map.Entry<String, StringSink> entry : sinks.entrySet()) {
results.put(entry.getKey(), entry.getValue().result());
}
return Collections.unmodifiableMap(results);
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getResults",
"(",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"results",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
"sinks",
".",
"size",
"(",
")",
")",
";",
... | Get the results as a Map from names to String data. The names are composed of
@return Map with results | [
"Get",
"the",
"results",
"as",
"a",
"Map",
"from",
"names",
"to",
"String",
"data",
".",
"The",
"names",
"are",
"composed",
"of"
] | 92ee94b6624cd673851497d78c218837dcf02b8a | https://github.com/JamesIry/jADT/blob/92ee94b6624cd673851497d78c218837dcf02b8a/jADT-core/src/main/java/com/pogofish/jadt/sink/StringSinkFactory.java#L52-L58 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java | AffectedChecker.main | public static void main(String[] args) {
// Parse arguments.
String coverageDirName = null;
if (args.length == 0) {
System.out.println("Incorrect arguments. Directory with coverage has to be specified.");
System.exit(1);
}
coverageDirName = args[0];
String mode = null;
if (args.length > 1) {
mode = args[1];
}
boolean forceCacheUse = false;
if (args.length > 2) {
forceCacheUse = args[2].equals(FORCE_CACHE_USE);
}
Set<String> allClasses = new HashSet<String>();
Set<String> affectedClasses = new HashSet<String>();
if (args.length > 3) {
String options = args[3];
Config.loadConfig(options, true);
} else {
Config.loadConfig();
}
List<String> nonAffectedClasses = findNonAffectedClasses(coverageDirName, forceCacheUse, allClasses, affectedClasses);
// Print non affected classes.
printNonAffectedClasses(allClasses, affectedClasses, nonAffectedClasses, mode);
} | java | public static void main(String[] args) {
// Parse arguments.
String coverageDirName = null;
if (args.length == 0) {
System.out.println("Incorrect arguments. Directory with coverage has to be specified.");
System.exit(1);
}
coverageDirName = args[0];
String mode = null;
if (args.length > 1) {
mode = args[1];
}
boolean forceCacheUse = false;
if (args.length > 2) {
forceCacheUse = args[2].equals(FORCE_CACHE_USE);
}
Set<String> allClasses = new HashSet<String>();
Set<String> affectedClasses = new HashSet<String>();
if (args.length > 3) {
String options = args[3];
Config.loadConfig(options, true);
} else {
Config.loadConfig();
}
List<String> nonAffectedClasses = findNonAffectedClasses(coverageDirName, forceCacheUse, allClasses, affectedClasses);
// Print non affected classes.
printNonAffectedClasses(allClasses, affectedClasses, nonAffectedClasses, mode);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"// Parse arguments.",
"String",
"coverageDirName",
"=",
"null",
";",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"In... | The user has to specify directory that keep coverage and optionally
mode that should be used to print non affected classes. | [
"The",
"user",
"has",
"to",
"specify",
"directory",
"that",
"keep",
"coverage",
"and",
"optionally",
"mode",
"that",
"should",
"be",
"used",
"to",
"print",
"non",
"affected",
"classes",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java#L68-L98 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java | AffectedChecker.findNonAffectedClasses | private static List<String> findNonAffectedClasses(String workingDirectory) {
Set<String> allClasses = new HashSet<String>();
Set<String> affectedClasses = new HashSet<String>();
loadConfig(workingDirectory);
// Find non affected classes.
List<String> nonAffectedClasses = findNonAffectedClasses(Config.ROOT_DIR_V, true, allClasses,
affectedClasses);
// Format list to include class names in expected format for Ant and Maven.
return formatNonAffectedClassesForAntAndMaven(nonAffectedClasses);
} | java | private static List<String> findNonAffectedClasses(String workingDirectory) {
Set<String> allClasses = new HashSet<String>();
Set<String> affectedClasses = new HashSet<String>();
loadConfig(workingDirectory);
// Find non affected classes.
List<String> nonAffectedClasses = findNonAffectedClasses(Config.ROOT_DIR_V, true, allClasses,
affectedClasses);
// Format list to include class names in expected format for Ant and Maven.
return formatNonAffectedClassesForAntAndMaven(nonAffectedClasses);
} | [
"private",
"static",
"List",
"<",
"String",
">",
"findNonAffectedClasses",
"(",
"String",
"workingDirectory",
")",
"{",
"Set",
"<",
"String",
">",
"allClasses",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"Set",
"<",
"String",
">",
"affectedC... | Returns list of non affected classes as discovered from the given
directory with dependencies. | [
"Returns",
"list",
"of",
"non",
"affected",
"classes",
"as",
"discovered",
"from",
"the",
"given",
"directory",
"with",
"dependencies",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java#L123-L132 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java | AffectedChecker.printNonAffectedClasses | private static void printNonAffectedClasses(Set<String> allClasses, Set<String> affectedClasses,
List<String> nonAffectedClasses, String mode) {
if (mode != null && mode.equals(ANT_MODE)) {
StringBuilder sb = new StringBuilder();
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude name=\"" + className + ".java\"/>");
}
System.out.println(sb);
} else if (mode != null && mode.equals(MAVEN_SIMPLE_MODE)) {
StringBuilder sb = new StringBuilder();
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude>");
sb.append(className).append(".java");
sb.append("</exclude>");
}
System.out.println(sb);
} else if (mode != null && mode.equals(MAVEN_MODE)) {
StringBuilder sb = new StringBuilder();
sb.append("<excludes>");
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude>");
sb.append(className).append(".java");
sb.append("</exclude>");
}
sb.append("</excludes>");
System.out.println(sb);
} else if (mode != null && mode.equals(DEBUG_MODE)) {
System.out.println("AFFECTED: " + affectedClasses);
System.out.println("NONAFFECTED: " + nonAffectedClasses);
} else {
for (String className : nonAffectedClasses) {
System.out.println(className);
}
}
} | java | private static void printNonAffectedClasses(Set<String> allClasses, Set<String> affectedClasses,
List<String> nonAffectedClasses, String mode) {
if (mode != null && mode.equals(ANT_MODE)) {
StringBuilder sb = new StringBuilder();
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude name=\"" + className + ".java\"/>");
}
System.out.println(sb);
} else if (mode != null && mode.equals(MAVEN_SIMPLE_MODE)) {
StringBuilder sb = new StringBuilder();
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude>");
sb.append(className).append(".java");
sb.append("</exclude>");
}
System.out.println(sb);
} else if (mode != null && mode.equals(MAVEN_MODE)) {
StringBuilder sb = new StringBuilder();
sb.append("<excludes>");
for (String className : nonAffectedClasses) {
className = className.replaceAll("\\.", "/");
sb.append("<exclude>");
sb.append(className).append(".java");
sb.append("</exclude>");
}
sb.append("</excludes>");
System.out.println(sb);
} else if (mode != null && mode.equals(DEBUG_MODE)) {
System.out.println("AFFECTED: " + affectedClasses);
System.out.println("NONAFFECTED: " + nonAffectedClasses);
} else {
for (String className : nonAffectedClasses) {
System.out.println(className);
}
}
} | [
"private",
"static",
"void",
"printNonAffectedClasses",
"(",
"Set",
"<",
"String",
">",
"allClasses",
",",
"Set",
"<",
"String",
">",
"affectedClasses",
",",
"List",
"<",
"String",
">",
"nonAffectedClasses",
",",
"String",
"mode",
")",
"{",
"if",
"(",
"mode"... | Prints non affected classes in the given mode. If mode is not specified,
one class is printed per line. | [
"Prints",
"non",
"affected",
"classes",
"in",
"the",
"given",
"mode",
".",
"If",
"mode",
"is",
"not",
"specified",
"one",
"class",
"is",
"printed",
"per",
"line",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java#L239-L276 | train |
gliga/ekstazi | org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java | AffectedChecker.includeAffected | private static void includeAffected(Set<String> allClasses, Set<String> affectedClasses, List<File> sortedFiles) {
Storer storer = Config.createStorer();
Hasher hasher = Config.createHasher();
NameBasedCheck classCheck = Config.DEBUG_MODE_V != Config.DebugMode.NONE ?
new DebugNameCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT) :
new NameBasedCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT);
NameBasedCheck covCheck = new NameBasedCheck(storer, hasher, DependencyAnalyzer.COV_EXT);
MethodCheck methodCheck = new MethodCheck(storer, hasher);
String prevClassName = null;
for (File file : sortedFiles) {
String fileName = file.getName();
String dirName = file.getParent();
String className = null;
if (file.isDirectory()) {
continue;
}
if (fileName.endsWith(DependencyAnalyzer.COV_EXT)) {
className = covCheck.includeAll(fileName, dirName);
} else if (fileName.endsWith(DependencyAnalyzer.CLASS_EXT)) {
className = classCheck.includeAll(fileName, dirName);
} else {
className = methodCheck.includeAll(fileName, dirName);
}
// Reset after some time to free space.
if (prevClassName != null && className != null && !prevClassName.equals(className)) {
methodCheck.includeAffected(affectedClasses);
methodCheck = new MethodCheck(Config.createStorer(), Config.createHasher());
}
if (className != null) {
allClasses.add(className);
prevClassName = className;
}
}
classCheck.includeAffected(affectedClasses);
covCheck.includeAffected(affectedClasses);
methodCheck.includeAffected(affectedClasses);
} | java | private static void includeAffected(Set<String> allClasses, Set<String> affectedClasses, List<File> sortedFiles) {
Storer storer = Config.createStorer();
Hasher hasher = Config.createHasher();
NameBasedCheck classCheck = Config.DEBUG_MODE_V != Config.DebugMode.NONE ?
new DebugNameCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT) :
new NameBasedCheck(storer, hasher, DependencyAnalyzer.CLASS_EXT);
NameBasedCheck covCheck = new NameBasedCheck(storer, hasher, DependencyAnalyzer.COV_EXT);
MethodCheck methodCheck = new MethodCheck(storer, hasher);
String prevClassName = null;
for (File file : sortedFiles) {
String fileName = file.getName();
String dirName = file.getParent();
String className = null;
if (file.isDirectory()) {
continue;
}
if (fileName.endsWith(DependencyAnalyzer.COV_EXT)) {
className = covCheck.includeAll(fileName, dirName);
} else if (fileName.endsWith(DependencyAnalyzer.CLASS_EXT)) {
className = classCheck.includeAll(fileName, dirName);
} else {
className = methodCheck.includeAll(fileName, dirName);
}
// Reset after some time to free space.
if (prevClassName != null && className != null && !prevClassName.equals(className)) {
methodCheck.includeAffected(affectedClasses);
methodCheck = new MethodCheck(Config.createStorer(), Config.createHasher());
}
if (className != null) {
allClasses.add(className);
prevClassName = className;
}
}
classCheck.includeAffected(affectedClasses);
covCheck.includeAffected(affectedClasses);
methodCheck.includeAffected(affectedClasses);
} | [
"private",
"static",
"void",
"includeAffected",
"(",
"Set",
"<",
"String",
">",
"allClasses",
",",
"Set",
"<",
"String",
">",
"affectedClasses",
",",
"List",
"<",
"File",
">",
"sortedFiles",
")",
"{",
"Storer",
"storer",
"=",
"Config",
".",
"createStorer",
... | Find all non affected classes. | [
"Find",
"all",
"non",
"affected",
"classes",
"."
] | 5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1 | https://github.com/gliga/ekstazi/blob/5bf4d39a13305afe62f8b8d2d7b4c573d37d42a1/org.ekstazi.core/src/main/java/org/ekstazi/check/AffectedChecker.java#L281-L318 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.