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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/simple/SimpleCrypt.java | SimpleCrypt.decode | public static String decode(final String toDecode, final int relocate)
{
final StringBuffer sb = new StringBuffer();
final char[] encrypt = toDecode.toCharArray();
final int arraylength = encrypt.length;
for (int i = 0; i < arraylength; i++)
{
final char a = (char)(encrypt[i] - relocate);
sb.append(a);
}
return sb.toString().trim();
} | java | public static String decode(final String toDecode, final int relocate)
{
final StringBuffer sb = new StringBuffer();
final char[] encrypt = toDecode.toCharArray();
final int arraylength = encrypt.length;
for (int i = 0; i < arraylength; i++)
{
final char a = (char)(encrypt[i] - relocate);
sb.append(a);
}
return sb.toString().trim();
} | [
"public",
"static",
"String",
"decode",
"(",
"final",
"String",
"toDecode",
",",
"final",
"int",
"relocate",
")",
"{",
"final",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"final",
"char",
"[",
"]",
"encrypt",
"=",
"toDecode",
".",
"... | Decrypt the given String.
@param toDecode
The String to decrypt.
@param relocate
How much places to switch.
@return The decrypted String. | [
"Decrypt",
"the",
"given",
"String",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/simple/SimpleCrypt.java#L60-L71 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/simple/SimpleCrypt.java | SimpleCrypt.encode | public static String encode(final String secret, final int relocate)
{
final StringBuffer sb = new StringBuffer();
final char[] encrypt = secret.toCharArray();
final int arraylength = encrypt.length;
for (int i = 0; i < arraylength; i++)
{
final char a = (char)(encrypt[i] + relocate);
sb.append(a);
}
return sb.toString().trim();
} | java | public static String encode(final String secret, final int relocate)
{
final StringBuffer sb = new StringBuffer();
final char[] encrypt = secret.toCharArray();
final int arraylength = encrypt.length;
for (int i = 0; i < arraylength; i++)
{
final char a = (char)(encrypt[i] + relocate);
sb.append(a);
}
return sb.toString().trim();
} | [
"public",
"static",
"String",
"encode",
"(",
"final",
"String",
"secret",
",",
"final",
"int",
"relocate",
")",
"{",
"final",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"final",
"char",
"[",
"]",
"encrypt",
"=",
"secret",
".",
"toCh... | Encrypt the given String.
@param secret
The String to encrypt.
@param relocate
How much places to switch.
@return The encrypted String. | [
"Encrypt",
"the",
"given",
"String",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/simple/SimpleCrypt.java#L94-L105 | train |
astrapi69/mystic-crypt | crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PublicKeyReader.java | PublicKeyReader.readPemPublicKey | public static PublicKey readPemPublicKey(final File file) throws IOException,
NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
{
final String publicKeyAsString = readPemFileAsBase64(file);
final byte[] decoded = Base64.decodeBase64(publicKeyAsString);
return readPublicKey(decoded);
} | java | public static PublicKey readPemPublicKey(final File file) throws IOException,
NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException
{
final String publicKeyAsString = readPemFileAsBase64(file);
final byte[] decoded = Base64.decodeBase64(publicKeyAsString);
return readPublicKey(decoded);
} | [
"public",
"static",
"PublicKey",
"readPemPublicKey",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
",",
"NoSuchAlgorithmException",
",",
"InvalidKeySpecException",
",",
"NoSuchProviderException",
"{",
"final",
"String",
"publicKeyAsString",
"=",
"readPemFile... | reads a public key from a file.
@param file
the file
@return the public key
@throws IOException
Signals that an I/O exception has occurred.
@throws NoSuchAlgorithmException
is thrown if instantiation of the cypher object fails.
@throws InvalidKeySpecException
is thrown if generation of the SecretKey object fails.
@throws NoSuchProviderException
is thrown if the specified provider is not registered in the security provider
list. | [
"reads",
"a",
"public",
"key",
"from",
"a",
"file",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PublicKeyReader.java#L141-L147 | train |
astrapi69/mystic-crypt | crypt-data/src/main/java/de/alpharogroup/crypto/key/PublicKeyExtensions.java | PublicKeyExtensions.toPemFormat | public static String toPemFormat(final PublicKey publicKey)
{
final String publicKeyAsBase64String = toBase64(publicKey);
final List<String> parts = StringExtensions.splitByFixedLength(publicKeyAsBase64String, 64);
final StringBuilder sb = new StringBuilder();
sb.append(PublicKeyReader.BEGIN_PUBLIC_KEY_PREFIX);
for (final String part : parts)
{
sb.append(part);
sb.append(System.lineSeparator());
}
sb.append(PublicKeyReader.END_PUBLIC_KEY_SUFFIX);
sb.append(System.lineSeparator());
return sb.toString();
} | java | public static String toPemFormat(final PublicKey publicKey)
{
final String publicKeyAsBase64String = toBase64(publicKey);
final List<String> parts = StringExtensions.splitByFixedLength(publicKeyAsBase64String, 64);
final StringBuilder sb = new StringBuilder();
sb.append(PublicKeyReader.BEGIN_PUBLIC_KEY_PREFIX);
for (final String part : parts)
{
sb.append(part);
sb.append(System.lineSeparator());
}
sb.append(PublicKeyReader.END_PUBLIC_KEY_SUFFIX);
sb.append(System.lineSeparator());
return sb.toString();
} | [
"public",
"static",
"String",
"toPemFormat",
"(",
"final",
"PublicKey",
"publicKey",
")",
"{",
"final",
"String",
"publicKeyAsBase64String",
"=",
"toBase64",
"(",
"publicKey",
")",
";",
"final",
"List",
"<",
"String",
">",
"parts",
"=",
"StringExtensions",
".",
... | Transform the public key in pem format.
@param publicKey
the public key
@return the public key in pem format | [
"Transform",
"the",
"public",
"key",
"in",
"pem",
"format",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/PublicKeyExtensions.java#L112-L127 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/io/AbstractThresholdingOutputStream.java | AbstractThresholdingOutputStream.checkThreshold | protected void checkThreshold (final int nCount) throws IOException
{
if (!m_bThresholdExceeded && (m_nWritten + nCount > m_nThreshold))
{
m_bThresholdExceeded = true;
onThresholdReached ();
}
} | java | protected void checkThreshold (final int nCount) throws IOException
{
if (!m_bThresholdExceeded && (m_nWritten + nCount > m_nThreshold))
{
m_bThresholdExceeded = true;
onThresholdReached ();
}
} | [
"protected",
"void",
"checkThreshold",
"(",
"final",
"int",
"nCount",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"m_bThresholdExceeded",
"&&",
"(",
"m_nWritten",
"+",
"nCount",
">",
"m_nThreshold",
")",
")",
"{",
"m_bThresholdExceeded",
"=",
"true",
";... | Checks to see if writing the specified number of bytes would cause the
configured threshold to be exceeded. If so, triggers an event to allow a
concrete implementation to take action on
@param nCount
The number of bytes about to be written to the underlying output
stream.
@exception IOException
if an error occurs. | [
"Checks",
"to",
"see",
"if",
"writing",
"the",
"specified",
"number",
"of",
"bytes",
"would",
"cause",
"the",
"configured",
"threshold",
"to",
"be",
"exceeded",
".",
"If",
"so",
"triggers",
"an",
"event",
"to",
"allow",
"a",
"concrete",
"implementation",
"to... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/io/AbstractThresholdingOutputStream.java#L208-L215 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockHttpServletResponse.java | MockHttpServletResponse.getHeaders | @Nonnull
public ICommonsList <String> getHeaders (@Nullable final String sName)
{
return new CommonsArrayList <> (m_aHeaders.get (_unifyHeaderName (sName)));
} | java | @Nonnull
public ICommonsList <String> getHeaders (@Nullable final String sName)
{
return new CommonsArrayList <> (m_aHeaders.get (_unifyHeaderName (sName)));
} | [
"@",
"Nonnull",
"public",
"ICommonsList",
"<",
"String",
">",
"getHeaders",
"(",
"@",
"Nullable",
"final",
"String",
"sName",
")",
"{",
"return",
"new",
"CommonsArrayList",
"<>",
"(",
"m_aHeaders",
".",
"get",
"(",
"_unifyHeaderName",
"(",
"sName",
")",
")",... | Return all values for the given header as a List of value objects.
@param sName
the name of the header
@return the associated header values, or an empty List if none | [
"Return",
"all",
"values",
"for",
"the",
"given",
"header",
"as",
"a",
"List",
"of",
"value",
"objects",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockHttpServletResponse.java#L398-L402 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/session/SessionHelper.java | SessionHelper.safeInvalidateSession | @Nonnull
public static EChange safeInvalidateSession (@Nullable final HttpSession aSession)
{
if (aSession != null)
{
try
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Invalidating session " + aSession.getId ());
aSession.invalidate ();
return EChange.CHANGED;
}
catch (final IllegalStateException ex)
{
// session already invalidated
}
}
return EChange.UNCHANGED;
} | java | @Nonnull
public static EChange safeInvalidateSession (@Nullable final HttpSession aSession)
{
if (aSession != null)
{
try
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Invalidating session " + aSession.getId ());
aSession.invalidate ();
return EChange.CHANGED;
}
catch (final IllegalStateException ex)
{
// session already invalidated
}
}
return EChange.UNCHANGED;
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"safeInvalidateSession",
"(",
"@",
"Nullable",
"final",
"HttpSession",
"aSession",
")",
"{",
"if",
"(",
"aSession",
"!=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")"... | Invalidate the session if the session is still active.
@param aSession
The session to be invalidated. May be <code>null</code>.
@return {@link EChange#CHANGED} if the session was invalidated,
{@link EChange#UNCHANGED} otherwise. | [
"Invalidate",
"the",
"session",
"if",
"the",
"session",
"is",
"still",
"active",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/session/SessionHelper.java#L60-L78 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/session/SessionHelper.java | SessionHelper.getAllAttributes | @Nonnull
public static Enumeration <String> getAllAttributes (@Nonnull final HttpSession aSession)
{
ValueEnforcer.notNull (aSession, "Session");
try
{
return GenericReflection.uncheckedCast (aSession.getAttributeNames ());
}
catch (final IllegalStateException ex)
{
// Session no longer valid
return new EmptyEnumeration <> ();
}
} | java | @Nonnull
public static Enumeration <String> getAllAttributes (@Nonnull final HttpSession aSession)
{
ValueEnforcer.notNull (aSession, "Session");
try
{
return GenericReflection.uncheckedCast (aSession.getAttributeNames ());
}
catch (final IllegalStateException ex)
{
// Session no longer valid
return new EmptyEnumeration <> ();
}
} | [
"@",
"Nonnull",
"public",
"static",
"Enumeration",
"<",
"String",
">",
"getAllAttributes",
"(",
"@",
"Nonnull",
"final",
"HttpSession",
"aSession",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aSession",
",",
"\"Session\"",
")",
";",
"try",
"{",
"return",
... | Get all attribute names present in the specified session.
@param aSession
The session to use. May not be <code>null</code>.
@return Never <code>null</code>. | [
"Get",
"all",
"attribute",
"names",
"present",
"in",
"the",
"specified",
"session",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/session/SessionHelper.java#L87-L101 | train |
phax/ph-web | ph-sitemap/src/main/java/com/helger/sitemap/XMLSitemapIndex.java | XMLSitemapIndex.getAsDocument | @Nonnull
public IMicroDocument getAsDocument (@Nonnull @Nonempty final String sFullContextPath)
{
final String sNamespaceURL = CXMLSitemap.XML_NAMESPACE_0_9;
final IMicroDocument ret = new MicroDocument ();
final IMicroElement eSitemapindex = ret.appendElement (sNamespaceURL, ELEMENT_SITEMAPINDEX);
int nIndex = 0;
for (final XMLSitemapURLSet aURLSet : m_aURLSets)
{
final IMicroElement eSitemap = eSitemapindex.appendElement (sNamespaceURL, ELEMENT_SITEMAP);
// The location of the sub-sitemaps must be prefixed with the full server
// and context path
eSitemap.appendElement (sNamespaceURL, ELEMENT_LOC)
.appendText (sFullContextPath + "/" + getSitemapFilename (nIndex));
final LocalDateTime aLastModification = aURLSet.getLastModificationDateTime ();
if (aLastModification != null)
{
eSitemap.appendElement (sNamespaceURL, ELEMENT_LASTMOD)
.appendText (PDTWebDateHelper.getAsStringXSD (aLastModification));
}
++nIndex;
}
return ret;
} | java | @Nonnull
public IMicroDocument getAsDocument (@Nonnull @Nonempty final String sFullContextPath)
{
final String sNamespaceURL = CXMLSitemap.XML_NAMESPACE_0_9;
final IMicroDocument ret = new MicroDocument ();
final IMicroElement eSitemapindex = ret.appendElement (sNamespaceURL, ELEMENT_SITEMAPINDEX);
int nIndex = 0;
for (final XMLSitemapURLSet aURLSet : m_aURLSets)
{
final IMicroElement eSitemap = eSitemapindex.appendElement (sNamespaceURL, ELEMENT_SITEMAP);
// The location of the sub-sitemaps must be prefixed with the full server
// and context path
eSitemap.appendElement (sNamespaceURL, ELEMENT_LOC)
.appendText (sFullContextPath + "/" + getSitemapFilename (nIndex));
final LocalDateTime aLastModification = aURLSet.getLastModificationDateTime ();
if (aLastModification != null)
{
eSitemap.appendElement (sNamespaceURL, ELEMENT_LASTMOD)
.appendText (PDTWebDateHelper.getAsStringXSD (aLastModification));
}
++nIndex;
}
return ret;
} | [
"@",
"Nonnull",
"public",
"IMicroDocument",
"getAsDocument",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sFullContextPath",
")",
"{",
"final",
"String",
"sNamespaceURL",
"=",
"CXMLSitemap",
".",
"XML_NAMESPACE_0_9",
";",
"final",
"IMicroDocument",
"ret... | Get the Index as a micro document.
@param sFullContextPath
Full context path like <code>scheme://server:port/context</code> or
<code>scheme://server:port</code> for the ROOT context.
@return The created micro document and never <code>null</code>. | [
"Get",
"the",
"Index",
"as",
"a",
"micro",
"document",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-sitemap/src/main/java/com/helger/sitemap/XMLSitemapIndex.java#L181-L206 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/scope/singleton/AbstractSessionWebSingleton.java | AbstractSessionWebSingleton.getSessionSingleton | @Nonnull
public static final <T extends AbstractSessionWebSingleton> T getSessionSingleton (@Nonnull final Class <T> aClass)
{
return getSingleton (_getStaticScope (true), aClass);
} | java | @Nonnull
public static final <T extends AbstractSessionWebSingleton> T getSessionSingleton (@Nonnull final Class <T> aClass)
{
return getSingleton (_getStaticScope (true), aClass);
} | [
"@",
"Nonnull",
"public",
"static",
"final",
"<",
"T",
"extends",
"AbstractSessionWebSingleton",
">",
"T",
"getSessionSingleton",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"T",
">",
"aClass",
")",
"{",
"return",
"getSingleton",
"(",
"_getStaticScope",
"(",
"... | Get the singleton object in the current session web scope, using the passed
class. If the singleton is not yet instantiated, a new instance is created.
@param <T>
The type to be returned
@param aClass
The class to be used. May not be <code>null</code>. The class must
be public as needs to have a public no-argument constructor.
@return The singleton object and never <code>null</code>. | [
"Get",
"the",
"singleton",
"object",
"in",
"the",
"current",
"session",
"web",
"scope",
"using",
"the",
"passed",
"class",
".",
"If",
"the",
"singleton",
"is",
"not",
"yet",
"instantiated",
"a",
"new",
"instance",
"is",
"created",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/scope/singleton/AbstractSessionWebSingleton.java#L79-L83 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/GLImplementation.java | GLImplementation.load | @SuppressWarnings("unchecked")
public static boolean load(GLImplementation implementation) {
try {
final Constructor<?> constructor = Class.forName(implementation.getContextName()).getDeclaredConstructor();
constructor.setAccessible(true);
implementations.put(implementation, (Constructor<Context>) constructor);
return true;
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
CausticUtil.getCausticLogger().log(Level.WARNING, "Couldn't load implementation", ex);
return false;
}
} | java | @SuppressWarnings("unchecked")
public static boolean load(GLImplementation implementation) {
try {
final Constructor<?> constructor = Class.forName(implementation.getContextName()).getDeclaredConstructor();
constructor.setAccessible(true);
implementations.put(implementation, (Constructor<Context>) constructor);
return true;
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
CausticUtil.getCausticLogger().log(Level.WARNING, "Couldn't load implementation", ex);
return false;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"boolean",
"load",
"(",
"GLImplementation",
"implementation",
")",
"{",
"try",
"{",
"final",
"Constructor",
"<",
"?",
">",
"constructor",
"=",
"Class",
".",
"forName",
"(",
"implementation",... | Loads the implementation, making it accessible.
@param implementation The implementation to load
@return Whether or not the loading succeeded | [
"Loads",
"the",
"implementation",
"making",
"it",
"accessible",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/GLImplementation.java#L81-L92 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java | MockServletPool.registerServlet | public void registerServlet (@Nonnull final Class <? extends Servlet> aServletClass,
@Nonnull @Nonempty final String sServletPath,
@Nonnull @Nonempty final String sServletName)
{
registerServlet (aServletClass, sServletPath, sServletName, (Map <String, String>) null);
} | java | public void registerServlet (@Nonnull final Class <? extends Servlet> aServletClass,
@Nonnull @Nonempty final String sServletPath,
@Nonnull @Nonempty final String sServletName)
{
registerServlet (aServletClass, sServletPath, sServletName, (Map <String, String>) null);
} | [
"public",
"void",
"registerServlet",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"?",
"extends",
"Servlet",
">",
"aServletClass",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sServletPath",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
... | Register a new servlet without servlet init parameters
@param aServletClass
The class of the servlet to be registered. May not be
<code>null</code>.
@param sServletPath
The path where the servlet should listen to requests. May neither be
<code>null</code> nor empty.
@param sServletName
The name of the servlet. May neither be <code>null</code> nor empty. | [
"Register",
"a",
"new",
"servlet",
"without",
"servlet",
"init",
"parameters"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java#L139-L144 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java | MockServletPool.registerServlet | public void registerServlet (@Nonnull final Class <? extends Servlet> aServletClass,
@Nonnull @Nonempty final String sServletPath,
@Nonnull @Nonempty final String sServletName,
@Nullable final Map <String, String> aServletInitParams)
{
ValueEnforcer.notNull (aServletClass, "ServletClass");
ValueEnforcer.notEmpty (sServletPath, "ServletPath");
for (final ServletItem aItem : m_aServlets)
{
// Check path uniqueness
if (aItem.getServletPath ().equals (sServletPath))
throw new IllegalArgumentException ("Another servlet with the path '" +
sServletPath +
"' is already registered: " +
aItem);
// Check name uniqueness
if (aItem.getServletName ().equals (sServletName))
throw new IllegalArgumentException ("Another servlet with the name '" +
sServletName +
"' is already registered: " +
aItem);
}
// Instantiate servlet
final Servlet aServlet = GenericReflection.newInstance (aServletClass);
if (aServlet == null)
throw new IllegalArgumentException ("Failed to instantiate servlet class " + aServletClass);
final ServletConfig aServletConfig = m_aSC.createServletConfig (sServletName, aServletInitParams);
try
{
aServlet.init (aServletConfig);
}
catch (final ServletException ex)
{
throw new IllegalStateException ("Failed to init servlet " +
aServlet +
" with configuration " +
aServletConfig +
" for path '" +
sServletPath +
"'");
}
m_aServlets.add (new ServletItem (aServlet, sServletPath));
} | java | public void registerServlet (@Nonnull final Class <? extends Servlet> aServletClass,
@Nonnull @Nonempty final String sServletPath,
@Nonnull @Nonempty final String sServletName,
@Nullable final Map <String, String> aServletInitParams)
{
ValueEnforcer.notNull (aServletClass, "ServletClass");
ValueEnforcer.notEmpty (sServletPath, "ServletPath");
for (final ServletItem aItem : m_aServlets)
{
// Check path uniqueness
if (aItem.getServletPath ().equals (sServletPath))
throw new IllegalArgumentException ("Another servlet with the path '" +
sServletPath +
"' is already registered: " +
aItem);
// Check name uniqueness
if (aItem.getServletName ().equals (sServletName))
throw new IllegalArgumentException ("Another servlet with the name '" +
sServletName +
"' is already registered: " +
aItem);
}
// Instantiate servlet
final Servlet aServlet = GenericReflection.newInstance (aServletClass);
if (aServlet == null)
throw new IllegalArgumentException ("Failed to instantiate servlet class " + aServletClass);
final ServletConfig aServletConfig = m_aSC.createServletConfig (sServletName, aServletInitParams);
try
{
aServlet.init (aServletConfig);
}
catch (final ServletException ex)
{
throw new IllegalStateException ("Failed to init servlet " +
aServlet +
" with configuration " +
aServletConfig +
" for path '" +
sServletPath +
"'");
}
m_aServlets.add (new ServletItem (aServlet, sServletPath));
} | [
"public",
"void",
"registerServlet",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"?",
"extends",
"Servlet",
">",
"aServletClass",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sServletPath",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
... | Register a new servlet
@param aServletClass
The class of the servlet to be registered. May not be
<code>null</code>.
@param sServletPath
The path where the servlet should listen to requests. May neither be
<code>null</code> nor empty.
@param sServletName
The name of the servlet. May neither be <code>null</code> nor empty.
@param aServletInitParams
An optional map of servlet init parameters. May be <code>null</code>
or empty. | [
"Register",
"a",
"new",
"servlet"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java#L161-L206 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java | MockServletPool.getServletOfPath | @Nullable
public Servlet getServletOfPath (@Nullable final String sPath)
{
final ICommonsList <ServletItem> aMatchingItems = new CommonsArrayList <> ();
if (StringHelper.hasText (sPath))
m_aServlets.findAll (aItem -> aItem.matchesPath (sPath), aMatchingItems::add);
final int nMatchingItems = aMatchingItems.size ();
if (nMatchingItems == 0)
return null;
if (nMatchingItems > 1)
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Found more than 1 servlet matching path '" + sPath + "' - using first one: " + aMatchingItems);
return aMatchingItems.getFirst ().getServlet ();
} | java | @Nullable
public Servlet getServletOfPath (@Nullable final String sPath)
{
final ICommonsList <ServletItem> aMatchingItems = new CommonsArrayList <> ();
if (StringHelper.hasText (sPath))
m_aServlets.findAll (aItem -> aItem.matchesPath (sPath), aMatchingItems::add);
final int nMatchingItems = aMatchingItems.size ();
if (nMatchingItems == 0)
return null;
if (nMatchingItems > 1)
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Found more than 1 servlet matching path '" + sPath + "' - using first one: " + aMatchingItems);
return aMatchingItems.getFirst ().getServlet ();
} | [
"@",
"Nullable",
"public",
"Servlet",
"getServletOfPath",
"(",
"@",
"Nullable",
"final",
"String",
"sPath",
")",
"{",
"final",
"ICommonsList",
"<",
"ServletItem",
">",
"aMatchingItems",
"=",
"new",
"CommonsArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"StringHel... | Find the servlet matching the specified path.
@param sPath
The path, relative to the servlet context. May be <code>null</code>.
@return <code>null</code> if no {@link Servlet} matching the specified path
was found. If more than one matching servlet was found, the first
one is returned. | [
"Find",
"the",
"servlet",
"matching",
"the",
"specified",
"path",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java#L217-L230 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java | MockServletPool.invalidate | public void invalidate ()
{
if (m_bInvalidated)
throw new IllegalArgumentException ("Servlet pool already invalidated!");
m_bInvalidated = true;
// Destroy all servlets
for (final ServletItem aServletItem : m_aServlets)
try
{
aServletItem.getServlet ().destroy ();
}
catch (final Exception ex)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Failed to destroy servlet " + aServletItem, ex);
}
m_aServlets.clear ();
} | java | public void invalidate ()
{
if (m_bInvalidated)
throw new IllegalArgumentException ("Servlet pool already invalidated!");
m_bInvalidated = true;
// Destroy all servlets
for (final ServletItem aServletItem : m_aServlets)
try
{
aServletItem.getServlet ().destroy ();
}
catch (final Exception ex)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Failed to destroy servlet " + aServletItem, ex);
}
m_aServlets.clear ();
} | [
"public",
"void",
"invalidate",
"(",
")",
"{",
"if",
"(",
"m_bInvalidated",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Servlet pool already invalidated!\"",
")",
";",
"m_bInvalidated",
"=",
"true",
";",
"// Destroy all servlets",
"for",
"(",
"final",
"... | Invalidate the servlet pool, by destroying all contained servlets. Also the
list of registered servlets is cleared. | [
"Invalidate",
"the",
"servlet",
"pool",
"by",
"destroying",
"all",
"contained",
"servlets",
".",
"Also",
"the",
"list",
"of",
"registered",
"servlets",
"is",
"cleared",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockServletPool.java#L236-L255 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHSamRecordIterator.java | GA4GHSamRecordIterator.queryNextInterval | ReadIteratorResource<Read, ReadGroupSet, Reference> queryNextInterval() {
Stopwatch w = Stopwatch.createStarted();
if (!isAtEnd()) {
intervalIndex++;
}
if (isAtEnd()) {
return null;
}
ReadIteratorResource<Read, ReadGroupSet, Reference> result =
queryForInterval(currentInterval());
LOG.info("Interval query took: " + w);
startTiming();
return result;
} | java | ReadIteratorResource<Read, ReadGroupSet, Reference> queryNextInterval() {
Stopwatch w = Stopwatch.createStarted();
if (!isAtEnd()) {
intervalIndex++;
}
if (isAtEnd()) {
return null;
}
ReadIteratorResource<Read, ReadGroupSet, Reference> result =
queryForInterval(currentInterval());
LOG.info("Interval query took: " + w);
startTiming();
return result;
} | [
"ReadIteratorResource",
"<",
"Read",
",",
"ReadGroupSet",
",",
"Reference",
">",
"queryNextInterval",
"(",
")",
"{",
"Stopwatch",
"w",
"=",
"Stopwatch",
".",
"createStarted",
"(",
")",
";",
"if",
"(",
"!",
"isAtEnd",
"(",
")",
")",
"{",
"intervalIndex",
"+... | Re-queries the API for the next interval | [
"Re",
"-",
"queries",
"the",
"API",
"for",
"the",
"next",
"interval"
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHSamRecordIterator.java#L82-L95 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHSamRecordIterator.java | GA4GHSamRecordIterator.queryForInterval | ReadIteratorResource<Read, ReadGroupSet, Reference> queryForInterval(GA4GHQueryInterval interval) {
try {
return dataSource.getReads(readSetId, interval.getSequence(),
interval.getStart(), interval.getEnd());
} catch (Exception ex) {
LOG.warning("Error getting data for interval " + ex.toString());
}
return null;
} | java | ReadIteratorResource<Read, ReadGroupSet, Reference> queryForInterval(GA4GHQueryInterval interval) {
try {
return dataSource.getReads(readSetId, interval.getSequence(),
interval.getStart(), interval.getEnd());
} catch (Exception ex) {
LOG.warning("Error getting data for interval " + ex.toString());
}
return null;
} | [
"ReadIteratorResource",
"<",
"Read",
",",
"ReadGroupSet",
",",
"Reference",
">",
"queryForInterval",
"(",
"GA4GHQueryInterval",
"interval",
")",
"{",
"try",
"{",
"return",
"dataSource",
".",
"getReads",
"(",
"readSetId",
",",
"interval",
".",
"getSequence",
"(",
... | Queries the API for an interval and returns the iterator resource, or null if failed | [
"Queries",
"the",
"API",
"for",
"an",
"interval",
"and",
"returns",
"the",
"iterator",
"resource",
"or",
"null",
"if",
"failed"
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHSamRecordIterator.java#L98-L106 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHSamRecordIterator.java | GA4GHSamRecordIterator.seekMatchingRead | void seekMatchingRead() {
while (!isAtEnd()) {
if (iterator == null || !iterator.hasNext()) {
LOG.info("Getting " +
(iterator == null ? "first" : "next") +
" interval from the API");
// We have hit an end (or this is first time) so we need to go fish
// to the API.
ReadIteratorResource<Read, ReadGroupSet, Reference> resource = queryNextInterval();
if (resource != null) {
LOG.info("Got next interval from the API");
header = resource.getSAMFileHeader();
iterator = resource.getSAMRecordIterable().iterator();
} else {
LOG.info("Failed to get next interval from the API");
header = null;
iterator = null;
}
} else {
nextRead = iterator.next();
if (currentInterval().matches(nextRead)) {
return; // Happy case, otherwise we keep spinning in the loop.
} else {
LOG.info("Skipping non matching read");
}
}
}
} | java | void seekMatchingRead() {
while (!isAtEnd()) {
if (iterator == null || !iterator.hasNext()) {
LOG.info("Getting " +
(iterator == null ? "first" : "next") +
" interval from the API");
// We have hit an end (or this is first time) so we need to go fish
// to the API.
ReadIteratorResource<Read, ReadGroupSet, Reference> resource = queryNextInterval();
if (resource != null) {
LOG.info("Got next interval from the API");
header = resource.getSAMFileHeader();
iterator = resource.getSAMRecordIterable().iterator();
} else {
LOG.info("Failed to get next interval from the API");
header = null;
iterator = null;
}
} else {
nextRead = iterator.next();
if (currentInterval().matches(nextRead)) {
return; // Happy case, otherwise we keep spinning in the loop.
} else {
LOG.info("Skipping non matching read");
}
}
}
} | [
"void",
"seekMatchingRead",
"(",
")",
"{",
"while",
"(",
"!",
"isAtEnd",
"(",
")",
")",
"{",
"if",
"(",
"iterator",
"==",
"null",
"||",
"!",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Getting \"",
"+",
"(",
"iterato... | Ensures next returned read will match the currently requested interval.
Since the API always returns overlapping reads we might need to skip some
reads if the interval asks for "included" or "starts at" types.
Also deals with the case of iterator being at an end and needing to query
for the next interval. | [
"Ensures",
"next",
"returned",
"read",
"will",
"match",
"the",
"currently",
"requested",
"interval",
".",
"Since",
"the",
"API",
"always",
"returns",
"overlapping",
"reads",
"we",
"might",
"need",
"to",
"skip",
"some",
"reads",
"if",
"the",
"interval",
"asks",... | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHSamRecordIterator.java#L115-L142 | train |
phax/ph-web | ph-http/src/main/java/com/helger/http/CacheControlBuilder.java | CacheControlBuilder.setMaxAge | @Nonnull
public CacheControlBuilder setMaxAge (@Nonnull final TimeUnit eTimeUnit, final long nDuration)
{
return setMaxAgeSeconds (eTimeUnit.toSeconds (nDuration));
} | java | @Nonnull
public CacheControlBuilder setMaxAge (@Nonnull final TimeUnit eTimeUnit, final long nDuration)
{
return setMaxAgeSeconds (eTimeUnit.toSeconds (nDuration));
} | [
"@",
"Nonnull",
"public",
"CacheControlBuilder",
"setMaxAge",
"(",
"@",
"Nonnull",
"final",
"TimeUnit",
"eTimeUnit",
",",
"final",
"long",
"nDuration",
")",
"{",
"return",
"setMaxAgeSeconds",
"(",
"eTimeUnit",
".",
"toSeconds",
"(",
"nDuration",
")",
")",
";",
... | Set the maximum age relative to the request time
@param eTimeUnit
{@link TimeUnit} to use
@param nDuration
The duration in the passed unit
@return this | [
"Set",
"the",
"maximum",
"age",
"relative",
"to",
"the",
"request",
"time"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-http/src/main/java/com/helger/http/CacheControlBuilder.java#L93-L97 | train |
khmarbaise/sapm | src/main/java/com/soebes/subversion/sapm/Groups.java | Groups.hasGroup | public boolean hasGroup(String groupName) {
boolean result = false;
for (Group item : getGroupsList()) {
if (item.getName().equals(groupName)) {
result = true;
}
}
return result;
} | java | public boolean hasGroup(String groupName) {
boolean result = false;
for (Group item : getGroupsList()) {
if (item.getName().equals(groupName)) {
result = true;
}
}
return result;
} | [
"public",
"boolean",
"hasGroup",
"(",
"String",
"groupName",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"for",
"(",
"Group",
"item",
":",
"getGroupsList",
"(",
")",
")",
"{",
"if",
"(",
"item",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"gr... | Check if a group with the given groupName exists in the
list or not.
The check will be done case-sensitive.
@param groupName The name we are searching for.
@return true if the group has been found false otherwise. | [
"Check",
"if",
"a",
"group",
"with",
"the",
"given",
"groupName",
"exists",
"in",
"the",
"list",
"or",
"not",
".",
"The",
"check",
"will",
"be",
"done",
"case",
"-",
"sensitive",
"."
] | b5da5b0d8929324f03cb3a4233a3534813f93eea | https://github.com/khmarbaise/sapm/blob/b5da5b0d8929324f03cb3a4233a3534813f93eea/src/main/java/com/soebes/subversion/sapm/Groups.java#L66-L74 | train |
khmarbaise/sapm | src/main/java/com/soebes/subversion/sapm/Groups.java | Groups.getGroup | public Group getGroup(String groupName) {
Group result = null;
for (Group item : getGroupsList()) {
if (item.getName().equals(groupName)) {
result = item;
}
}
return result;
} | java | public Group getGroup(String groupName) {
Group result = null;
for (Group item : getGroupsList()) {
if (item.getName().equals(groupName)) {
result = item;
}
}
return result;
} | [
"public",
"Group",
"getGroup",
"(",
"String",
"groupName",
")",
"{",
"Group",
"result",
"=",
"null",
";",
"for",
"(",
"Group",
"item",
":",
"getGroupsList",
"(",
")",
")",
"{",
"if",
"(",
"item",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"groupNa... | Get the Group instance from the list by
name.
@param groupName The group for which will be searched.
@return The Group instance for the given group name. | [
"Get",
"the",
"Group",
"instance",
"from",
"the",
"list",
"by",
"name",
"."
] | b5da5b0d8929324f03cb3a4233a3534813f93eea | https://github.com/khmarbaise/sapm/blob/b5da5b0d8929324f03cb3a4233a3534813f93eea/src/main/java/com/soebes/subversion/sapm/Groups.java#L86-L94 | train |
jianlins/FastContext | src/main/java/edu/utah/bmi/nlp/fastcontext/ContextRuleProcessor.java | ContextRuleProcessor.processDigits | protected void processDigits(List<Span> contextTokens, char compare, HashMap rule, int matchBegin, int currentPosition,
LinkedHashMap<String, ConTextSpan> matches) {
mt = pdigit.matcher(contextTokens.get(currentPosition).text);
if (mt.find()) {
double thisDigit;
// prevent length over limit
if (mt.group(1).length() < 4) {
String a = mt.group(1);
thisDigit = Double.parseDouble(mt.group(1));
} else {
thisDigit = 1000;
}
Set<String> numbers = rule.keySet();
for (String num : numbers) {
double ruleDigit = Double.parseDouble(num);
if ((compare == '>' && thisDigit > ruleDigit) || (compare == '<' && thisDigit < ruleDigit)) {
if (mt.group(2) == null) {
// if this token is a number
processRules(contextTokens, (HashMap) rule.get(num), matchBegin, currentPosition + 1, matches);
} else {
// thisToken is like "30-days"
HashMap ruletmp = (HashMap) rule.get(ruleDigit + "");
String subtoken = mt.group(2).substring(1);
if (ruletmp.containsKey(subtoken)) {
processRules(contextTokens, (HashMap) ruletmp.get(subtoken), matchBegin, currentPosition + 1, matches);
}
}
}
}
}
} | java | protected void processDigits(List<Span> contextTokens, char compare, HashMap rule, int matchBegin, int currentPosition,
LinkedHashMap<String, ConTextSpan> matches) {
mt = pdigit.matcher(contextTokens.get(currentPosition).text);
if (mt.find()) {
double thisDigit;
// prevent length over limit
if (mt.group(1).length() < 4) {
String a = mt.group(1);
thisDigit = Double.parseDouble(mt.group(1));
} else {
thisDigit = 1000;
}
Set<String> numbers = rule.keySet();
for (String num : numbers) {
double ruleDigit = Double.parseDouble(num);
if ((compare == '>' && thisDigit > ruleDigit) || (compare == '<' && thisDigit < ruleDigit)) {
if (mt.group(2) == null) {
// if this token is a number
processRules(contextTokens, (HashMap) rule.get(num), matchBegin, currentPosition + 1, matches);
} else {
// thisToken is like "30-days"
HashMap ruletmp = (HashMap) rule.get(ruleDigit + "");
String subtoken = mt.group(2).substring(1);
if (ruletmp.containsKey(subtoken)) {
processRules(contextTokens, (HashMap) ruletmp.get(subtoken), matchBegin, currentPosition + 1, matches);
}
}
}
}
}
} | [
"protected",
"void",
"processDigits",
"(",
"List",
"<",
"Span",
">",
"contextTokens",
",",
"char",
"compare",
",",
"HashMap",
"rule",
",",
"int",
"matchBegin",
",",
"int",
"currentPosition",
",",
"LinkedHashMap",
"<",
"String",
",",
"ConTextSpan",
">",
"matche... | Because the digit regular expressions are revised into the format like
"> 13 days", the rulesMap need to be handled differently to the token
matching
rulesMap
@param contextTokens The context tokens in an ArrayList of String
@param compare great than or less than for numeric compare
@param rule Constructed Rules Map
@param matchBegin Keep track of the begin position of matched span
@param currentPosition Keep track of the position where matching starts
@param matches Storing the matched context spans | [
"Because",
"the",
"digit",
"regular",
"expressions",
"are",
"revised",
"into",
"the",
"format",
"like",
">",
";",
"13",
"days",
"the",
"rulesMap",
"need",
"to",
"be",
"handled",
"differently",
"to",
"the",
"token",
"matching",
"rulesMap"
] | e3f7cfa7e6eb69bbeb49a51021d8ec5613654fc8 | https://github.com/jianlins/FastContext/blob/e3f7cfa7e6eb69bbeb49a51021d8ec5613654fc8/src/main/java/edu/utah/bmi/nlp/fastcontext/ContextRuleProcessor.java#L260-L290 | train |
googlegenomics/gatk-tools-java | src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHQueryInterval.java | GA4GHQueryInterval.matches | public boolean matches(SAMRecord record) {
int myEnd = end == 0 ? Integer.MAX_VALUE : end;
switch (readPositionConstraint) {
case OVERLAPPING:
return CoordMath.overlaps(start, myEnd,
record.getAlignmentStart(), record.getAlignmentEnd());
case CONTAINED:
return CoordMath.encloses(start, myEnd,
record.getAlignmentStart(), record.getAlignmentEnd());
case START_AT:
return start == record.getAlignmentStart();
}
return false;
} | java | public boolean matches(SAMRecord record) {
int myEnd = end == 0 ? Integer.MAX_VALUE : end;
switch (readPositionConstraint) {
case OVERLAPPING:
return CoordMath.overlaps(start, myEnd,
record.getAlignmentStart(), record.getAlignmentEnd());
case CONTAINED:
return CoordMath.encloses(start, myEnd,
record.getAlignmentStart(), record.getAlignmentEnd());
case START_AT:
return start == record.getAlignmentStart();
}
return false;
} | [
"public",
"boolean",
"matches",
"(",
"SAMRecord",
"record",
")",
"{",
"int",
"myEnd",
"=",
"end",
"==",
"0",
"?",
"Integer",
".",
"MAX_VALUE",
":",
"end",
";",
"switch",
"(",
"readPositionConstraint",
")",
"{",
"case",
"OVERLAPPING",
":",
"return",
"CoordM... | Returns true iff the read specified by the record matches the interval
given the interval's constraints and the read position. | [
"Returns",
"true",
"iff",
"the",
"read",
"specified",
"by",
"the",
"record",
"matches",
"the",
"interval",
"given",
"the",
"interval",
"s",
"constraints",
"and",
"the",
"read",
"position",
"."
] | 5521664e8d6274b113962659f2737c27cc361065 | https://github.com/googlegenomics/gatk-tools-java/blob/5521664e8d6274b113962659f2737c27cc361065/src/main/java/com/google/cloud/genomics/gatk/htsjdk/GA4GHQueryInterval.java#L83-L96 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/ServletContextPathHolder.java | ServletContextPathHolder.clearContextPath | public static void clearContextPath ()
{
if (s_sServletContextPath != null)
{
if (LOGGER.isInfoEnabled () && !isSilentMode ())
LOGGER.info ("The servlet context path '" + s_sServletContextPath + "' was cleared!");
s_sServletContextPath = null;
}
if (s_sCustomContextPath != null)
{
if (LOGGER.isInfoEnabled () && !isSilentMode ())
LOGGER.info ("The custom servlet context path '" + s_sCustomContextPath + "' was cleared!");
s_sCustomContextPath = null;
}
} | java | public static void clearContextPath ()
{
if (s_sServletContextPath != null)
{
if (LOGGER.isInfoEnabled () && !isSilentMode ())
LOGGER.info ("The servlet context path '" + s_sServletContextPath + "' was cleared!");
s_sServletContextPath = null;
}
if (s_sCustomContextPath != null)
{
if (LOGGER.isInfoEnabled () && !isSilentMode ())
LOGGER.info ("The custom servlet context path '" + s_sCustomContextPath + "' was cleared!");
s_sCustomContextPath = null;
}
} | [
"public",
"static",
"void",
"clearContextPath",
"(",
")",
"{",
"if",
"(",
"s_sServletContextPath",
"!=",
"null",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
"(",
")",
"&&",
"!",
"isSilentMode",
"(",
")",
")",
"LOGGER",
".",
"info",
"(",
"\"The s... | Clears both servlet context and custom context path. | [
"Clears",
"both",
"servlet",
"context",
"and",
"custom",
"context",
"path",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/ServletContextPathHolder.java#L195-L209 | train |
tanhaichao/leopard-data | leopard-jdbc/src/main/java/io/leopard/jdbc/JdbcDaoSupport.java | JdbcDaoSupport.setDataSource | public final void setDataSource(DataSource dataSource) {
if (this.jdbcTemplate == null || dataSource != this.jdbcTemplate.getDataSource()) {
this.jdbcTemplate = createJdbcTemplate(dataSource);
initTemplateConfig();
}
} | java | public final void setDataSource(DataSource dataSource) {
if (this.jdbcTemplate == null || dataSource != this.jdbcTemplate.getDataSource()) {
this.jdbcTemplate = createJdbcTemplate(dataSource);
initTemplateConfig();
}
} | [
"public",
"final",
"void",
"setDataSource",
"(",
"DataSource",
"dataSource",
")",
"{",
"if",
"(",
"this",
".",
"jdbcTemplate",
"==",
"null",
"||",
"dataSource",
"!=",
"this",
".",
"jdbcTemplate",
".",
"getDataSource",
"(",
")",
")",
"{",
"this",
".",
"jdbc... | Set the JDBC DataSource to be used by this DAO. | [
"Set",
"the",
"JDBC",
"DataSource",
"to",
"be",
"used",
"by",
"this",
"DAO",
"."
] | 2fae872f34f68ca6a23bcfe4554d47821b503281 | https://github.com/tanhaichao/leopard-data/blob/2fae872f34f68ca6a23bcfe4554d47821b503281/leopard-jdbc/src/main/java/io/leopard/jdbc/JdbcDaoSupport.java#L22-L27 | train |
phax/ph-web | ph-http/src/main/java/com/helger/http/digestauth/HttpDigestAuth.java | HttpDigestAuth.getDigestAuthClientCredentials | @Nullable
public static DigestAuthClientCredentials getDigestAuthClientCredentials (@Nullable final String sAuthHeader)
{
final ICommonsOrderedMap <String, String> aParams = getDigestAuthParams (sAuthHeader);
if (aParams == null)
return null;
final String sUserName = aParams.remove ("username");
if (sUserName == null)
{
LOGGER.error ("Digest Auth does not container 'username'");
return null;
}
final String sRealm = aParams.remove ("realm");
if (sRealm == null)
{
LOGGER.error ("Digest Auth does not container 'realm'");
return null;
}
final String sNonce = aParams.remove ("nonce");
if (sNonce == null)
{
LOGGER.error ("Digest Auth does not container 'nonce'");
return null;
}
final String sDigestURI = aParams.remove ("uri");
if (sDigestURI == null)
{
LOGGER.error ("Digest Auth does not container 'uri'");
return null;
}
final String sResponse = aParams.remove ("response");
if (sResponse == null)
{
LOGGER.error ("Digest Auth does not container 'response'");
return null;
}
final String sAlgorithm = aParams.remove ("algorithm");
final String sCNonce = aParams.remove ("cnonce");
final String sOpaque = aParams.remove ("opaque");
final String sMessageQOP = aParams.remove ("qop");
final String sNonceCount = aParams.remove ("nc");
if (aParams.isNotEmpty ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Digest Auth contains unhandled parameters: " + aParams.toString ());
return new DigestAuthClientCredentials (sUserName,
sRealm,
sNonce,
sDigestURI,
sResponse,
sAlgorithm,
sCNonce,
sOpaque,
sMessageQOP,
sNonceCount);
} | java | @Nullable
public static DigestAuthClientCredentials getDigestAuthClientCredentials (@Nullable final String sAuthHeader)
{
final ICommonsOrderedMap <String, String> aParams = getDigestAuthParams (sAuthHeader);
if (aParams == null)
return null;
final String sUserName = aParams.remove ("username");
if (sUserName == null)
{
LOGGER.error ("Digest Auth does not container 'username'");
return null;
}
final String sRealm = aParams.remove ("realm");
if (sRealm == null)
{
LOGGER.error ("Digest Auth does not container 'realm'");
return null;
}
final String sNonce = aParams.remove ("nonce");
if (sNonce == null)
{
LOGGER.error ("Digest Auth does not container 'nonce'");
return null;
}
final String sDigestURI = aParams.remove ("uri");
if (sDigestURI == null)
{
LOGGER.error ("Digest Auth does not container 'uri'");
return null;
}
final String sResponse = aParams.remove ("response");
if (sResponse == null)
{
LOGGER.error ("Digest Auth does not container 'response'");
return null;
}
final String sAlgorithm = aParams.remove ("algorithm");
final String sCNonce = aParams.remove ("cnonce");
final String sOpaque = aParams.remove ("opaque");
final String sMessageQOP = aParams.remove ("qop");
final String sNonceCount = aParams.remove ("nc");
if (aParams.isNotEmpty ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Digest Auth contains unhandled parameters: " + aParams.toString ());
return new DigestAuthClientCredentials (sUserName,
sRealm,
sNonce,
sDigestURI,
sResponse,
sAlgorithm,
sCNonce,
sOpaque,
sMessageQOP,
sNonceCount);
} | [
"@",
"Nullable",
"public",
"static",
"DigestAuthClientCredentials",
"getDigestAuthClientCredentials",
"(",
"@",
"Nullable",
"final",
"String",
"sAuthHeader",
")",
"{",
"final",
"ICommonsOrderedMap",
"<",
"String",
",",
"String",
">",
"aParams",
"=",
"getDigestAuthParams... | Get the Digest authentication credentials from the passed HTTP header
value.
@param sAuthHeader
The HTTP header value to be interpreted. May be <code>null</code>.
@return <code>null</code> if the passed value is not a correct HTTP Digest
Authentication header value. | [
"Get",
"the",
"Digest",
"authentication",
"credentials",
"from",
"the",
"passed",
"HTTP",
"header",
"value",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-http/src/main/java/com/helger/http/digestauth/HttpDigestAuth.java#L237-L293 | train |
phax/ph-web | ph-http/src/main/java/com/helger/http/digestauth/HttpDigestAuth.java | HttpDigestAuth.createDigestAuthClientCredentials | @Nonnull
public static DigestAuthClientCredentials createDigestAuthClientCredentials (@Nonnull final EHttpMethod eMethod,
@Nonnull @Nonempty final String sDigestURI,
@Nonnull @Nonempty final String sUserName,
@Nonnull final String sPassword,
@Nonnull @Nonempty final String sRealm,
@Nonnull @Nonempty final String sServerNonce,
@Nullable final String sAlgorithm,
@Nullable final String sClientNonce,
@Nullable final String sOpaque,
@Nullable final String sMessageQOP,
@CheckForSigned final int nNonceCount)
{
ValueEnforcer.notNull (eMethod, "Method");
ValueEnforcer.notEmpty (sDigestURI, "DigestURI");
ValueEnforcer.notEmpty (sUserName, "UserName");
ValueEnforcer.notNull (sPassword, "Password");
ValueEnforcer.notEmpty (sRealm, "Realm");
ValueEnforcer.notEmpty (sServerNonce, "ServerNonce");
if (sMessageQOP != null && StringHelper.hasNoText (sClientNonce))
throw new IllegalArgumentException ("If a QOP is defined, client nonce must be set!");
if (sMessageQOP != null && nNonceCount <= 0)
throw new IllegalArgumentException ("If a QOP is defined, nonce count must be positive!");
final String sRealAlgorithm = sAlgorithm == null ? DEFAULT_ALGORITHM : sAlgorithm;
if (!sRealAlgorithm.equals (ALGORITHM_MD5) && !sRealAlgorithm.equals (ALGORITHM_MD5_SESS))
throw new IllegalArgumentException ("Currently only '" +
ALGORITHM_MD5 +
"' and '" +
ALGORITHM_MD5_SESS +
"' algorithms are supported!");
if (sMessageQOP != null && !sMessageQOP.equals (QOP_AUTH))
throw new IllegalArgumentException ("Currently only '" + QOP_AUTH + "' QOP is supported!");
// Nonce must always by 8 chars long
final String sNonceCount = getNonceCountString (nNonceCount);
// Create HA1
String sHA1 = _md5 (sUserName + SEPARATOR + sRealm + SEPARATOR + sPassword);
if (sRealAlgorithm.equals (ALGORITHM_MD5_SESS))
{
if (StringHelper.hasNoText (sClientNonce))
throw new IllegalArgumentException ("Algorithm requires client nonce!");
sHA1 = _md5 (sHA1 + SEPARATOR + sServerNonce + SEPARATOR + sClientNonce);
}
// Create HA2
// Method name must be upper-case!
final String sHA2 = _md5 (eMethod.getName () + SEPARATOR + sDigestURI);
// Create the request digest - result must be all lowercase hex chars!
String sRequestDigest;
if (sMessageQOP == null)
{
// RFC 2069 backwards compatibility
sRequestDigest = _md5 (sHA1 + SEPARATOR + sServerNonce + SEPARATOR + sHA2);
}
else
{
sRequestDigest = _md5 (sHA1 +
SEPARATOR +
sServerNonce +
SEPARATOR +
sNonceCount +
SEPARATOR +
sClientNonce +
SEPARATOR +
sMessageQOP +
SEPARATOR +
sHA2);
}
return new DigestAuthClientCredentials (sUserName,
sRealm,
sServerNonce,
sDigestURI,
sRequestDigest,
sAlgorithm,
sClientNonce,
sOpaque,
sMessageQOP,
sNonceCount);
} | java | @Nonnull
public static DigestAuthClientCredentials createDigestAuthClientCredentials (@Nonnull final EHttpMethod eMethod,
@Nonnull @Nonempty final String sDigestURI,
@Nonnull @Nonempty final String sUserName,
@Nonnull final String sPassword,
@Nonnull @Nonempty final String sRealm,
@Nonnull @Nonempty final String sServerNonce,
@Nullable final String sAlgorithm,
@Nullable final String sClientNonce,
@Nullable final String sOpaque,
@Nullable final String sMessageQOP,
@CheckForSigned final int nNonceCount)
{
ValueEnforcer.notNull (eMethod, "Method");
ValueEnforcer.notEmpty (sDigestURI, "DigestURI");
ValueEnforcer.notEmpty (sUserName, "UserName");
ValueEnforcer.notNull (sPassword, "Password");
ValueEnforcer.notEmpty (sRealm, "Realm");
ValueEnforcer.notEmpty (sServerNonce, "ServerNonce");
if (sMessageQOP != null && StringHelper.hasNoText (sClientNonce))
throw new IllegalArgumentException ("If a QOP is defined, client nonce must be set!");
if (sMessageQOP != null && nNonceCount <= 0)
throw new IllegalArgumentException ("If a QOP is defined, nonce count must be positive!");
final String sRealAlgorithm = sAlgorithm == null ? DEFAULT_ALGORITHM : sAlgorithm;
if (!sRealAlgorithm.equals (ALGORITHM_MD5) && !sRealAlgorithm.equals (ALGORITHM_MD5_SESS))
throw new IllegalArgumentException ("Currently only '" +
ALGORITHM_MD5 +
"' and '" +
ALGORITHM_MD5_SESS +
"' algorithms are supported!");
if (sMessageQOP != null && !sMessageQOP.equals (QOP_AUTH))
throw new IllegalArgumentException ("Currently only '" + QOP_AUTH + "' QOP is supported!");
// Nonce must always by 8 chars long
final String sNonceCount = getNonceCountString (nNonceCount);
// Create HA1
String sHA1 = _md5 (sUserName + SEPARATOR + sRealm + SEPARATOR + sPassword);
if (sRealAlgorithm.equals (ALGORITHM_MD5_SESS))
{
if (StringHelper.hasNoText (sClientNonce))
throw new IllegalArgumentException ("Algorithm requires client nonce!");
sHA1 = _md5 (sHA1 + SEPARATOR + sServerNonce + SEPARATOR + sClientNonce);
}
// Create HA2
// Method name must be upper-case!
final String sHA2 = _md5 (eMethod.getName () + SEPARATOR + sDigestURI);
// Create the request digest - result must be all lowercase hex chars!
String sRequestDigest;
if (sMessageQOP == null)
{
// RFC 2069 backwards compatibility
sRequestDigest = _md5 (sHA1 + SEPARATOR + sServerNonce + SEPARATOR + sHA2);
}
else
{
sRequestDigest = _md5 (sHA1 +
SEPARATOR +
sServerNonce +
SEPARATOR +
sNonceCount +
SEPARATOR +
sClientNonce +
SEPARATOR +
sMessageQOP +
SEPARATOR +
sHA2);
}
return new DigestAuthClientCredentials (sUserName,
sRealm,
sServerNonce,
sDigestURI,
sRequestDigest,
sAlgorithm,
sClientNonce,
sOpaque,
sMessageQOP,
sNonceCount);
} | [
"@",
"Nonnull",
"public",
"static",
"DigestAuthClientCredentials",
"createDigestAuthClientCredentials",
"(",
"@",
"Nonnull",
"final",
"EHttpMethod",
"eMethod",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sDigestURI",
",",
"@",
"Nonnull",
"@",
"Nonempty",... | Create HTTP Digest auth credentials for a client
@param eMethod
The HTTP method of the request. May not be <code>null</code>.
@param sDigestURI
The URI from Request-URI of the Request-Line; duplicated here
because proxies are allowed to change the Request-Line in transit.
May neither be <code>null</code> nor empty.
@param sUserName
User name to use. May neither be <code>null</code> nor empty.
@param sPassword
The user's password. May not be <code>null</code>.
@param sRealm
The realm as provided by the server. May neither be
<code>null</code> nor empty.
@param sServerNonce
The nonce as supplied by the server. May neither be
<code>null</code> nor empty.
@param sAlgorithm
The algorithm as provided by the server. Currently only
{@link #ALGORITHM_MD5} and {@link #ALGORITHM_MD5_SESS} is supported.
If it is <code>null</code> than {@link #ALGORITHM_MD5} is used as
default.
@param sClientNonce
The client nonce to be used. Must be present if message QOP is
specified or if algorithm is {@link #ALGORITHM_MD5_SESS}.<br>
This MUST be specified if a qop directive is sent, and MUST NOT be
specified if the server did not send a qop directive in the
WWW-Authenticate header field. The cnonce-value is an opaque quoted
string value provided by the client and used by both client and
server to avoid chosen plain text attacks, to provide mutual
authentication, and to provide some message integrity protection.
See the descriptions below of the calculation of the response-
digest and request-digest values.
@param sOpaque
The opaque value as supplied by the server. May be <code>null</code>
.
@param sMessageQOP
The message QOP. Currently only {@link #QOP_AUTH} is supported. If
<code>null</code> is passed, than {@link #QOP_AUTH} with backward
compatibility handling for RFC 2069 is applied.<br>
Indicates what "quality of protection" the client has applied to the
message. If present, its value MUST be one of the alternatives the
server indicated it supports in the WWW-Authenticate header. These
values affect the computation of the request-digest. Note that this
is a single token, not a quoted list of alternatives as in WWW-
Authenticate. This directive is optional in order to preserve
backward compatibility with a minimal implementation of RFC 2069
[6], but SHOULD be used if the server indicated that qop is
supported by providing a qop directive in the WWW-Authenticate
header field.
@param nNonceCount
This MUST be specified if a qop directive is sent (see above), and
MUST NOT be specified if the server did not send a qop directive in
the WWW-Authenticate header field. The nc-value is the hexadecimal
count of the number of requests (including the current request) that
the client has sent with the nonce value in this request. For
example, in the first request sent in response to a given nonce
value, the client sends "nc=00000001". The purpose of this directive
is to allow the server to detect request replays by maintaining its
own copy of this count - if the same nc-value is seen twice, then
the request is a replay.
@return The created DigestAuthCredentials | [
"Create",
"HTTP",
"Digest",
"auth",
"credentials",
"for",
"a",
"client"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-http/src/main/java/com/helger/http/digestauth/HttpDigestAuth.java#L372-L455 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/data/UniformHolder.java | UniformHolder.get | @SuppressWarnings("unchecked")
public <U extends Uniform> U get(String name) {
final Uniform uniform = uniforms.get(name);
if (uniform == null) {
return null;
}
return (U) uniform;
} | java | @SuppressWarnings("unchecked")
public <U extends Uniform> U get(String name) {
final Uniform uniform = uniforms.get(name);
if (uniform == null) {
return null;
}
return (U) uniform;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"U",
"extends",
"Uniform",
">",
"U",
"get",
"(",
"String",
"name",
")",
"{",
"final",
"Uniform",
"uniform",
"=",
"uniforms",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"uniform",
"==... | Returns the uniform with the provided name, or null if non can be found.
@param name The name to lookup
@return The uniform | [
"Returns",
"the",
"uniform",
"with",
"the",
"provided",
"name",
"or",
"null",
"if",
"non",
"can",
"be",
"found",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/data/UniformHolder.java#L72-L79 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/AbstractFileUploadBase.java | AbstractFileUploadBase._getFilename | @Nullable
private static String _getFilename (@Nullable final String sContentDisposition)
{
String sFilename = null;
if (sContentDisposition != null)
{
final String sContentDispositionLC = sContentDisposition.toLowerCase (Locale.US);
if (sContentDispositionLC.startsWith (RequestHelper.FORM_DATA) ||
sContentDispositionLC.startsWith (RequestHelper.ATTACHMENT))
{
// Parameter parser can handle null input
final ICommonsMap <String, String> aParams = new ParameterParser ().setLowerCaseNames (true)
.parse (sContentDisposition, ';');
if (aParams.containsKey ("filename"))
{
sFilename = aParams.get ("filename");
if (sFilename != null)
{
sFilename = sFilename.trim ();
}
else
{
// Even if there is no value, the parameter is present,
// so we return an empty file name rather than no file
// name.
sFilename = "";
}
}
}
}
return sFilename;
} | java | @Nullable
private static String _getFilename (@Nullable final String sContentDisposition)
{
String sFilename = null;
if (sContentDisposition != null)
{
final String sContentDispositionLC = sContentDisposition.toLowerCase (Locale.US);
if (sContentDispositionLC.startsWith (RequestHelper.FORM_DATA) ||
sContentDispositionLC.startsWith (RequestHelper.ATTACHMENT))
{
// Parameter parser can handle null input
final ICommonsMap <String, String> aParams = new ParameterParser ().setLowerCaseNames (true)
.parse (sContentDisposition, ';');
if (aParams.containsKey ("filename"))
{
sFilename = aParams.get ("filename");
if (sFilename != null)
{
sFilename = sFilename.trim ();
}
else
{
// Even if there is no value, the parameter is present,
// so we return an empty file name rather than no file
// name.
sFilename = "";
}
}
}
}
return sFilename;
} | [
"@",
"Nullable",
"private",
"static",
"String",
"_getFilename",
"(",
"@",
"Nullable",
"final",
"String",
"sContentDisposition",
")",
"{",
"String",
"sFilename",
"=",
"null",
";",
"if",
"(",
"sContentDisposition",
"!=",
"null",
")",
"{",
"final",
"String",
"sCo... | Returns the given content-disposition headers file name.
@param sContentDisposition
The content-disposition headers value.
@return The file name or <code>null</code>. | [
"Returns",
"the",
"given",
"content",
"-",
"disposition",
"headers",
"file",
"name",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/AbstractFileUploadBase.java#L385-L416 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/AbstractFileUploadBase.java | AbstractFileUploadBase._getFieldName | @Nullable
private static String _getFieldName (@Nullable final String sContentDisposition)
{
String sFieldName = null;
if (sContentDisposition != null && sContentDisposition.toLowerCase (Locale.US).startsWith (RequestHelper.FORM_DATA))
{
// Parameter parser can handle null input
final ICommonsMap <String, String> aParams = new ParameterParser ().setLowerCaseNames (true)
.parse (sContentDisposition, ';');
sFieldName = aParams.get ("name");
if (sFieldName != null)
sFieldName = sFieldName.trim ();
}
return sFieldName;
} | java | @Nullable
private static String _getFieldName (@Nullable final String sContentDisposition)
{
String sFieldName = null;
if (sContentDisposition != null && sContentDisposition.toLowerCase (Locale.US).startsWith (RequestHelper.FORM_DATA))
{
// Parameter parser can handle null input
final ICommonsMap <String, String> aParams = new ParameterParser ().setLowerCaseNames (true)
.parse (sContentDisposition, ';');
sFieldName = aParams.get ("name");
if (sFieldName != null)
sFieldName = sFieldName.trim ();
}
return sFieldName;
} | [
"@",
"Nullable",
"private",
"static",
"String",
"_getFieldName",
"(",
"@",
"Nullable",
"final",
"String",
"sContentDisposition",
")",
"{",
"String",
"sFieldName",
"=",
"null",
";",
"if",
"(",
"sContentDisposition",
"!=",
"null",
"&&",
"sContentDisposition",
".",
... | Returns the field name, which is given by the content-disposition header.
@param sContentDisposition
The content-dispositions header value.
@return The field name | [
"Returns",
"the",
"field",
"name",
"which",
"is",
"given",
"by",
"the",
"content",
"-",
"disposition",
"header",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/AbstractFileUploadBase.java#L438-L452 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/scope/impl/RequestWebScope.java | RequestWebScope.isForbiddenParamValueChar | public static boolean isForbiddenParamValueChar (final char c)
{
// INVALID_VALUE_CHAR_XML10 + 0x7f
return (c >= 0x0 && c <= 0x8) ||
(c >= 0xb && c <= 0xc) ||
(c >= 0xe && c <= 0x1f) ||
(c == 0x7f) ||
(c >= 0xd800 && c <= 0xdfff) ||
(c >= 0xfffe && c <= 0xffff);
} | java | public static boolean isForbiddenParamValueChar (final char c)
{
// INVALID_VALUE_CHAR_XML10 + 0x7f
return (c >= 0x0 && c <= 0x8) ||
(c >= 0xb && c <= 0xc) ||
(c >= 0xe && c <= 0x1f) ||
(c == 0x7f) ||
(c >= 0xd800 && c <= 0xdfff) ||
(c >= 0xfffe && c <= 0xffff);
} | [
"public",
"static",
"boolean",
"isForbiddenParamValueChar",
"(",
"final",
"char",
"c",
")",
"{",
"// INVALID_VALUE_CHAR_XML10 + 0x7f",
"return",
"(",
"c",
">=",
"0x0",
"&&",
"c",
"<=",
"0x8",
")",
"||",
"(",
"c",
">=",
"0xb",
"&&",
"c",
"<=",
"0xc",
")",
... | Check if the provided char is forbidden in a request value or not.
@param c
Char to check
@return <code>true</code> if it is forbidden, <code>false</code> if not.
@see #getWithoutForbiddenChars(String)
@since 9.0.6 | [
"Check",
"if",
"the",
"provided",
"char",
"is",
"forbidden",
"in",
"a",
"request",
"value",
"or",
"not",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/scope/impl/RequestWebScope.java#L193-L202 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/scope/impl/RequestWebScope.java | RequestWebScope.getWithoutForbiddenChars | @Nullable
public static String getWithoutForbiddenChars (@Nullable final String s)
{
if (s == null)
return null;
final StringBuilder aCleanValue = new StringBuilder (s.length ());
int nForbidden = 0;
for (final char c : s.toCharArray ())
if (isForbiddenParamValueChar (c))
nForbidden++;
else
aCleanValue.append (c);
if (nForbidden == 0)
{
// Return "as-is"
return s;
}
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Removed " + nForbidden + " forbidden character(s) from a request parameter value!");
return aCleanValue.toString ();
} | java | @Nullable
public static String getWithoutForbiddenChars (@Nullable final String s)
{
if (s == null)
return null;
final StringBuilder aCleanValue = new StringBuilder (s.length ());
int nForbidden = 0;
for (final char c : s.toCharArray ())
if (isForbiddenParamValueChar (c))
nForbidden++;
else
aCleanValue.append (c);
if (nForbidden == 0)
{
// Return "as-is"
return s;
}
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Removed " + nForbidden + " forbidden character(s) from a request parameter value!");
return aCleanValue.toString ();
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getWithoutForbiddenChars",
"(",
"@",
"Nullable",
"final",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"return",
"null",
";",
"final",
"StringBuilder",
"aCleanValue",
"=",
"new",
"StringBuilder",
... | Remove all chars from the input that cannot be serialized as XML.
@param s
The source value. May be <code>null</code>.
@return <code>null</code> if the source value is <code>null</code>.
@see #isForbiddenParamValueChar(char)
@since 9.0.4 | [
"Remove",
"all",
"chars",
"from",
"the",
"input",
"that",
"cannot",
"be",
"serialized",
"as",
"XML",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/scope/impl/RequestWebScope.java#L213-L238 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/model/StringModel.java | StringModel.setString | public void setString(String string) {
rawString = string;
colorIndices.clear();
// Search for color codes
final StringBuilder stringBuilder = new StringBuilder(string);
final Matcher matcher = COLOR_PATTERN.matcher(string);
int removedCount = 0;
while (matcher.find()) {
final int index = matcher.start() - removedCount;
// Ignore escaped color codes
if (index > 0 && stringBuilder.charAt(index - 1) == '\\') {
// Remove the escape character
stringBuilder.deleteCharAt(index - 1);
removedCount++;
continue;
}
// Add the color for the index and delete it from the string
final String colorCode = matcher.group();
colorIndices.put(index, CausticUtil.fromPackedARGB(Long.decode(colorCode).intValue()));
final int length = colorCode.length();
stringBuilder.delete(index, index + length);
removedCount += length;
}
// Color code free string
this.string = stringBuilder.toString();
} | java | public void setString(String string) {
rawString = string;
colorIndices.clear();
// Search for color codes
final StringBuilder stringBuilder = new StringBuilder(string);
final Matcher matcher = COLOR_PATTERN.matcher(string);
int removedCount = 0;
while (matcher.find()) {
final int index = matcher.start() - removedCount;
// Ignore escaped color codes
if (index > 0 && stringBuilder.charAt(index - 1) == '\\') {
// Remove the escape character
stringBuilder.deleteCharAt(index - 1);
removedCount++;
continue;
}
// Add the color for the index and delete it from the string
final String colorCode = matcher.group();
colorIndices.put(index, CausticUtil.fromPackedARGB(Long.decode(colorCode).intValue()));
final int length = colorCode.length();
stringBuilder.delete(index, index + length);
removedCount += length;
}
// Color code free string
this.string = stringBuilder.toString();
} | [
"public",
"void",
"setString",
"(",
"String",
"string",
")",
"{",
"rawString",
"=",
"string",
";",
"colorIndices",
".",
"clear",
"(",
")",
";",
"// Search for color codes",
"final",
"StringBuilder",
"stringBuilder",
"=",
"new",
"StringBuilder",
"(",
"string",
")... | Sets the string to render.
@param string The string to render | [
"Sets",
"the",
"string",
"to",
"render",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/model/StringModel.java#L230-L255 | train |
astrapi69/mystic-crypt | crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PrivateKeyReader.java | PrivateKeyReader.readPrivateKey | public static PrivateKey readPrivateKey(final File root, final String directory,
final String fileName) throws NoSuchAlgorithmException, InvalidKeySpecException,
NoSuchProviderException, IOException
{
final File privatekeyDir = new File(root, directory);
final File privatekeyFile = new File(privatekeyDir, fileName);
final PrivateKey privateKey = PrivateKeyReader.readPrivateKey(privatekeyFile);
return privateKey;
} | java | public static PrivateKey readPrivateKey(final File root, final String directory,
final String fileName) throws NoSuchAlgorithmException, InvalidKeySpecException,
NoSuchProviderException, IOException
{
final File privatekeyDir = new File(root, directory);
final File privatekeyFile = new File(privatekeyDir, fileName);
final PrivateKey privateKey = PrivateKeyReader.readPrivateKey(privatekeyFile);
return privateKey;
} | [
"public",
"static",
"PrivateKey",
"readPrivateKey",
"(",
"final",
"File",
"root",
",",
"final",
"String",
"directory",
",",
"final",
"String",
"fileName",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeySpecException",
",",
"NoSuchProviderException",
",",
"... | Constructs from the given root, parent directory and file name the file and reads the private
key.
@param root
the root directory of the parent directory
@param directory
the parent directory of the private key file
@param fileName
the file name of the file that contains the private key
@return the private key
@throws NoSuchAlgorithmException
is thrown if instantiation of the SecretKeyFactory object fails.
@throws InvalidKeySpecException
is thrown if generation of the SecretKey object fails.
@throws NoSuchProviderException
the no such provider exception
@throws IOException
Signals that an I/O exception has occurred. | [
"Constructs",
"from",
"the",
"given",
"root",
"parent",
"directory",
"and",
"file",
"name",
"the",
"file",
"and",
"reads",
"the",
"private",
"key",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PrivateKeyReader.java#L365-L375 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/core/AbstractCryptor.java | AbstractCryptor.newAlgorithm | protected String newAlgorithm()
{
if (getModel().getAlgorithm() == null)
{
return SunJCEAlgorithm.PBEWithMD5AndDES.getAlgorithm();
}
return getModel().getAlgorithm().getAlgorithm();
} | java | protected String newAlgorithm()
{
if (getModel().getAlgorithm() == null)
{
return SunJCEAlgorithm.PBEWithMD5AndDES.getAlgorithm();
}
return getModel().getAlgorithm().getAlgorithm();
} | [
"protected",
"String",
"newAlgorithm",
"(",
")",
"{",
"if",
"(",
"getModel",
"(",
")",
".",
"getAlgorithm",
"(",
")",
"==",
"null",
")",
"{",
"return",
"SunJCEAlgorithm",
".",
"PBEWithMD5AndDES",
".",
"getAlgorithm",
"(",
")",
";",
"}",
"return",
"getModel... | Factory method for creating a new algorithm that will be used with the cipher object.
Overwrite this method to provide a specific algorithm.
@return the new algorithm that will be used with the cipher object. | [
"Factory",
"method",
"for",
"creating",
"a",
"new",
"algorithm",
"that",
"will",
"be",
"used",
"with",
"the",
"cipher",
"object",
".",
"Overwrite",
"this",
"method",
"to",
"provide",
"a",
"specific",
"algorithm",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/core/AbstractCryptor.java#L136-L143 | train |
phax/ph-web | ph-xservlet/src/main/java/com/helger/xservlet/AbstractXServlet.java | AbstractXServlet.init | @Override
public final void init (@Nonnull final ServletConfig aSC) throws ServletException
{
super.init (aSC);
m_aStatusMgr.onServletInit (getClass ());
try
{
// Build init parameter map
final ICommonsMap <String, String> aInitParams = new CommonsHashMap <> ();
final Enumeration <String> aEnum = aSC.getInitParameterNames ();
while (aEnum.hasMoreElements ())
{
final String sName = aEnum.nextElement ();
aInitParams.put (sName, aSC.getInitParameter (sName));
}
// Invoke each handler for potential initialization
m_aHandlerRegistry.forEachHandlerThrowing (x -> x.onServletInit (aInitParams));
}
catch (final ServletException ex)
{
m_aStatusMgr.onServletInitFailed (ex, getClass ());
throw ex;
}
} | java | @Override
public final void init (@Nonnull final ServletConfig aSC) throws ServletException
{
super.init (aSC);
m_aStatusMgr.onServletInit (getClass ());
try
{
// Build init parameter map
final ICommonsMap <String, String> aInitParams = new CommonsHashMap <> ();
final Enumeration <String> aEnum = aSC.getInitParameterNames ();
while (aEnum.hasMoreElements ())
{
final String sName = aEnum.nextElement ();
aInitParams.put (sName, aSC.getInitParameter (sName));
}
// Invoke each handler for potential initialization
m_aHandlerRegistry.forEachHandlerThrowing (x -> x.onServletInit (aInitParams));
}
catch (final ServletException ex)
{
m_aStatusMgr.onServletInitFailed (ex, getClass ());
throw ex;
}
} | [
"@",
"Override",
"public",
"final",
"void",
"init",
"(",
"@",
"Nonnull",
"final",
"ServletConfig",
"aSC",
")",
"throws",
"ServletException",
"{",
"super",
".",
"init",
"(",
"aSC",
")",
";",
"m_aStatusMgr",
".",
"onServletInit",
"(",
"getClass",
"(",
")",
"... | A final overload of "init". Overload "init" instead. | [
"A",
"final",
"overload",
"of",
"init",
".",
"Overload",
"init",
"instead",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-xservlet/src/main/java/com/helger/xservlet/AbstractXServlet.java#L268-L291 | train |
phax/ph-web | ph-xservlet/src/main/java/com/helger/xservlet/AbstractXServlet.java | AbstractXServlet.service | @Override
public final void service (@Nonnull final ServletRequest req,
@Nonnull final ServletResponse res) throws ServletException, IOException
{
super.service (req, res);
} | java | @Override
public final void service (@Nonnull final ServletRequest req,
@Nonnull final ServletResponse res) throws ServletException, IOException
{
super.service (req, res);
} | [
"@",
"Override",
"public",
"final",
"void",
"service",
"(",
"@",
"Nonnull",
"final",
"ServletRequest",
"req",
",",
"@",
"Nonnull",
"final",
"ServletResponse",
"res",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"super",
".",
"service",
"(",
"req... | Avoid overloading in sub classes | [
"Avoid",
"overloading",
"in",
"sub",
"classes"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-xservlet/src/main/java/com/helger/xservlet/AbstractXServlet.java#L583-L588 | train |
phax/ph-web | ph-httpclient/src/main/java/com/helger/httpclient/HttpDebugger.java | HttpDebugger.beforeRequest | public static void beforeRequest (@Nonnull final HttpUriRequest aRequest, @Nullable final HttpContext aHttpContext)
{
if (isEnabled ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Before HTTP call: " +
aRequest.getMethod () +
" " +
aRequest.getURI () +
(aHttpContext != null ? " (with special HTTP context)" : ""));
} | java | public static void beforeRequest (@Nonnull final HttpUriRequest aRequest, @Nullable final HttpContext aHttpContext)
{
if (isEnabled ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Before HTTP call: " +
aRequest.getMethod () +
" " +
aRequest.getURI () +
(aHttpContext != null ? " (with special HTTP context)" : ""));
} | [
"public",
"static",
"void",
"beforeRequest",
"(",
"@",
"Nonnull",
"final",
"HttpUriRequest",
"aRequest",
",",
"@",
"Nullable",
"final",
"HttpContext",
"aHttpContext",
")",
"{",
"if",
"(",
"isEnabled",
"(",
")",
")",
"if",
"(",
"LOGGER",
".",
"isInfoEnabled",
... | Call before an invocation
@param aRequest
The request to be executed. May not be <code>null</code>.
@param aHttpContext
The special HTTP content for this call. May be <code>null</code>. | [
"Call",
"before",
"an",
"invocation"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-httpclient/src/main/java/com/helger/httpclient/HttpDebugger.java#L66-L75 | train |
phax/ph-web | ph-httpclient/src/main/java/com/helger/httpclient/HttpDebugger.java | HttpDebugger.afterRequest | public static void afterRequest (@Nonnull final HttpUriRequest aRequest,
@Nullable final Object aResponse,
@Nullable final Throwable aCaughtException)
{
if (isEnabled ())
if (LOGGER.isInfoEnabled ())
{
final HttpResponseException aHex = aCaughtException instanceof HttpResponseException ? (HttpResponseException) aCaughtException
: null;
LOGGER.info ("After HTTP call: " +
aRequest.getMethod () +
(aResponse != null ? ". Response: " + aResponse : "") +
(aHex != null ? ". Status " + aHex.getStatusCode () : ""),
aHex != null ? null : aCaughtException);
}
} | java | public static void afterRequest (@Nonnull final HttpUriRequest aRequest,
@Nullable final Object aResponse,
@Nullable final Throwable aCaughtException)
{
if (isEnabled ())
if (LOGGER.isInfoEnabled ())
{
final HttpResponseException aHex = aCaughtException instanceof HttpResponseException ? (HttpResponseException) aCaughtException
: null;
LOGGER.info ("After HTTP call: " +
aRequest.getMethod () +
(aResponse != null ? ". Response: " + aResponse : "") +
(aHex != null ? ". Status " + aHex.getStatusCode () : ""),
aHex != null ? null : aCaughtException);
}
} | [
"public",
"static",
"void",
"afterRequest",
"(",
"@",
"Nonnull",
"final",
"HttpUriRequest",
"aRequest",
",",
"@",
"Nullable",
"final",
"Object",
"aResponse",
",",
"@",
"Nullable",
"final",
"Throwable",
"aCaughtException",
")",
"{",
"if",
"(",
"isEnabled",
"(",
... | Call after an invocation.
@param aRequest
The source request. May not be modified internally. May not be
<code>null</code>.
@param aResponse
The response object retrieved. May be anything including
<code>null</code> (e.g. in case of exception).
@param aCaughtException
The caught exception. May be <code>null</code>.
@since 8.8.2 | [
"Call",
"after",
"an",
"invocation",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-httpclient/src/main/java/com/helger/httpclient/HttpDebugger.java#L90-L105 | train |
hmsonline/json-transformer | src/main/java/com/hmsonline/json/transformer/JsonRule.java | JsonRule.transform | private void transform(JSONArray root) {
for (int i = 0, size = root.size(); i < size; i++)
{
Object target = root.get(i);
if (target instanceof JSONObject)
this.transform((JSONObject)target);
}
} | java | private void transform(JSONArray root) {
for (int i = 0, size = root.size(); i < size; i++)
{
Object target = root.get(i);
if (target instanceof JSONObject)
this.transform((JSONObject)target);
}
} | [
"private",
"void",
"transform",
"(",
"JSONArray",
"root",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"size",
"=",
"root",
".",
"size",
"(",
")",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"Object",
"target",
"=",
"root",
".",
"get",... | Apply transform to each json object in the json array
@param root | [
"Apply",
"transform",
"to",
"each",
"json",
"object",
"in",
"the",
"json",
"array"
] | 4c739170db8b30a166066436af71c14288c65a4e | https://github.com/hmsonline/json-transformer/blob/4c739170db8b30a166066436af71c14288c65a4e/src/main/java/com/hmsonline/json/transformer/JsonRule.java#L62-L69 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/pw/PasswordEncryptor.java | PasswordEncryptor.hashAndHexPassword | public String hashAndHexPassword(final String password, final String salt)
throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException,
InvalidKeySpecException, InvalidAlgorithmParameterException
{
return hashAndHexPassword(password, salt, DEFAULT_ALGORITHM, DEFAULT_CHARSET);
} | java | public String hashAndHexPassword(final String password, final String salt)
throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException,
InvalidKeySpecException, InvalidAlgorithmParameterException
{
return hashAndHexPassword(password, salt, DEFAULT_ALGORITHM, DEFAULT_CHARSET);
} | [
"public",
"String",
"hashAndHexPassword",
"(",
"final",
"String",
"password",
",",
"final",
"String",
"salt",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
",",
"UnsupportedEncodingException",
",",
"NoSuchPaddingException",
",",
"IllegalBlockSizeExc... | Hash and hex password with the given salt.
@param password
the password
@param salt
the salt
@return the generated {@link String} object
@throws NoSuchAlgorithmException
is thrown if instantiation of the MessageDigest object fails.
@throws UnsupportedEncodingException
is thrown by get the byte array of the private key String object fails.
@throws NoSuchPaddingException
is thrown if instantiation of the cypher object fails.
@throws InvalidKeyException
the invalid key exception is thrown if initialization of the cypher object fails.
@throws BadPaddingException
is thrown if {@link Cipher#doFinal(byte[])} fails.
@throws IllegalBlockSizeException
is thrown if {@link Cipher#doFinal(byte[])} fails.
@throws InvalidAlgorithmParameterException
is thrown if initialization of the cypher object fails.
@throws InvalidKeySpecException
is thrown if generation of the SecretKey object fails. | [
"Hash",
"and",
"hex",
"password",
"with",
"the",
"given",
"salt",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/pw/PasswordEncryptor.java#L148-L154 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/pw/PasswordEncryptor.java | PasswordEncryptor.hashAndHexPassword | public String hashAndHexPassword(final String password, final String salt,
final HashAlgorithm hashAlgorithm, final Charset charset)
throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException,
InvalidKeySpecException, InvalidAlgorithmParameterException
{
final String hashedPassword = Hasher.hashAndHex(password, salt, hashAlgorithm, charset);
return hashedPassword;
} | java | public String hashAndHexPassword(final String password, final String salt,
final HashAlgorithm hashAlgorithm, final Charset charset)
throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException,
InvalidKeySpecException, InvalidAlgorithmParameterException
{
final String hashedPassword = Hasher.hashAndHex(password, salt, hashAlgorithm, charset);
return hashedPassword;
} | [
"public",
"String",
"hashAndHexPassword",
"(",
"final",
"String",
"password",
",",
"final",
"String",
"salt",
",",
"final",
"HashAlgorithm",
"hashAlgorithm",
",",
"final",
"Charset",
"charset",
")",
"throws",
"NoSuchAlgorithmException",
",",
"InvalidKeyException",
","... | Hash and hex the given password with the given salt, hash algorithm and charset.
@param password
the password
@param salt
the salt
@param hashAlgorithm
the hash algorithm
@param charset
the charset
@return the generated {@link String} object
@throws NoSuchAlgorithmException
is thrown if instantiation of the MessageDigest object fails.
@throws UnsupportedEncodingException
is thrown by get the byte array of the private key String object fails.
@throws NoSuchPaddingException
is thrown if instantiation of the cypher object fails.
@throws InvalidKeyException
the invalid key exception is thrown if initialization of the cypher object fails.
@throws BadPaddingException
is thrown if {@link Cipher#doFinal(byte[])} fails.
@throws IllegalBlockSizeException
is thrown if {@link Cipher#doFinal(byte[])} fails.
@throws InvalidAlgorithmParameterException
is thrown if initialization of the cypher object fails.
@throws InvalidKeySpecException
is thrown if generation of the SecretKey object fails. | [
"Hash",
"and",
"hex",
"the",
"given",
"password",
"with",
"the",
"given",
"salt",
"hash",
"algorithm",
"and",
"charset",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/pw/PasswordEncryptor.java#L185-L193 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/pw/PasswordEncryptor.java | PasswordEncryptor.hashPassword | public String hashPassword(final String password, final String salt,
final HashAlgorithm hashAlgorithm, final Charset charset) throws NoSuchAlgorithmException
{
final String hashedPassword = HashExtensions.hash(password, salt, hashAlgorithm, charset);
return hashedPassword;
} | java | public String hashPassword(final String password, final String salt,
final HashAlgorithm hashAlgorithm, final Charset charset) throws NoSuchAlgorithmException
{
final String hashedPassword = HashExtensions.hash(password, salt, hashAlgorithm, charset);
return hashedPassword;
} | [
"public",
"String",
"hashPassword",
"(",
"final",
"String",
"password",
",",
"final",
"String",
"salt",
",",
"final",
"HashAlgorithm",
"hashAlgorithm",
",",
"final",
"Charset",
"charset",
")",
"throws",
"NoSuchAlgorithmException",
"{",
"final",
"String",
"hashedPass... | Hashes the given password with the given salt, hash algorithm and charset.
@param password
the password
@param salt
the salt
@param hashAlgorithm
the hash algorithm
@param charset
the charset
@return the generated {@link String} object
@throws NoSuchAlgorithmException
the no such algorithm exception | [
"Hashes",
"the",
"given",
"password",
"with",
"the",
"given",
"salt",
"hash",
"algorithm",
"and",
"charset",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/pw/PasswordEncryptor.java#L210-L215 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/scope/singleton/AbstractGlobalWebSingleton.java | AbstractGlobalWebSingleton.getGlobalSingleton | @Nonnull
public static final <T extends AbstractGlobalWebSingleton> T getGlobalSingleton (@Nonnull final Class <T> aClass)
{
return getSingleton (_getStaticScope (true), aClass);
} | java | @Nonnull
public static final <T extends AbstractGlobalWebSingleton> T getGlobalSingleton (@Nonnull final Class <T> aClass)
{
return getSingleton (_getStaticScope (true), aClass);
} | [
"@",
"Nonnull",
"public",
"static",
"final",
"<",
"T",
"extends",
"AbstractGlobalWebSingleton",
">",
"T",
"getGlobalSingleton",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"T",
">",
"aClass",
")",
"{",
"return",
"getSingleton",
"(",
"_getStaticScope",
"(",
"tr... | Get the singleton object in the current global web scope, using the passed
class. If the singleton is not yet instantiated, a new instance is created.
@param <T>
The type to be returned
@param aClass
The class to be used. May not be <code>null</code>. The class must
be public as needs to have a public no-argument constructor.
@return The singleton object and never <code>null</code>. | [
"Get",
"the",
"singleton",
"object",
"in",
"the",
"current",
"global",
"web",
"scope",
"using",
"the",
"passed",
"class",
".",
"If",
"the",
"singleton",
"is",
"not",
"yet",
"instantiated",
"a",
"new",
"instance",
"is",
"created",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/scope/singleton/AbstractGlobalWebSingleton.java#L62-L66 | train |
phax/ph-web | ph-network/src/main/java/com/helger/network/dns/DNSHelper.java | DNSHelper.setDNSCacheTime | public static void setDNSCacheTime (final int nSeconds)
{
final String sValue = Integer.toString (nSeconds);
Security.setProperty ("networkaddress.cache.ttl", sValue);
Security.setProperty ("networkaddress.cache.negative.ttl", sValue);
SystemProperties.setPropertyValue ("disableWSAddressCaching", nSeconds == 0);
} | java | public static void setDNSCacheTime (final int nSeconds)
{
final String sValue = Integer.toString (nSeconds);
Security.setProperty ("networkaddress.cache.ttl", sValue);
Security.setProperty ("networkaddress.cache.negative.ttl", sValue);
SystemProperties.setPropertyValue ("disableWSAddressCaching", nSeconds == 0);
} | [
"public",
"static",
"void",
"setDNSCacheTime",
"(",
"final",
"int",
"nSeconds",
")",
"{",
"final",
"String",
"sValue",
"=",
"Integer",
".",
"toString",
"(",
"nSeconds",
")",
";",
"Security",
".",
"setProperty",
"(",
"\"networkaddress.cache.ttl\"",
",",
"sValue",... | Set special DNS client properties that have influence on the DNS client
behavior. This method should be called as soon as possible on startup. In
most cases it may be beneficiary if the respective system properties are
provided as system properties on the commandline!
@param nSeconds
DNS client caching time in seconds. | [
"Set",
"special",
"DNS",
"client",
"properties",
"that",
"have",
"influence",
"on",
"the",
"DNS",
"client",
"behavior",
".",
"This",
"method",
"should",
"be",
"called",
"as",
"soon",
"as",
"possible",
"on",
"startup",
".",
"In",
"most",
"cases",
"it",
"may... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-network/src/main/java/com/helger/network/dns/DNSHelper.java#L44-L50 | train |
phax/ph-web | ph-http/src/main/java/com/helger/http/AcceptCharsetList.java | AcceptCharsetList.getQValueOfCharset | @Nonnull
public QValue getQValueOfCharset (@Nonnull final String sCharset)
{
ValueEnforcer.notNull (sCharset, "Charset");
// Find charset direct
QValue aQuality = m_aMap.get (_unify (sCharset));
if (aQuality == null)
{
// If not explicitly given, check for "*"
aQuality = m_aMap.get (AcceptCharsetHandler.ANY_CHARSET);
if (aQuality == null)
{
// Neither charset nor "*" is present
return sCharset.equals (AcceptCharsetHandler.DEFAULT_CHARSET) ? QValue.MAX_QVALUE : QValue.MIN_QVALUE;
}
}
return aQuality;
} | java | @Nonnull
public QValue getQValueOfCharset (@Nonnull final String sCharset)
{
ValueEnforcer.notNull (sCharset, "Charset");
// Find charset direct
QValue aQuality = m_aMap.get (_unify (sCharset));
if (aQuality == null)
{
// If not explicitly given, check for "*"
aQuality = m_aMap.get (AcceptCharsetHandler.ANY_CHARSET);
if (aQuality == null)
{
// Neither charset nor "*" is present
return sCharset.equals (AcceptCharsetHandler.DEFAULT_CHARSET) ? QValue.MAX_QVALUE : QValue.MIN_QVALUE;
}
}
return aQuality;
} | [
"@",
"Nonnull",
"public",
"QValue",
"getQValueOfCharset",
"(",
"@",
"Nonnull",
"final",
"String",
"sCharset",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"sCharset",
",",
"\"Charset\"",
")",
";",
"// Find charset direct",
"QValue",
"aQuality",
"=",
"m_aMap",
... | Return the associated quality of the given charset.
@param sCharset
The charset name to query. May not be <code>null</code>.
@return The associated {@link QValue}. | [
"Return",
"the",
"associated",
"quality",
"of",
"the",
"given",
"charset",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-http/src/main/java/com/helger/http/AcceptCharsetList.java#L55-L73 | train |
flow/caustic | lwjgl/src/main/java/com/flowpowered/caustic/lwjgl/LWJGLUtil.java | LWJGLUtil.checkForGLError | public static void checkForGLError() {
if (CausticUtil.isDebugEnabled()) {
final int errorValue = GL11.glGetError();
if (errorValue != GL11.GL_NO_ERROR) {
throw new GLException("GL ERROR: " + GLU.gluErrorString(errorValue));
}
}
} | java | public static void checkForGLError() {
if (CausticUtil.isDebugEnabled()) {
final int errorValue = GL11.glGetError();
if (errorValue != GL11.GL_NO_ERROR) {
throw new GLException("GL ERROR: " + GLU.gluErrorString(errorValue));
}
}
} | [
"public",
"static",
"void",
"checkForGLError",
"(",
")",
"{",
"if",
"(",
"CausticUtil",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"final",
"int",
"errorValue",
"=",
"GL11",
".",
"glGetError",
"(",
")",
";",
"if",
"(",
"errorValue",
"!=",
"GL11",
".",
... | Throws an exception if OpenGL reports an error.
@throws GLException If OpenGL reports an error | [
"Throws",
"an",
"exception",
"if",
"OpenGL",
"reports",
"an",
"error",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/lwjgl/src/main/java/com/flowpowered/caustic/lwjgl/LWJGLUtil.java#L125-L132 | train |
astrapi69/mystic-crypt | crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PemObjectReader.java | PemObjectReader.getPemObject | public static PemObject getPemObject(final File file) throws IOException
{
PemObject pemObject;
try (PemReader pemReader = new PemReader(new InputStreamReader(new FileInputStream(file))))
{
pemObject = pemReader.readPemObject();
}
return pemObject;
} | java | public static PemObject getPemObject(final File file) throws IOException
{
PemObject pemObject;
try (PemReader pemReader = new PemReader(new InputStreamReader(new FileInputStream(file))))
{
pemObject = pemReader.readPemObject();
}
return pemObject;
} | [
"public",
"static",
"PemObject",
"getPemObject",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"PemObject",
"pemObject",
";",
"try",
"(",
"PemReader",
"pemReader",
"=",
"new",
"PemReader",
"(",
"new",
"InputStreamReader",
"(",
"new",
"FileInpu... | Gets the pem object.
@param file
the file
@return the pem object
@throws IOException
Signals that an I/O exception has occurred. | [
"Gets",
"the",
"pem",
"object",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/PemObjectReader.java#L65-L73 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockHttpSession.java | MockHttpSession.clearAttributes | public void clearAttributes ()
{
for (final Map.Entry <String, Object> entry : m_aAttributes.entrySet ())
{
final String sName = entry.getKey ();
final Object aValue = entry.getValue ();
if (aValue instanceof HttpSessionBindingListener)
((HttpSessionBindingListener) aValue).valueUnbound (new HttpSessionBindingEvent (this, sName, aValue));
}
m_aAttributes.clear ();
} | java | public void clearAttributes ()
{
for (final Map.Entry <String, Object> entry : m_aAttributes.entrySet ())
{
final String sName = entry.getKey ();
final Object aValue = entry.getValue ();
if (aValue instanceof HttpSessionBindingListener)
((HttpSessionBindingListener) aValue).valueUnbound (new HttpSessionBindingEvent (this, sName, aValue));
}
m_aAttributes.clear ();
} | [
"public",
"void",
"clearAttributes",
"(",
")",
"{",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"m_aAttributes",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"sName",
"=",
"entry",
".",
"getKey"... | Clear all of this session's attributes. | [
"Clear",
"all",
"of",
"this",
"session",
"s",
"attributes",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockHttpSession.java#L218-L228 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockHttpSession.java | MockHttpSession.serializeState | @Nonnull
public Serializable serializeState ()
{
final ICommonsMap <String, Object> aState = new CommonsHashMap <> ();
for (final Map.Entry <String, Object> entry : m_aAttributes.entrySet ())
{
final String sName = entry.getKey ();
final Object aValue = entry.getValue ();
if (aValue instanceof Serializable)
{
aState.put (sName, aValue);
}
else
{
// Not serializable... Servlet containers usually automatically
// unbind the attribute in this case.
if (aValue instanceof HttpSessionBindingListener)
{
((HttpSessionBindingListener) aValue).valueUnbound (new HttpSessionBindingEvent (this, sName, aValue));
}
}
}
m_aAttributes.clear ();
return aState;
} | java | @Nonnull
public Serializable serializeState ()
{
final ICommonsMap <String, Object> aState = new CommonsHashMap <> ();
for (final Map.Entry <String, Object> entry : m_aAttributes.entrySet ())
{
final String sName = entry.getKey ();
final Object aValue = entry.getValue ();
if (aValue instanceof Serializable)
{
aState.put (sName, aValue);
}
else
{
// Not serializable... Servlet containers usually automatically
// unbind the attribute in this case.
if (aValue instanceof HttpSessionBindingListener)
{
((HttpSessionBindingListener) aValue).valueUnbound (new HttpSessionBindingEvent (this, sName, aValue));
}
}
}
m_aAttributes.clear ();
return aState;
} | [
"@",
"Nonnull",
"public",
"Serializable",
"serializeState",
"(",
")",
"{",
"final",
"ICommonsMap",
"<",
"String",
",",
"Object",
">",
"aState",
"=",
"new",
"CommonsHashMap",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",... | Serialize the attributes of this session into an object that can be turned
into a byte array with standard Java serialization.
@return a representation of this session's serialized state | [
"Serialize",
"the",
"attributes",
"of",
"this",
"session",
"into",
"an",
"object",
"that",
"can",
"be",
"turned",
"into",
"a",
"byte",
"array",
"with",
"standard",
"Java",
"serialization",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockHttpSession.java#L264-L288 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/response/ResponseHelperSettings.java | ResponseHelperSettings.setAll | @Nonnull
public static EChange setAll (final boolean bResponseCompressionEnabled,
final boolean bResponseGzipEnabled,
final boolean bResponseDeflateEnabled)
{
return s_aRWLock.writeLocked ( () -> {
EChange eChange = EChange.UNCHANGED;
if (s_bResponseCompressionEnabled != bResponseCompressionEnabled)
{
s_bResponseCompressionEnabled = bResponseCompressionEnabled;
eChange = EChange.CHANGED;
LOGGER.info ("ResponseHelper responseCompressEnabled=" + bResponseCompressionEnabled);
}
if (s_bResponseGzipEnabled != bResponseGzipEnabled)
{
s_bResponseGzipEnabled = bResponseGzipEnabled;
eChange = EChange.CHANGED;
LOGGER.info ("ResponseHelper responseGzipEnabled=" + bResponseGzipEnabled);
}
if (s_bResponseDeflateEnabled != bResponseDeflateEnabled)
{
s_bResponseDeflateEnabled = bResponseDeflateEnabled;
eChange = EChange.CHANGED;
LOGGER.info ("ResponseHelper responseDeflateEnabled=" + bResponseDeflateEnabled);
}
return eChange;
});
} | java | @Nonnull
public static EChange setAll (final boolean bResponseCompressionEnabled,
final boolean bResponseGzipEnabled,
final boolean bResponseDeflateEnabled)
{
return s_aRWLock.writeLocked ( () -> {
EChange eChange = EChange.UNCHANGED;
if (s_bResponseCompressionEnabled != bResponseCompressionEnabled)
{
s_bResponseCompressionEnabled = bResponseCompressionEnabled;
eChange = EChange.CHANGED;
LOGGER.info ("ResponseHelper responseCompressEnabled=" + bResponseCompressionEnabled);
}
if (s_bResponseGzipEnabled != bResponseGzipEnabled)
{
s_bResponseGzipEnabled = bResponseGzipEnabled;
eChange = EChange.CHANGED;
LOGGER.info ("ResponseHelper responseGzipEnabled=" + bResponseGzipEnabled);
}
if (s_bResponseDeflateEnabled != bResponseDeflateEnabled)
{
s_bResponseDeflateEnabled = bResponseDeflateEnabled;
eChange = EChange.CHANGED;
LOGGER.info ("ResponseHelper responseDeflateEnabled=" + bResponseDeflateEnabled);
}
return eChange;
});
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"setAll",
"(",
"final",
"boolean",
"bResponseCompressionEnabled",
",",
"final",
"boolean",
"bResponseGzipEnabled",
",",
"final",
"boolean",
"bResponseDeflateEnabled",
")",
"{",
"return",
"s_aRWLock",
".",
"writeLocked",
"... | Set all parameters at once as an atomic transaction
@param bResponseCompressionEnabled
<code>true</code> to overall enable the usage
@param bResponseGzipEnabled
<code>true</code> to enable GZip if compression is enabled
@param bResponseDeflateEnabled
<code>true</code> to enable Deflate if compression is enabled
@return {@link EChange} | [
"Set",
"all",
"parameters",
"at",
"once",
"as",
"an",
"atomic",
"transaction"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/response/ResponseHelperSettings.java#L169-L196 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/response/ResponseHelperSettings.java | ResponseHelperSettings.setExpirationSeconds | @Nonnull
public static EChange setExpirationSeconds (final int nExpirationSeconds)
{
return s_aRWLock.writeLocked ( () -> {
if (s_nExpirationSeconds == nExpirationSeconds)
return EChange.UNCHANGED;
s_nExpirationSeconds = nExpirationSeconds;
LOGGER.info ("ResponseHelper expirationSeconds=" + nExpirationSeconds);
return EChange.CHANGED;
});
} | java | @Nonnull
public static EChange setExpirationSeconds (final int nExpirationSeconds)
{
return s_aRWLock.writeLocked ( () -> {
if (s_nExpirationSeconds == nExpirationSeconds)
return EChange.UNCHANGED;
s_nExpirationSeconds = nExpirationSeconds;
LOGGER.info ("ResponseHelper expirationSeconds=" + nExpirationSeconds);
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"static",
"EChange",
"setExpirationSeconds",
"(",
"final",
"int",
"nExpirationSeconds",
")",
"{",
"return",
"s_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"s_nExpirationSeconds",
"==",
"nExpirationSeconds",
")",
"... | Set the default expiration settings to be used for objects that should use
HTTP caching
@param nExpirationSeconds
The number of seconds for which the response should be cached
@return {@link EChange} | [
"Set",
"the",
"default",
"expiration",
"settings",
"to",
"be",
"used",
"for",
"objects",
"that",
"should",
"use",
"HTTP",
"caching"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/response/ResponseHelperSettings.java#L206-L216 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/parse/FileItemStream.java | FileItemStream.openStream | @Nonnull
public InputStream openStream () throws IOException
{
if (m_aIS instanceof ICloseable && ((ICloseable) m_aIS).isClosed ())
throw new MultipartItemSkippedException ();
return m_aIS;
} | java | @Nonnull
public InputStream openStream () throws IOException
{
if (m_aIS instanceof ICloseable && ((ICloseable) m_aIS).isClosed ())
throw new MultipartItemSkippedException ();
return m_aIS;
} | [
"@",
"Nonnull",
"public",
"InputStream",
"openStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"m_aIS",
"instanceof",
"ICloseable",
"&&",
"(",
"(",
"ICloseable",
")",
"m_aIS",
")",
".",
"isClosed",
"(",
")",
")",
"throw",
"new",
"MultipartItemSkip... | Returns an input stream, which may be used to read the items contents.
@return Opened input stream.
@throws IOException
An I/O error occurred. | [
"Returns",
"an",
"input",
"stream",
"which",
"may",
"be",
"used",
"to",
"read",
"the",
"items",
"contents",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/parse/FileItemStream.java#L213-L219 | train |
shred/commons-xml | src/main/java/org/shredzone/commons/xml/XQuery.java | XQuery.text | public @Nonnull String text() {
return new NodeListSpliterator(node.getChildNodes()).stream()
.filter(it -> it instanceof Text)
.map(it -> ((Text) it).getNodeValue())
.collect(joining());
} | java | public @Nonnull String text() {
return new NodeListSpliterator(node.getChildNodes()).stream()
.filter(it -> it instanceof Text)
.map(it -> ((Text) it).getNodeValue())
.collect(joining());
} | [
"public",
"@",
"Nonnull",
"String",
"text",
"(",
")",
"{",
"return",
"new",
"NodeListSpliterator",
"(",
"node",
".",
"getChildNodes",
"(",
")",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"it",
"->",
"it",
"instanceof",
"Text",
")",
".",
"map",
... | Returns the text content of this node.
@return this {@link XQuery} node's text content, non recursively. | [
"Returns",
"the",
"text",
"content",
"of",
"this",
"node",
"."
] | e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f | https://github.com/shred/commons-xml/blob/e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f/src/main/java/org/shredzone/commons/xml/XQuery.java#L276-L281 | train |
shred/commons-xml | src/main/java/org/shredzone/commons/xml/XQuery.java | XQuery.attr | public @Nonnull Map<String, String> attr() {
synchronized (this) {
if (attrMap.get() == null) {
attrMap.set(
Optional.ofNullable(node.getAttributes())
.map(XQuery::attributesToMap)
.map(Collections::unmodifiableMap)
.orElseGet(Collections::emptyMap)
);
}
}
return attrMap.get();
} | java | public @Nonnull Map<String, String> attr() {
synchronized (this) {
if (attrMap.get() == null) {
attrMap.set(
Optional.ofNullable(node.getAttributes())
.map(XQuery::attributesToMap)
.map(Collections::unmodifiableMap)
.orElseGet(Collections::emptyMap)
);
}
}
return attrMap.get();
} | [
"public",
"@",
"Nonnull",
"Map",
"<",
"String",
",",
"String",
">",
"attr",
"(",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"attrMap",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"attrMap",
".",
"set",
"(",
"Optional",
".",
"of... | Returns a map of attributes.
@return a map of this node's attributes. | [
"Returns",
"a",
"map",
"of",
"attributes",
"."
] | e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f | https://github.com/shred/commons-xml/blob/e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f/src/main/java/org/shredzone/commons/xml/XQuery.java#L297-L309 | train |
shred/commons-xml | src/main/java/org/shredzone/commons/xml/XQuery.java | XQuery.evaluate | private @Nonnull NodeList evaluate(String xpath) {
try {
XPathExpression expr = xpf.newXPath().compile(xpath);
return (NodeList) expr.evaluate(node, XPathConstants.NODESET);
} catch (XPathExpressionException ex) {
throw new IllegalArgumentException("Invalid XPath '" + xpath + "'", ex);
}
} | java | private @Nonnull NodeList evaluate(String xpath) {
try {
XPathExpression expr = xpf.newXPath().compile(xpath);
return (NodeList) expr.evaluate(node, XPathConstants.NODESET);
} catch (XPathExpressionException ex) {
throw new IllegalArgumentException("Invalid XPath '" + xpath + "'", ex);
}
} | [
"private",
"@",
"Nonnull",
"NodeList",
"evaluate",
"(",
"String",
"xpath",
")",
"{",
"try",
"{",
"XPathExpression",
"expr",
"=",
"xpf",
".",
"newXPath",
"(",
")",
".",
"compile",
"(",
"xpath",
")",
";",
"return",
"(",
"NodeList",
")",
"expr",
".",
"eva... | Evaluates the XPath expression and returns a list of nodes.
@param xpath
XPath expression
@return {@link NodeList} matching the expression
@throws IllegalArgumentException
if the XPath expression was invalid | [
"Evaluates",
"the",
"XPath",
"expression",
"and",
"returns",
"a",
"list",
"of",
"nodes",
"."
] | e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f | https://github.com/shred/commons-xml/blob/e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f/src/main/java/org/shredzone/commons/xml/XQuery.java#L360-L367 | train |
shred/commons-xml | src/main/java/org/shredzone/commons/xml/XQuery.java | XQuery.findElement | private @Nonnull Optional<XQuery> findElement(Function<Node, Node> iterator) {
Node it = node;
do {
it = iterator.apply(it);
} while (it != null && !(it instanceof Element));
return Optional.ofNullable(it).map(XQuery::new);
} | java | private @Nonnull Optional<XQuery> findElement(Function<Node, Node> iterator) {
Node it = node;
do {
it = iterator.apply(it);
} while (it != null && !(it instanceof Element));
return Optional.ofNullable(it).map(XQuery::new);
} | [
"private",
"@",
"Nonnull",
"Optional",
"<",
"XQuery",
">",
"findElement",
"(",
"Function",
"<",
"Node",
",",
"Node",
">",
"iterator",
")",
"{",
"Node",
"it",
"=",
"node",
";",
"do",
"{",
"it",
"=",
"iterator",
".",
"apply",
"(",
"it",
")",
";",
"}"... | Finds an Element node by applying the iterator function until another Element was
found.
@param iterator
Iterator to apply
@return node that was found | [
"Finds",
"an",
"Element",
"node",
"by",
"applying",
"the",
"iterator",
"function",
"until",
"another",
"Element",
"was",
"found",
"."
] | e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f | https://github.com/shred/commons-xml/blob/e0b928cc6db85d9a5fedacd7c06527ec0d98bb6f/src/main/java/org/shredzone/commons/xml/XQuery.java#L377-L383 | train |
phax/ph-web | ph-http/src/main/java/com/helger/http/digestauth/DigestAuthServerBuilder.java | DigestAuthServerBuilder.setOpaque | @Nonnull
public DigestAuthServerBuilder setOpaque (@Nonnull final String sOpaque)
{
if (!HttpStringHelper.isQuotedTextContent (sOpaque))
throw new IllegalArgumentException ("opaque is invalid: " + sOpaque);
m_sOpaque = sOpaque;
return this;
} | java | @Nonnull
public DigestAuthServerBuilder setOpaque (@Nonnull final String sOpaque)
{
if (!HttpStringHelper.isQuotedTextContent (sOpaque))
throw new IllegalArgumentException ("opaque is invalid: " + sOpaque);
m_sOpaque = sOpaque;
return this;
} | [
"@",
"Nonnull",
"public",
"DigestAuthServerBuilder",
"setOpaque",
"(",
"@",
"Nonnull",
"final",
"String",
"sOpaque",
")",
"{",
"if",
"(",
"!",
"HttpStringHelper",
".",
"isQuotedTextContent",
"(",
"sOpaque",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"("... | A string of data, specified by the server, which should be returned by the
client unchanged in the Authorization header of subsequent requests with
URIs in the same protection space. It is recommended that this string be
base64 or hexadecimal data.
@param sOpaque
The opaque value. May not be <code>null</code>.
@return this | [
"A",
"string",
"of",
"data",
"specified",
"by",
"the",
"server",
"which",
"should",
"be",
"returned",
"by",
"the",
"client",
"unchanged",
"in",
"the",
"Authorization",
"header",
"of",
"subsequent",
"requests",
"with",
"URIs",
"in",
"the",
"same",
"protection",... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-http/src/main/java/com/helger/http/digestauth/DigestAuthServerBuilder.java#L161-L169 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java | ServletHelper.getRequestPathInfo | @Nonnull
public static String getRequestPathInfo (@Nullable final HttpServletRequest aRequest)
{
String ret = null;
if (aRequest != null)
try
{
// They may return null!
if (aRequest.isAsyncSupported () && aRequest.isAsyncStarted ())
ret = (String) aRequest.getAttribute (AsyncContext.ASYNC_PATH_INFO);
else
ret = aRequest.getPathInfo ();
}
catch (final UnsupportedOperationException ex)
{
// Offline request - fall through
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine path info of HTTP request", ex);
}
return ret == null ? "" : ret;
} | java | @Nonnull
public static String getRequestPathInfo (@Nullable final HttpServletRequest aRequest)
{
String ret = null;
if (aRequest != null)
try
{
// They may return null!
if (aRequest.isAsyncSupported () && aRequest.isAsyncStarted ())
ret = (String) aRequest.getAttribute (AsyncContext.ASYNC_PATH_INFO);
else
ret = aRequest.getPathInfo ();
}
catch (final UnsupportedOperationException ex)
{
// Offline request - fall through
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine path info of HTTP request", ex);
}
return ret == null ? "" : ret;
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getRequestPathInfo",
"(",
"@",
"Nullable",
"final",
"HttpServletRequest",
"aRequest",
")",
"{",
"String",
"ret",
"=",
"null",
";",
"if",
"(",
"aRequest",
"!=",
"null",
")",
"try",
"{",
"// They may return null!",
... | Get the path info of an request, supporting sync and async requests.
@param aRequest
Source request. May be <code>null</code>.
@return Empty string if request is <code>null</code> or a the path info. | [
"Get",
"the",
"path",
"info",
"of",
"an",
"request",
"supporting",
"sync",
"and",
"async",
"requests",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java#L168-L193 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java | ServletHelper.getRequestRequestURI | @Nonnull
public static String getRequestRequestURI (@Nullable final HttpServletRequest aRequest)
{
String ret = "";
if (aRequest != null)
try
{
if (aRequest.isAsyncSupported () && aRequest.isAsyncStarted ())
ret = (String) aRequest.getAttribute (AsyncContext.ASYNC_REQUEST_URI);
else
ret = aRequest.getRequestURI ();
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine request URI of HTTP request", ex);
}
return ret;
} | java | @Nonnull
public static String getRequestRequestURI (@Nullable final HttpServletRequest aRequest)
{
String ret = "";
if (aRequest != null)
try
{
if (aRequest.isAsyncSupported () && aRequest.isAsyncStarted ())
ret = (String) aRequest.getAttribute (AsyncContext.ASYNC_REQUEST_URI);
else
ret = aRequest.getRequestURI ();
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine request URI of HTTP request", ex);
}
return ret;
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getRequestRequestURI",
"(",
"@",
"Nullable",
"final",
"HttpServletRequest",
"aRequest",
")",
"{",
"String",
"ret",
"=",
"\"\"",
";",
"if",
"(",
"aRequest",
"!=",
"null",
")",
"try",
"{",
"if",
"(",
"aRequest",
... | Get the request URI of an request, supporting sync and async requests.
@param aRequest
Source request. May be <code>null</code>.
@return Empty string if request is <code>null</code> or the request URI. | [
"Get",
"the",
"request",
"URI",
"of",
"an",
"request",
"supporting",
"sync",
"and",
"async",
"requests",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java#L238-L258 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java | ServletHelper.getRequestRequestURL | @Nonnull
public static StringBuffer getRequestRequestURL (@Nullable final HttpServletRequest aRequest)
{
StringBuffer ret = null;
if (aRequest != null)
try
{
ret = aRequest.getRequestURL ();
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine request URL of HTTP request", ex);
}
return ret != null ? ret : new StringBuffer ();
} | java | @Nonnull
public static StringBuffer getRequestRequestURL (@Nullable final HttpServletRequest aRequest)
{
StringBuffer ret = null;
if (aRequest != null)
try
{
ret = aRequest.getRequestURL ();
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine request URL of HTTP request", ex);
}
return ret != null ? ret : new StringBuffer ();
} | [
"@",
"Nonnull",
"public",
"static",
"StringBuffer",
"getRequestRequestURL",
"(",
"@",
"Nullable",
"final",
"HttpServletRequest",
"aRequest",
")",
"{",
"StringBuffer",
"ret",
"=",
"null",
";",
"if",
"(",
"aRequest",
"!=",
"null",
")",
"try",
"{",
"ret",
"=",
... | Get the request URL of an request, supporting sync and async requests.
@param aRequest
Source request. May be <code>null</code>.
@return Empty {@link StringBuffer} if request is <code>null</code> or the
request URL. | [
"Get",
"the",
"request",
"URL",
"of",
"an",
"request",
"supporting",
"sync",
"and",
"async",
"requests",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java#L268-L285 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java | ServletHelper.getRequestServletPath | @Nonnull
public static String getRequestServletPath (@Nullable final HttpServletRequest aRequest)
{
String ret = "";
if (aRequest != null)
try
{
if (aRequest.isAsyncSupported () && aRequest.isAsyncStarted ())
ret = (String) aRequest.getAttribute (AsyncContext.ASYNC_SERVLET_PATH);
else
ret = aRequest.getServletPath ();
}
catch (final UnsupportedOperationException ex)
{
// Offline request - fall through
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine servlet path of HTTP request", ex);
}
return ret;
} | java | @Nonnull
public static String getRequestServletPath (@Nullable final HttpServletRequest aRequest)
{
String ret = "";
if (aRequest != null)
try
{
if (aRequest.isAsyncSupported () && aRequest.isAsyncStarted ())
ret = (String) aRequest.getAttribute (AsyncContext.ASYNC_SERVLET_PATH);
else
ret = aRequest.getServletPath ();
}
catch (final UnsupportedOperationException ex)
{
// Offline request - fall through
}
catch (final Exception ex)
{
// fall through
if (isLogExceptions ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("[ServletHelper] Failed to determine servlet path of HTTP request", ex);
}
return ret;
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getRequestServletPath",
"(",
"@",
"Nullable",
"final",
"HttpServletRequest",
"aRequest",
")",
"{",
"String",
"ret",
"=",
"\"\"",
";",
"if",
"(",
"aRequest",
"!=",
"null",
")",
"try",
"{",
"if",
"(",
"aRequest",
... | Get the servlet path of an request, supporting sync and async requests.
@param aRequest
Source request. May be <code>null</code>.
@return Empty string if request is <code>null</code> or the servlet path.
@since 8.8.0 | [
"Get",
"the",
"servlet",
"path",
"of",
"an",
"request",
"supporting",
"sync",
"and",
"async",
"requests",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/ServletHelper.java#L295-L319 | train |
phax/ph-web | ph-http/src/main/java/com/helger/http/basicauth/BasicAuthServerBuilder.java | BasicAuthServerBuilder.setRealm | @Nonnull
public BasicAuthServerBuilder setRealm (@Nonnull final String sRealm)
{
ValueEnforcer.isTrue (HttpStringHelper.isQuotedTextContent (sRealm), () -> "Realm is invalid: " + sRealm);
m_sRealm = sRealm;
return this;
} | java | @Nonnull
public BasicAuthServerBuilder setRealm (@Nonnull final String sRealm)
{
ValueEnforcer.isTrue (HttpStringHelper.isQuotedTextContent (sRealm), () -> "Realm is invalid: " + sRealm);
m_sRealm = sRealm;
return this;
} | [
"@",
"Nonnull",
"public",
"BasicAuthServerBuilder",
"setRealm",
"(",
"@",
"Nonnull",
"final",
"String",
"sRealm",
")",
"{",
"ValueEnforcer",
".",
"isTrue",
"(",
"HttpStringHelper",
".",
"isQuotedTextContent",
"(",
"sRealm",
")",
",",
"(",
")",
"->",
"\"Realm is ... | Set the realm to be used.
@param sRealm
The realm to be used. May not be <code>null</code> and should not be
empty.
@return this | [
"Set",
"the",
"realm",
"to",
"be",
"used",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-http/src/main/java/com/helger/http/basicauth/BasicAuthServerBuilder.java#L45-L52 | train |
khmarbaise/sapm | src/main/java/com/soebes/subversion/sapm/Path.java | Path.contains | public boolean contains(String path) {
boolean result = false;
FileName fn = new FileName(path);
if (fn.getPath().startsWith(getPath())) {
result = true;
}
return result;
} | java | public boolean contains(String path) {
boolean result = false;
FileName fn = new FileName(path);
if (fn.getPath().startsWith(getPath())) {
result = true;
}
return result;
} | [
"public",
"boolean",
"contains",
"(",
"String",
"path",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"FileName",
"fn",
"=",
"new",
"FileName",
"(",
"path",
")",
";",
"if",
"(",
"fn",
".",
"getPath",
"(",
")",
".",
"startsWith",
"(",
"getPath",
"... | This will check if the given path
is part of the path which is represented by
this instance.
@see {@link PathTest}
@param path The path to check for.
@return true if the given path is contained in false otherwise. | [
"This",
"will",
"check",
"if",
"the",
"given",
"path",
"is",
"part",
"of",
"the",
"path",
"which",
"is",
"represented",
"by",
"this",
"instance",
"."
] | b5da5b0d8929324f03cb3a4233a3534813f93eea | https://github.com/khmarbaise/sapm/blob/b5da5b0d8929324f03cb3a4233a3534813f93eea/src/main/java/com/soebes/subversion/sapm/Path.java#L60-L67 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/processors/wordlist/WordlistsProcessor.java | WordlistsProcessor.getCurrentAttempt | public String getCurrentAttempt()
{
if (currentIndex < words.size())
{
final String currentAttempt = words.get(currentIndex);
return currentAttempt;
}
return null;
} | java | public String getCurrentAttempt()
{
if (currentIndex < words.size())
{
final String currentAttempt = words.get(currentIndex);
return currentAttempt;
}
return null;
} | [
"public",
"String",
"getCurrentAttempt",
"(",
")",
"{",
"if",
"(",
"currentIndex",
"<",
"words",
".",
"size",
"(",
")",
")",
"{",
"final",
"String",
"currentAttempt",
"=",
"words",
".",
"get",
"(",
"currentIndex",
")",
";",
"return",
"currentAttempt",
";",... | Gets the current attempt.
@return the current attempt | [
"Gets",
"the",
"current",
"attempt",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/processors/wordlist/WordlistsProcessor.java#L86-L94 | train |
astrapi69/mystic-crypt | crypt-core/src/main/java/de/alpharogroup/crypto/processors/wordlist/WordlistsProcessor.java | WordlistsProcessor.process | public boolean process()
{
boolean continueIterate = true;
boolean found = false;
String attempt = getCurrentAttempt();
while (continueIterate)
{
if (attempt.equals(toCheckAgainst))
{
found = true;
break;
}
attempt = getCurrentAttempt();
continueIterate = increment();
}
return found;
} | java | public boolean process()
{
boolean continueIterate = true;
boolean found = false;
String attempt = getCurrentAttempt();
while (continueIterate)
{
if (attempt.equals(toCheckAgainst))
{
found = true;
break;
}
attempt = getCurrentAttempt();
continueIterate = increment();
}
return found;
} | [
"public",
"boolean",
"process",
"(",
")",
"{",
"boolean",
"continueIterate",
"=",
"true",
";",
"boolean",
"found",
"=",
"false",
";",
"String",
"attempt",
"=",
"getCurrentAttempt",
"(",
")",
";",
"while",
"(",
"continueIterate",
")",
"{",
"if",
"(",
"attem... | Processes the word list.
@return true, if successful | [
"Processes",
"the",
"word",
"list",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-core/src/main/java/de/alpharogroup/crypto/processors/wordlist/WordlistsProcessor.java#L116-L132 | train |
phax/ph-web | ph-smtp/src/main/java/com/helger/smtp/failed/FailedMailQueue.java | FailedMailQueue.remove | @Nullable
public FailedMailData remove (@Nullable final String sID)
{
if (StringHelper.hasNoText (sID))
return null;
return m_aRWLock.writeLocked ( () -> internalRemove (sID));
} | java | @Nullable
public FailedMailData remove (@Nullable final String sID)
{
if (StringHelper.hasNoText (sID))
return null;
return m_aRWLock.writeLocked ( () -> internalRemove (sID));
} | [
"@",
"Nullable",
"public",
"FailedMailData",
"remove",
"(",
"@",
"Nullable",
"final",
"String",
"sID",
")",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sID",
")",
")",
"return",
"null",
";",
"return",
"m_aRWLock",
".",
"writeLocked",
"(",
"(",
... | Remove the failed mail at the given index.
@param sID
The ID of the failed mail data to be removed.
@return <code>null</code> if no such data exists | [
"Remove",
"the",
"failed",
"mail",
"at",
"the",
"given",
"index",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-smtp/src/main/java/com/helger/smtp/failed/FailedMailQueue.java#L92-L99 | train |
phax/ph-web | ph-http/src/main/java/com/helger/http/basicauth/HttpBasicAuth.java | HttpBasicAuth.getBasicAuthClientCredentials | @Nullable
public static BasicAuthClientCredentials getBasicAuthClientCredentials (@Nullable final String sAuthHeader)
{
final String sRealHeader = StringHelper.trim (sAuthHeader);
if (StringHelper.hasNoText (sRealHeader))
return null;
final String [] aElements = RegExHelper.getSplitToArray (sRealHeader, "\\s+", 2);
if (aElements.length != 2)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("String is not Basic Auth: " + sRealHeader);
return null;
}
if (!aElements[0].equals (HEADER_VALUE_PREFIX_BASIC))
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("String does not start with 'Basic': " + sRealHeader);
return null;
}
// Apply Base64 decoding
final String sEncodedCredentials = aElements[1];
final String sUsernamePassword = Base64.safeDecodeAsString (sEncodedCredentials, CHARSET);
if (sUsernamePassword == null)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Illegal Base64 encoded value '" + sEncodedCredentials + "'");
return null;
}
// Do we have a username/password separator?
final int nIndex = sUsernamePassword.indexOf (USERNAME_PASSWORD_SEPARATOR);
if (nIndex >= 0)
return new BasicAuthClientCredentials (sUsernamePassword.substring (0, nIndex),
sUsernamePassword.substring (nIndex + 1));
return new BasicAuthClientCredentials (sUsernamePassword);
} | java | @Nullable
public static BasicAuthClientCredentials getBasicAuthClientCredentials (@Nullable final String sAuthHeader)
{
final String sRealHeader = StringHelper.trim (sAuthHeader);
if (StringHelper.hasNoText (sRealHeader))
return null;
final String [] aElements = RegExHelper.getSplitToArray (sRealHeader, "\\s+", 2);
if (aElements.length != 2)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("String is not Basic Auth: " + sRealHeader);
return null;
}
if (!aElements[0].equals (HEADER_VALUE_PREFIX_BASIC))
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("String does not start with 'Basic': " + sRealHeader);
return null;
}
// Apply Base64 decoding
final String sEncodedCredentials = aElements[1];
final String sUsernamePassword = Base64.safeDecodeAsString (sEncodedCredentials, CHARSET);
if (sUsernamePassword == null)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Illegal Base64 encoded value '" + sEncodedCredentials + "'");
return null;
}
// Do we have a username/password separator?
final int nIndex = sUsernamePassword.indexOf (USERNAME_PASSWORD_SEPARATOR);
if (nIndex >= 0)
return new BasicAuthClientCredentials (sUsernamePassword.substring (0, nIndex),
sUsernamePassword.substring (nIndex + 1));
return new BasicAuthClientCredentials (sUsernamePassword);
} | [
"@",
"Nullable",
"public",
"static",
"BasicAuthClientCredentials",
"getBasicAuthClientCredentials",
"(",
"@",
"Nullable",
"final",
"String",
"sAuthHeader",
")",
"{",
"final",
"String",
"sRealHeader",
"=",
"StringHelper",
".",
"trim",
"(",
"sAuthHeader",
")",
";",
"i... | Get the Basic authentication credentials from the passed HTTP header value.
@param sAuthHeader
The HTTP header value to be interpreted. May be <code>null</code>.
@return <code>null</code> if the passed value is not a correct HTTP Basic
Authentication header value. | [
"Get",
"the",
"Basic",
"authentication",
"credentials",
"from",
"the",
"passed",
"HTTP",
"header",
"value",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-http/src/main/java/com/helger/http/basicauth/HttpBasicAuth.java#L62-L100 | train |
phax/ph-web | ph-xservlet/src/main/java/com/helger/xservlet/servletstatus/ServletStatusManager.java | ServletStatusManager.onServletInit | public void onServletInit (@Nonnull final Class <? extends GenericServlet> aServletClass)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("onServletInit: " + aServletClass);
_updateStatus (aServletClass, EServletStatus.INITED);
} | java | public void onServletInit (@Nonnull final Class <? extends GenericServlet> aServletClass)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("onServletInit: " + aServletClass);
_updateStatus (aServletClass, EServletStatus.INITED);
} | [
"public",
"void",
"onServletInit",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"?",
"extends",
"GenericServlet",
">",
"aServletClass",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"debug",
"(",
"\"onServletInit: \"",
"+... | Invoked at the beginning of the servlet initialization.
@param aServletClass
Relevant servlet class. May not be <code>null</code>. | [
"Invoked",
"at",
"the",
"beginning",
"of",
"the",
"servlet",
"initialization",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-xservlet/src/main/java/com/helger/xservlet/servletstatus/ServletStatusManager.java#L122-L127 | train |
phax/ph-web | ph-xservlet/src/main/java/com/helger/xservlet/servletstatus/ServletStatusManager.java | ServletStatusManager.onServletInvocation | public void onServletInvocation (@Nonnull final Class <? extends GenericServlet> aServletClass)
{
m_aRWLock.writeLocked ( () -> _getOrCreateServletStatus (aServletClass).internalIncrementInvocationCount ());
} | java | public void onServletInvocation (@Nonnull final Class <? extends GenericServlet> aServletClass)
{
m_aRWLock.writeLocked ( () -> _getOrCreateServletStatus (aServletClass).internalIncrementInvocationCount ());
} | [
"public",
"void",
"onServletInvocation",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"?",
"extends",
"GenericServlet",
">",
"aServletClass",
")",
"{",
"m_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"_getOrCreateServletStatus",
"(",
"aServletClass",
")",
"... | Invoked at the beginning of a servlet invocation
@param aServletClass
Servlet class invoked. May not be <code>null</code>. | [
"Invoked",
"at",
"the",
"beginning",
"of",
"a",
"servlet",
"invocation"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-xservlet/src/main/java/com/helger/xservlet/servletstatus/ServletStatusManager.java#L144-L147 | train |
phax/ph-web | ph-network/src/main/java/com/helger/network/port/NetworkPortHelper.java | NetworkPortHelper.checkPortOpen | @Nonnull
public static ENetworkPortStatus checkPortOpen (@Nonnull @Nonempty final String sHostName,
@Nonnegative final int nPort,
@Nonnegative final int nTimeoutMillisecs)
{
ValueEnforcer.notEmpty (sHostName, "Hostname");
ValueEnforcer.isGE0 (nPort, "Port");
ValueEnforcer.isGE0 (nTimeoutMillisecs, "TimeoutMillisecs");
LOGGER.info ("Checking TCP port status for " +
sHostName +
":" +
nPort +
" with timeouf of " +
nTimeoutMillisecs +
" ms");
try (final Socket aSocket = new Socket ())
{
aSocket.setReuseAddress (true);
final SocketAddress aSocketAddr = new InetSocketAddress (sHostName, nPort);
aSocket.connect (aSocketAddr, nTimeoutMillisecs);
return ENetworkPortStatus.PORT_IS_OPEN;
}
catch (final IOException ex)
{
// Can also be:
// Connection refused: connect
if (ex.getMessage ().startsWith ("Connection refused"))
return ENetworkPortStatus.PORT_IS_CLOSED;
if (ex instanceof java.net.UnknownHostException)
return ENetworkPortStatus.HOST_NOT_EXISTING;
if (ex instanceof java.net.SocketTimeoutException)
return ENetworkPortStatus.CONNECTION_TIMEOUT;
if (ex instanceof java.net.ConnectException)
{
// E.g. for port 0
return ENetworkPortStatus.GENERIC_IO_ERROR;
}
LOGGER.error ("Other error checking TCP port status", ex);
return ENetworkPortStatus.GENERIC_IO_ERROR;
}
} | java | @Nonnull
public static ENetworkPortStatus checkPortOpen (@Nonnull @Nonempty final String sHostName,
@Nonnegative final int nPort,
@Nonnegative final int nTimeoutMillisecs)
{
ValueEnforcer.notEmpty (sHostName, "Hostname");
ValueEnforcer.isGE0 (nPort, "Port");
ValueEnforcer.isGE0 (nTimeoutMillisecs, "TimeoutMillisecs");
LOGGER.info ("Checking TCP port status for " +
sHostName +
":" +
nPort +
" with timeouf of " +
nTimeoutMillisecs +
" ms");
try (final Socket aSocket = new Socket ())
{
aSocket.setReuseAddress (true);
final SocketAddress aSocketAddr = new InetSocketAddress (sHostName, nPort);
aSocket.connect (aSocketAddr, nTimeoutMillisecs);
return ENetworkPortStatus.PORT_IS_OPEN;
}
catch (final IOException ex)
{
// Can also be:
// Connection refused: connect
if (ex.getMessage ().startsWith ("Connection refused"))
return ENetworkPortStatus.PORT_IS_CLOSED;
if (ex instanceof java.net.UnknownHostException)
return ENetworkPortStatus.HOST_NOT_EXISTING;
if (ex instanceof java.net.SocketTimeoutException)
return ENetworkPortStatus.CONNECTION_TIMEOUT;
if (ex instanceof java.net.ConnectException)
{
// E.g. for port 0
return ENetworkPortStatus.GENERIC_IO_ERROR;
}
LOGGER.error ("Other error checking TCP port status", ex);
return ENetworkPortStatus.GENERIC_IO_ERROR;
}
} | [
"@",
"Nonnull",
"public",
"static",
"ENetworkPortStatus",
"checkPortOpen",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sHostName",
",",
"@",
"Nonnegative",
"final",
"int",
"nPort",
",",
"@",
"Nonnegative",
"final",
"int",
"nTimeoutMillisecs",
")",
... | Check the status of a remote port.
@param sHostName
Hostname or IP address to check.
@param nPort
Port number to check.
@param nTimeoutMillisecs
Connection timeout in milliseconds.
@return Never <code>null</code>. | [
"Check",
"the",
"status",
"of",
"a",
"remote",
"port",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-network/src/main/java/com/helger/network/port/NetworkPortHelper.java#L76-L118 | train |
phax/ph-web | ph-useragent/src/main/java/com/helger/useragent/UserAgentDecryptor.java | UserAgentDecryptor._decryptUserAgent | @Nonnull
private static UserAgentElementList _decryptUserAgent (@Nonnull final String sUserAgent)
{
final UserAgentElementList ret = new UserAgentElementList ();
final StringScanner aSS = new StringScanner (sUserAgent.trim ());
while (true)
{
aSS.skipWhitespaces ();
final int nIndex = aSS.findFirstIndex ('/', ' ', '[', '(');
if (nIndex == -1)
break;
switch (aSS.getCharAtIndex (nIndex))
{
case '/':
{
// e.g. "a/b"
final String sKey = aSS.getUntilIndex (nIndex);
final String sValue = aSS.skip (1).getUntilWhiteSpace ();
final String sFullValue = sKey + "/" + sValue;
// Special handling of URLs :)
if (URLProtocolRegistry.getInstance ().hasKnownProtocol (sFullValue))
ret.add (sFullValue);
else
ret.add (Pair.create (sKey, sValue));
break;
}
case ' ':
{
// e.g. "Opera 6.03"
// e.g. "HTC_P3700 Opera/9.50 (Windows NT 5.1; U; de)"
final String sText = aSS.getUntilIndex (nIndex).trim ();
final Matcher aMatcher = RegExHelper.getMatcher ("([^\\s]+)\\s+([0-9]+\\.[0-9]+)", sText);
if (aMatcher.matches ())
ret.add (Pair.create (aMatcher.group (1), aMatcher.group (2)));
else
ret.add (sText);
break;
}
case '[':
{
// e.g. "[en]"
aSS.setIndex (nIndex).skip (1); // skip incl. "["
ret.add (aSS.getUntil (']'));
aSS.skip (1);
break;
}
case '(':
{
// e.g. "(compatible; MSIE 5.0; Windows 2000)"
aSS.setIndex (nIndex).skip (1); // skip incl. "("
final String sParams = aSS.getUntilBalanced (1, '(', ')');
// convert to ";" separated list
final ICommonsList <String> aParams = StringHelper.getExploded (';', sParams);
ret.add (aParams.getAllMapped (String::trim));
break;
}
default:
throw new IllegalStateException ("Invalid character: " + aSS.getCharAtIndex (nIndex));
}
}
// add all remaining parts as is
final String sRest = aSS.getRest ().trim ();
if (sRest.length () > 0)
ret.add (sRest);
return ret;
} | java | @Nonnull
private static UserAgentElementList _decryptUserAgent (@Nonnull final String sUserAgent)
{
final UserAgentElementList ret = new UserAgentElementList ();
final StringScanner aSS = new StringScanner (sUserAgent.trim ());
while (true)
{
aSS.skipWhitespaces ();
final int nIndex = aSS.findFirstIndex ('/', ' ', '[', '(');
if (nIndex == -1)
break;
switch (aSS.getCharAtIndex (nIndex))
{
case '/':
{
// e.g. "a/b"
final String sKey = aSS.getUntilIndex (nIndex);
final String sValue = aSS.skip (1).getUntilWhiteSpace ();
final String sFullValue = sKey + "/" + sValue;
// Special handling of URLs :)
if (URLProtocolRegistry.getInstance ().hasKnownProtocol (sFullValue))
ret.add (sFullValue);
else
ret.add (Pair.create (sKey, sValue));
break;
}
case ' ':
{
// e.g. "Opera 6.03"
// e.g. "HTC_P3700 Opera/9.50 (Windows NT 5.1; U; de)"
final String sText = aSS.getUntilIndex (nIndex).trim ();
final Matcher aMatcher = RegExHelper.getMatcher ("([^\\s]+)\\s+([0-9]+\\.[0-9]+)", sText);
if (aMatcher.matches ())
ret.add (Pair.create (aMatcher.group (1), aMatcher.group (2)));
else
ret.add (sText);
break;
}
case '[':
{
// e.g. "[en]"
aSS.setIndex (nIndex).skip (1); // skip incl. "["
ret.add (aSS.getUntil (']'));
aSS.skip (1);
break;
}
case '(':
{
// e.g. "(compatible; MSIE 5.0; Windows 2000)"
aSS.setIndex (nIndex).skip (1); // skip incl. "("
final String sParams = aSS.getUntilBalanced (1, '(', ')');
// convert to ";" separated list
final ICommonsList <String> aParams = StringHelper.getExploded (';', sParams);
ret.add (aParams.getAllMapped (String::trim));
break;
}
default:
throw new IllegalStateException ("Invalid character: " + aSS.getCharAtIndex (nIndex));
}
}
// add all remaining parts as is
final String sRest = aSS.getRest ().trim ();
if (sRest.length () > 0)
ret.add (sRest);
return ret;
} | [
"@",
"Nonnull",
"private",
"static",
"UserAgentElementList",
"_decryptUserAgent",
"(",
"@",
"Nonnull",
"final",
"String",
"sUserAgent",
")",
"{",
"final",
"UserAgentElementList",
"ret",
"=",
"new",
"UserAgentElementList",
"(",
")",
";",
"final",
"StringScanner",
"aS... | Parse the passed user agent.
@param sUserAgent
The user agent string to parse.
@return A list than can contain {@link ReadOnlyPair}, {@link String} and
{@link ICommonsList} of String objects. | [
"Parse",
"the",
"passed",
"user",
"agent",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-useragent/src/main/java/com/helger/useragent/UserAgentDecryptor.java#L58-L126 | train |
phax/ph-web | ph-useragent/src/main/java/com/helger/useragent/UserAgentDecryptor.java | UserAgentDecryptor.decryptUserAgentString | @Nonnull
public static IUserAgent decryptUserAgentString (@Nonnull final String sUserAgent)
{
ValueEnforcer.notNull (sUserAgent, "UserAgent");
String sRealUserAgent = sUserAgent;
// Check if surrounded with '"' or '''
if (sRealUserAgent.length () >= 2)
{
final char cFirst = sRealUserAgent.charAt (0);
if ((cFirst == '\'' || cFirst == '"') && StringHelper.getLastChar (sRealUserAgent) == cFirst)
sRealUserAgent = sRealUserAgent.substring (1, sRealUserAgent.length () - 1);
}
// Skip a certain prefix that is known to occur frequently
if (sRealUserAgent.startsWith (SKIP_PREFIX))
sRealUserAgent = sRealUserAgent.substring (SKIP_PREFIX.length ());
return new UserAgent (sRealUserAgent, _decryptUserAgent (sRealUserAgent));
} | java | @Nonnull
public static IUserAgent decryptUserAgentString (@Nonnull final String sUserAgent)
{
ValueEnforcer.notNull (sUserAgent, "UserAgent");
String sRealUserAgent = sUserAgent;
// Check if surrounded with '"' or '''
if (sRealUserAgent.length () >= 2)
{
final char cFirst = sRealUserAgent.charAt (0);
if ((cFirst == '\'' || cFirst == '"') && StringHelper.getLastChar (sRealUserAgent) == cFirst)
sRealUserAgent = sRealUserAgent.substring (1, sRealUserAgent.length () - 1);
}
// Skip a certain prefix that is known to occur frequently
if (sRealUserAgent.startsWith (SKIP_PREFIX))
sRealUserAgent = sRealUserAgent.substring (SKIP_PREFIX.length ());
return new UserAgent (sRealUserAgent, _decryptUserAgent (sRealUserAgent));
} | [
"@",
"Nonnull",
"public",
"static",
"IUserAgent",
"decryptUserAgentString",
"(",
"@",
"Nonnull",
"final",
"String",
"sUserAgent",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"sUserAgent",
",",
"\"UserAgent\"",
")",
";",
"String",
"sRealUserAgent",
"=",
"sUserA... | Decrypt the passed user agent string.
@param sUserAgent
The user agent string to decrypt. May not be <code>null</code>.
@return The user agent object. Never <code>null</code>. | [
"Decrypt",
"the",
"passed",
"user",
"agent",
"string",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-useragent/src/main/java/com/helger/useragent/UserAgentDecryptor.java#L135-L155 | train |
phax/ph-web | ph-network/src/main/java/com/helger/network/proxy/AuthenticatorProxySettingsManager.java | AuthenticatorProxySettingsManager.requestProxyPasswordAuthentication | @Nullable
public static PasswordAuthentication requestProxyPasswordAuthentication (@Nullable final String sHostName,
@Nullable final int nPort,
@Nullable final String sProtocol)
{
return requestPasswordAuthentication (sHostName,
(InetAddress) null,
nPort,
sProtocol,
(String) null,
(String) null,
(URL) null,
RequestorType.PROXY);
} | java | @Nullable
public static PasswordAuthentication requestProxyPasswordAuthentication (@Nullable final String sHostName,
@Nullable final int nPort,
@Nullable final String sProtocol)
{
return requestPasswordAuthentication (sHostName,
(InetAddress) null,
nPort,
sProtocol,
(String) null,
(String) null,
(URL) null,
RequestorType.PROXY);
} | [
"@",
"Nullable",
"public",
"static",
"PasswordAuthentication",
"requestProxyPasswordAuthentication",
"(",
"@",
"Nullable",
"final",
"String",
"sHostName",
",",
"@",
"Nullable",
"final",
"int",
"nPort",
",",
"@",
"Nullable",
"final",
"String",
"sProtocol",
")",
"{",
... | Shortcut method for requesting proxy password authentication. This method
can also be used, if this class is NOT the default Authenticator.
@param sHostName
Hostname to query
@param nPort
Port to query
@param sProtocol
Protocol to use
@return <code>null</code> if nothing is found. | [
"Shortcut",
"method",
"for",
"requesting",
"proxy",
"password",
"authentication",
".",
"This",
"method",
"can",
"also",
"be",
"used",
"if",
"this",
"class",
"is",
"NOT",
"the",
"default",
"Authenticator",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-network/src/main/java/com/helger/network/proxy/AuthenticatorProxySettingsManager.java#L130-L143 | train |
beothorn/webGrude | src/main/java/webGrude/Browser.java | Browser.get | public static <T> T get(final Class<T> pageClass, final String... params) {
cryIfNotAnnotated(pageClass);
try {
final String pageUrl = pageClass.getAnnotation(Page.class).value();
return loadPage(pageUrl, pageClass, Arrays.asList(params));
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | java | public static <T> T get(final Class<T> pageClass, final String... params) {
cryIfNotAnnotated(pageClass);
try {
final String pageUrl = pageClass.getAnnotation(Page.class).value();
return loadPage(pageUrl, pageClass, Arrays.asList(params));
} catch (final Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"<",
"T",
">",
"T",
"get",
"(",
"final",
"Class",
"<",
"T",
">",
"pageClass",
",",
"final",
"String",
"...",
"params",
")",
"{",
"cryIfNotAnnotated",
"(",
"pageClass",
")",
";",
"try",
"{",
"final",
"String",
"pageUrl",
"=",
"pageCl... | Loads content from url from the Page annotation on pageClass onto an instance of pageClass.
@param <T> A instance of the class with a {@literal @}Page annotantion
@param pageClass A class with a {@literal @}Page annotantion
@param params Optional, if the pageClass has a url with parameters
@return The class instantiated and with the fields with the
{@literal @}Selector annotation populated.
@throws webGrude.http.GetException When calling get on the BrowserClient raises an exception | [
"Loads",
"content",
"from",
"url",
"from",
"the",
"Page",
"annotation",
"on",
"pageClass",
"onto",
"an",
"instance",
"of",
"pageClass",
"."
] | e30f281723bf0edaf72bcbfc9582d67f8fe39c1f | https://github.com/beothorn/webGrude/blob/e30f281723bf0edaf72bcbfc9582d67f8fe39c1f/src/main/java/webGrude/Browser.java#L83-L91 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java | RequestParamMap._getChildMapExceptLast | @Nullable
private ICommonsOrderedMap <String, RequestParamMapItem> _getChildMapExceptLast (@Nonnull @Nonempty final String... aPath)
{
ValueEnforcer.notEmpty (aPath, "Path");
ICommonsOrderedMap <String, RequestParamMapItem> aMap = m_aMap;
// Until the second last object
for (int i = 0; i < aPath.length - 1; ++i)
{
aMap = _getChildMap (aMap, aPath[i]);
if (aMap == null)
return null;
}
return aMap;
} | java | @Nullable
private ICommonsOrderedMap <String, RequestParamMapItem> _getChildMapExceptLast (@Nonnull @Nonempty final String... aPath)
{
ValueEnforcer.notEmpty (aPath, "Path");
ICommonsOrderedMap <String, RequestParamMapItem> aMap = m_aMap;
// Until the second last object
for (int i = 0; i < aPath.length - 1; ++i)
{
aMap = _getChildMap (aMap, aPath[i]);
if (aMap == null)
return null;
}
return aMap;
} | [
"@",
"Nullable",
"private",
"ICommonsOrderedMap",
"<",
"String",
",",
"RequestParamMapItem",
">",
"_getChildMapExceptLast",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"...",
"aPath",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"aPath",
",",
"\... | Iterate the root map down to the map specified by the passed path except
for the last element.
@param aPath
The path to iterate. May neither be <code>null</code> nor empty.
@return The map. May be <code>null</code> if the path did not find such a
child. | [
"Iterate",
"the",
"root",
"map",
"down",
"to",
"the",
"map",
"specified",
"by",
"the",
"passed",
"path",
"except",
"for",
"the",
"last",
"element",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java#L166-L180 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java | RequestParamMap.getFieldName | @Nonnull
@Nonempty
@Deprecated
public static String getFieldName (@Nonnull @Nonempty final String sBaseName)
{
ValueEnforcer.notEmpty (sBaseName, "BaseName");
return sBaseName;
} | java | @Nonnull
@Nonempty
@Deprecated
public static String getFieldName (@Nonnull @Nonempty final String sBaseName)
{
ValueEnforcer.notEmpty (sBaseName, "BaseName");
return sBaseName;
} | [
"@",
"Nonnull",
"@",
"Nonempty",
"@",
"Deprecated",
"public",
"static",
"String",
"getFieldName",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sBaseName",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sBaseName",
",",
"\"BaseName\"",
")",
";",... | This method doesn't make sense but it should stay, so that it's easy to
spot usage of this invalid method.
@param sBaseName
Base name
@return Base name as is. | [
"This",
"method",
"doesn",
"t",
"make",
"sense",
"but",
"it",
"should",
"stay",
"so",
"that",
"it",
"s",
"easy",
"to",
"spot",
"usage",
"of",
"this",
"invalid",
"method",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java#L365-L373 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java | RequestParamMap.setSeparators | public static void setSeparators (final char cOpen, final char cClose)
{
ValueEnforcer.isFalse (cOpen == cClose, "Open and closing element may not be identical!");
s_sOpen = Character.toString (cOpen);
s_sClose = Character.toString (cClose);
} | java | public static void setSeparators (final char cOpen, final char cClose)
{
ValueEnforcer.isFalse (cOpen == cClose, "Open and closing element may not be identical!");
s_sOpen = Character.toString (cOpen);
s_sClose = Character.toString (cClose);
} | [
"public",
"static",
"void",
"setSeparators",
"(",
"final",
"char",
"cOpen",
",",
"final",
"char",
"cClose",
")",
"{",
"ValueEnforcer",
".",
"isFalse",
"(",
"cOpen",
"==",
"cClose",
",",
"\"Open and closing element may not be identical!\"",
")",
";",
"s_sOpen",
"="... | Set the separator chars to use.
@param cOpen
Open char
@param cClose
Close char - must be different from open char! | [
"Set",
"the",
"separator",
"chars",
"to",
"use",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java#L415-L420 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java | RequestParamMap.setSeparators | public static void setSeparators (@Nonnull @Nonempty final String sOpen, @Nonnull @Nonempty final String sClose)
{
ValueEnforcer.notEmpty (sOpen, "Open");
ValueEnforcer.notEmpty (sClose, "Close");
ValueEnforcer.isFalse (sOpen.contains (sClose), "open may not contain close");
ValueEnforcer.isFalse (sClose.contains (sOpen), "close may not contain open");
s_sOpen = sOpen;
s_sClose = sClose;
} | java | public static void setSeparators (@Nonnull @Nonempty final String sOpen, @Nonnull @Nonempty final String sClose)
{
ValueEnforcer.notEmpty (sOpen, "Open");
ValueEnforcer.notEmpty (sClose, "Close");
ValueEnforcer.isFalse (sOpen.contains (sClose), "open may not contain close");
ValueEnforcer.isFalse (sClose.contains (sOpen), "close may not contain open");
s_sOpen = sOpen;
s_sClose = sClose;
} | [
"public",
"static",
"void",
"setSeparators",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sOpen",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sClose",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sOpen",
",",
"\"Open\"",
")",
... | Set the separators to use.
@param sOpen
Open string. May neither be <code>null</code> nor empty.
@param sClose
Close string. May neither be <code>null</code> nor empty. | [
"Set",
"the",
"separators",
"to",
"use",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestParamMap.java#L430-L438 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getWithoutSessionID | @Nonnull
public static SimpleURL getWithoutSessionID (@Nonnull final ISimpleURL aURL)
{
ValueEnforcer.notNull (aURL, "URL");
// Strip the parameter from the path, but keep parameters and anchor intact!
// Note: using URLData avoid parsing, since the data was already parsed!
return new SimpleURL (new URLData (getWithoutSessionID (aURL.getPath ()), aURL.params (), aURL.getAnchor ()));
} | java | @Nonnull
public static SimpleURL getWithoutSessionID (@Nonnull final ISimpleURL aURL)
{
ValueEnforcer.notNull (aURL, "URL");
// Strip the parameter from the path, but keep parameters and anchor intact!
// Note: using URLData avoid parsing, since the data was already parsed!
return new SimpleURL (new URLData (getWithoutSessionID (aURL.getPath ()), aURL.params (), aURL.getAnchor ()));
} | [
"@",
"Nonnull",
"public",
"static",
"SimpleURL",
"getWithoutSessionID",
"(",
"@",
"Nonnull",
"final",
"ISimpleURL",
"aURL",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aURL",
",",
"\"URL\"",
")",
";",
"// Strip the parameter from the path, but keep parameters and a... | Get the passed string without an eventually contained session ID like in
"test.html;JSESSIONID=1234?param=value".
@param aURL
The value to strip the session ID from the path
@return The value without a session ID or the original string. | [
"Get",
"the",
"passed",
"string",
"without",
"an",
"eventually",
"contained",
"session",
"ID",
"like",
"in",
"test",
".",
"html",
";",
"JSESSIONID",
"=",
"1234?param",
"=",
"value",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L155-L162 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getPathWithinServletContext | @Nonnull
public static String getPathWithinServletContext (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final String sRequestURI = getRequestURI (aHttpRequest);
if (StringHelper.hasNoText (sRequestURI))
{
// Can e.g. happen for "Request(GET //localhost:90/)"
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Having empty request URI '" + sRequestURI + "' from request " + aHttpRequest);
return "/";
}
// Always use the context path
final String sContextPath = ServletContextPathHolder.getContextPath ();
if (StringHelper.hasNoText (sContextPath) || !sRequestURI.startsWith (sContextPath))
return sRequestURI;
// Normal case: URI contains context path.
final String sPath = sRequestURI.substring (sContextPath.length ());
return sPath.length () > 0 ? sPath : "/";
} | java | @Nonnull
public static String getPathWithinServletContext (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final String sRequestURI = getRequestURI (aHttpRequest);
if (StringHelper.hasNoText (sRequestURI))
{
// Can e.g. happen for "Request(GET //localhost:90/)"
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Having empty request URI '" + sRequestURI + "' from request " + aHttpRequest);
return "/";
}
// Always use the context path
final String sContextPath = ServletContextPathHolder.getContextPath ();
if (StringHelper.hasNoText (sContextPath) || !sRequestURI.startsWith (sContextPath))
return sRequestURI;
// Normal case: URI contains context path.
final String sPath = sRequestURI.substring (sContextPath.length ());
return sPath.length () > 0 ? sPath : "/";
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getPathWithinServletContext",
"(",
"@",
"Nonnull",
"final",
"HttpServletRequest",
"aHttpRequest",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aHttpRequest",
",",
"\"HttpRequest\"",
")",
";",
"final",
"String",
"sRe... | Return the URI of the request within the servlet context.
@param aHttpRequest
The HTTP request. May not be <code>null</code>.
@return the path within the web application and never <code>null</code>. By
default "/" is returned is an empty request URI is determined. | [
"Return",
"the",
"URI",
"of",
"the",
"request",
"within",
"the",
"servlet",
"context",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L282-L304 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getHttpVersion | @Nullable
public static EHttpVersion getHttpVersion (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final String sProtocol = aHttpRequest.getProtocol ();
return EHttpVersion.getFromNameOrNull (sProtocol);
} | java | @Nullable
public static EHttpVersion getHttpVersion (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final String sProtocol = aHttpRequest.getProtocol ();
return EHttpVersion.getFromNameOrNull (sProtocol);
} | [
"@",
"Nullable",
"public",
"static",
"EHttpVersion",
"getHttpVersion",
"(",
"@",
"Nonnull",
"final",
"HttpServletRequest",
"aHttpRequest",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aHttpRequest",
",",
"\"HttpRequest\"",
")",
";",
"final",
"String",
"sProtocol... | Get the HTTP version associated with the given HTTP request
@param aHttpRequest
The http request to query. May not be <code>null</code>.
@return <code>null</code> if no supported HTTP version is contained | [
"Get",
"the",
"HTTP",
"version",
"associated",
"with",
"the",
"given",
"HTTP",
"request"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L510-L517 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getHttpMethod | @Nullable
public static EHttpMethod getHttpMethod (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final String sMethod = aHttpRequest.getMethod ();
return EHttpMethod.getFromNameOrNull (sMethod);
} | java | @Nullable
public static EHttpMethod getHttpMethod (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final String sMethod = aHttpRequest.getMethod ();
return EHttpMethod.getFromNameOrNull (sMethod);
} | [
"@",
"Nullable",
"public",
"static",
"EHttpMethod",
"getHttpMethod",
"(",
"@",
"Nonnull",
"final",
"HttpServletRequest",
"aHttpRequest",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aHttpRequest",
",",
"\"HttpRequest\"",
")",
";",
"final",
"String",
"sMethod",
... | Get the HTTP method associated with the given HTTP request
@param aHttpRequest
The http request to query. May not be <code>null</code>.
@return <code>null</code> if no supported HTTP method is contained | [
"Get",
"the",
"HTTP",
"method",
"associated",
"with",
"the",
"given",
"HTTP",
"request"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L526-L533 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getRequestHeaderMap | @Nonnull
@ReturnsMutableCopy
public static HttpHeaderMap getRequestHeaderMap (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final HttpHeaderMap ret = new HttpHeaderMap ();
final Enumeration <String> aHeaders = aHttpRequest.getHeaderNames ();
while (aHeaders.hasMoreElements ())
{
final String sName = aHeaders.nextElement ();
final Enumeration <String> eHeaderValues = aHttpRequest.getHeaders (sName);
while (eHeaderValues.hasMoreElements ())
{
final String sValue = eHeaderValues.nextElement ();
ret.addHeader (sName, sValue);
}
}
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static HttpHeaderMap getRequestHeaderMap (@Nonnull final HttpServletRequest aHttpRequest)
{
ValueEnforcer.notNull (aHttpRequest, "HttpRequest");
final HttpHeaderMap ret = new HttpHeaderMap ();
final Enumeration <String> aHeaders = aHttpRequest.getHeaderNames ();
while (aHeaders.hasMoreElements ())
{
final String sName = aHeaders.nextElement ();
final Enumeration <String> eHeaderValues = aHttpRequest.getHeaders (sName);
while (eHeaderValues.hasMoreElements ())
{
final String sValue = eHeaderValues.nextElement ();
ret.addHeader (sName, sValue);
}
}
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"HttpHeaderMap",
"getRequestHeaderMap",
"(",
"@",
"Nonnull",
"final",
"HttpServletRequest",
"aHttpRequest",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aHttpRequest",
",",
"\"HttpRequest\"",
")",
";",... | Get a complete request header map as a copy.
@param aHttpRequest
The source HTTP request. May not be <code>null</code>.
@return Never <code>null</code>. | [
"Get",
"a",
"complete",
"request",
"header",
"map",
"as",
"a",
"copy",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L542-L561 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getRequestClientCertificates | @Nullable
public static X509Certificate [] getRequestClientCertificates (@Nonnull final HttpServletRequest aHttpRequest)
{
return _getRequestAttr (aHttpRequest, SERVLET_ATTR_CLIENT_CERTIFICATE, X509Certificate [].class);
} | java | @Nullable
public static X509Certificate [] getRequestClientCertificates (@Nonnull final HttpServletRequest aHttpRequest)
{
return _getRequestAttr (aHttpRequest, SERVLET_ATTR_CLIENT_CERTIFICATE, X509Certificate [].class);
} | [
"@",
"Nullable",
"public",
"static",
"X509Certificate",
"[",
"]",
"getRequestClientCertificates",
"(",
"@",
"Nonnull",
"final",
"HttpServletRequest",
"aHttpRequest",
")",
"{",
"return",
"_getRequestAttr",
"(",
"aHttpRequest",
",",
"SERVLET_ATTR_CLIENT_CERTIFICATE",
",",
... | Get the client certificates provided by a HTTP servlet request.
@param aHttpRequest
The HTTP servlet request to extract the information from. May not be
<code>null</code>.
@return <code>null</code> if the passed request does not contain any client
certificate | [
"Get",
"the",
"client",
"certificates",
"provided",
"by",
"a",
"HTTP",
"servlet",
"request",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L668-L672 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getHttpUserAgentStringFromRequest | @Nullable
public static String getHttpUserAgentStringFromRequest (@Nonnull final HttpServletRequest aHttpRequest)
{
// Use non-standard headers first
String sUserAgent = aHttpRequest.getHeader (CHttpHeader.UA);
if (sUserAgent == null)
{
sUserAgent = aHttpRequest.getHeader (CHttpHeader.X_DEVICE_USER_AGENT);
if (sUserAgent == null)
sUserAgent = aHttpRequest.getHeader (CHttpHeader.USER_AGENT);
}
return sUserAgent;
} | java | @Nullable
public static String getHttpUserAgentStringFromRequest (@Nonnull final HttpServletRequest aHttpRequest)
{
// Use non-standard headers first
String sUserAgent = aHttpRequest.getHeader (CHttpHeader.UA);
if (sUserAgent == null)
{
sUserAgent = aHttpRequest.getHeader (CHttpHeader.X_DEVICE_USER_AGENT);
if (sUserAgent == null)
sUserAgent = aHttpRequest.getHeader (CHttpHeader.USER_AGENT);
}
return sUserAgent;
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getHttpUserAgentStringFromRequest",
"(",
"@",
"Nonnull",
"final",
"HttpServletRequest",
"aHttpRequest",
")",
"{",
"// Use non-standard headers first",
"String",
"sUserAgent",
"=",
"aHttpRequest",
".",
"getHeader",
"(",
"CHtt... | Get the user agent from the given request.
@param aHttpRequest
The HTTP request to get the UA from.
@return <code>null</code> if no user agent string is present | [
"Get",
"the",
"user",
"agent",
"from",
"the",
"given",
"request",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L836-L848 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java | RequestHelper.getCheckBoxHiddenFieldName | @Nonnull
@Nonempty
public static String getCheckBoxHiddenFieldName (@Nonnull @Nonempty final String sFieldName)
{
ValueEnforcer.notEmpty (sFieldName, "FieldName");
return DEFAULT_CHECKBOX_HIDDEN_FIELD_PREFIX + sFieldName;
} | java | @Nonnull
@Nonempty
public static String getCheckBoxHiddenFieldName (@Nonnull @Nonempty final String sFieldName)
{
ValueEnforcer.notEmpty (sFieldName, "FieldName");
return DEFAULT_CHECKBOX_HIDDEN_FIELD_PREFIX + sFieldName;
} | [
"@",
"Nonnull",
"@",
"Nonempty",
"public",
"static",
"String",
"getCheckBoxHiddenFieldName",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sFieldName",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sFieldName",
",",
"\"FieldName\"",
")",
";",
"re... | Get the name of the automatic hidden field associated with a check-box.
@param sFieldName
The name of the check-box.
@return The name of the hidden field associated with the given check-box
name. | [
"Get",
"the",
"name",
"of",
"the",
"automatic",
"hidden",
"field",
"associated",
"with",
"a",
"check",
"-",
"box",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/request/RequestHelper.java#L926-L932 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/cookie/CookieHelper.java | CookieHelper.createCookie | @Nonnull
public static Cookie createCookie (@Nonnull final String sName,
@Nullable final String sValue,
final String sPath,
final boolean bExpireWhenBrowserIsClosed)
{
final Cookie aCookie = new Cookie (sName, sValue);
aCookie.setPath (sPath);
if (bExpireWhenBrowserIsClosed)
aCookie.setMaxAge (-1);
else
aCookie.setMaxAge (DEFAULT_MAX_AGE_SECONDS);
return aCookie;
} | java | @Nonnull
public static Cookie createCookie (@Nonnull final String sName,
@Nullable final String sValue,
final String sPath,
final boolean bExpireWhenBrowserIsClosed)
{
final Cookie aCookie = new Cookie (sName, sValue);
aCookie.setPath (sPath);
if (bExpireWhenBrowserIsClosed)
aCookie.setMaxAge (-1);
else
aCookie.setMaxAge (DEFAULT_MAX_AGE_SECONDS);
return aCookie;
} | [
"@",
"Nonnull",
"public",
"static",
"Cookie",
"createCookie",
"(",
"@",
"Nonnull",
"final",
"String",
"sName",
",",
"@",
"Nullable",
"final",
"String",
"sValue",
",",
"final",
"String",
"sPath",
",",
"final",
"boolean",
"bExpireWhenBrowserIsClosed",
")",
"{",
... | Create a cookie that is bound on a certain path within the local web
server.
@param sName
The cookie name.
@param sValue
The cookie value.
@param sPath
The path the cookie is valid for.
@param bExpireWhenBrowserIsClosed
<code>true</code> if this is a browser session cookie
@return The created cookie object. | [
"Create",
"a",
"cookie",
"that",
"is",
"bound",
"on",
"a",
"certain",
"path",
"within",
"the",
"local",
"web",
"server",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/cookie/CookieHelper.java#L99-L112 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/cookie/CookieHelper.java | CookieHelper.removeCookie | public static void removeCookie (@Nonnull final HttpServletResponse aHttpResponse, @Nonnull final Cookie aCookie)
{
ValueEnforcer.notNull (aHttpResponse, "HttpResponse");
ValueEnforcer.notNull (aCookie, "aCookie");
// expire the cookie!
aCookie.setMaxAge (0);
aHttpResponse.addCookie (aCookie);
} | java | public static void removeCookie (@Nonnull final HttpServletResponse aHttpResponse, @Nonnull final Cookie aCookie)
{
ValueEnforcer.notNull (aHttpResponse, "HttpResponse");
ValueEnforcer.notNull (aCookie, "aCookie");
// expire the cookie!
aCookie.setMaxAge (0);
aHttpResponse.addCookie (aCookie);
} | [
"public",
"static",
"void",
"removeCookie",
"(",
"@",
"Nonnull",
"final",
"HttpServletResponse",
"aHttpResponse",
",",
"@",
"Nonnull",
"final",
"Cookie",
"aCookie",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aHttpResponse",
",",
"\"HttpResponse\"",
")",
";",... | Remove a cookie by setting the max age to 0.
@param aHttpResponse
The HTTP response. May not be <code>null</code>.
@param aCookie
The cookie to be removed. May not be <code>null</code>. | [
"Remove",
"a",
"cookie",
"by",
"setting",
"the",
"max",
"age",
"to",
"0",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/cookie/CookieHelper.java#L135-L143 | train |
astrapi69/mystic-crypt | crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/EncryptedPrivateKeyReader.java | EncryptedPrivateKeyReader.readPasswordProtectedPrivateKey | public static PrivateKey readPasswordProtectedPrivateKey(final byte[] encryptedPrivateKeyBytes,
final String password, final String algorithm)
throws IOException, NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException
{
final EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new EncryptedPrivateKeyInfo(
encryptedPrivateKeyBytes);
final String algName = encryptedPrivateKeyInfo.getAlgName();
final Cipher cipher = CipherFactory.newCipher(algName);
final KeySpec pbeKeySpec = KeySpecFactory.newPBEKeySpec(password);
final SecretKeyFactory secretKeyFactory = SecretKeyFactoryExtensions
.newSecretKeyFactory(algName);
final Key pbeKey = secretKeyFactory.generateSecret(pbeKeySpec);
final AlgorithmParameters algParameters = encryptedPrivateKeyInfo.getAlgParameters();
cipher.init(Cipher.DECRYPT_MODE, pbeKey, algParameters);
final KeySpec pkcs8KeySpec = encryptedPrivateKeyInfo.getKeySpec(cipher);
final KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
return keyFactory.generatePrivate(pkcs8KeySpec);
} | java | public static PrivateKey readPasswordProtectedPrivateKey(final byte[] encryptedPrivateKeyBytes,
final String password, final String algorithm)
throws IOException, NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException
{
final EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new EncryptedPrivateKeyInfo(
encryptedPrivateKeyBytes);
final String algName = encryptedPrivateKeyInfo.getAlgName();
final Cipher cipher = CipherFactory.newCipher(algName);
final KeySpec pbeKeySpec = KeySpecFactory.newPBEKeySpec(password);
final SecretKeyFactory secretKeyFactory = SecretKeyFactoryExtensions
.newSecretKeyFactory(algName);
final Key pbeKey = secretKeyFactory.generateSecret(pbeKeySpec);
final AlgorithmParameters algParameters = encryptedPrivateKeyInfo.getAlgParameters();
cipher.init(Cipher.DECRYPT_MODE, pbeKey, algParameters);
final KeySpec pkcs8KeySpec = encryptedPrivateKeyInfo.getKeySpec(cipher);
final KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
return keyFactory.generatePrivate(pkcs8KeySpec);
} | [
"public",
"static",
"PrivateKey",
"readPasswordProtectedPrivateKey",
"(",
"final",
"byte",
"[",
"]",
"encryptedPrivateKeyBytes",
",",
"final",
"String",
"password",
",",
"final",
"String",
"algorithm",
")",
"throws",
"IOException",
",",
"NoSuchAlgorithmException",
",",
... | Reads the given byte array that contains a password protected private key.
@param encryptedPrivateKeyBytes
the byte array that contains the password protected private key
@param password
the password
@param algorithm
the algorithm
@return the {@link PrivateKey} object
@throws IOException
Signals that an I/O exception has occurred.
@throws NoSuchAlgorithmException
is thrown if instantiation of the SecretKeyFactory object fails.
@throws NoSuchPaddingException
the no such padding exception
@throws InvalidKeySpecException
is thrown if generation of the SecretKey object fails.
@throws InvalidKeyException
is thrown if initialization of the cipher object fails.
@throws InvalidAlgorithmParameterException
is thrown if initialization of the cipher object fails. | [
"Reads",
"the",
"given",
"byte",
"array",
"that",
"contains",
"a",
"password",
"protected",
"private",
"key",
"."
] | 7f51ef5e4457e24de7ff391f10bfc5609e6f1a34 | https://github.com/astrapi69/mystic-crypt/blob/7f51ef5e4457e24de7ff391f10bfc5609e6f1a34/crypt-data/src/main/java/de/alpharogroup/crypto/key/reader/EncryptedPrivateKeyReader.java#L94-L112 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/async/ServletAsyncSpec.java | ServletAsyncSpec.createAsync | @Nonnull
public static ServletAsyncSpec createAsync (@CheckForSigned final long nTimeoutMillis,
@Nullable final Iterable <? extends AsyncListener> aAsyncListeners)
{
return new ServletAsyncSpec (true, nTimeoutMillis, aAsyncListeners);
} | java | @Nonnull
public static ServletAsyncSpec createAsync (@CheckForSigned final long nTimeoutMillis,
@Nullable final Iterable <? extends AsyncListener> aAsyncListeners)
{
return new ServletAsyncSpec (true, nTimeoutMillis, aAsyncListeners);
} | [
"@",
"Nonnull",
"public",
"static",
"ServletAsyncSpec",
"createAsync",
"(",
"@",
"CheckForSigned",
"final",
"long",
"nTimeoutMillis",
",",
"@",
"Nullable",
"final",
"Iterable",
"<",
"?",
"extends",
"AsyncListener",
">",
"aAsyncListeners",
")",
"{",
"return",
"new"... | Create an async spec.
@param nTimeoutMillis
Timeout in milliseconds. Only value > 0 are considered.
@param aAsyncListeners
The async listeners to use. May be <code>null</code>.
@return A new {@link ServletAsyncSpec} and never <code>null</code>. | [
"Create",
"an",
"async",
"spec",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/async/ServletAsyncSpec.java#L169-L174 | train |
bbqrob/merge-maven-plugin | src/main/java/org/zcore/maven/MergeMojo.java | MergeMojo.initOutput | protected OutputStream initOutput(final File file)
throws MojoExecutionException {
// stream to return
final OutputStream stream;
// plenty of things can go wrong...
try {
// directory?
if (file.isDirectory()) {
throw new MojoExecutionException("File "
+ file.getAbsolutePath() + " is directory!");
}
// already exists && can't remove it?
if (file.exists() && !file.delete()) {
throw new MojoExecutionException("Could not remove file: "
+ file.getAbsolutePath());
}
// get directory above file file
final File fileDirectory = file.getParentFile();
// does not exist && create it?
if (!fileDirectory.exists() && !fileDirectory.mkdirs()) {
throw new MojoExecutionException(
"Could not create directory: "
+ fileDirectory.getAbsolutePath());
}
// moar wtf: parent directory is no directory?
if (!fileDirectory.isDirectory()) {
throw new MojoExecutionException("Not a directory: "
+ fileDirectory.getAbsolutePath());
}
// file file is for any reason not creatable?
if (!file.createNewFile()) {
throw new MojoExecutionException("Could not create file: "
+ file.getAbsolutePath());
}
// finally create some file
stream = new FileOutputStream(file);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could not find file: "
+ file.getAbsolutePath(), e);
} catch (IOException e) {
throw new MojoExecutionException("Could not write to file: "
+ file.getAbsolutePath(), e);
}
// return
return stream;
} | java | protected OutputStream initOutput(final File file)
throws MojoExecutionException {
// stream to return
final OutputStream stream;
// plenty of things can go wrong...
try {
// directory?
if (file.isDirectory()) {
throw new MojoExecutionException("File "
+ file.getAbsolutePath() + " is directory!");
}
// already exists && can't remove it?
if (file.exists() && !file.delete()) {
throw new MojoExecutionException("Could not remove file: "
+ file.getAbsolutePath());
}
// get directory above file file
final File fileDirectory = file.getParentFile();
// does not exist && create it?
if (!fileDirectory.exists() && !fileDirectory.mkdirs()) {
throw new MojoExecutionException(
"Could not create directory: "
+ fileDirectory.getAbsolutePath());
}
// moar wtf: parent directory is no directory?
if (!fileDirectory.isDirectory()) {
throw new MojoExecutionException("Not a directory: "
+ fileDirectory.getAbsolutePath());
}
// file file is for any reason not creatable?
if (!file.createNewFile()) {
throw new MojoExecutionException("Could not create file: "
+ file.getAbsolutePath());
}
// finally create some file
stream = new FileOutputStream(file);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could not find file: "
+ file.getAbsolutePath(), e);
} catch (IOException e) {
throw new MojoExecutionException("Could not write to file: "
+ file.getAbsolutePath(), e);
}
// return
return stream;
} | [
"protected",
"OutputStream",
"initOutput",
"(",
"final",
"File",
"file",
")",
"throws",
"MojoExecutionException",
"{",
"// stream to return",
"final",
"OutputStream",
"stream",
";",
"// plenty of things can go wrong...",
"try",
"{",
"// directory?",
"if",
"(",
"file",
"... | Opens an OutputStream, based on the supplied file
@param target {@linkplain File}
@return {@linkplain OutputStream}
@throws MojoExecutionException | [
"Opens",
"an",
"OutputStream",
"based",
"on",
"the",
"supplied",
"file"
] | 7a0fa3b1bc0bff83ba56c601f8af0c0c2294767e | https://github.com/bbqrob/merge-maven-plugin/blob/7a0fa3b1bc0bff83ba56c601f8af0c0c2294767e/src/main/java/org/zcore/maven/MergeMojo.java#L54-L99 | train |
bbqrob/merge-maven-plugin | src/main/java/org/zcore/maven/MergeMojo.java | MergeMojo.initInput | protected InputStream initInput(final File file)
throws MojoExecutionException {
InputStream stream = null;
try {
if (file.isDirectory()) {
throw new MojoExecutionException("File "
+ file.getAbsolutePath()
+ " is directory!");
}
if (!file.exists()) {
throw new MojoExecutionException("File "
+ file.getAbsolutePath()
+ " does not exist!");
}
stream = new FileInputStream(file);
//append to outfile here
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could not find file: "
+ file.getAbsolutePath(), e);
}
return stream;
} | java | protected InputStream initInput(final File file)
throws MojoExecutionException {
InputStream stream = null;
try {
if (file.isDirectory()) {
throw new MojoExecutionException("File "
+ file.getAbsolutePath()
+ " is directory!");
}
if (!file.exists()) {
throw new MojoExecutionException("File "
+ file.getAbsolutePath()
+ " does not exist!");
}
stream = new FileInputStream(file);
//append to outfile here
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could not find file: "
+ file.getAbsolutePath(), e);
}
return stream;
} | [
"protected",
"InputStream",
"initInput",
"(",
"final",
"File",
"file",
")",
"throws",
"MojoExecutionException",
"{",
"InputStream",
"stream",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"MojoExecut... | Opens an InputStream, based on the supplied file
@param target {@linkplain File}
@return {@linkplain InputStream}
@throws MojoExecutionException | [
"Opens",
"an",
"InputStream",
"based",
"on",
"the",
"supplied",
"file"
] | 7a0fa3b1bc0bff83ba56c601f8af0c0c2294767e | https://github.com/bbqrob/merge-maven-plugin/blob/7a0fa3b1bc0bff83ba56c601f8af0c0c2294767e/src/main/java/org/zcore/maven/MergeMojo.java#L107-L128 | train |
bbqrob/merge-maven-plugin | src/main/java/org/zcore/maven/MergeMojo.java | MergeMojo.appendStream | protected void appendStream(final InputStream input,
final OutputStream output) throws MojoExecutionException {
// prebuffer
int character;
try {
// get line seperator, based on system
final String newLine = System.getProperty("line.separator");
// read & write
while ((character = input.read()) != -1) {
output.write(character);
}
// append newline
output.write(newLine.getBytes());
// flush
output.flush();
} catch (IOException e) {
throw new MojoExecutionException("Error in buffering/writing "
+ e.getMessage(), e);
}
} | java | protected void appendStream(final InputStream input,
final OutputStream output) throws MojoExecutionException {
// prebuffer
int character;
try {
// get line seperator, based on system
final String newLine = System.getProperty("line.separator");
// read & write
while ((character = input.read()) != -1) {
output.write(character);
}
// append newline
output.write(newLine.getBytes());
// flush
output.flush();
} catch (IOException e) {
throw new MojoExecutionException("Error in buffering/writing "
+ e.getMessage(), e);
}
} | [
"protected",
"void",
"appendStream",
"(",
"final",
"InputStream",
"input",
",",
"final",
"OutputStream",
"output",
")",
"throws",
"MojoExecutionException",
"{",
"// prebuffer",
"int",
"character",
";",
"try",
"{",
"// get line seperator, based on system",
"final",
"Stri... | Appends inputstream to outputstream
@param input {@linkplain InputStream}
@param output {@linkplain OutputStream}
@throws MojoExecutionException | [
"Appends",
"inputstream",
"to",
"outputstream"
] | 7a0fa3b1bc0bff83ba56c601f8af0c0c2294767e | https://github.com/bbqrob/merge-maven-plugin/blob/7a0fa3b1bc0bff83ba56c601f8af0c0c2294767e/src/main/java/org/zcore/maven/MergeMojo.java#L178-L197 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/io/DeferredFileOutputStream.java | DeferredFileOutputStream.onThresholdReached | @Override
protected void onThresholdReached () throws IOException
{
FileOutputStream aFOS = null;
try
{
aFOS = new FileOutputStream (m_aOutputFile);
m_aMemoryOS.writeTo (aFOS);
m_aCurrentOS = aFOS;
// Explicitly close the stream (even though this is a no-op)
StreamHelper.close (m_aMemoryOS);
m_aMemoryOS = null;
}
catch (final IOException ex)
{
StreamHelper.close (aFOS);
throw ex;
}
} | java | @Override
protected void onThresholdReached () throws IOException
{
FileOutputStream aFOS = null;
try
{
aFOS = new FileOutputStream (m_aOutputFile);
m_aMemoryOS.writeTo (aFOS);
m_aCurrentOS = aFOS;
// Explicitly close the stream (even though this is a no-op)
StreamHelper.close (m_aMemoryOS);
m_aMemoryOS = null;
}
catch (final IOException ex)
{
StreamHelper.close (aFOS);
throw ex;
}
} | [
"@",
"Override",
"protected",
"void",
"onThresholdReached",
"(",
")",
"throws",
"IOException",
"{",
"FileOutputStream",
"aFOS",
"=",
"null",
";",
"try",
"{",
"aFOS",
"=",
"new",
"FileOutputStream",
"(",
"m_aOutputFile",
")",
";",
"m_aMemoryOS",
".",
"writeTo",
... | Switches the underlying output stream from a memory based stream to one
that is backed by disk. This is the point at which we realise that too much
data is being written to keep in memory, so we elect to switch to
disk-based storage.
@exception IOException
if an error occurs. | [
"Switches",
"the",
"underlying",
"output",
"stream",
"from",
"a",
"memory",
"based",
"stream",
"to",
"one",
"that",
"is",
"backed",
"by",
"disk",
".",
"This",
"is",
"the",
"point",
"at",
"which",
"we",
"realise",
"that",
"too",
"much",
"data",
"is",
"bei... | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/io/DeferredFileOutputStream.java#L117-L136 | train |
phax/ph-web | ph-web/src/main/java/com/helger/web/fileupload/io/DeferredFileOutputStream.java | DeferredFileOutputStream.writeTo | public void writeTo (@Nonnull @WillNotClose final OutputStream aOS) throws IOException
{
// we may only need to check if this is closed if we are working with a file
// but we should force the habit of closing whether we are working with
// a file or memory.
if (!m_bClosed)
throw new IOException ("This stream is not closed");
if (isInMemory ())
{
m_aMemoryOS.writeTo (aOS);
}
else
{
final InputStream aIS = FileHelper.getInputStream (m_aOutputFile);
StreamHelper.copyInputStreamToOutputStream (aIS, aOS);
}
} | java | public void writeTo (@Nonnull @WillNotClose final OutputStream aOS) throws IOException
{
// we may only need to check if this is closed if we are working with a file
// but we should force the habit of closing whether we are working with
// a file or memory.
if (!m_bClosed)
throw new IOException ("This stream is not closed");
if (isInMemory ())
{
m_aMemoryOS.writeTo (aOS);
}
else
{
final InputStream aIS = FileHelper.getInputStream (m_aOutputFile);
StreamHelper.copyInputStreamToOutputStream (aIS, aOS);
}
} | [
"public",
"void",
"writeTo",
"(",
"@",
"Nonnull",
"@",
"WillNotClose",
"final",
"OutputStream",
"aOS",
")",
"throws",
"IOException",
"{",
"// we may only need to check if this is closed if we are working with a file",
"// but we should force the habit of closing whether we are workin... | Writes the data from this output stream to the specified output stream,
after it has been closed.
@param aOS
output stream to write to.
@exception IOException
if this stream is not yet closed or an error occurs. | [
"Writes",
"the",
"data",
"from",
"this",
"output",
"stream",
"to",
"the",
"specified",
"output",
"stream",
"after",
"it",
"has",
"been",
"closed",
"."
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-web/src/main/java/com/helger/web/fileupload/io/DeferredFileOutputStream.java#L233-L250 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java | MeshGenerator.generatePlane | public static VertexData generatePlane(Vector2f size) {
final VertexData destination = new VertexData();
final VertexAttribute positionsAttribute = new VertexAttribute("positions", DataType.FLOAT, 3);
destination.addAttribute(0, positionsAttribute);
final TFloatList positions = new TFloatArrayList();
final VertexAttribute normalsAttribute = new VertexAttribute("normals", DataType.FLOAT, 3);
destination.addAttribute(1, normalsAttribute);
final TFloatList normals = new TFloatArrayList();
final VertexAttribute textureCoordsAttribute = new VertexAttribute("textureCoords", DataType.FLOAT, 2);
destination.addAttribute(2, textureCoordsAttribute);
final TFloatList textureCoords = new TFloatArrayList();
final TIntList indices = destination.getIndices();
// Generate the mesh
generatePlane(positions, normals, textureCoords, indices, size);
// Put the mesh in the vertex data
positionsAttribute.setData(positions);
normalsAttribute.setData(normals);
textureCoordsAttribute.setData(textureCoords);
return destination;
} | java | public static VertexData generatePlane(Vector2f size) {
final VertexData destination = new VertexData();
final VertexAttribute positionsAttribute = new VertexAttribute("positions", DataType.FLOAT, 3);
destination.addAttribute(0, positionsAttribute);
final TFloatList positions = new TFloatArrayList();
final VertexAttribute normalsAttribute = new VertexAttribute("normals", DataType.FLOAT, 3);
destination.addAttribute(1, normalsAttribute);
final TFloatList normals = new TFloatArrayList();
final VertexAttribute textureCoordsAttribute = new VertexAttribute("textureCoords", DataType.FLOAT, 2);
destination.addAttribute(2, textureCoordsAttribute);
final TFloatList textureCoords = new TFloatArrayList();
final TIntList indices = destination.getIndices();
// Generate the mesh
generatePlane(positions, normals, textureCoords, indices, size);
// Put the mesh in the vertex data
positionsAttribute.setData(positions);
normalsAttribute.setData(normals);
textureCoordsAttribute.setData(textureCoords);
return destination;
} | [
"public",
"static",
"VertexData",
"generatePlane",
"(",
"Vector2f",
"size",
")",
"{",
"final",
"VertexData",
"destination",
"=",
"new",
"VertexData",
"(",
")",
";",
"final",
"VertexAttribute",
"positionsAttribute",
"=",
"new",
"VertexAttribute",
"(",
"\"positions\""... | Generates a plane on xy. The center is at the middle of the plane.
@param size The size of the plane to generate, on x and y
@return The vertex data | [
"Generates",
"a",
"plane",
"on",
"xy",
".",
"The",
"center",
"is",
"at",
"the",
"middle",
"of",
"the",
"plane",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java#L593-L612 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java | MeshGenerator.generatePlane | public static void generatePlane(TFloatList positions, TFloatList normals, TFloatList textureCoords, TIntList indices, Vector2f size) {
/*
* 2-----3
* | |
* | |
* 0-----1
*/
// Corner positions
final Vector2f p = size.div(2);
final Vector3f p3 = new Vector3f(p.getX(), p.getY(), 0);
final Vector3f p2 = new Vector3f(-p.getX(), p.getY(), 0);
final Vector3f p1 = new Vector3f(p.getX(), -p.getY(), 0);
final Vector3f p0 = new Vector3f(-p.getX(), -p.getY(), 0);
// Normal
final Vector3f n = new Vector3f(0, 0, 1);
// Face
addVector(positions, p0);
addVector(normals, n);
addAll(textureCoords, 0, 0);
addVector(positions, p1);
addVector(normals, n);
addAll(textureCoords, 1, 0);
addVector(positions, p2);
addVector(normals, n);
addAll(textureCoords, 0, 1);
addVector(positions, p3);
addVector(normals, n);
addAll(textureCoords, 1, 1);
addAll(indices, 0, 3, 2, 0, 1, 3);
} | java | public static void generatePlane(TFloatList positions, TFloatList normals, TFloatList textureCoords, TIntList indices, Vector2f size) {
/*
* 2-----3
* | |
* | |
* 0-----1
*/
// Corner positions
final Vector2f p = size.div(2);
final Vector3f p3 = new Vector3f(p.getX(), p.getY(), 0);
final Vector3f p2 = new Vector3f(-p.getX(), p.getY(), 0);
final Vector3f p1 = new Vector3f(p.getX(), -p.getY(), 0);
final Vector3f p0 = new Vector3f(-p.getX(), -p.getY(), 0);
// Normal
final Vector3f n = new Vector3f(0, 0, 1);
// Face
addVector(positions, p0);
addVector(normals, n);
addAll(textureCoords, 0, 0);
addVector(positions, p1);
addVector(normals, n);
addAll(textureCoords, 1, 0);
addVector(positions, p2);
addVector(normals, n);
addAll(textureCoords, 0, 1);
addVector(positions, p3);
addVector(normals, n);
addAll(textureCoords, 1, 1);
addAll(indices, 0, 3, 2, 0, 1, 3);
} | [
"public",
"static",
"void",
"generatePlane",
"(",
"TFloatList",
"positions",
",",
"TFloatList",
"normals",
",",
"TFloatList",
"textureCoords",
",",
"TIntList",
"indices",
",",
"Vector2f",
"size",
")",
"{",
"/*\n * 2-----3\n * | |\n * | |\n ... | Generates a textured plane on xy. The center is at the middle of the plane.
@param positions Where to save the position information
@param normals Where to save the normal information, can be null to ignore the attribute
@param textureCoords Where to save the texture coordinate information, can be null to ignore the attribute
@param indices Where to save the indices
@param size The size of the plane to generate, on x and y | [
"Generates",
"a",
"textured",
"plane",
"on",
"xy",
".",
"The",
"center",
"is",
"at",
"the",
"middle",
"of",
"the",
"plane",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java#L623-L652 | train |
flow/caustic | api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java | MeshGenerator.generateCylinder | public static void generateCylinder(TFloatList positions, TFloatList normals, TIntList indices, float radius, float height) {
// 0,0,0 will be halfway up the cylinder in the middle
final float halfHeight = height / 2;
// The positions at the rims of the cylinders
final List<Vector3f> rims = new ArrayList<>();
for (int angle = 0; angle < 360; angle += 15) {
final double angleRads = Math.toRadians(angle);
rims.add(new Vector3f(
radius * TrigMath.cos(angleRads),
halfHeight,
radius * -TrigMath.sin(angleRads)));
}
// The normals for the triangles of the top and bottom faces
final Vector3f topNormal = new Vector3f(0, 1, 0);
final Vector3f bottomNormal = new Vector3f(0, -1, 0);
// Add the top and bottom face center vertices
addVector(positions, new Vector3f(0, halfHeight, 0));// 0
addVector(normals, topNormal);
addVector(positions, new Vector3f(0, -halfHeight, 0));// 1
addVector(normals, bottomNormal);
// Add all the faces section by section, turning around the y axis
final int rimsSize = rims.size();
for (int i = 0; i < rimsSize; i++) {
// Get the top and bottom vertex positions and the side normal
final Vector3f t = rims.get(i);
final Vector3f b = new Vector3f(t.getX(), -t.getY(), t.getZ());
final Vector3f n = new Vector3f(t.getX(), 0, t.getZ()).normalize();
// Top face vertex
addVector(positions, t);// index
addVector(normals, topNormal);
// Bottom face vertex
addVector(positions, b);// index + 1
addVector(normals, bottomNormal);
// Side top vertex
addVector(positions, t);// index + 2
addVector(normals, n);
// Side bottom vertex
addVector(positions, b);// index + 3
addVector(normals, n);
// Get the current index for our vertices
final int currentIndex = i * 4 + 2;
// Get the index for the next iteration, wrapping around at the end
final int nextIndex = (i == rimsSize - 1 ? 0 : i + 1) * 4 + 2;
// Add the 4 triangles (1 top, 1 bottom, 2 for the side)
addAll(indices, 0, currentIndex, nextIndex);
addAll(indices, 1, nextIndex + 1, currentIndex + 1);
addAll(indices, currentIndex + 2, currentIndex + 3, nextIndex + 2);
addAll(indices, currentIndex + 3, nextIndex + 3, nextIndex + 2);
}
} | java | public static void generateCylinder(TFloatList positions, TFloatList normals, TIntList indices, float radius, float height) {
// 0,0,0 will be halfway up the cylinder in the middle
final float halfHeight = height / 2;
// The positions at the rims of the cylinders
final List<Vector3f> rims = new ArrayList<>();
for (int angle = 0; angle < 360; angle += 15) {
final double angleRads = Math.toRadians(angle);
rims.add(new Vector3f(
radius * TrigMath.cos(angleRads),
halfHeight,
radius * -TrigMath.sin(angleRads)));
}
// The normals for the triangles of the top and bottom faces
final Vector3f topNormal = new Vector3f(0, 1, 0);
final Vector3f bottomNormal = new Vector3f(0, -1, 0);
// Add the top and bottom face center vertices
addVector(positions, new Vector3f(0, halfHeight, 0));// 0
addVector(normals, topNormal);
addVector(positions, new Vector3f(0, -halfHeight, 0));// 1
addVector(normals, bottomNormal);
// Add all the faces section by section, turning around the y axis
final int rimsSize = rims.size();
for (int i = 0; i < rimsSize; i++) {
// Get the top and bottom vertex positions and the side normal
final Vector3f t = rims.get(i);
final Vector3f b = new Vector3f(t.getX(), -t.getY(), t.getZ());
final Vector3f n = new Vector3f(t.getX(), 0, t.getZ()).normalize();
// Top face vertex
addVector(positions, t);// index
addVector(normals, topNormal);
// Bottom face vertex
addVector(positions, b);// index + 1
addVector(normals, bottomNormal);
// Side top vertex
addVector(positions, t);// index + 2
addVector(normals, n);
// Side bottom vertex
addVector(positions, b);// index + 3
addVector(normals, n);
// Get the current index for our vertices
final int currentIndex = i * 4 + 2;
// Get the index for the next iteration, wrapping around at the end
final int nextIndex = (i == rimsSize - 1 ? 0 : i + 1) * 4 + 2;
// Add the 4 triangles (1 top, 1 bottom, 2 for the side)
addAll(indices, 0, currentIndex, nextIndex);
addAll(indices, 1, nextIndex + 1, currentIndex + 1);
addAll(indices, currentIndex + 2, currentIndex + 3, nextIndex + 2);
addAll(indices, currentIndex + 3, nextIndex + 3, nextIndex + 2);
}
} | [
"public",
"static",
"void",
"generateCylinder",
"(",
"TFloatList",
"positions",
",",
"TFloatList",
"normals",
",",
"TIntList",
"indices",
",",
"float",
"radius",
",",
"float",
"height",
")",
"{",
"// 0,0,0 will be halfway up the cylinder in the middle",
"final",
"float"... | Generates a cylindrical solid mesh. The center is at middle of the of the cylinder.
@param positions Where to save the position information
@param normals Where to save the normal information, can be null to ignore the attribute
@param indices Where to save the indices
@param radius The radius of the base and top
@param height The height (distance from the base to the top) | [
"Generates",
"a",
"cylindrical",
"solid",
"mesh",
".",
"The",
"center",
"is",
"at",
"middle",
"of",
"the",
"of",
"the",
"cylinder",
"."
] | 88652fcf0621ce158a0e92ce4c570ed6b1f6fca9 | https://github.com/flow/caustic/blob/88652fcf0621ce158a0e92ce4c570ed6b1f6fca9/api/src/main/java/com/flowpowered/caustic/api/util/MeshGenerator.java#L941-L990 | train |
phax/ph-web | ph-servlet/src/main/java/com/helger/servlet/mock/MockEventListenerList.java | MockEventListenerList.setFrom | @Nonnull
public EChange setFrom (@Nonnull final MockEventListenerList aList)
{
ValueEnforcer.notNull (aList, "List");
// Assigning this to this?
if (this == aList)
return EChange.UNCHANGED;
// Get all listeners to assign
final ICommonsList <EventListener> aOtherListeners = aList.getAllListeners ();
return m_aRWLock.writeLocked ( () -> {
if (m_aListener.isEmpty () && aOtherListeners.isEmpty ())
return EChange.UNCHANGED;
m_aListener.setAll (aOtherListeners);
return EChange.CHANGED;
});
} | java | @Nonnull
public EChange setFrom (@Nonnull final MockEventListenerList aList)
{
ValueEnforcer.notNull (aList, "List");
// Assigning this to this?
if (this == aList)
return EChange.UNCHANGED;
// Get all listeners to assign
final ICommonsList <EventListener> aOtherListeners = aList.getAllListeners ();
return m_aRWLock.writeLocked ( () -> {
if (m_aListener.isEmpty () && aOtherListeners.isEmpty ())
return EChange.UNCHANGED;
m_aListener.setAll (aOtherListeners);
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"EChange",
"setFrom",
"(",
"@",
"Nonnull",
"final",
"MockEventListenerList",
"aList",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aList",
",",
"\"List\"",
")",
";",
"// Assigning this to this?",
"if",
"(",
"this",
"==",
"aList",
... | Set all listeners from the passed list to this list
@param aList
The other list. May not be <code>null</code>.
@return {@link EChange} | [
"Set",
"all",
"listeners",
"from",
"the",
"passed",
"list",
"to",
"this",
"list"
] | d445fd25184605b62682c93c9782409acf0ae813 | https://github.com/phax/ph-web/blob/d445fd25184605b62682c93c9782409acf0ae813/ph-servlet/src/main/java/com/helger/servlet/mock/MockEventListenerList.java#L67-L86 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.