id int32 0 165k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
136,800 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java | XMLCharHelper.isInvalidXMLNameChar | public static boolean isInvalidXMLNameChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_NAME_CHAR_XML10.get (c);
case XML_11:
return INVALID_NAME_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | java | public static boolean isInvalidXMLNameChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_NAME_CHAR_XML10.get (c);
case XML_11:
return INVALID_NAME_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | [
"public",
"static",
"boolean",
"isInvalidXMLNameChar",
"(",
"@",
"Nonnull",
"final",
"EXMLSerializeVersion",
"eXMLVersion",
",",
"final",
"int",
"c",
")",
"{",
"switch",
"(",
"eXMLVersion",
")",
"{",
"case",
"XML_10",
":",
"return",
"INVALID_NAME_CHAR_XML10",
".",... | Check if the passed character is invalid for an element or attribute name
after the first position
@param eXMLVersion
XML version to be used. May not be <code>null</code>.
@param c
char to check
@return <code>true</code> if the char is invalid | [
"Check",
"if",
"the",
"passed",
"character",
"is",
"invalid",
"for",
"an",
"element",
"or",
"attribute",
"name",
"after",
"the",
"first",
"position"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java#L668-L681 |
136,801 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java | XMLCharHelper.isInvalidXMLTextChar | public static boolean isInvalidXMLTextChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_VALUE_CHAR_XML10.get (c);
case XML_11:
return INVALID_TEXT_VALUE_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | java | public static boolean isInvalidXMLTextChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_VALUE_CHAR_XML10.get (c);
case XML_11:
return INVALID_TEXT_VALUE_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | [
"public",
"static",
"boolean",
"isInvalidXMLTextChar",
"(",
"@",
"Nonnull",
"final",
"EXMLSerializeVersion",
"eXMLVersion",
",",
"final",
"int",
"c",
")",
"{",
"switch",
"(",
"eXMLVersion",
")",
"{",
"case",
"XML_10",
":",
"return",
"INVALID_VALUE_CHAR_XML10",
"."... | Check if the passed character is invalid for a text node.
@param eXMLVersion
XML version to be used. May not be <code>null</code>.
@param c
char to check
@return <code>true</code> if the char is invalid | [
"Check",
"if",
"the",
"passed",
"character",
"is",
"invalid",
"for",
"a",
"text",
"node",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java#L778-L791 |
136,802 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java | XMLCharHelper.isInvalidXMLCDATAChar | public static boolean isInvalidXMLCDATAChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_VALUE_CHAR_XML10.get (c);
case XML_11:
return INVALID_CDATA_VALUE_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | java | public static boolean isInvalidXMLCDATAChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_VALUE_CHAR_XML10.get (c);
case XML_11:
return INVALID_CDATA_VALUE_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | [
"public",
"static",
"boolean",
"isInvalidXMLCDATAChar",
"(",
"@",
"Nonnull",
"final",
"EXMLSerializeVersion",
"eXMLVersion",
",",
"final",
"int",
"c",
")",
"{",
"switch",
"(",
"eXMLVersion",
")",
"{",
"case",
"XML_10",
":",
"return",
"INVALID_VALUE_CHAR_XML10",
".... | Check if the passed character is invalid for a CDATA node.
@param eXMLVersion
XML version to be used. May not be <code>null</code>.
@param c
char to check
@return <code>true</code> if the char is invalid | [
"Check",
"if",
"the",
"passed",
"character",
"is",
"invalid",
"for",
"a",
"CDATA",
"node",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java#L867-L880 |
136,803 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java | XMLCharHelper.isInvalidXMLAttributeValueChar | public static boolean isInvalidXMLAttributeValueChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_VALUE_CHAR_XML10.get (c);
case XML_11:
return INVALID_ATTR_VALUE_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | java | public static boolean isInvalidXMLAttributeValueChar (@Nonnull final EXMLSerializeVersion eXMLVersion, final int c)
{
switch (eXMLVersion)
{
case XML_10:
return INVALID_VALUE_CHAR_XML10.get (c);
case XML_11:
return INVALID_ATTR_VALUE_CHAR_XML11.get (c);
case HTML:
return INVALID_CHAR_HTML.get (c);
default:
throw new IllegalArgumentException ("Unsupported XML version " + eXMLVersion + "!");
}
} | [
"public",
"static",
"boolean",
"isInvalidXMLAttributeValueChar",
"(",
"@",
"Nonnull",
"final",
"EXMLSerializeVersion",
"eXMLVersion",
",",
"final",
"int",
"c",
")",
"{",
"switch",
"(",
"eXMLVersion",
")",
"{",
"case",
"XML_10",
":",
"return",
"INVALID_VALUE_CHAR_XML... | Check if the passed character is invalid for a attribute value node.
@param eXMLVersion
XML version to be used. May not be <code>null</code>.
@param c
char to check
@return <code>true</code> if the char is invalid | [
"Check",
"if",
"the",
"passed",
"character",
"is",
"invalid",
"for",
"a",
"attribute",
"value",
"node",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/write/XMLCharHelper.java#L956-L969 |
136,804 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/stream/NonBlockingBufferedInputStream.java | NonBlockingBufferedInputStream._fill | private void _fill () throws IOException
{
byte [] buffer = _getBufIfOpen ();
if (m_nMarkPos < 0)
m_nPos = 0; /* no mark: throw away the buffer */
else
if (m_nPos >= buffer.length) /* no room left in buffer */
if (m_nMarkPos > 0)
{
/* can throw away early part of the buffer */
final int sz = m_nPos - m_nMarkPos;
System.arraycopy (buffer, m_nMarkPos, buffer, 0, sz);
m_nPos = sz;
m_nMarkPos = 0;
}
else
if (buffer.length >= m_nMarkLimit)
{
/* buffer got too big, invalidate mark */
m_nMarkPos = -1;
/* drop buffer contents */
m_nPos = 0;
}
else
{
/* grow buffer */
int nsz = m_nPos * 2;
if (nsz > m_nMarkLimit)
nsz = m_nMarkLimit;
final byte [] nbuf = new byte [nsz];
System.arraycopy (buffer, 0, nbuf, 0, m_nPos);
if (!s_aBufUpdater.compareAndSet (this, buffer, nbuf))
{
// Can't replace buf if there was an async close.
// Note: This would need to be changed if fill()
// is ever made accessible to multiple threads.
// But for now, the only way CAS can fail is via close.
// assert buf == null;
throw new IOException ("Stream closed");
}
buffer = nbuf;
}
m_nCount = m_nPos;
// Potentially blocking read
final int n = _getInIfOpen ().read (buffer, m_nPos, buffer.length - m_nPos);
if (n > 0)
m_nCount = n + m_nPos;
} | java | private void _fill () throws IOException
{
byte [] buffer = _getBufIfOpen ();
if (m_nMarkPos < 0)
m_nPos = 0; /* no mark: throw away the buffer */
else
if (m_nPos >= buffer.length) /* no room left in buffer */
if (m_nMarkPos > 0)
{
/* can throw away early part of the buffer */
final int sz = m_nPos - m_nMarkPos;
System.arraycopy (buffer, m_nMarkPos, buffer, 0, sz);
m_nPos = sz;
m_nMarkPos = 0;
}
else
if (buffer.length >= m_nMarkLimit)
{
/* buffer got too big, invalidate mark */
m_nMarkPos = -1;
/* drop buffer contents */
m_nPos = 0;
}
else
{
/* grow buffer */
int nsz = m_nPos * 2;
if (nsz > m_nMarkLimit)
nsz = m_nMarkLimit;
final byte [] nbuf = new byte [nsz];
System.arraycopy (buffer, 0, nbuf, 0, m_nPos);
if (!s_aBufUpdater.compareAndSet (this, buffer, nbuf))
{
// Can't replace buf if there was an async close.
// Note: This would need to be changed if fill()
// is ever made accessible to multiple threads.
// But for now, the only way CAS can fail is via close.
// assert buf == null;
throw new IOException ("Stream closed");
}
buffer = nbuf;
}
m_nCount = m_nPos;
// Potentially blocking read
final int n = _getInIfOpen ().read (buffer, m_nPos, buffer.length - m_nPos);
if (n > 0)
m_nCount = n + m_nPos;
} | [
"private",
"void",
"_fill",
"(",
")",
"throws",
"IOException",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"_getBufIfOpen",
"(",
")",
";",
"if",
"(",
"m_nMarkPos",
"<",
"0",
")",
"m_nPos",
"=",
"0",
";",
"/* no mark: throw away the buffer */",
"else",
"if",
"(",... | Fills the buffer with more data, taking into account shuffling and other
tricks for dealing with marks. Assumes that it is being called by a method.
This method also assumes that all data has already been read in, hence pos
> count. | [
"Fills",
"the",
"buffer",
"with",
"more",
"data",
"taking",
"into",
"account",
"shuffling",
"and",
"other",
"tricks",
"for",
"dealing",
"with",
"marks",
".",
"Assumes",
"that",
"it",
"is",
"being",
"called",
"by",
"a",
"method",
".",
"This",
"method",
"als... | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/stream/NonBlockingBufferedInputStream.java#L178-L225 |
136,805 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/lang/StackTraceHelper.java | StackTraceHelper.getStackAsString | @Nonnull
public static String getStackAsString (@Nullable final Throwable t, final boolean bOmitCommonStackTraceElements)
{
if (t == null)
return "";
// convert call stack to string
final StringBuilder aCallStack = _getRecursiveStackAsStringBuilder (t,
null,
null,
1,
bOmitCommonStackTraceElements);
// avoid having a separator at the end -> remove the last char
if (StringHelper.getLastChar (aCallStack) == STACKELEMENT_LINESEP)
aCallStack.deleteCharAt (aCallStack.length () - 1);
// no changes
return aCallStack.toString ();
} | java | @Nonnull
public static String getStackAsString (@Nullable final Throwable t, final boolean bOmitCommonStackTraceElements)
{
if (t == null)
return "";
// convert call stack to string
final StringBuilder aCallStack = _getRecursiveStackAsStringBuilder (t,
null,
null,
1,
bOmitCommonStackTraceElements);
// avoid having a separator at the end -> remove the last char
if (StringHelper.getLastChar (aCallStack) == STACKELEMENT_LINESEP)
aCallStack.deleteCharAt (aCallStack.length () - 1);
// no changes
return aCallStack.toString ();
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getStackAsString",
"(",
"@",
"Nullable",
"final",
"Throwable",
"t",
",",
"final",
"boolean",
"bOmitCommonStackTraceElements",
")",
"{",
"if",
"(",
"t",
"==",
"null",
")",
"return",
"\"\"",
";",
"// convert call stac... | Get the stack trace of a throwable as string.
@param t
The throwable to be converted. May be <code>null</code>.
@param bOmitCommonStackTraceElements
If <code>true</code> the stack trace is cut after certain class
names occurring. If <code>false</code> the complete stack trace is
returned.
@return the stack trace as newline separated string. If the passed
Throwable is <code>null</code> an empty string is returned. | [
"Get",
"the",
"stack",
"trace",
"of",
"a",
"throwable",
"as",
"string",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/lang/StackTraceHelper.java#L207-L226 |
136,806 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/serialize/write/AbstractXMLSerializer.java | AbstractXMLSerializer.handlePutNamespaceContextPrefixInRoot | protected final void handlePutNamespaceContextPrefixInRoot (@Nonnull final Map <QName, String> aAttrMap)
{
if (m_aSettings.isEmitNamespaces () &&
m_aNSStack.size () == 1 &&
m_aSettings.isPutNamespaceContextPrefixesInRoot ())
{
// The only place where the namespace context prefixes are added to the
// root element
for (final Map.Entry <String, String> aEntry : m_aRootNSMap.entrySet ())
{
aAttrMap.put (XMLHelper.getXMLNSAttrQName (aEntry.getKey ()), aEntry.getValue ());
m_aNSStack.addNamespaceMapping (aEntry.getKey (), aEntry.getValue ());
}
}
} | java | protected final void handlePutNamespaceContextPrefixInRoot (@Nonnull final Map <QName, String> aAttrMap)
{
if (m_aSettings.isEmitNamespaces () &&
m_aNSStack.size () == 1 &&
m_aSettings.isPutNamespaceContextPrefixesInRoot ())
{
// The only place where the namespace context prefixes are added to the
// root element
for (final Map.Entry <String, String> aEntry : m_aRootNSMap.entrySet ())
{
aAttrMap.put (XMLHelper.getXMLNSAttrQName (aEntry.getKey ()), aEntry.getValue ());
m_aNSStack.addNamespaceMapping (aEntry.getKey (), aEntry.getValue ());
}
}
} | [
"protected",
"final",
"void",
"handlePutNamespaceContextPrefixInRoot",
"(",
"@",
"Nonnull",
"final",
"Map",
"<",
"QName",
",",
"String",
">",
"aAttrMap",
")",
"{",
"if",
"(",
"m_aSettings",
".",
"isEmitNamespaces",
"(",
")",
"&&",
"m_aNSStack",
".",
"size",
"(... | This method handles the case, if all namespace context entries should be
emitted on the root element.
@param aAttrMap | [
"This",
"method",
"handles",
"the",
"case",
"if",
"all",
"namespace",
"context",
"entries",
"should",
"be",
"emitted",
"on",
"the",
"root",
"element",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/write/AbstractXMLSerializer.java#L498-L512 |
136,807 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/version/VersionRange.java | VersionRange.compareTo | public int compareTo (@Nonnull final VersionRange rhs)
{
int i = m_aFloorVersion.compareTo (rhs.m_aFloorVersion);
if (i == 0)
{
if (m_bIncludeFloor && !rhs.m_bIncludeFloor)
{
// this < rhs
i = -1;
}
else
if (!m_bIncludeFloor && rhs.m_bIncludeFloor)
{
// this > rhs
i = +1;
}
if (i == 0)
{
// compare ceiling
if (m_aCeilVersion != null && rhs.m_aCeilVersion == null)
i = -1;
else
if (m_aCeilVersion == null && rhs.m_aCeilVersion != null)
i = +1;
else
if (m_aCeilVersion != null && rhs.m_aCeilVersion != null)
i = m_aCeilVersion.compareTo (rhs.m_aCeilVersion);
// else i stays 0 if both are null
if (i == 0)
{
if (m_bIncludeCeil && !rhs.m_bIncludeCeil)
i = +1;
else
if (!m_bIncludeCeil && rhs.m_bIncludeCeil)
i = -1;
}
}
}
return i;
} | java | public int compareTo (@Nonnull final VersionRange rhs)
{
int i = m_aFloorVersion.compareTo (rhs.m_aFloorVersion);
if (i == 0)
{
if (m_bIncludeFloor && !rhs.m_bIncludeFloor)
{
// this < rhs
i = -1;
}
else
if (!m_bIncludeFloor && rhs.m_bIncludeFloor)
{
// this > rhs
i = +1;
}
if (i == 0)
{
// compare ceiling
if (m_aCeilVersion != null && rhs.m_aCeilVersion == null)
i = -1;
else
if (m_aCeilVersion == null && rhs.m_aCeilVersion != null)
i = +1;
else
if (m_aCeilVersion != null && rhs.m_aCeilVersion != null)
i = m_aCeilVersion.compareTo (rhs.m_aCeilVersion);
// else i stays 0 if both are null
if (i == 0)
{
if (m_bIncludeCeil && !rhs.m_bIncludeCeil)
i = +1;
else
if (!m_bIncludeCeil && rhs.m_bIncludeCeil)
i = -1;
}
}
}
return i;
} | [
"public",
"int",
"compareTo",
"(",
"@",
"Nonnull",
"final",
"VersionRange",
"rhs",
")",
"{",
"int",
"i",
"=",
"m_aFloorVersion",
".",
"compareTo",
"(",
"rhs",
".",
"m_aFloorVersion",
")",
";",
"if",
"(",
"i",
"==",
"0",
")",
"{",
"if",
"(",
"m_bInclude... | Compare this version range to another version range. Returns -1 if this is
< than the passed version or +1 if this is > the passed version range
@param rhs
the version range to compare to
@return 0 if the passed version range is equal to this version range<br>
-1 if the floor version of this is < than the floor version of
the passed version range.<br>
-1 if the floor versions are equal but the ceiling version of this
has a lower upper bound than the passed version range<br>
+1 if the floor version of this is > than the floor version of
the passed version range.<br>
+1 if the floor versions are equal but the ceiling version of this
has a higher upper bound than the passed version range<br> | [
"Compare",
"this",
"version",
"range",
"to",
"another",
"version",
"range",
".",
"Returns",
"-",
"1",
"if",
"this",
"is",
"<",
";",
"than",
"the",
"passed",
"version",
"or",
"+",
"1",
"if",
"this",
"is",
">",
";",
"the",
"passed",
"version",
"range... | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/version/VersionRange.java#L272-L313 |
136,808 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/channel/ChannelHelper.java | ChannelHelper.channelCopy | @Nonnegative
public static long channelCopy (@Nonnull @WillNotClose final ReadableByteChannel aSrc,
@Nonnull @WillNotClose final WritableByteChannel aDest) throws IOException
{
ValueEnforcer.notNull (aSrc, "SourceChannel");
ValueEnforcer.isTrue (aSrc.isOpen (), "SourceChannel is not open!");
ValueEnforcer.notNull (aDest, "DestinationChannel");
ValueEnforcer.isTrue (aDest.isOpen (), "DestinationChannel is not open!");
long nBytesWritten;
if (USE_COPY_V1)
nBytesWritten = _channelCopy1 (aSrc, aDest);
else
nBytesWritten = _channelCopy2 (aSrc, aDest);
return nBytesWritten;
} | java | @Nonnegative
public static long channelCopy (@Nonnull @WillNotClose final ReadableByteChannel aSrc,
@Nonnull @WillNotClose final WritableByteChannel aDest) throws IOException
{
ValueEnforcer.notNull (aSrc, "SourceChannel");
ValueEnforcer.isTrue (aSrc.isOpen (), "SourceChannel is not open!");
ValueEnforcer.notNull (aDest, "DestinationChannel");
ValueEnforcer.isTrue (aDest.isOpen (), "DestinationChannel is not open!");
long nBytesWritten;
if (USE_COPY_V1)
nBytesWritten = _channelCopy1 (aSrc, aDest);
else
nBytesWritten = _channelCopy2 (aSrc, aDest);
return nBytesWritten;
} | [
"@",
"Nonnegative",
"public",
"static",
"long",
"channelCopy",
"(",
"@",
"Nonnull",
"@",
"WillNotClose",
"final",
"ReadableByteChannel",
"aSrc",
",",
"@",
"Nonnull",
"@",
"WillNotClose",
"final",
"WritableByteChannel",
"aDest",
")",
"throws",
"IOException",
"{",
"... | Copy all content from the source channel to the destination channel.
@param aSrc
Source channel. May not be <code>null</code>. Is not closed after
the operation.
@param aDest
Destination channel. May not be <code>null</code>. Is not closed
after the operation.
@return The number of bytes written.
@throws IOException
In case of IO error | [
"Copy",
"all",
"content",
"from",
"the",
"source",
"channel",
"to",
"the",
"destination",
"channel",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/channel/ChannelHelper.java#L74-L89 |
136,809 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/url/URLParameterList.java | URLParameterList.remove | @Nonnull
public URLParameterList remove (@Nullable final String sName)
{
removeIf (aParam -> aParam.hasName (sName));
return this;
} | java | @Nonnull
public URLParameterList remove (@Nullable final String sName)
{
removeIf (aParam -> aParam.hasName (sName));
return this;
} | [
"@",
"Nonnull",
"public",
"URLParameterList",
"remove",
"(",
"@",
"Nullable",
"final",
"String",
"sName",
")",
"{",
"removeIf",
"(",
"aParam",
"->",
"aParam",
".",
"hasName",
"(",
"sName",
")",
")",
";",
"return",
"this",
";",
"}"
] | Remove all parameter with the given name.
@param sName
The key to remove
@return this | [
"Remove",
"all",
"parameter",
"with",
"the",
"given",
"name",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/url/URLParameterList.java#L58-L63 |
136,810 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/url/URLParameterList.java | URLParameterList.remove | @Nonnull
public URLParameterList remove (@Nullable final String sName, @Nullable final String sValue)
{
removeIf (aParam -> aParam.hasName (sName) && aParam.hasValue (sValue));
return this;
} | java | @Nonnull
public URLParameterList remove (@Nullable final String sName, @Nullable final String sValue)
{
removeIf (aParam -> aParam.hasName (sName) && aParam.hasValue (sValue));
return this;
} | [
"@",
"Nonnull",
"public",
"URLParameterList",
"remove",
"(",
"@",
"Nullable",
"final",
"String",
"sName",
",",
"@",
"Nullable",
"final",
"String",
"sValue",
")",
"{",
"removeIf",
"(",
"aParam",
"->",
"aParam",
".",
"hasName",
"(",
"sName",
")",
"&&",
"aPar... | Remove all parameter with the given name and value.
@param sName
The key to remove. May be <code>null</code>.
@param sValue
The value to be removed. May be <code>null</code>.
@return this | [
"Remove",
"all",
"parameter",
"with",
"the",
"given",
"name",
"and",
"value",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/url/URLParameterList.java#L74-L79 |
136,811 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/url/URLParameterList.java | URLParameterList.getFirstParamValue | @Nullable
public String getFirstParamValue (@Nullable final String sName)
{
return sName == null ? null : findFirstMapped (aParam -> aParam.hasName (sName), URLParameter::getValue);
} | java | @Nullable
public String getFirstParamValue (@Nullable final String sName)
{
return sName == null ? null : findFirstMapped (aParam -> aParam.hasName (sName), URLParameter::getValue);
} | [
"@",
"Nullable",
"public",
"String",
"getFirstParamValue",
"(",
"@",
"Nullable",
"final",
"String",
"sName",
")",
"{",
"return",
"sName",
"==",
"null",
"?",
"null",
":",
"findFirstMapped",
"(",
"aParam",
"->",
"aParam",
".",
"hasName",
"(",
"sName",
")",
"... | Get the value of the first parameter with the provided name
@param sName
The parameter name to search
@return <code>null</code> if no such parameter is present. | [
"Get",
"the",
"value",
"of",
"the",
"first",
"parameter",
"with",
"the",
"provided",
"name"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/url/URLParameterList.java#L119-L123 |
136,812 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroReader.java | MicroReader.readMicroXML | @Nullable
public static IMicroDocument readMicroXML (@WillClose @Nullable final InputSource aInputSource,
@Nullable final ISAXReaderSettings aSettings)
{
if (aInputSource == null)
return null;
final EntityResolver aEntityResolver = aSettings == null ? null : aSettings.getEntityResolver ();
final MicroSAXHandler aMicroHandler = new MicroSAXHandler (false, aEntityResolver, true);
// Copy and modify settings
final SAXReaderSettings aRealSettings = SAXReaderSettings.createCloneOnDemand (aSettings);
aRealSettings.setEntityResolver (aMicroHandler)
.setDTDHandler (aMicroHandler)
.setContentHandler (aMicroHandler)
.setLexicalHandler (aMicroHandler);
if (aRealSettings.getErrorHandler () == null)
{
// Use MicroHandler as default error handler if none is specified
aRealSettings.setErrorHandler (aMicroHandler);
}
if (aEntityResolver instanceof EntityResolver2)
{
// Ensure to use the new aEntityResolver2 APIs if available
aRealSettings.setFeatureValue (EXMLParserFeature.USE_ENTITY_RESOLVER2, true);
}
if (SAXReader.readXMLSAX (aInputSource, aRealSettings).isFailure ())
return null;
return aMicroHandler.getDocument ();
} | java | @Nullable
public static IMicroDocument readMicroXML (@WillClose @Nullable final InputSource aInputSource,
@Nullable final ISAXReaderSettings aSettings)
{
if (aInputSource == null)
return null;
final EntityResolver aEntityResolver = aSettings == null ? null : aSettings.getEntityResolver ();
final MicroSAXHandler aMicroHandler = new MicroSAXHandler (false, aEntityResolver, true);
// Copy and modify settings
final SAXReaderSettings aRealSettings = SAXReaderSettings.createCloneOnDemand (aSettings);
aRealSettings.setEntityResolver (aMicroHandler)
.setDTDHandler (aMicroHandler)
.setContentHandler (aMicroHandler)
.setLexicalHandler (aMicroHandler);
if (aRealSettings.getErrorHandler () == null)
{
// Use MicroHandler as default error handler if none is specified
aRealSettings.setErrorHandler (aMicroHandler);
}
if (aEntityResolver instanceof EntityResolver2)
{
// Ensure to use the new aEntityResolver2 APIs if available
aRealSettings.setFeatureValue (EXMLParserFeature.USE_ENTITY_RESOLVER2, true);
}
if (SAXReader.readXMLSAX (aInputSource, aRealSettings).isFailure ())
return null;
return aMicroHandler.getDocument ();
} | [
"@",
"Nullable",
"public",
"static",
"IMicroDocument",
"readMicroXML",
"(",
"@",
"WillClose",
"@",
"Nullable",
"final",
"InputSource",
"aInputSource",
",",
"@",
"Nullable",
"final",
"ISAXReaderSettings",
"aSettings",
")",
"{",
"if",
"(",
"aInputSource",
"==",
"nul... | Read the passed input source as MicroXML.
@param aInputSource
The input source to use. May be <code>null</code> in which case
<code>null</code> is directly returned.
@param aSettings
The settings to use. If <code>null</code> the default settings will
be used.
@return <code>null</code> if either the input source is <code>null</code>
or if the input was invalid XML. | [
"Read",
"the",
"passed",
"input",
"source",
"as",
"MicroXML",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/microdom/serialize/MicroReader.java#L79-L109 |
136,813 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/locale/language/LanguageCache.java | LanguageCache.containsLanguage | public boolean containsLanguage (@Nullable final String sLanguage)
{
if (sLanguage == null)
return false;
final String sValidLanguage = LocaleHelper.getValidLanguageCode (sLanguage);
if (sValidLanguage == null)
return false;
return m_aRWLock.readLocked ( () -> m_aLanguages.contains (sValidLanguage));
} | java | public boolean containsLanguage (@Nullable final String sLanguage)
{
if (sLanguage == null)
return false;
final String sValidLanguage = LocaleHelper.getValidLanguageCode (sLanguage);
if (sValidLanguage == null)
return false;
return m_aRWLock.readLocked ( () -> m_aLanguages.contains (sValidLanguage));
} | [
"public",
"boolean",
"containsLanguage",
"(",
"@",
"Nullable",
"final",
"String",
"sLanguage",
")",
"{",
"if",
"(",
"sLanguage",
"==",
"null",
")",
"return",
"false",
";",
"final",
"String",
"sValidLanguage",
"=",
"LocaleHelper",
".",
"getValidLanguageCode",
"("... | Check if the passed language is known.
@param sLanguage
The language to check. May be <code>null</code>.
@return <code>true</code> if the passed language is contained,
<code>false</code> otherwise. | [
"Check",
"if",
"the",
"passed",
"language",
"is",
"known",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/locale/language/LanguageCache.java#L165-L174 |
136,814 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/serialize/convert/SerializationConverterRegistry.java | SerializationConverterRegistry.iterateAllRegisteredSerializationConverters | public void iterateAllRegisteredSerializationConverters (@Nonnull final ISerializationConverterCallback aCallback)
{
// Create a static (non weak) copy of the map
final Map <Class <?>, ISerializationConverter <?>> aCopy = m_aRWLock.readLocked ( () -> new CommonsHashMap <> (m_aMap));
// And iterate the copy
for (final Map.Entry <Class <?>, ISerializationConverter <?>> aEntry : aCopy.entrySet ())
if (aCallback.call (aEntry.getKey (), aEntry.getValue ()).isBreak ())
break;
} | java | public void iterateAllRegisteredSerializationConverters (@Nonnull final ISerializationConverterCallback aCallback)
{
// Create a static (non weak) copy of the map
final Map <Class <?>, ISerializationConverter <?>> aCopy = m_aRWLock.readLocked ( () -> new CommonsHashMap <> (m_aMap));
// And iterate the copy
for (final Map.Entry <Class <?>, ISerializationConverter <?>> aEntry : aCopy.entrySet ())
if (aCallback.call (aEntry.getKey (), aEntry.getValue ()).isBreak ())
break;
} | [
"public",
"void",
"iterateAllRegisteredSerializationConverters",
"(",
"@",
"Nonnull",
"final",
"ISerializationConverterCallback",
"aCallback",
")",
"{",
"// Create a static (non weak) copy of the map",
"final",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"ISerializationConverter... | Iterate all registered serialization converters. For informational purposes
only.
@param aCallback
The callback invoked for all iterations. | [
"Iterate",
"all",
"registered",
"serialization",
"converters",
".",
"For",
"informational",
"purposes",
"only",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/serialize/convert/SerializationConverterRegistry.java#L155-L164 |
136,815 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/serialize/SerializationHelper.java | SerializationHelper.getSerializedByteArray | @Nonnull
public static byte [] getSerializedByteArray (@Nonnull final Serializable aData)
{
ValueEnforcer.notNull (aData, "Data");
try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ())
{
// Convert to byte array
try (final ObjectOutputStream aOOS = new ObjectOutputStream (aBAOS))
{
aOOS.writeObject (aData);
}
// Main sending
return aBAOS.toByteArray ();
}
catch (final NotSerializableException ex)
{
throw new IllegalArgumentException ("Not serializable: " + ex.getMessage (), ex);
}
catch (final IOException ex)
{
throw new IllegalArgumentException ("Failed to write serializable object " +
aData +
" of type " +
aData.getClass ().getName (),
ex);
}
} | java | @Nonnull
public static byte [] getSerializedByteArray (@Nonnull final Serializable aData)
{
ValueEnforcer.notNull (aData, "Data");
try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ())
{
// Convert to byte array
try (final ObjectOutputStream aOOS = new ObjectOutputStream (aBAOS))
{
aOOS.writeObject (aData);
}
// Main sending
return aBAOS.toByteArray ();
}
catch (final NotSerializableException ex)
{
throw new IllegalArgumentException ("Not serializable: " + ex.getMessage (), ex);
}
catch (final IOException ex)
{
throw new IllegalArgumentException ("Failed to write serializable object " +
aData +
" of type " +
aData.getClass ().getName (),
ex);
}
} | [
"@",
"Nonnull",
"public",
"static",
"byte",
"[",
"]",
"getSerializedByteArray",
"(",
"@",
"Nonnull",
"final",
"Serializable",
"aData",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aData",
",",
"\"Data\"",
")",
";",
"try",
"(",
"final",
"NonBlockingByteArra... | Convert the passed Serializable object to a serialized byte array.
@param aData
Source object. May not be <code>null</code>.
@return A non-<code>null</code> byte array.
@throws IllegalStateException
If serialization failed | [
"Convert",
"the",
"passed",
"Serializable",
"object",
"to",
"a",
"serialized",
"byte",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/serialize/SerializationHelper.java#L54-L82 |
136,816 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/serialize/SerializationHelper.java | SerializationHelper.getDeserializedObject | @Nonnull
public static <T> T getDeserializedObject (@Nonnull final byte [] aData)
{
ValueEnforcer.notNull (aData, "Data");
// Read new object from byte array
try (final ObjectInputStream aOIS = new ObjectInputStream (new NonBlockingByteArrayInputStream (aData)))
{
return GenericReflection.uncheckedCast (aOIS.readObject ());
}
catch (final Exception ex)
{
throw new IllegalStateException ("Failed to read serializable object", ex);
}
} | java | @Nonnull
public static <T> T getDeserializedObject (@Nonnull final byte [] aData)
{
ValueEnforcer.notNull (aData, "Data");
// Read new object from byte array
try (final ObjectInputStream aOIS = new ObjectInputStream (new NonBlockingByteArrayInputStream (aData)))
{
return GenericReflection.uncheckedCast (aOIS.readObject ());
}
catch (final Exception ex)
{
throw new IllegalStateException ("Failed to read serializable object", ex);
}
} | [
"@",
"Nonnull",
"public",
"static",
"<",
"T",
">",
"T",
"getDeserializedObject",
"(",
"@",
"Nonnull",
"final",
"byte",
"[",
"]",
"aData",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aData",
",",
"\"Data\"",
")",
";",
"// Read new object from byte array",
... | Convert the passed byte array to an object using deserialization.
@param aData
The source serialized byte array. Must contain a single object only.
May not be <code>null</code>.
@return The deserialized object. Never <code>null</code>.
@throws IllegalStateException
If deserialization failed
@param <T>
The type of the deserialized object | [
"Convert",
"the",
"passed",
"byte",
"array",
"to",
"an",
"object",
"using",
"deserialization",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/serialize/SerializationHelper.java#L96-L110 |
136,817 | phax/ph-commons | ph-datetime/src/main/java/com/helger/datetime/util/PDTIOHelper.java | PDTIOHelper.getLocalDateTimeForFilename | @Nonnull
public static String getLocalDateTimeForFilename (@Nonnull final LocalDateTime aDT)
{
return PDTToString.getAsString (PATTERN_DATETIME, aDT);
} | java | @Nonnull
public static String getLocalDateTimeForFilename (@Nonnull final LocalDateTime aDT)
{
return PDTToString.getAsString (PATTERN_DATETIME, aDT);
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getLocalDateTimeForFilename",
"(",
"@",
"Nonnull",
"final",
"LocalDateTime",
"aDT",
")",
"{",
"return",
"PDTToString",
".",
"getAsString",
"(",
"PATTERN_DATETIME",
",",
"aDT",
")",
";",
"}"
] | Get the passed local date time formatted suitable for a file name.
@param aDT
The local date time to be formatted. May not be <code>null</code>.
@return The formatted string. | [
"Get",
"the",
"passed",
"local",
"date",
"time",
"formatted",
"suitable",
"for",
"a",
"file",
"name",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-datetime/src/main/java/com/helger/datetime/util/PDTIOHelper.java#L67-L71 |
136,818 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/file/FileSystemRecursiveIterator.java | FileSystemRecursiveIterator.recurseIntoDirectory | @OverrideOnDemand
protected boolean recurseIntoDirectory (@Nonnull final File aDirectory)
{
return m_aRecursionFilter == null || m_aRecursionFilter.test (aDirectory);
} | java | @OverrideOnDemand
protected boolean recurseIntoDirectory (@Nonnull final File aDirectory)
{
return m_aRecursionFilter == null || m_aRecursionFilter.test (aDirectory);
} | [
"@",
"OverrideOnDemand",
"protected",
"boolean",
"recurseIntoDirectory",
"(",
"@",
"Nonnull",
"final",
"File",
"aDirectory",
")",
"{",
"return",
"m_aRecursionFilter",
"==",
"null",
"||",
"m_aRecursionFilter",
".",
"test",
"(",
"aDirectory",
")",
";",
"}"
] | Override this method to manually filter the directories, which are recursed
into.
@param aDirectory
The non-<code>null</code> directory
@return <code>true</code> if all children of this directory should be
investigated | [
"Override",
"this",
"method",
"to",
"manually",
"filter",
"the",
"directories",
"which",
"are",
"recursed",
"into",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/file/FileSystemRecursiveIterator.java#L138-L142 |
136,819 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java | LocaleFormatter.getFormatted | @Nonnull
public static String getFormatted (@Nonnull final BigDecimal aValue,
@Nonnegative final int nFractionDigits,
@Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aValue, "Value");
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
final NumberFormat aNF = NumberFormat.getInstance (aDisplayLocale);
aNF.setMinimumFractionDigits (nFractionDigits);
aNF.setMaximumFractionDigits (nFractionDigits);
return aNF.format (aValue);
} | java | @Nonnull
public static String getFormatted (@Nonnull final BigDecimal aValue,
@Nonnegative final int nFractionDigits,
@Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aValue, "Value");
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
final NumberFormat aNF = NumberFormat.getInstance (aDisplayLocale);
aNF.setMinimumFractionDigits (nFractionDigits);
aNF.setMaximumFractionDigits (nFractionDigits);
return aNF.format (aValue);
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getFormatted",
"(",
"@",
"Nonnull",
"final",
"BigDecimal",
"aValue",
",",
"@",
"Nonnegative",
"final",
"int",
"nFractionDigits",
",",
"@",
"Nonnull",
"final",
"Locale",
"aDisplayLocale",
")",
"{",
"ValueEnforcer",
"... | Format the passed value according to the rules specified by the given
locale.
@param aValue
The value to be formatted. May not be <code>null</code>.
@param nFractionDigits
The number of fractional digits to use. Must be ≥ 0.
@param aDisplayLocale
The locale to be used. May not be <code>null</code>.
@return The formatted string. | [
"Format",
"the",
"passed",
"value",
"according",
"to",
"the",
"rules",
"specified",
"by",
"the",
"given",
"locale",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java#L155-L167 |
136,820 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java | LocaleFormatter.getFormattedWithAllFractionDigits | @Nonnull
public static String getFormattedWithAllFractionDigits (@Nonnull final BigDecimal aValue,
@Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aValue, "Value");
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
final NumberFormat aNF = NumberFormat.getInstance (aDisplayLocale);
aNF.setMaximumFractionDigits (aValue.scale ());
return aNF.format (aValue);
} | java | @Nonnull
public static String getFormattedWithAllFractionDigits (@Nonnull final BigDecimal aValue,
@Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aValue, "Value");
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
final NumberFormat aNF = NumberFormat.getInstance (aDisplayLocale);
aNF.setMaximumFractionDigits (aValue.scale ());
return aNF.format (aValue);
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getFormattedWithAllFractionDigits",
"(",
"@",
"Nonnull",
"final",
"BigDecimal",
"aValue",
",",
"@",
"Nonnull",
"final",
"Locale",
"aDisplayLocale",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aValue",
",",
"\"Val... | Format the passed value according to the rules specified by the given
locale. All fraction digits of the passed value are displayed.
@param aValue
The value to be formatted. May not be <code>null</code>.
@param aDisplayLocale
The locale to be used. May not be <code>null</code>.
@return The formatted string. | [
"Format",
"the",
"passed",
"value",
"according",
"to",
"the",
"rules",
"specified",
"by",
"the",
"given",
"locale",
".",
"All",
"fraction",
"digits",
"of",
"the",
"passed",
"value",
"are",
"displayed",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java#L179-L189 |
136,821 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java | LocaleFormatter.getFormattedPercent | @Nonnull
public static String getFormattedPercent (final double dValue, @Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
return NumberFormat.getPercentInstance (aDisplayLocale).format (dValue);
} | java | @Nonnull
public static String getFormattedPercent (final double dValue, @Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
return NumberFormat.getPercentInstance (aDisplayLocale).format (dValue);
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getFormattedPercent",
"(",
"final",
"double",
"dValue",
",",
"@",
"Nonnull",
"final",
"Locale",
"aDisplayLocale",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aDisplayLocale",
",",
"\"DisplayLocale\"",
")",
";",
... | Format the given value as percentage. The "%" sign is automatically
appended according to the requested locale. The number of fractional digits
depend on the locale.
@param dValue
The value to be used. E.g. "0.125" will result in something like
"12.5%"
@param aDisplayLocale
The locale to use.
@return The non-<code>null</code> formatted string. | [
"Format",
"the",
"given",
"value",
"as",
"percentage",
".",
"The",
"%",
"sign",
"is",
"automatically",
"appended",
"according",
"to",
"the",
"requested",
"locale",
".",
"The",
"number",
"of",
"fractional",
"digits",
"depend",
"on",
"the",
"locale",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java#L203-L209 |
136,822 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java | LocaleFormatter.getFormattedPercent | @Nonnull
public static String getFormattedPercent (final double dValue,
@Nonnegative final int nFractionDigits,
@Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
final NumberFormat aNF = NumberFormat.getPercentInstance (aDisplayLocale);
aNF.setMinimumFractionDigits (nFractionDigits);
aNF.setMaximumFractionDigits (nFractionDigits);
return aNF.format (dValue);
} | java | @Nonnull
public static String getFormattedPercent (final double dValue,
@Nonnegative final int nFractionDigits,
@Nonnull final Locale aDisplayLocale)
{
ValueEnforcer.notNull (aDisplayLocale, "DisplayLocale");
final NumberFormat aNF = NumberFormat.getPercentInstance (aDisplayLocale);
aNF.setMinimumFractionDigits (nFractionDigits);
aNF.setMaximumFractionDigits (nFractionDigits);
return aNF.format (dValue);
} | [
"@",
"Nonnull",
"public",
"static",
"String",
"getFormattedPercent",
"(",
"final",
"double",
"dValue",
",",
"@",
"Nonnegative",
"final",
"int",
"nFractionDigits",
",",
"@",
"Nonnull",
"final",
"Locale",
"aDisplayLocale",
")",
"{",
"ValueEnforcer",
".",
"notNull",
... | Format the given value as percentage. The "%" sign is automatically
appended according to the requested locale.
@param dValue
The value to be used. E.g. "0.125" will result in something like
"12.5%"
@param nFractionDigits
The number of fractional digits to use. Must be ≥ 0.
@param aDisplayLocale
The locale to use.
@return The non-<code>null</code> formatted string. | [
"Format",
"the",
"given",
"value",
"as",
"percentage",
".",
"The",
"%",
"sign",
"is",
"automatically",
"appended",
"according",
"to",
"the",
"requested",
"locale",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/locale/LocaleFormatter.java#L224-L235 |
136,823 | phax/ph-commons | ph-collection/src/main/java/com/helger/collection/ring/RingBufferFifo.java | RingBufferFifo.put | @Nonnull
public EChange put (@Nullable final ELEMENTTYPE aElement)
{
if (m_nAvailable < m_nCapacity)
{
if (m_nWritePos >= m_nCapacity)
m_nWritePos = 0;
m_aElements[m_nWritePos] = aElement;
m_nWritePos++;
m_nAvailable++;
return EChange.CHANGED;
}
else
if (m_bAllowOverwrite)
{
if (m_nWritePos >= m_nCapacity)
m_nWritePos = 0;
m_aElements[m_nWritePos] = aElement;
m_nWritePos++;
return EChange.CHANGED;
}
return EChange.UNCHANGED;
} | java | @Nonnull
public EChange put (@Nullable final ELEMENTTYPE aElement)
{
if (m_nAvailable < m_nCapacity)
{
if (m_nWritePos >= m_nCapacity)
m_nWritePos = 0;
m_aElements[m_nWritePos] = aElement;
m_nWritePos++;
m_nAvailable++;
return EChange.CHANGED;
}
else
if (m_bAllowOverwrite)
{
if (m_nWritePos >= m_nCapacity)
m_nWritePos = 0;
m_aElements[m_nWritePos] = aElement;
m_nWritePos++;
return EChange.CHANGED;
}
return EChange.UNCHANGED;
} | [
"@",
"Nonnull",
"public",
"EChange",
"put",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"aElement",
")",
"{",
"if",
"(",
"m_nAvailable",
"<",
"m_nCapacity",
")",
"{",
"if",
"(",
"m_nWritePos",
">=",
"m_nCapacity",
")",
"m_nWritePos",
"=",
"0",
";",
"m_aE... | Add a new element into the ring buffer
@param aElement
The element to be added. May be <code>null</code>.
@return {@link EChange#CHANGED} if the element was successfully added or if
allow overwrite is active and the element was overwritten. | [
"Add",
"a",
"new",
"element",
"into",
"the",
"ring",
"buffer"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-collection/src/main/java/com/helger/collection/ring/RingBufferFifo.java#L115-L138 |
136,824 | phax/ph-commons | ph-collection/src/main/java/com/helger/collection/ring/RingBufferFifo.java | RingBufferFifo.take | @Nullable
public ELEMENTTYPE take ()
{
final int nAvailable = m_nAvailable;
if (nAvailable == 0)
return null;
int nIndex = m_nWritePos - nAvailable;
if (nIndex < 0)
nIndex += m_nCapacity;
final Object ret = m_aElements[nIndex];
m_nAvailable--;
return GenericReflection.uncheckedCast (ret);
} | java | @Nullable
public ELEMENTTYPE take ()
{
final int nAvailable = m_nAvailable;
if (nAvailable == 0)
return null;
int nIndex = m_nWritePos - nAvailable;
if (nIndex < 0)
nIndex += m_nCapacity;
final Object ret = m_aElements[nIndex];
m_nAvailable--;
return GenericReflection.uncheckedCast (ret);
} | [
"@",
"Nullable",
"public",
"ELEMENTTYPE",
"take",
"(",
")",
"{",
"final",
"int",
"nAvailable",
"=",
"m_nAvailable",
";",
"if",
"(",
"nAvailable",
"==",
"0",
")",
"return",
"null",
";",
"int",
"nIndex",
"=",
"m_nWritePos",
"-",
"nAvailable",
";",
"if",
"(... | Take an element from the ring buffer.
@return <code>null</code> if no more element is available or if the current
element is <code>null</code>. | [
"Take",
"an",
"element",
"from",
"the",
"ring",
"buffer",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-collection/src/main/java/com/helger/collection/ring/RingBufferFifo.java#L146-L160 |
136,825 | phax/ph-commons | ph-jaxb/src/main/java/com/helger/jaxb/validation/AbstractValidationEventHandler.java | AbstractValidationEventHandler.getErrorLevel | @Nonnull
@OverrideOnDemand
protected IErrorLevel getErrorLevel (final int nSeverity)
{
switch (nSeverity)
{
case ValidationEvent.WARNING:
return EErrorLevel.WARN;
case ValidationEvent.ERROR:
return EErrorLevel.ERROR;
case ValidationEvent.FATAL_ERROR:
return EErrorLevel.FATAL_ERROR;
default:
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Unknown JAXB validation severity: " + nSeverity + "; defaulting to error");
return EErrorLevel.ERROR;
}
} | java | @Nonnull
@OverrideOnDemand
protected IErrorLevel getErrorLevel (final int nSeverity)
{
switch (nSeverity)
{
case ValidationEvent.WARNING:
return EErrorLevel.WARN;
case ValidationEvent.ERROR:
return EErrorLevel.ERROR;
case ValidationEvent.FATAL_ERROR:
return EErrorLevel.FATAL_ERROR;
default:
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("Unknown JAXB validation severity: " + nSeverity + "; defaulting to error");
return EErrorLevel.ERROR;
}
} | [
"@",
"Nonnull",
"@",
"OverrideOnDemand",
"protected",
"IErrorLevel",
"getErrorLevel",
"(",
"final",
"int",
"nSeverity",
")",
"{",
"switch",
"(",
"nSeverity",
")",
"{",
"case",
"ValidationEvent",
".",
"WARNING",
":",
"return",
"EErrorLevel",
".",
"WARN",
";",
"... | Get the error level matching the passed JAXB severity.
@param nSeverity
The JAXB severity.
@return The matching {@link IErrorLevel}. Never <code>null</code>. | [
"Get",
"the",
"error",
"level",
"matching",
"the",
"passed",
"JAXB",
"severity",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-jaxb/src/main/java/com/helger/jaxb/validation/AbstractValidationEventHandler.java#L67-L84 |
136,826 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/serialize/read/SAXReader.java | SAXReader.readXMLSAX | @Nonnull
public static ESuccess readXMLSAX (@WillClose @Nonnull final InputSource aIS,
@Nonnull final ISAXReaderSettings aSettings)
{
ValueEnforcer.notNull (aIS, "InputStream");
ValueEnforcer.notNull (aSettings, "Settings");
try
{
boolean bFromPool = false;
org.xml.sax.XMLReader aParser;
if (aSettings.requiresNewXMLParser ())
{
aParser = SAXReaderFactory.createXMLReader ();
}
else
{
// use parser from pool
aParser = s_aSAXPool.borrowObject ();
bFromPool = true;
}
try
{
final StopWatch aSW = StopWatch.createdStarted ();
// Apply settings
aSettings.applyToSAXReader (aParser);
// Start parsing
aParser.parse (aIS);
// Statistics
s_aSaxSuccessCounterHdl.increment ();
s_aSaxTimerHdl.addTime (aSW.stopAndGetMillis ());
return ESuccess.SUCCESS;
}
finally
{
if (bFromPool)
{
// Return parser to pool
s_aSAXPool.returnObject (aParser);
}
}
}
catch (final SAXParseException ex)
{
boolean bHandled = false;
if (aSettings.getErrorHandler () != null)
try
{
aSettings.getErrorHandler ().fatalError (ex);
bHandled = true;
}
catch (final SAXException ex2)
{
// fall-through
}
if (!bHandled)
aSettings.exceptionCallbacks ().forEach (x -> x.onException (ex));
}
catch (final Exception ex)
{
aSettings.exceptionCallbacks ().forEach (x -> x.onException (ex));
}
finally
{
// Close both byte stream and character stream, as we don't know which one
// was used
StreamHelper.close (aIS.getByteStream ());
StreamHelper.close (aIS.getCharacterStream ());
}
s_aSaxErrorCounterHdl.increment ();
return ESuccess.FAILURE;
} | java | @Nonnull
public static ESuccess readXMLSAX (@WillClose @Nonnull final InputSource aIS,
@Nonnull final ISAXReaderSettings aSettings)
{
ValueEnforcer.notNull (aIS, "InputStream");
ValueEnforcer.notNull (aSettings, "Settings");
try
{
boolean bFromPool = false;
org.xml.sax.XMLReader aParser;
if (aSettings.requiresNewXMLParser ())
{
aParser = SAXReaderFactory.createXMLReader ();
}
else
{
// use parser from pool
aParser = s_aSAXPool.borrowObject ();
bFromPool = true;
}
try
{
final StopWatch aSW = StopWatch.createdStarted ();
// Apply settings
aSettings.applyToSAXReader (aParser);
// Start parsing
aParser.parse (aIS);
// Statistics
s_aSaxSuccessCounterHdl.increment ();
s_aSaxTimerHdl.addTime (aSW.stopAndGetMillis ());
return ESuccess.SUCCESS;
}
finally
{
if (bFromPool)
{
// Return parser to pool
s_aSAXPool.returnObject (aParser);
}
}
}
catch (final SAXParseException ex)
{
boolean bHandled = false;
if (aSettings.getErrorHandler () != null)
try
{
aSettings.getErrorHandler ().fatalError (ex);
bHandled = true;
}
catch (final SAXException ex2)
{
// fall-through
}
if (!bHandled)
aSettings.exceptionCallbacks ().forEach (x -> x.onException (ex));
}
catch (final Exception ex)
{
aSettings.exceptionCallbacks ().forEach (x -> x.onException (ex));
}
finally
{
// Close both byte stream and character stream, as we don't know which one
// was used
StreamHelper.close (aIS.getByteStream ());
StreamHelper.close (aIS.getCharacterStream ());
}
s_aSaxErrorCounterHdl.increment ();
return ESuccess.FAILURE;
} | [
"@",
"Nonnull",
"public",
"static",
"ESuccess",
"readXMLSAX",
"(",
"@",
"WillClose",
"@",
"Nonnull",
"final",
"InputSource",
"aIS",
",",
"@",
"Nonnull",
"final",
"ISAXReaderSettings",
"aSettings",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aIS",
",",
"\"... | Read an XML document via a SAX handler. The streams are closed after
reading.
@param aIS
The input source to read from. Automatically closed upon success or
error. May not be <code>null</code>.
{@link com.helger.xml.sax.InputSourceFactory} may be used to create
{@link InputSource} objects from different input types.
@param aSettings
Reader settings. At least a content handler should be set. May be
<code>null</code>.
@return {@link ESuccess#SUCCESS} if reading succeeded,
{@link ESuccess#FAILURE} otherwise | [
"Read",
"an",
"XML",
"document",
"via",
"a",
"SAX",
"handler",
".",
"The",
"streams",
"are",
"closed",
"after",
"reading",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/read/SAXReader.java#L199-L275 |
136,827 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/log/InMemoryLogger.java | InMemoryLogger.createLogMessage | @Nullable
@OverrideOnDemand
protected LogMessage createLogMessage (@Nonnull final IErrorLevel eErrorLevel,
@Nonnull final Serializable aMsg,
@Nullable final Throwable t)
{
return new LogMessage (eErrorLevel, aMsg, t);
} | java | @Nullable
@OverrideOnDemand
protected LogMessage createLogMessage (@Nonnull final IErrorLevel eErrorLevel,
@Nonnull final Serializable aMsg,
@Nullable final Throwable t)
{
return new LogMessage (eErrorLevel, aMsg, t);
} | [
"@",
"Nullable",
"@",
"OverrideOnDemand",
"protected",
"LogMessage",
"createLogMessage",
"(",
"@",
"Nonnull",
"final",
"IErrorLevel",
"eErrorLevel",
",",
"@",
"Nonnull",
"final",
"Serializable",
"aMsg",
",",
"@",
"Nullable",
"final",
"Throwable",
"t",
")",
"{",
... | Override this method to create a different LogMessage object or to filter
certain log messages.
@param eErrorLevel
Error level. Never <code>null</code>.
@param aMsg
The message object. Never <code>null</code>.
@param t
An optional exception. May be <code>null</code>.
@return The returned value. May be <code>null</code> in which case the
message will not be logged. | [
"Override",
"this",
"method",
"to",
"create",
"a",
"different",
"LogMessage",
"object",
"or",
"to",
"filter",
"certain",
"log",
"messages",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/log/InMemoryLogger.java#L63-L70 |
136,828 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/schema/SchemaCache.java | SchemaCache.getValidatorFromSchema | @Nonnull
public final Validator getValidatorFromSchema (@Nonnull final Schema aSchema)
{
ValueEnforcer.notNull (aSchema, "Schema");
final Validator aValidator = aSchema.newValidator ();
aValidator.setErrorHandler (m_aSchemaFactory.getErrorHandler ());
return aValidator;
} | java | @Nonnull
public final Validator getValidatorFromSchema (@Nonnull final Schema aSchema)
{
ValueEnforcer.notNull (aSchema, "Schema");
final Validator aValidator = aSchema.newValidator ();
aValidator.setErrorHandler (m_aSchemaFactory.getErrorHandler ());
return aValidator;
} | [
"@",
"Nonnull",
"public",
"final",
"Validator",
"getValidatorFromSchema",
"(",
"@",
"Nonnull",
"final",
"Schema",
"aSchema",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aSchema",
",",
"\"Schema\"",
")",
";",
"final",
"Validator",
"aValidator",
"=",
"aSchema... | Utility method to get the validator for a given schema using the error
handler provided in the constructor.
@param aSchema
The schema for which the validator is to be retrieved. May not be
<code>null</code>.
@return The validator and never <code>null</code>. | [
"Utility",
"method",
"to",
"get",
"the",
"validator",
"for",
"a",
"given",
"schema",
"using",
"the",
"error",
"handler",
"provided",
"in",
"the",
"constructor",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/schema/SchemaCache.java#L183-L191 |
136,829 | phax/ph-commons | ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java | CertificateHelper.convertByteArrayToCertficate | @Nullable
public static X509Certificate convertByteArrayToCertficate (@Nullable final byte [] aCertBytes) throws CertificateException
{
if (ArrayHelper.isEmpty (aCertBytes))
return null;
// Certificate is always ISO-8859-1 encoded
return convertStringToCertficate (new String (aCertBytes, CERT_CHARSET));
} | java | @Nullable
public static X509Certificate convertByteArrayToCertficate (@Nullable final byte [] aCertBytes) throws CertificateException
{
if (ArrayHelper.isEmpty (aCertBytes))
return null;
// Certificate is always ISO-8859-1 encoded
return convertStringToCertficate (new String (aCertBytes, CERT_CHARSET));
} | [
"@",
"Nullable",
"public",
"static",
"X509Certificate",
"convertByteArrayToCertficate",
"(",
"@",
"Nullable",
"final",
"byte",
"[",
"]",
"aCertBytes",
")",
"throws",
"CertificateException",
"{",
"if",
"(",
"ArrayHelper",
".",
"isEmpty",
"(",
"aCertBytes",
")",
")"... | Convert the passed byte array to an X.509 certificate object.
@param aCertBytes
The original certificate bytes. May be <code>null</code> or empty.
@return <code>null</code> if the passed byte array is <code>null</code> or
empty
@throws CertificateException
In case the passed string cannot be converted to an X.509
certificate. | [
"Convert",
"the",
"passed",
"byte",
"array",
"to",
"an",
"X",
".",
"509",
"certificate",
"object",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java#L211-L219 |
136,830 | phax/ph-commons | ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java | CertificateHelper.convertStringToCertficate | @Nullable
public static X509Certificate convertStringToCertficate (@Nullable final String sCertString) throws CertificateException
{
if (StringHelper.hasNoText (sCertString))
{
// No string -> no certificate
return null;
}
final CertificateFactory aCertificateFactory = getX509CertificateFactory ();
// Convert certificate string to an object
try
{
return _str2cert (sCertString, aCertificateFactory);
}
catch (final IllegalArgumentException | CertificateException ex)
{
// In some weird configurations, the result string is a hex encoded
// certificate instead of the string
// -> Try to work around it
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Failed to decode provided X.509 certificate string: " + sCertString);
String sHexDecodedString;
try
{
sHexDecodedString = new String (StringHelper.getHexDecoded (sCertString), CERT_CHARSET);
}
catch (final IllegalArgumentException ex2)
{
// Can happen, when the source string has an odd length (like 3 or 117).
// In this case the original exception is rethrown
throw ex;
}
return _str2cert (sHexDecodedString, aCertificateFactory);
}
} | java | @Nullable
public static X509Certificate convertStringToCertficate (@Nullable final String sCertString) throws CertificateException
{
if (StringHelper.hasNoText (sCertString))
{
// No string -> no certificate
return null;
}
final CertificateFactory aCertificateFactory = getX509CertificateFactory ();
// Convert certificate string to an object
try
{
return _str2cert (sCertString, aCertificateFactory);
}
catch (final IllegalArgumentException | CertificateException ex)
{
// In some weird configurations, the result string is a hex encoded
// certificate instead of the string
// -> Try to work around it
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Failed to decode provided X.509 certificate string: " + sCertString);
String sHexDecodedString;
try
{
sHexDecodedString = new String (StringHelper.getHexDecoded (sCertString), CERT_CHARSET);
}
catch (final IllegalArgumentException ex2)
{
// Can happen, when the source string has an odd length (like 3 or 117).
// In this case the original exception is rethrown
throw ex;
}
return _str2cert (sHexDecodedString, aCertificateFactory);
}
} | [
"@",
"Nullable",
"public",
"static",
"X509Certificate",
"convertStringToCertficate",
"(",
"@",
"Nullable",
"final",
"String",
"sCertString",
")",
"throws",
"CertificateException",
"{",
"if",
"(",
"StringHelper",
".",
"hasNoText",
"(",
"sCertString",
")",
")",
"{",
... | Convert the passed String to an X.509 certificate.
@param sCertString
The original text string. May be <code>null</code> or empty. The
String must be ISO-8859-1 encoded for the binary certificate to be
read!
@return <code>null</code> if the passed string is <code>null</code> or
empty
@throws CertificateException
In case the passed string cannot be converted to an X.509
certificate.
@throws IllegalArgumentException
If the input string is e.g. invalid Base64 encoded. | [
"Convert",
"the",
"passed",
"String",
"to",
"an",
"X",
".",
"509",
"certificate",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java#L246-L284 |
136,831 | phax/ph-commons | ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java | CertificateHelper.convertCertificateStringToByteArray | @Nullable
public static byte [] convertCertificateStringToByteArray (@Nullable final String sCertificate)
{
// Remove prefix/suffix
final String sPlainCert = getWithoutPEMHeader (sCertificate);
if (StringHelper.hasNoText (sPlainCert))
return null;
// The remaining string is supposed to be Base64 encoded -> decode
return Base64.safeDecode (sPlainCert);
} | java | @Nullable
public static byte [] convertCertificateStringToByteArray (@Nullable final String sCertificate)
{
// Remove prefix/suffix
final String sPlainCert = getWithoutPEMHeader (sCertificate);
if (StringHelper.hasNoText (sPlainCert))
return null;
// The remaining string is supposed to be Base64 encoded -> decode
return Base64.safeDecode (sPlainCert);
} | [
"@",
"Nullable",
"public",
"static",
"byte",
"[",
"]",
"convertCertificateStringToByteArray",
"(",
"@",
"Nullable",
"final",
"String",
"sCertificate",
")",
"{",
"// Remove prefix/suffix",
"final",
"String",
"sPlainCert",
"=",
"getWithoutPEMHeader",
"(",
"sCertificate",
... | Convert the passed X.509 certificate string to a byte array.
@param sCertificate
The original certificate string. May be <code>null</code> or empty.
@return <code>null</code> if the passed string is <code>null</code> or
empty or an invalid Base64 string | [
"Convert",
"the",
"passed",
"X",
".",
"509",
"certificate",
"string",
"to",
"a",
"byte",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-security/src/main/java/com/helger/security/certificate/CertificateHelper.java#L294-L304 |
136,832 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/gfx/ImageDataManager.java | ImageDataManager.clearCachedSize | @Nonnull
public EChange clearCachedSize (@Nullable final IReadableResource aRes)
{
if (aRes == null)
return EChange.UNCHANGED;
return m_aRWLock.writeLocked ( () -> {
// Existing resource?
if (m_aImageData.remove (aRes) != null)
return EChange.CHANGED;
// Non-existing resource?
if (m_aNonExistingResources.remove (aRes))
return EChange.CHANGED;
return EChange.UNCHANGED;
});
} | java | @Nonnull
public EChange clearCachedSize (@Nullable final IReadableResource aRes)
{
if (aRes == null)
return EChange.UNCHANGED;
return m_aRWLock.writeLocked ( () -> {
// Existing resource?
if (m_aImageData.remove (aRes) != null)
return EChange.CHANGED;
// Non-existing resource?
if (m_aNonExistingResources.remove (aRes))
return EChange.CHANGED;
return EChange.UNCHANGED;
});
} | [
"@",
"Nonnull",
"public",
"EChange",
"clearCachedSize",
"(",
"@",
"Nullable",
"final",
"IReadableResource",
"aRes",
")",
"{",
"if",
"(",
"aRes",
"==",
"null",
")",
"return",
"EChange",
".",
"UNCHANGED",
";",
"return",
"m_aRWLock",
".",
"writeLocked",
"(",
"(... | Remove a single resource from the cache.
@param aRes
The resource to be removed. May be <code>null</code>.
@return Never <code>null</code>. | [
"Remove",
"a",
"single",
"resource",
"from",
"the",
"cache",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/gfx/ImageDataManager.java#L208-L225 |
136,833 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/gfx/ImageDataManager.java | ImageDataManager.clearCache | @Nonnull
public EChange clearCache ()
{
return m_aRWLock.writeLocked ( () -> {
if (m_aImageData.isEmpty () && m_aNonExistingResources.isEmpty ())
return EChange.UNCHANGED;
m_aImageData.clear ();
m_aNonExistingResources.clear ();
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Cache was cleared: " + ImageDataManager.class.getName ());
return EChange.CHANGED;
});
} | java | @Nonnull
public EChange clearCache ()
{
return m_aRWLock.writeLocked ( () -> {
if (m_aImageData.isEmpty () && m_aNonExistingResources.isEmpty ())
return EChange.UNCHANGED;
m_aImageData.clear ();
m_aNonExistingResources.clear ();
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Cache was cleared: " + ImageDataManager.class.getName ());
return EChange.CHANGED;
});
} | [
"@",
"Nonnull",
"public",
"EChange",
"clearCache",
"(",
")",
"{",
"return",
"m_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"m_aImageData",
".",
"isEmpty",
"(",
")",
"&&",
"m_aNonExistingResources",
".",
"isEmpty",
"(",
")",
")",
"r... | Remove all cached elements
@return {@link EChange} - never null | [
"Remove",
"all",
"cached",
"elements"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/gfx/ImageDataManager.java#L232-L246 |
136,834 | phax/ph-commons | ph-jaxb/src/main/java/com/helger/jaxb/builder/AbstractWritingJAXBBuilder.java | AbstractWritingJAXBBuilder.createMarshaller | @Nonnull
@OverrideOnDemand
protected Marshaller createMarshaller () throws JAXBException
{
final JAXBContext aJAXBContext = getJAXBContext ();
// create a Marshaller
final Marshaller aMarshaller = aJAXBContext.createMarshaller ();
// Validating (if possible)
final Schema aSchema = getSchema ();
if (aSchema != null)
aMarshaller.setSchema (aSchema);
return aMarshaller;
} | java | @Nonnull
@OverrideOnDemand
protected Marshaller createMarshaller () throws JAXBException
{
final JAXBContext aJAXBContext = getJAXBContext ();
// create a Marshaller
final Marshaller aMarshaller = aJAXBContext.createMarshaller ();
// Validating (if possible)
final Schema aSchema = getSchema ();
if (aSchema != null)
aMarshaller.setSchema (aSchema);
return aMarshaller;
} | [
"@",
"Nonnull",
"@",
"OverrideOnDemand",
"protected",
"Marshaller",
"createMarshaller",
"(",
")",
"throws",
"JAXBException",
"{",
"final",
"JAXBContext",
"aJAXBContext",
"=",
"getJAXBContext",
"(",
")",
";",
"// create a Marshaller",
"final",
"Marshaller",
"aMarshaller"... | Create the main marshaller with the contained settings.
@return The Marshaller and never <code>null</code>.
@throws JAXBException
In case creation fails | [
"Create",
"the",
"main",
"marshaller",
"with",
"the",
"contained",
"settings",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-jaxb/src/main/java/com/helger/jaxb/builder/AbstractWritingJAXBBuilder.java#L77-L92 |
136,835 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/sax/DefaultEntityResolver.java | DefaultEntityResolver.createOnDemand | @Nullable
public static DefaultEntityResolver createOnDemand (@Nonnull final IReadableResource aBaseResource)
{
final URL aURL = aBaseResource.getAsURL ();
return aURL == null ? null : new DefaultEntityResolver (aURL);
} | java | @Nullable
public static DefaultEntityResolver createOnDemand (@Nonnull final IReadableResource aBaseResource)
{
final URL aURL = aBaseResource.getAsURL ();
return aURL == null ? null : new DefaultEntityResolver (aURL);
} | [
"@",
"Nullable",
"public",
"static",
"DefaultEntityResolver",
"createOnDemand",
"(",
"@",
"Nonnull",
"final",
"IReadableResource",
"aBaseResource",
")",
"{",
"final",
"URL",
"aURL",
"=",
"aBaseResource",
".",
"getAsURL",
"(",
")",
";",
"return",
"aURL",
"==",
"n... | Factory method with a resource.
@param aBaseResource
The base resource. May not be <code>null</code>.
@return <code>null</code> if the resource does not exist | [
"Factory",
"method",
"with",
"a",
"resource",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/sax/DefaultEntityResolver.java#L92-L97 |
136,836 | phax/ph-commons | ph-less-commons/src/main/java/com/helger/lesscommons/charset/StringDecoder.java | StringDecoder.reserve | public void reserve (@Nonnegative final int nExpectedLength)
{
ValueEnforcer.isGE0 (nExpectedLength, "ExpectedLength");
if (m_aBuffer.position () != 0)
throw new IllegalStateException ("cannot be called except after finish()");
if (nExpectedLength > m_aBuffer.capacity ())
{
// Allocate a temporary buffer large enough for this string rounded up
int nDesiredLength = nExpectedLength;
if ((nDesiredLength & SIZE_ALIGNMENT_MASK) != 0)
{
// round up
nDesiredLength = (nExpectedLength + SIZE_ALIGNMENT) & ~SIZE_ALIGNMENT_MASK;
}
assert nDesiredLength % SIZE_ALIGNMENT == 0;
m_aBuffer = CharBuffer.allocate (nDesiredLength);
}
if (m_aBuffer.position () != 0)
throw new IllegalStateException ("Buffer position weird!");
if (nExpectedLength > m_aBuffer.capacity ())
throw new IllegalStateException ();
} | java | public void reserve (@Nonnegative final int nExpectedLength)
{
ValueEnforcer.isGE0 (nExpectedLength, "ExpectedLength");
if (m_aBuffer.position () != 0)
throw new IllegalStateException ("cannot be called except after finish()");
if (nExpectedLength > m_aBuffer.capacity ())
{
// Allocate a temporary buffer large enough for this string rounded up
int nDesiredLength = nExpectedLength;
if ((nDesiredLength & SIZE_ALIGNMENT_MASK) != 0)
{
// round up
nDesiredLength = (nExpectedLength + SIZE_ALIGNMENT) & ~SIZE_ALIGNMENT_MASK;
}
assert nDesiredLength % SIZE_ALIGNMENT == 0;
m_aBuffer = CharBuffer.allocate (nDesiredLength);
}
if (m_aBuffer.position () != 0)
throw new IllegalStateException ("Buffer position weird!");
if (nExpectedLength > m_aBuffer.capacity ())
throw new IllegalStateException ();
} | [
"public",
"void",
"reserve",
"(",
"@",
"Nonnegative",
"final",
"int",
"nExpectedLength",
")",
"{",
"ValueEnforcer",
".",
"isGE0",
"(",
"nExpectedLength",
",",
"\"ExpectedLength\"",
")",
";",
"if",
"(",
"m_aBuffer",
".",
"position",
"(",
")",
"!=",
"0",
")",
... | Reserve space for the next string that will be ≤ expectedLength
characters long. Must only be called when the buffer is empty.
@param nExpectedLength
The number of chars to reserve. Must be ≥ 0. | [
"Reserve",
"space",
"for",
"the",
"next",
"string",
"that",
"will",
"be",
"&le",
";",
"expectedLength",
"characters",
"long",
".",
"Must",
"only",
"be",
"called",
"when",
"the",
"buffer",
"is",
"empty",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-less-commons/src/main/java/com/helger/lesscommons/charset/StringDecoder.java#L66-L89 |
136,837 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/text/resourcebundle/ResourceBundleHelper.java | ResourceBundleHelper.clearCache | public static void clearCache (@Nonnull final ClassLoader aClassLoader)
{
ResourceBundle.clearCache (aClassLoader);
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Cache was cleared: " + ResourceBundle.class.getName () + "; classloader=" + aClassLoader);
} | java | public static void clearCache (@Nonnull final ClassLoader aClassLoader)
{
ResourceBundle.clearCache (aClassLoader);
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Cache was cleared: " + ResourceBundle.class.getName () + "; classloader=" + aClassLoader);
} | [
"public",
"static",
"void",
"clearCache",
"(",
"@",
"Nonnull",
"final",
"ClassLoader",
"aClassLoader",
")",
"{",
"ResourceBundle",
".",
"clearCache",
"(",
"aClassLoader",
")",
";",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"LOGGER",
".",
"de... | Clear the complete resource bundle cache using the specified class loader!
@param aClassLoader
The class loader to be used. May not be <code>null</code>. | [
"Clear",
"the",
"complete",
"resource",
"bundle",
"cache",
"using",
"the",
"specified",
"class",
"loader!"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/text/resourcebundle/ResourceBundleHelper.java#L167-L172 |
136,838 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/callback/exception/LoggingExceptionCallback.java | LoggingExceptionCallback.setErrorLevel | @Nonnull
public final LoggingExceptionCallback setErrorLevel (@Nonnull final IErrorLevel aErrorLevel)
{
m_aErrorLevel = ValueEnforcer.notNull (aErrorLevel, "ErrorLevel");
return this;
} | java | @Nonnull
public final LoggingExceptionCallback setErrorLevel (@Nonnull final IErrorLevel aErrorLevel)
{
m_aErrorLevel = ValueEnforcer.notNull (aErrorLevel, "ErrorLevel");
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"LoggingExceptionCallback",
"setErrorLevel",
"(",
"@",
"Nonnull",
"final",
"IErrorLevel",
"aErrorLevel",
")",
"{",
"m_aErrorLevel",
"=",
"ValueEnforcer",
".",
"notNull",
"(",
"aErrorLevel",
",",
"\"ErrorLevel\"",
")",
";",
"return"... | Set the error level to be used.
@param aErrorLevel
Error level to use. May not be <code>null</code>.
@return this for chaining | [
"Set",
"the",
"error",
"level",
"to",
"be",
"used",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/callback/exception/LoggingExceptionCallback.java#L68-L73 |
136,839 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/callback/exception/LoggingExceptionCallback.java | LoggingExceptionCallback.getLogMessage | @Nonnull
@Nonempty
@OverrideOnDemand
protected String getLogMessage (@Nullable final Throwable t)
{
if (t == null)
return "An error occurred";
return "An exception was thrown";
} | java | @Nonnull
@Nonempty
@OverrideOnDemand
protected String getLogMessage (@Nullable final Throwable t)
{
if (t == null)
return "An error occurred";
return "An exception was thrown";
} | [
"@",
"Nonnull",
"@",
"Nonempty",
"@",
"OverrideOnDemand",
"protected",
"String",
"getLogMessage",
"(",
"@",
"Nullable",
"final",
"Throwable",
"t",
")",
"{",
"if",
"(",
"t",
"==",
"null",
")",
"return",
"\"An error occurred\"",
";",
"return",
"\"An exception was ... | Get the text to be logged for a certain exception
@param t
The exception to be logged. May theoretically be <code>null</code>.
@return The text to be logged. May neither be <code>null</code> nor empty. | [
"Get",
"the",
"text",
"to",
"be",
"logged",
"for",
"a",
"certain",
"exception"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/callback/exception/LoggingExceptionCallback.java#L82-L90 |
136,840 | phax/ph-commons | ph-tree/src/main/java/com/helger/tree/sort/TreeSorter.java | TreeSorter.sort | public static <DATATYPE, ITEMTYPE extends ITreeItem <DATATYPE, ITEMTYPE>> void sort (@Nonnull final IBasicTree <? extends DATATYPE, ITEMTYPE> aTree,
@Nonnull final Comparator <? super DATATYPE> aValueComparator)
{
_sort (aTree, Comparator.comparing (IBasicTreeItem::getData, aValueComparator));
} | java | public static <DATATYPE, ITEMTYPE extends ITreeItem <DATATYPE, ITEMTYPE>> void sort (@Nonnull final IBasicTree <? extends DATATYPE, ITEMTYPE> aTree,
@Nonnull final Comparator <? super DATATYPE> aValueComparator)
{
_sort (aTree, Comparator.comparing (IBasicTreeItem::getData, aValueComparator));
} | [
"public",
"static",
"<",
"DATATYPE",
",",
"ITEMTYPE",
"extends",
"ITreeItem",
"<",
"DATATYPE",
",",
"ITEMTYPE",
">",
">",
"void",
"sort",
"(",
"@",
"Nonnull",
"final",
"IBasicTree",
"<",
"?",
"extends",
"DATATYPE",
",",
"ITEMTYPE",
">",
"aTree",
",",
"@",
... | Sort each level of the passed tree with the specified comparator.
@param aTree
The tree to be sorted.
@param aValueComparator
The comparator to be used for sorting the tree items on each level.
@param <DATATYPE>
The tree item data type
@param <ITEMTYPE>
The tree item type | [
"Sort",
"each",
"level",
"of",
"the",
"passed",
"tree",
"with",
"the",
"specified",
"comparator",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-tree/src/main/java/com/helger/tree/sort/TreeSorter.java#L80-L84 |
136,841 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/deadlock/ThreadDeadlockDetectionTimer.java | ThreadDeadlockDetectionTimer.stop | @Nonnull
public EChange stop ()
{
if (!m_aTimerTask.cancel ())
return EChange.UNCHANGED;
LOGGER.info ("Deadlock detector stopped!");
return EChange.CHANGED;
} | java | @Nonnull
public EChange stop ()
{
if (!m_aTimerTask.cancel ())
return EChange.UNCHANGED;
LOGGER.info ("Deadlock detector stopped!");
return EChange.CHANGED;
} | [
"@",
"Nonnull",
"public",
"EChange",
"stop",
"(",
")",
"{",
"if",
"(",
"!",
"m_aTimerTask",
".",
"cancel",
"(",
")",
")",
"return",
"EChange",
".",
"UNCHANGED",
";",
"LOGGER",
".",
"info",
"(",
"\"Deadlock detector stopped!\"",
")",
";",
"return",
"EChange... | Stop the deadlock detection task
@return {@link EChange} | [
"Stop",
"the",
"deadlock",
"detection",
"task"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/deadlock/ThreadDeadlockDetectionTimer.java#L80-L87 |
136,842 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java | DateTimeFormatterCache.getDateTimeFormatterStrict | @Nonnull
public static DateTimeFormatter getDateTimeFormatterStrict (@Nonnull @Nonempty final String sPattern)
{
return getDateTimeFormatter (sPattern, ResolverStyle.STRICT);
} | java | @Nonnull
public static DateTimeFormatter getDateTimeFormatterStrict (@Nonnull @Nonempty final String sPattern)
{
return getDateTimeFormatter (sPattern, ResolverStyle.STRICT);
} | [
"@",
"Nonnull",
"public",
"static",
"DateTimeFormatter",
"getDateTimeFormatterStrict",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sPattern",
")",
"{",
"return",
"getDateTimeFormatter",
"(",
"sPattern",
",",
"ResolverStyle",
".",
"STRICT",
")",
";",
... | Get the cached DateTimeFormatter using STRICT resolving.
@param sPattern
The pattern to retrieve. May neither be <code>null</code> nor empty.
@return The compiled DateTimeFormatter and never <code>null</code> .
@throws IllegalArgumentException
If the pattern is invalid | [
"Get",
"the",
"cached",
"DateTimeFormatter",
"using",
"STRICT",
"resolving",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java#L76-L80 |
136,843 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java | DateTimeFormatterCache.getDateTimeFormatterSmart | @Nonnull
public static DateTimeFormatter getDateTimeFormatterSmart (@Nonnull @Nonempty final String sPattern)
{
return getDateTimeFormatter (sPattern, ResolverStyle.SMART);
} | java | @Nonnull
public static DateTimeFormatter getDateTimeFormatterSmart (@Nonnull @Nonempty final String sPattern)
{
return getDateTimeFormatter (sPattern, ResolverStyle.SMART);
} | [
"@",
"Nonnull",
"public",
"static",
"DateTimeFormatter",
"getDateTimeFormatterSmart",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sPattern",
")",
"{",
"return",
"getDateTimeFormatter",
"(",
"sPattern",
",",
"ResolverStyle",
".",
"SMART",
")",
";",
"}... | Get the cached DateTimeFormatter using SMART resolving.
@param sPattern
The pattern to retrieve. May neither be <code>null</code> nor empty.
@return The compiled DateTimeFormatter and never <code>null</code> .
@throws IllegalArgumentException
If the pattern is invalid | [
"Get",
"the",
"cached",
"DateTimeFormatter",
"using",
"SMART",
"resolving",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java#L91-L95 |
136,844 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java | DateTimeFormatterCache.getDateTimeFormatterLenient | @Nonnull
public static DateTimeFormatter getDateTimeFormatterLenient (@Nonnull @Nonempty final String sPattern)
{
return getDateTimeFormatter (sPattern, ResolverStyle.LENIENT);
} | java | @Nonnull
public static DateTimeFormatter getDateTimeFormatterLenient (@Nonnull @Nonempty final String sPattern)
{
return getDateTimeFormatter (sPattern, ResolverStyle.LENIENT);
} | [
"@",
"Nonnull",
"public",
"static",
"DateTimeFormatter",
"getDateTimeFormatterLenient",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sPattern",
")",
"{",
"return",
"getDateTimeFormatter",
"(",
"sPattern",
",",
"ResolverStyle",
".",
"LENIENT",
")",
";",
... | Get the cached DateTimeFormatter using LENIENT resolving.
@param sPattern
The pattern to retrieve. May neither be <code>null</code> nor empty.
@return The compiled DateTimeFormatter and never <code>null</code> .
@throws IllegalArgumentException
If the pattern is invalid | [
"Get",
"the",
"cached",
"DateTimeFormatter",
"using",
"LENIENT",
"resolving",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java#L106-L110 |
136,845 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java | DateTimeFormatterCache.getDateTimeFormatter | @Nonnull
public static DateTimeFormatter getDateTimeFormatter (@Nonnull @Nonempty final String sPattern,
@Nonnull final ResolverStyle eResolverStyle)
{
return getInstance ().getFromCache (new DateTimeFormatterPattern (sPattern, eResolverStyle));
} | java | @Nonnull
public static DateTimeFormatter getDateTimeFormatter (@Nonnull @Nonempty final String sPattern,
@Nonnull final ResolverStyle eResolverStyle)
{
return getInstance ().getFromCache (new DateTimeFormatterPattern (sPattern, eResolverStyle));
} | [
"@",
"Nonnull",
"public",
"static",
"DateTimeFormatter",
"getDateTimeFormatter",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sPattern",
",",
"@",
"Nonnull",
"final",
"ResolverStyle",
"eResolverStyle",
")",
"{",
"return",
"getInstance",
"(",
")",
".",... | Get the cached DateTimeFormatter using the provided resolver style.
@param sPattern
The pattern to retrieve. May neither be <code>null</code> nor empty.
@param eResolverStyle
The resolver style to be used. May not be <code>null</code>.
@return The compiled DateTimeFormatter and never <code>null</code>.
@throws IllegalArgumentException
If the pattern is invalid | [
"Get",
"the",
"cached",
"DateTimeFormatter",
"using",
"the",
"provided",
"resolver",
"style",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/datetime/DateTimeFormatterCache.java#L123-L128 |
136,846 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/regex/RegExCache.java | RegExCache.getPattern | @Nonnull
public static Pattern getPattern (@Nonnull @Nonempty @RegEx final String sRegEx)
{
return getInstance ().getFromCache (new RegExPattern (sRegEx));
} | java | @Nonnull
public static Pattern getPattern (@Nonnull @Nonempty @RegEx final String sRegEx)
{
return getInstance ().getFromCache (new RegExPattern (sRegEx));
} | [
"@",
"Nonnull",
"public",
"static",
"Pattern",
"getPattern",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"@",
"RegEx",
"final",
"String",
"sRegEx",
")",
"{",
"return",
"getInstance",
"(",
")",
".",
"getFromCache",
"(",
"new",
"RegExPattern",
"(",
"sRegEx",
")",
... | Get the cached regular expression pattern.
@param sRegEx
The regular expression to retrieve. May neither be <code>null</code>
nor empty.
@return The compiled regular expression pattern and never <code>null</code>
.
@throws IllegalArgumentException
If the passed regular expression has an illegal syntax | [
"Get",
"the",
"cached",
"regular",
"expression",
"pattern",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/regex/RegExCache.java#L79-L83 |
136,847 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/log/LogHelper.java | LogHelper.isEnabled | public static boolean isEnabled (@Nonnull final Class <?> aLoggingClass,
@Nonnull final IHasErrorLevel aErrorLevelProvider)
{
return isEnabled (LoggerFactory.getLogger (aLoggingClass), aErrorLevelProvider.getErrorLevel ());
} | java | public static boolean isEnabled (@Nonnull final Class <?> aLoggingClass,
@Nonnull final IHasErrorLevel aErrorLevelProvider)
{
return isEnabled (LoggerFactory.getLogger (aLoggingClass), aErrorLevelProvider.getErrorLevel ());
} | [
"public",
"static",
"boolean",
"isEnabled",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"?",
">",
"aLoggingClass",
",",
"@",
"Nonnull",
"final",
"IHasErrorLevel",
"aErrorLevelProvider",
")",
"{",
"return",
"isEnabled",
"(",
"LoggerFactory",
".",
"getLogger",
"("... | Check if logging is enabled for the passed class based on the error level
provider by the passed object
@param aLoggingClass
The class to determine the logger from. May not be <code>null</code>
.
@param aErrorLevelProvider
The error level provider. May not be <code>null</code>.
@return <code>true</code> if the respective log level is allowed,
<code>false</code> if not | [
"Check",
"if",
"logging",
"is",
"enabled",
"for",
"the",
"passed",
"class",
"based",
"on",
"the",
"error",
"level",
"provider",
"by",
"the",
"passed",
"object"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/log/LogHelper.java#L118-L122 |
136,848 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/log/LogHelper.java | LogHelper.isEnabled | public static boolean isEnabled (@Nonnull final Logger aLogger, @Nonnull final IHasErrorLevel aErrorLevelProvider)
{
return isEnabled (aLogger, aErrorLevelProvider.getErrorLevel ());
} | java | public static boolean isEnabled (@Nonnull final Logger aLogger, @Nonnull final IHasErrorLevel aErrorLevelProvider)
{
return isEnabled (aLogger, aErrorLevelProvider.getErrorLevel ());
} | [
"public",
"static",
"boolean",
"isEnabled",
"(",
"@",
"Nonnull",
"final",
"Logger",
"aLogger",
",",
"@",
"Nonnull",
"final",
"IHasErrorLevel",
"aErrorLevelProvider",
")",
"{",
"return",
"isEnabled",
"(",
"aLogger",
",",
"aErrorLevelProvider",
".",
"getErrorLevel",
... | Check if logging is enabled for the passed logger based on the error level
provider by the passed object
@param aLogger
The logger. May not be <code>null</code>.
@param aErrorLevelProvider
The error level provider. May not be <code>null</code>.
@return <code>true</code> if the respective log level is allowed,
<code>false</code> if not | [
"Check",
"if",
"logging",
"is",
"enabled",
"for",
"the",
"passed",
"logger",
"based",
"on",
"the",
"error",
"level",
"provider",
"by",
"the",
"passed",
"object"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/log/LogHelper.java#L135-L138 |
136,849 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/log/LogHelper.java | LogHelper.isEnabled | public static boolean isEnabled (@Nonnull final Class <?> aLoggingClass, @Nonnull final IErrorLevel aErrorLevel)
{
return isEnabled (LoggerFactory.getLogger (aLoggingClass), aErrorLevel);
} | java | public static boolean isEnabled (@Nonnull final Class <?> aLoggingClass, @Nonnull final IErrorLevel aErrorLevel)
{
return isEnabled (LoggerFactory.getLogger (aLoggingClass), aErrorLevel);
} | [
"public",
"static",
"boolean",
"isEnabled",
"(",
"@",
"Nonnull",
"final",
"Class",
"<",
"?",
">",
"aLoggingClass",
",",
"@",
"Nonnull",
"final",
"IErrorLevel",
"aErrorLevel",
")",
"{",
"return",
"isEnabled",
"(",
"LoggerFactory",
".",
"getLogger",
"(",
"aLoggi... | Check if logging is enabled for the passed class based on the error level
provided
@param aLoggingClass
The class to determine the logger from. May not be <code>null</code>
.
@param aErrorLevel
The error level. May not be <code>null</code>.
@return <code>true</code> if the respective log level is allowed,
<code>false</code> if not | [
"Check",
"if",
"logging",
"is",
"enabled",
"for",
"the",
"passed",
"class",
"based",
"on",
"the",
"error",
"level",
"provided"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/log/LogHelper.java#L152-L155 |
136,850 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/log/LogHelper.java | LogHelper.isEnabled | public static boolean isEnabled (@Nonnull final Logger aLogger, @Nonnull final IErrorLevel aErrorLevel)
{
return getFuncIsEnabled (aLogger, aErrorLevel).isEnabled ();
} | java | public static boolean isEnabled (@Nonnull final Logger aLogger, @Nonnull final IErrorLevel aErrorLevel)
{
return getFuncIsEnabled (aLogger, aErrorLevel).isEnabled ();
} | [
"public",
"static",
"boolean",
"isEnabled",
"(",
"@",
"Nonnull",
"final",
"Logger",
"aLogger",
",",
"@",
"Nonnull",
"final",
"IErrorLevel",
"aErrorLevel",
")",
"{",
"return",
"getFuncIsEnabled",
"(",
"aLogger",
",",
"aErrorLevel",
")",
".",
"isEnabled",
"(",
"... | Check if logging is enabled for the passed logger based on the error level
provided
@param aLogger
The logger. May not be <code>null</code>.
@param aErrorLevel
The error level. May not be <code>null</code>.
@return <code>true</code> if the respective log level is allowed,
<code>false</code> if not | [
"Check",
"if",
"logging",
"is",
"enabled",
"for",
"the",
"passed",
"logger",
"based",
"on",
"the",
"error",
"level",
"provided"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/log/LogHelper.java#L168-L171 |
136,851 | phax/ph-commons | ph-security/src/main/java/com/helger/security/keystore/LoadedKey.java | LoadedKey.getErrorText | @Nullable
public String getErrorText (@Nonnull final Locale aContentLocale)
{
return m_eError == null ? null : m_eError.getDisplayTextWithArgs (aContentLocale, (Object []) m_aErrorParams);
} | java | @Nullable
public String getErrorText (@Nonnull final Locale aContentLocale)
{
return m_eError == null ? null : m_eError.getDisplayTextWithArgs (aContentLocale, (Object []) m_aErrorParams);
} | [
"@",
"Nullable",
"public",
"String",
"getErrorText",
"(",
"@",
"Nonnull",
"final",
"Locale",
"aContentLocale",
")",
"{",
"return",
"m_eError",
"==",
"null",
"?",
"null",
":",
"m_eError",
".",
"getDisplayTextWithArgs",
"(",
"aContentLocale",
",",
"(",
"Object",
... | Get the error text
@param aContentLocale
The locale to use. May not be <code>null</code>.
@return <code>null</code> if no error occurred, the error text otherwise. | [
"Get",
"the",
"error",
"text"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-security/src/main/java/com/helger/security/keystore/LoadedKey.java#L94-L98 |
136,852 | phax/ph-commons | ph-wsclient/src/main/java/com/helger/wsclient/WSClientConfig.java | WSClientConfig.setCompressedRequest | @Nonnull
public final WSClientConfig setCompressedRequest (final boolean bCompress)
{
if (bCompress)
m_aHTTPHeaders.setHeader (CHttpHeader.CONTENT_ENCODING, "gzip");
else
m_aHTTPHeaders.removeHeaders (CHttpHeader.CONTENT_ENCODING);
return this;
} | java | @Nonnull
public final WSClientConfig setCompressedRequest (final boolean bCompress)
{
if (bCompress)
m_aHTTPHeaders.setHeader (CHttpHeader.CONTENT_ENCODING, "gzip");
else
m_aHTTPHeaders.removeHeaders (CHttpHeader.CONTENT_ENCODING);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"WSClientConfig",
"setCompressedRequest",
"(",
"final",
"boolean",
"bCompress",
")",
"{",
"if",
"(",
"bCompress",
")",
"m_aHTTPHeaders",
".",
"setHeader",
"(",
"CHttpHeader",
".",
"CONTENT_ENCODING",
",",
"\"gzip\"",
")",
";",
... | Forces this client to send compressed HTTP content. Disabled by default.
@param bCompress
<code>true</code> to enable, <code>false</code> to disable.
@return this for chaining | [
"Forces",
"this",
"client",
"to",
"send",
"compressed",
"HTTP",
"content",
".",
"Disabled",
"by",
"default",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-wsclient/src/main/java/com/helger/wsclient/WSClientConfig.java#L449-L457 |
136,853 | phax/ph-commons | ph-wsclient/src/main/java/com/helger/wsclient/WSClientConfig.java | WSClientConfig.setCompressedResponse | @Nonnull
public final WSClientConfig setCompressedResponse (final boolean bCompress)
{
if (bCompress)
m_aHTTPHeaders.setHeader (CHttpHeader.ACCEPT_ENCODING, "gzip");
else
m_aHTTPHeaders.removeHeaders (CHttpHeader.ACCEPT_ENCODING);
return this;
} | java | @Nonnull
public final WSClientConfig setCompressedResponse (final boolean bCompress)
{
if (bCompress)
m_aHTTPHeaders.setHeader (CHttpHeader.ACCEPT_ENCODING, "gzip");
else
m_aHTTPHeaders.removeHeaders (CHttpHeader.ACCEPT_ENCODING);
return this;
} | [
"@",
"Nonnull",
"public",
"final",
"WSClientConfig",
"setCompressedResponse",
"(",
"final",
"boolean",
"bCompress",
")",
"{",
"if",
"(",
"bCompress",
")",
"m_aHTTPHeaders",
".",
"setHeader",
"(",
"CHttpHeader",
".",
"ACCEPT_ENCODING",
",",
"\"gzip\"",
")",
";",
... | Add a hint that this client understands compressed HTTP content. Disabled
by default.
@param bCompress
<code>true</code> to enable, <code>false</code> to disable.
@return this for chaining | [
"Add",
"a",
"hint",
"that",
"this",
"client",
"understands",
"compressed",
"HTTP",
"content",
".",
"Disabled",
"by",
"default",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-wsclient/src/main/java/com/helger/wsclient/WSClientConfig.java#L467-L475 |
136,854 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/compare/CollatorHelper.java | CollatorHelper.getCollatorSpaceBeforeDot | @Nonnull
@ReturnsMutableCopy
public static Collator getCollatorSpaceBeforeDot (@Nullable final Locale aLocale)
{
// Ensure to not pass null locale in
final Locale aRealLocale = aLocale == null ? SystemHelper.getSystemLocale () : aLocale;
// Always create a clone!
return (Collator) s_aCache.getFromCache (aRealLocale).clone ();
} | java | @Nonnull
@ReturnsMutableCopy
public static Collator getCollatorSpaceBeforeDot (@Nullable final Locale aLocale)
{
// Ensure to not pass null locale in
final Locale aRealLocale = aLocale == null ? SystemHelper.getSystemLocale () : aLocale;
// Always create a clone!
return (Collator) s_aCache.getFromCache (aRealLocale).clone ();
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"Collator",
"getCollatorSpaceBeforeDot",
"(",
"@",
"Nullable",
"final",
"Locale",
"aLocale",
")",
"{",
"// Ensure to not pass null locale in",
"final",
"Locale",
"aRealLocale",
"=",
"aLocale",
"==",
"null",
... | Create a collator that is based on the standard collator but sorts spaces
before dots, because spaces are more important word separators than dots.
Another example is the correct sorting of things like "1.1 a" vs. "1.1.1 b"
. This is the default collator used for sorting by default!
@param aLocale
The locale for which the collator is to be retrieved. May be
<code>null</code> to indicate the usage of the default locale.
@return The created {@link RuleBasedCollator} and never <code>null</code>. | [
"Create",
"a",
"collator",
"that",
"is",
"based",
"on",
"the",
"standard",
"collator",
"but",
"sorts",
"spaces",
"before",
"dots",
"because",
"spaces",
"are",
"more",
"important",
"word",
"separators",
"than",
"dots",
".",
"Another",
"example",
"is",
"the",
... | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/compare/CollatorHelper.java#L119-L128 |
136,855 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/serialize/write/XMLMaskHelper.java | XMLMaskHelper.getAsCharArray | @Nonnull
@ReturnsMutableCopy
public static char [] getAsCharArray (@Nonnull final Set <Character> aChars)
{
ValueEnforcer.notNull (aChars, "Chars");
final char [] ret = new char [aChars.size ()];
int nIndex = 0;
for (final Character aChar : aChars)
ret[nIndex++] = aChar.charValue ();
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static char [] getAsCharArray (@Nonnull final Set <Character> aChars)
{
ValueEnforcer.notNull (aChars, "Chars");
final char [] ret = new char [aChars.size ()];
int nIndex = 0;
for (final Character aChar : aChars)
ret[nIndex++] = aChar.charValue ();
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"char",
"[",
"]",
"getAsCharArray",
"(",
"@",
"Nonnull",
"final",
"Set",
"<",
"Character",
">",
"aChars",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aChars",
",",
"\"Chars\"",
")",
";",
"... | Convert the passed set to an array
@param aChars
Character set to use. May not be <code>null</code>.
@return A new array with the same length as the source set. | [
"Convert",
"the",
"passed",
"set",
"to",
"an",
"array"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/serialize/write/XMLMaskHelper.java#L565-L576 |
136,856 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/datetime/PDTWebDateHelper.java | PDTWebDateHelper.parseOffsetDateTimeUsingMask | @Nullable
public static OffsetDateTime parseOffsetDateTimeUsingMask (@Nonnull final PDTMask <?> [] aMasks,
@Nonnull @Nonempty final String sDate)
{
for (final PDTMask <?> aMask : aMasks)
{
final DateTimeFormatter aDTF = PDTFormatter.getForPattern (aMask.getPattern (), LOCALE_TO_USE);
try
{
final Temporal ret = aDTF.parse (sDate, aMask.getQuery ());
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Parsed '" + sDate + "' with '" + aMask.getPattern () + "' to " + ret.getClass ().getName ());
return TypeConverter.convert (ret, OffsetDateTime.class);
}
catch (final DateTimeParseException ex)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Failed to parse '" + sDate + "' with '" + aMask.getPattern () + "': " + ex.getMessage ());
}
}
return null;
} | java | @Nullable
public static OffsetDateTime parseOffsetDateTimeUsingMask (@Nonnull final PDTMask <?> [] aMasks,
@Nonnull @Nonempty final String sDate)
{
for (final PDTMask <?> aMask : aMasks)
{
final DateTimeFormatter aDTF = PDTFormatter.getForPattern (aMask.getPattern (), LOCALE_TO_USE);
try
{
final Temporal ret = aDTF.parse (sDate, aMask.getQuery ());
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Parsed '" + sDate + "' with '" + aMask.getPattern () + "' to " + ret.getClass ().getName ());
return TypeConverter.convert (ret, OffsetDateTime.class);
}
catch (final DateTimeParseException ex)
{
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Failed to parse '" + sDate + "' with '" + aMask.getPattern () + "': " + ex.getMessage ());
}
}
return null;
} | [
"@",
"Nullable",
"public",
"static",
"OffsetDateTime",
"parseOffsetDateTimeUsingMask",
"(",
"@",
"Nonnull",
"final",
"PDTMask",
"<",
"?",
">",
"[",
"]",
"aMasks",
",",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sDate",
")",
"{",
"for",
"(",
"final"... | Parses a Date out of a string using an array of masks. It uses the masks in
order until one of them succeeds or all fail.
@param aMasks
array of masks to use for parsing the string
@param sDate
string to parse for a date.
@return the Date represented by the given string using one of the given
masks. It returns <b>null</b> if it was not possible to parse the
the string with any of the masks. | [
"Parses",
"a",
"Date",
"out",
"of",
"a",
"string",
"using",
"an",
"array",
"of",
"masks",
".",
"It",
"uses",
"the",
"masks",
"in",
"order",
"until",
"one",
"of",
"them",
"succeeds",
"or",
"all",
"fail",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/datetime/PDTWebDateHelper.java#L167-L188 |
136,857 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/datetime/PDTWebDateHelper.java | PDTWebDateHelper.extractDateTimeZone | @Nonnull
public static WithZoneId extractDateTimeZone (@Nonnull final String sDate)
{
ValueEnforcer.notNull (sDate, "Date");
final int nDateLen = sDate.length ();
for (final PDTZoneID aSupp : PDTZoneID.getDefaultZoneIDs ())
{
final String sDTZ = aSupp.getZoneIDString ();
if (sDate.endsWith (" " + sDTZ))
return new WithZoneId (sDate.substring (0, nDateLen - (1 + sDTZ.length ())), aSupp.getZoneID ());
if (sDate.endsWith (sDTZ))
return new WithZoneId (sDate.substring (0, nDateLen - sDTZ.length ()), aSupp.getZoneID ());
}
return new WithZoneId (sDate, null);
} | java | @Nonnull
public static WithZoneId extractDateTimeZone (@Nonnull final String sDate)
{
ValueEnforcer.notNull (sDate, "Date");
final int nDateLen = sDate.length ();
for (final PDTZoneID aSupp : PDTZoneID.getDefaultZoneIDs ())
{
final String sDTZ = aSupp.getZoneIDString ();
if (sDate.endsWith (" " + sDTZ))
return new WithZoneId (sDate.substring (0, nDateLen - (1 + sDTZ.length ())), aSupp.getZoneID ());
if (sDate.endsWith (sDTZ))
return new WithZoneId (sDate.substring (0, nDateLen - sDTZ.length ()), aSupp.getZoneID ());
}
return new WithZoneId (sDate, null);
} | [
"@",
"Nonnull",
"public",
"static",
"WithZoneId",
"extractDateTimeZone",
"(",
"@",
"Nonnull",
"final",
"String",
"sDate",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"sDate",
",",
"\"Date\"",
")",
";",
"final",
"int",
"nDateLen",
"=",
"sDate",
".",
"leng... | Extract the time zone from the passed string. UTC and GMT are supported.
@param sDate
The date string.
@return A non-<code>null</code> {@link WithZoneId}, where the remaining
string to be parsed (never <code>null</code>) and and the extracted
time zone (may be <code>null</code>) are contained. | [
"Extract",
"the",
"time",
"zone",
"from",
"the",
"passed",
"string",
".",
"UTC",
"and",
"GMT",
"are",
"supported",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/datetime/PDTWebDateHelper.java#L239-L254 |
136,858 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/datetime/PDTWebDateHelper.java | PDTWebDateHelper.getAsStringW3C | @Nullable
public static String getAsStringW3C (@Nullable final LocalDateTime aDateTime)
{
if (aDateTime == null)
return null;
return getAsStringW3C (aDateTime.atOffset (ZoneOffset.UTC));
} | java | @Nullable
public static String getAsStringW3C (@Nullable final LocalDateTime aDateTime)
{
if (aDateTime == null)
return null;
return getAsStringW3C (aDateTime.atOffset (ZoneOffset.UTC));
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getAsStringW3C",
"(",
"@",
"Nullable",
"final",
"LocalDateTime",
"aDateTime",
")",
"{",
"if",
"(",
"aDateTime",
"==",
"null",
")",
"return",
"null",
";",
"return",
"getAsStringW3C",
"(",
"aDateTime",
".",
"atOffs... | create a W3C Date Time representation of a date.
@param aDateTime
Date to print. May not be <code>null</code>.
@return the W3C Date Time represented by the given Date. | [
"create",
"a",
"W3C",
"Date",
"Time",
"representation",
"of",
"a",
"date",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/datetime/PDTWebDateHelper.java#L446-L452 |
136,859 | phax/ph-commons | ph-dao/src/main/java/com/helger/dao/wal/WALListener.java | WALListener.registerForLaterWriting | public void registerForLaterWriting (@Nonnull final AbstractWALDAO <?> aDAO,
@Nonnull final String sWALFilename,
@Nonnull final TimeValue aWaitingWime)
{
// In case many DAOs of the same class exist, the filename is also added
final String sKey = aDAO.getClass ().getName () + "::" + sWALFilename;
// Check if the passed DAO is already scheduled for writing
final boolean bDoScheduleForWriting = m_aRWLock.writeLocked ( () -> m_aWaitingDAOs.add (sKey));
if (bDoScheduleForWriting)
{
// We need to schedule it now
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Now scheduling writing for DAO " + sKey);
// What should be executed upon writing
final Runnable r = () -> {
// Use DAO lock!
aDAO.internalWriteLocked ( () -> {
// Main DAO writing
aDAO._writeToFileAndResetPendingChanges ("ScheduledWriter.run");
// Delete the WAL file
aDAO._deleteWALFileAfterProcessing (sWALFilename);
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Finished scheduled writing for DAO " + sKey);
});
// Remove from the internal set so that another job will be
// scheduled for the same DAO
// Do this after the writing to the file
m_aRWLock.writeLocked ( () -> {
// Remove from the overall set as well as from the scheduled items
m_aWaitingDAOs.remove (sKey);
m_aScheduledItems.remove (sKey);
});
};
// Schedule exactly once in the specified waiting time
final ScheduledFuture <?> aFuture = m_aES.schedule (r, aWaitingWime.getDuration (), aWaitingWime.getTimeUnit ());
// Remember the scheduled item and the runnable so that the task can
// be rescheduled upon shutdown.
m_aRWLock.writeLocked ( () -> m_aScheduledItems.put (sKey, new WALItem (aFuture, r)));
}
// else the writing of the passed DAO is already scheduled and no further
// action is necessary
} | java | public void registerForLaterWriting (@Nonnull final AbstractWALDAO <?> aDAO,
@Nonnull final String sWALFilename,
@Nonnull final TimeValue aWaitingWime)
{
// In case many DAOs of the same class exist, the filename is also added
final String sKey = aDAO.getClass ().getName () + "::" + sWALFilename;
// Check if the passed DAO is already scheduled for writing
final boolean bDoScheduleForWriting = m_aRWLock.writeLocked ( () -> m_aWaitingDAOs.add (sKey));
if (bDoScheduleForWriting)
{
// We need to schedule it now
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Now scheduling writing for DAO " + sKey);
// What should be executed upon writing
final Runnable r = () -> {
// Use DAO lock!
aDAO.internalWriteLocked ( () -> {
// Main DAO writing
aDAO._writeToFileAndResetPendingChanges ("ScheduledWriter.run");
// Delete the WAL file
aDAO._deleteWALFileAfterProcessing (sWALFilename);
if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Finished scheduled writing for DAO " + sKey);
});
// Remove from the internal set so that another job will be
// scheduled for the same DAO
// Do this after the writing to the file
m_aRWLock.writeLocked ( () -> {
// Remove from the overall set as well as from the scheduled items
m_aWaitingDAOs.remove (sKey);
m_aScheduledItems.remove (sKey);
});
};
// Schedule exactly once in the specified waiting time
final ScheduledFuture <?> aFuture = m_aES.schedule (r, aWaitingWime.getDuration (), aWaitingWime.getTimeUnit ());
// Remember the scheduled item and the runnable so that the task can
// be rescheduled upon shutdown.
m_aRWLock.writeLocked ( () -> m_aScheduledItems.put (sKey, new WALItem (aFuture, r)));
}
// else the writing of the passed DAO is already scheduled and no further
// action is necessary
} | [
"public",
"void",
"registerForLaterWriting",
"(",
"@",
"Nonnull",
"final",
"AbstractWALDAO",
"<",
"?",
">",
"aDAO",
",",
"@",
"Nonnull",
"final",
"String",
"sWALFilename",
",",
"@",
"Nonnull",
"final",
"TimeValue",
"aWaitingWime",
")",
"{",
"// In case many DAOs o... | This is the main method for registration of later writing.
@param aDAO
The DAO to be written
@param sWALFilename
The filename of the WAL file for later deletion (in case the
filename changes over time).
@param aWaitingWime
The time to wait, until the file is physically written. May not be
<code>null</code>. | [
"This",
"is",
"the",
"main",
"method",
"for",
"registration",
"of",
"later",
"writing",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-dao/src/main/java/com/helger/dao/wal/WALListener.java#L128-L176 |
136,860 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/file/FileOperations.java | FileOperations.createDirRecursive | @Nonnull
public static FileIOError createDirRecursive (@Nonnull final File aDir)
{
ValueEnforcer.notNull (aDir, "Directory");
// Does the directory already exist?
if (aDir.exists ())
return EFileIOErrorCode.TARGET_ALREADY_EXISTS.getAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, aDir);
// Is the parent directory writable?
final File aParentDir = aDir.getParentFile ();
if (aParentDir != null && aParentDir.exists () && !aParentDir.canWrite ())
return EFileIOErrorCode.SOURCE_PARENT_NOT_WRITABLE.getAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, aDir);
try
{
final EFileIOErrorCode eError = aDir.mkdirs () ? EFileIOErrorCode.NO_ERROR : EFileIOErrorCode.OPERATION_FAILED;
return eError.getAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, aDir);
}
catch (final SecurityException ex)
{
return EFileIOErrorCode.getSecurityAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, ex);
}
} | java | @Nonnull
public static FileIOError createDirRecursive (@Nonnull final File aDir)
{
ValueEnforcer.notNull (aDir, "Directory");
// Does the directory already exist?
if (aDir.exists ())
return EFileIOErrorCode.TARGET_ALREADY_EXISTS.getAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, aDir);
// Is the parent directory writable?
final File aParentDir = aDir.getParentFile ();
if (aParentDir != null && aParentDir.exists () && !aParentDir.canWrite ())
return EFileIOErrorCode.SOURCE_PARENT_NOT_WRITABLE.getAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, aDir);
try
{
final EFileIOErrorCode eError = aDir.mkdirs () ? EFileIOErrorCode.NO_ERROR : EFileIOErrorCode.OPERATION_FAILED;
return eError.getAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, aDir);
}
catch (final SecurityException ex)
{
return EFileIOErrorCode.getSecurityAsIOError (EFileIOOperation.CREATE_DIR_RECURSIVE, ex);
}
} | [
"@",
"Nonnull",
"public",
"static",
"FileIOError",
"createDirRecursive",
"(",
"@",
"Nonnull",
"final",
"File",
"aDir",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aDir",
",",
"\"Directory\"",
")",
";",
"// Does the directory already exist?",
"if",
"(",
"aDir"... | Create a new directory. The parent directories are created if they are
missing.
@param aDir
The directory to be created. May not be <code>null</code>.
@return A non-<code>null</code> error code. | [
"Create",
"a",
"new",
"directory",
".",
"The",
"parent",
"directories",
"are",
"created",
"if",
"they",
"are",
"missing",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/file/FileOperations.java#L135-L158 |
136,861 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/text/util/TextHelper.java | TextHelper.getCopyWithLocales | @Nonnull
@ReturnsMutableCopy
public static MultilingualText getCopyWithLocales (@Nonnull final IMultilingualText aMLT,
@Nonnull final Collection <Locale> aContentLocales)
{
final MultilingualText ret = new MultilingualText ();
for (final Locale aConrentLocale : aContentLocales)
if (aMLT.texts ().containsKey (aConrentLocale))
ret.setText (aConrentLocale, aMLT.getText (aConrentLocale));
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static MultilingualText getCopyWithLocales (@Nonnull final IMultilingualText aMLT,
@Nonnull final Collection <Locale> aContentLocales)
{
final MultilingualText ret = new MultilingualText ();
for (final Locale aConrentLocale : aContentLocales)
if (aMLT.texts ().containsKey (aConrentLocale))
ret.setText (aConrentLocale, aMLT.getText (aConrentLocale));
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"MultilingualText",
"getCopyWithLocales",
"(",
"@",
"Nonnull",
"final",
"IMultilingualText",
"aMLT",
",",
"@",
"Nonnull",
"final",
"Collection",
"<",
"Locale",
">",
"aContentLocales",
")",
"{",
"final",
... | Get a copy of this object with the specified locales. The default locale is
copied.
@param aMLT
The initial multilingual text. May not be <code>null</code>.
@param aContentLocales
The list of locales of which the strings are desired. May not be
<code>null</code>.
@return The object containing only the texts of the given locales. Never
<code>null</code>. | [
"Get",
"a",
"copy",
"of",
"this",
"object",
"with",
"the",
"specified",
"locales",
".",
"The",
"default",
"locale",
"is",
"copied",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/text/util/TextHelper.java#L137-L147 |
136,862 | phax/ph-commons | ph-dao/src/main/java/com/helger/dao/wal/AbstractWALDAO.java | AbstractWALDAO.onRecoveryErrorConvertToNative | @OverrideOnDemand
protected void onRecoveryErrorConvertToNative (@Nonnull final EDAOActionType eActionType,
@Nonnegative final int i,
@Nonnull final String sElement)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Action [" +
eActionType +
"][" +
i +
"]: failed to convert the following element to native:\n" +
sElement);
} | java | @OverrideOnDemand
protected void onRecoveryErrorConvertToNative (@Nonnull final EDAOActionType eActionType,
@Nonnegative final int i,
@Nonnull final String sElement)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Action [" +
eActionType +
"][" +
i +
"]: failed to convert the following element to native:\n" +
sElement);
} | [
"@",
"OverrideOnDemand",
"protected",
"void",
"onRecoveryErrorConvertToNative",
"(",
"@",
"Nonnull",
"final",
"EDAOActionType",
"eActionType",
",",
"@",
"Nonnegative",
"final",
"int",
"i",
",",
"@",
"Nonnull",
"final",
"String",
"sElement",
")",
"{",
"if",
"(",
... | This method is called, when the conversion from the read XML string to the
native type failed. By default an error message is logged and processing
continues.
@param eActionType
The action type to recover. May not be <code>null</code>
@param i
The index of the element to recover. Always ≥ 0.
@param sElement
The string read from the WAL file that could not be recovered.
@since 9.1.6 | [
"This",
"method",
"is",
"called",
"when",
"the",
"conversion",
"from",
"the",
"read",
"XML",
"string",
"to",
"the",
"native",
"type",
"failed",
".",
"By",
"default",
"an",
"error",
"message",
"is",
"logged",
"and",
"processing",
"continues",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-dao/src/main/java/com/helger/dao/wal/AbstractWALDAO.java#L384-L396 |
136,863 | phax/ph-commons | ph-dao/src/main/java/com/helger/dao/wal/AbstractWALDAO.java | AbstractWALDAO._deleteWALFileAfterProcessing | final void _deleteWALFileAfterProcessing (@Nonnull @Nonempty final String sWALFilename)
{
ValueEnforcer.notEmpty (sWALFilename, "WALFilename");
final File aWALFile = m_aIO.getFile (sWALFilename);
if (FileOperationManager.INSTANCE.deleteFile (aWALFile).isFailure ())
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Failed to delete WAL file '" + aWALFile.getAbsolutePath () + "'");
}
else
{
if (!isSilentMode ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Deleted successfully imported WAL file '" + aWALFile.getAbsolutePath () + "'");
}
} | java | final void _deleteWALFileAfterProcessing (@Nonnull @Nonempty final String sWALFilename)
{
ValueEnforcer.notEmpty (sWALFilename, "WALFilename");
final File aWALFile = m_aIO.getFile (sWALFilename);
if (FileOperationManager.INSTANCE.deleteFile (aWALFile).isFailure ())
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Failed to delete WAL file '" + aWALFile.getAbsolutePath () + "'");
}
else
{
if (!isSilentMode ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Deleted successfully imported WAL file '" + aWALFile.getAbsolutePath () + "'");
}
} | [
"final",
"void",
"_deleteWALFileAfterProcessing",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sWALFilename",
")",
"{",
"ValueEnforcer",
".",
"notEmpty",
"(",
"sWALFilename",
",",
"\"WALFilename\"",
")",
";",
"final",
"File",
"aWALFile",
"=",
"m_aIO",... | This method may only be triggered with valid WAL filenames, as the passed
file is deleted! | [
"This",
"method",
"may",
"only",
"be",
"triggered",
"with",
"valid",
"WAL",
"filenames",
"as",
"the",
"passed",
"file",
"is",
"deleted!"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-dao/src/main/java/com/helger/dao/wal/AbstractWALDAO.java#L997-L1012 |
136,864 | phax/ph-commons | ph-dao/src/main/java/com/helger/dao/simple/AbstractSimpleDAO.java | AbstractSimpleDAO.initialRead | @MustBeLocked (ELockType.WRITE)
protected final void initialRead () throws DAOException
{
File aFile = null;
final String sFilename = m_aFilenameProvider.get ();
if (sFilename == null)
{
// required for testing
if (!isSilentMode ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("This DAO of class " + getClass ().getName () + " will not be able to read from a file");
// do not return - run initialization anyway
}
else
{
// Check consistency
aFile = getSafeFile (sFilename, EMode.READ);
}
final File aFinalFile = aFile;
m_aRWLock.writeLockedThrowing ( () -> {
final boolean bIsInitialization = aFinalFile == null || !aFinalFile.exists ();
try
{
ESuccess eWriteSuccess = ESuccess.SUCCESS;
if (bIsInitialization)
{
// initial setup for non-existing file
if (isDebugLogging ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Trying to initialize DAO XML file '" + aFinalFile + "'");
beginWithoutAutoSave ();
try
{
m_aStatsCounterInitTotal.increment ();
final StopWatch aSW = StopWatch.createdStarted ();
if (onInit ().isChanged ())
if (aFinalFile != null)
eWriteSuccess = _writeToFile ();
m_aStatsCounterInitTimer.addTime (aSW.stopAndGetMillis ());
m_aStatsCounterInitSuccess.increment ();
m_nInitCount++;
m_aLastInitDT = PDTFactory.getCurrentLocalDateTime ();
}
finally
{
endWithoutAutoSave ();
// reset any pending changes, because the initialization should
// be read-only. If the implementing class changed something,
// the return value of onInit() is what counts
internalSetPendingChanges (false);
}
}
else
{
// Read existing file
if (isDebugLogging ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Trying to read DAO XML file '" + aFinalFile + "'");
m_aStatsCounterReadTotal.increment ();
final IMicroDocument aDoc = MicroReader.readMicroXML (aFinalFile);
if (aDoc == null)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Failed to read XML document from file '" + aFinalFile + "'");
}
else
{
// Valid XML - start interpreting
beginWithoutAutoSave ();
try
{
final StopWatch aSW = StopWatch.createdStarted ();
if (onRead (aDoc).isChanged ())
eWriteSuccess = _writeToFile ();
m_aStatsCounterReadTimer.addTime (aSW.stopAndGetMillis ());
m_aStatsCounterReadSuccess.increment ();
m_nReadCount++;
m_aLastReadDT = PDTFactory.getCurrentLocalDateTime ();
}
finally
{
endWithoutAutoSave ();
// reset any pending changes, because the initialization should
// be read-only. If the implementing class changed something,
// the return value of onRead() is what counts
internalSetPendingChanges (false);
}
}
}
// Check if writing was successful on any of the 2 branches
if (eWriteSuccess.isSuccess ())
internalSetPendingChanges (false);
else
{
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("File '" + aFinalFile + "' has pending changes after initialRead!");
}
}
catch (final Exception ex)
{
triggerExceptionHandlersRead (ex, bIsInitialization, aFinalFile);
throw new DAOException ("Error " +
(bIsInitialization ? "initializing" : "reading") +
" the file '" +
aFinalFile +
"'",
ex);
}
});
} | java | @MustBeLocked (ELockType.WRITE)
protected final void initialRead () throws DAOException
{
File aFile = null;
final String sFilename = m_aFilenameProvider.get ();
if (sFilename == null)
{
// required for testing
if (!isSilentMode ())
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("This DAO of class " + getClass ().getName () + " will not be able to read from a file");
// do not return - run initialization anyway
}
else
{
// Check consistency
aFile = getSafeFile (sFilename, EMode.READ);
}
final File aFinalFile = aFile;
m_aRWLock.writeLockedThrowing ( () -> {
final boolean bIsInitialization = aFinalFile == null || !aFinalFile.exists ();
try
{
ESuccess eWriteSuccess = ESuccess.SUCCESS;
if (bIsInitialization)
{
// initial setup for non-existing file
if (isDebugLogging ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Trying to initialize DAO XML file '" + aFinalFile + "'");
beginWithoutAutoSave ();
try
{
m_aStatsCounterInitTotal.increment ();
final StopWatch aSW = StopWatch.createdStarted ();
if (onInit ().isChanged ())
if (aFinalFile != null)
eWriteSuccess = _writeToFile ();
m_aStatsCounterInitTimer.addTime (aSW.stopAndGetMillis ());
m_aStatsCounterInitSuccess.increment ();
m_nInitCount++;
m_aLastInitDT = PDTFactory.getCurrentLocalDateTime ();
}
finally
{
endWithoutAutoSave ();
// reset any pending changes, because the initialization should
// be read-only. If the implementing class changed something,
// the return value of onInit() is what counts
internalSetPendingChanges (false);
}
}
else
{
// Read existing file
if (isDebugLogging ())
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Trying to read DAO XML file '" + aFinalFile + "'");
m_aStatsCounterReadTotal.increment ();
final IMicroDocument aDoc = MicroReader.readMicroXML (aFinalFile);
if (aDoc == null)
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("Failed to read XML document from file '" + aFinalFile + "'");
}
else
{
// Valid XML - start interpreting
beginWithoutAutoSave ();
try
{
final StopWatch aSW = StopWatch.createdStarted ();
if (onRead (aDoc).isChanged ())
eWriteSuccess = _writeToFile ();
m_aStatsCounterReadTimer.addTime (aSW.stopAndGetMillis ());
m_aStatsCounterReadSuccess.increment ();
m_nReadCount++;
m_aLastReadDT = PDTFactory.getCurrentLocalDateTime ();
}
finally
{
endWithoutAutoSave ();
// reset any pending changes, because the initialization should
// be read-only. If the implementing class changed something,
// the return value of onRead() is what counts
internalSetPendingChanges (false);
}
}
}
// Check if writing was successful on any of the 2 branches
if (eWriteSuccess.isSuccess ())
internalSetPendingChanges (false);
else
{
if (LOGGER.isWarnEnabled ())
LOGGER.warn ("File '" + aFinalFile + "' has pending changes after initialRead!");
}
}
catch (final Exception ex)
{
triggerExceptionHandlersRead (ex, bIsInitialization, aFinalFile);
throw new DAOException ("Error " +
(bIsInitialization ? "initializing" : "reading") +
" the file '" +
aFinalFile +
"'",
ex);
}
});
} | [
"@",
"MustBeLocked",
"(",
"ELockType",
".",
"WRITE",
")",
"protected",
"final",
"void",
"initialRead",
"(",
")",
"throws",
"DAOException",
"{",
"File",
"aFile",
"=",
"null",
";",
"final",
"String",
"sFilename",
"=",
"m_aFilenameProvider",
".",
"get",
"(",
")... | Call this method inside the constructor to read the file contents directly.
This method is write locked!
@throws DAOException
in case initialization or reading failed! | [
"Call",
"this",
"method",
"inside",
"the",
"constructor",
"to",
"read",
"the",
"file",
"contents",
"directly",
".",
"This",
"method",
"is",
"write",
"locked!"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-dao/src/main/java/com/helger/dao/simple/AbstractSimpleDAO.java#L250-L368 |
136,865 | phax/ph-commons | ph-dao/src/main/java/com/helger/dao/simple/AbstractSimpleDAO.java | AbstractSimpleDAO.writeToFileOnPendingChanges | public final void writeToFileOnPendingChanges ()
{
if (hasPendingChanges ())
{
m_aRWLock.writeLocked ( () -> {
// Write to file
if (_writeToFile ().isSuccess ())
internalSetPendingChanges (false);
else
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("The DAO of class " +
getClass ().getName () +
" still has pending changes after writeToFileOnPendingChanges!");
}
});
}
} | java | public final void writeToFileOnPendingChanges ()
{
if (hasPendingChanges ())
{
m_aRWLock.writeLocked ( () -> {
// Write to file
if (_writeToFile ().isSuccess ())
internalSetPendingChanges (false);
else
{
if (LOGGER.isErrorEnabled ())
LOGGER.error ("The DAO of class " +
getClass ().getName () +
" still has pending changes after writeToFileOnPendingChanges!");
}
});
}
} | [
"public",
"final",
"void",
"writeToFileOnPendingChanges",
"(",
")",
"{",
"if",
"(",
"hasPendingChanges",
"(",
")",
")",
"{",
"m_aRWLock",
".",
"writeLocked",
"(",
"(",
")",
"->",
"{",
"// Write to file",
"if",
"(",
"_writeToFile",
"(",
")",
".",
"isSuccess",... | In case there are pending changes write them to the file. This method is
write locked! | [
"In",
"case",
"there",
"are",
"pending",
"changes",
"write",
"them",
"to",
"the",
"file",
".",
"This",
"method",
"is",
"write",
"locked!"
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-dao/src/main/java/com/helger/dao/simple/AbstractSimpleDAO.java#L599-L616 |
136,866 | phax/ph-commons | ph-xml/src/main/java/com/helger/xml/microdom/util/XMLListHandler.java | XMLListHandler.writeList | @Nonnull
public static ESuccess writeList (@Nonnull final Collection <String> aCollection,
@Nonnull @WillClose final OutputStream aOS)
{
ValueEnforcer.notNull (aCollection, "Collection");
ValueEnforcer.notNull (aOS, "OutputStream");
try
{
final IMicroDocument aDoc = createListDocument (aCollection);
return MicroWriter.writeToStream (aDoc, aOS, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
finally
{
StreamHelper.close (aOS);
}
} | java | @Nonnull
public static ESuccess writeList (@Nonnull final Collection <String> aCollection,
@Nonnull @WillClose final OutputStream aOS)
{
ValueEnforcer.notNull (aCollection, "Collection");
ValueEnforcer.notNull (aOS, "OutputStream");
try
{
final IMicroDocument aDoc = createListDocument (aCollection);
return MicroWriter.writeToStream (aDoc, aOS, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
finally
{
StreamHelper.close (aOS);
}
} | [
"@",
"Nonnull",
"public",
"static",
"ESuccess",
"writeList",
"(",
"@",
"Nonnull",
"final",
"Collection",
"<",
"String",
">",
"aCollection",
",",
"@",
"Nonnull",
"@",
"WillClose",
"final",
"OutputStream",
"aOS",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
... | Write the passed collection to the passed output stream using the
predefined XML layout.
@param aCollection
The map to be written. May not be <code>null</code>.
@param aOS
The output stream to write to. The stream is closed independent of
success or failure. May not be <code>null</code>.
@return {@link ESuccess#SUCCESS} when everything went well,
{@link ESuccess#FAILURE} otherwise. | [
"Write",
"the",
"passed",
"collection",
"to",
"the",
"passed",
"output",
"stream",
"using",
"the",
"predefined",
"XML",
"layout",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-xml/src/main/java/com/helger/xml/microdom/util/XMLListHandler.java#L224-L240 |
136,867 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/lang/ByteBufferHelper.java | ByteBufferHelper.transfer | @Nonnegative
public static int transfer (@Nonnull final ByteBuffer aSrcBuffer,
@Nonnull final ByteBuffer aDstBuffer,
final boolean bNeedsFlip)
{
ValueEnforcer.notNull (aSrcBuffer, "SourceBuffer");
ValueEnforcer.notNull (aDstBuffer, "DestinationBuffer");
int nRead = 0;
if (bNeedsFlip)
{
if (aSrcBuffer.position () > 0)
{
aSrcBuffer.flip ();
nRead = _doTransfer (aSrcBuffer, aDstBuffer);
if (aSrcBuffer.hasRemaining ())
aSrcBuffer.compact ();
else
aSrcBuffer.clear ();
}
}
else
{
if (aSrcBuffer.hasRemaining ())
nRead = _doTransfer (aSrcBuffer, aDstBuffer);
}
return nRead;
} | java | @Nonnegative
public static int transfer (@Nonnull final ByteBuffer aSrcBuffer,
@Nonnull final ByteBuffer aDstBuffer,
final boolean bNeedsFlip)
{
ValueEnforcer.notNull (aSrcBuffer, "SourceBuffer");
ValueEnforcer.notNull (aDstBuffer, "DestinationBuffer");
int nRead = 0;
if (bNeedsFlip)
{
if (aSrcBuffer.position () > 0)
{
aSrcBuffer.flip ();
nRead = _doTransfer (aSrcBuffer, aDstBuffer);
if (aSrcBuffer.hasRemaining ())
aSrcBuffer.compact ();
else
aSrcBuffer.clear ();
}
}
else
{
if (aSrcBuffer.hasRemaining ())
nRead = _doTransfer (aSrcBuffer, aDstBuffer);
}
return nRead;
} | [
"@",
"Nonnegative",
"public",
"static",
"int",
"transfer",
"(",
"@",
"Nonnull",
"final",
"ByteBuffer",
"aSrcBuffer",
",",
"@",
"Nonnull",
"final",
"ByteBuffer",
"aDstBuffer",
",",
"final",
"boolean",
"bNeedsFlip",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
... | Transfer as much as possible from source to dest buffer.
@param aSrcBuffer
Source buffer. May not be <code>null</code>.
@param aDstBuffer
Destination buffer. May not be <code>null</code>.
@param bNeedsFlip
whether or not to flip src
@return The amount of data transferred. Always ≥ 0. | [
"Transfer",
"as",
"much",
"as",
"possible",
"from",
"source",
"to",
"dest",
"buffer",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/lang/ByteBufferHelper.java#L73-L100 |
136,868 | phax/ph-commons | ph-security/src/main/java/com/helger/security/authentication/result/AuthIdentificationResult.java | AuthIdentificationResult.createSuccess | @Nonnull
public static AuthIdentificationResult createSuccess (@Nonnull final IAuthToken aAuthToken)
{
ValueEnforcer.notNull (aAuthToken, "AuthToken");
return new AuthIdentificationResult (aAuthToken, null);
} | java | @Nonnull
public static AuthIdentificationResult createSuccess (@Nonnull final IAuthToken aAuthToken)
{
ValueEnforcer.notNull (aAuthToken, "AuthToken");
return new AuthIdentificationResult (aAuthToken, null);
} | [
"@",
"Nonnull",
"public",
"static",
"AuthIdentificationResult",
"createSuccess",
"(",
"@",
"Nonnull",
"final",
"IAuthToken",
"aAuthToken",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aAuthToken",
",",
"\"AuthToken\"",
")",
";",
"return",
"new",
"AuthIdentificat... | Factory method for success authentication.
@param aAuthToken
The auth token. May not be <code>null</code>.
@return Never <code>null</code>. | [
"Factory",
"method",
"for",
"success",
"authentication",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-security/src/main/java/com/helger/security/authentication/result/AuthIdentificationResult.java#L106-L111 |
136,869 | phax/ph-commons | ph-security/src/main/java/com/helger/security/authentication/result/AuthIdentificationResult.java | AuthIdentificationResult.createFailure | @Nonnull
public static AuthIdentificationResult createFailure (@Nonnull final ICredentialValidationResult aCredentialValidationFailure)
{
ValueEnforcer.notNull (aCredentialValidationFailure, "CredentialValidationFailure");
return new AuthIdentificationResult (null, aCredentialValidationFailure);
} | java | @Nonnull
public static AuthIdentificationResult createFailure (@Nonnull final ICredentialValidationResult aCredentialValidationFailure)
{
ValueEnforcer.notNull (aCredentialValidationFailure, "CredentialValidationFailure");
return new AuthIdentificationResult (null, aCredentialValidationFailure);
} | [
"@",
"Nonnull",
"public",
"static",
"AuthIdentificationResult",
"createFailure",
"(",
"@",
"Nonnull",
"final",
"ICredentialValidationResult",
"aCredentialValidationFailure",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"aCredentialValidationFailure",
",",
"\"CredentialVali... | Factory method for error in authentication.
@param aCredentialValidationFailure
The validation failure. May not be <code>null</code> in case of
failure!
@return Never <code>null</code>. | [
"Factory",
"method",
"for",
"error",
"in",
"authentication",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-security/src/main/java/com/helger/security/authentication/result/AuthIdentificationResult.java#L121-L126 |
136,870 | phax/ph-commons | ph-settings/src/main/java/com/helger/settings/exchange/configfile/ConfigFile.java | ConfigFile.applyAsSystemProperties | public void applyAsSystemProperties (@Nullable final String... aPropertyNames)
{
if (isRead () && aPropertyNames != null)
for (final String sProperty : aPropertyNames)
{
final String sConfigFileValue = getAsString (sProperty);
if (sConfigFileValue != null)
{
SystemProperties.setPropertyValue (sProperty, sConfigFileValue);
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Set Java system property from configuration: " + sProperty + "=" + sConfigFileValue);
}
}
} | java | public void applyAsSystemProperties (@Nullable final String... aPropertyNames)
{
if (isRead () && aPropertyNames != null)
for (final String sProperty : aPropertyNames)
{
final String sConfigFileValue = getAsString (sProperty);
if (sConfigFileValue != null)
{
SystemProperties.setPropertyValue (sProperty, sConfigFileValue);
if (LOGGER.isInfoEnabled ())
LOGGER.info ("Set Java system property from configuration: " + sProperty + "=" + sConfigFileValue);
}
}
} | [
"public",
"void",
"applyAsSystemProperties",
"(",
"@",
"Nullable",
"final",
"String",
"...",
"aPropertyNames",
")",
"{",
"if",
"(",
"isRead",
"(",
")",
"&&",
"aPropertyNames",
"!=",
"null",
")",
"for",
"(",
"final",
"String",
"sProperty",
":",
"aPropertyNames"... | This is a utility method, that takes the provided property names, checks if
they are defined in the configuration and if so, applies applies them as
System properties. It does it only when the configuration file was read
correctly.
@param aPropertyNames
The property names to consider.
@since 8.5.3 | [
"This",
"is",
"a",
"utility",
"method",
"that",
"takes",
"the",
"provided",
"property",
"names",
"checks",
"if",
"they",
"are",
"defined",
"in",
"the",
"configuration",
"and",
"if",
"so",
"applies",
"applies",
"them",
"as",
"System",
"properties",
".",
"It",... | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-settings/src/main/java/com/helger/settings/exchange/configfile/ConfigFile.java#L117-L130 |
136,871 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java | CSVReader.setSkipLines | @Nonnull
public CSVReader setSkipLines (@Nonnegative final int nSkipLines)
{
ValueEnforcer.isGE0 (nSkipLines, "SkipLines");
m_nSkipLines = nSkipLines;
return this;
} | java | @Nonnull
public CSVReader setSkipLines (@Nonnegative final int nSkipLines)
{
ValueEnforcer.isGE0 (nSkipLines, "SkipLines");
m_nSkipLines = nSkipLines;
return this;
} | [
"@",
"Nonnull",
"public",
"CSVReader",
"setSkipLines",
"(",
"@",
"Nonnegative",
"final",
"int",
"nSkipLines",
")",
"{",
"ValueEnforcer",
".",
"isGE0",
"(",
"nSkipLines",
",",
"\"SkipLines\"",
")",
";",
"m_nSkipLines",
"=",
"nSkipLines",
";",
"return",
"this",
... | Sets the line number to skip for start reading.
@param nSkipLines
the line number to skip for start reading.
@return this | [
"Sets",
"the",
"line",
"number",
"to",
"skip",
"for",
"start",
"reading",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java#L281-L287 |
136,872 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java | CSVReader.readAll | public void readAll (@Nonnull final Consumer <? super ICommonsList <String>> aLineConsumer) throws IOException
{
while (m_bHasNext)
{
final ICommonsList <String> aNextLineAsTokens = readNext ();
if (aNextLineAsTokens != null)
aLineConsumer.accept (aNextLineAsTokens);
}
} | java | public void readAll (@Nonnull final Consumer <? super ICommonsList <String>> aLineConsumer) throws IOException
{
while (m_bHasNext)
{
final ICommonsList <String> aNextLineAsTokens = readNext ();
if (aNextLineAsTokens != null)
aLineConsumer.accept (aNextLineAsTokens);
}
} | [
"public",
"void",
"readAll",
"(",
"@",
"Nonnull",
"final",
"Consumer",
"<",
"?",
"super",
"ICommonsList",
"<",
"String",
">",
">",
"aLineConsumer",
")",
"throws",
"IOException",
"{",
"while",
"(",
"m_bHasNext",
")",
"{",
"final",
"ICommonsList",
"<",
"String... | Reads the entire file line by line and invoke a callback for each line.
@param aLineConsumer
The consumer that is invoked for every line. May not be
<code>null</code>.
@throws IOException
if bad things happen during the read | [
"Reads",
"the",
"entire",
"file",
"line",
"by",
"line",
"and",
"invoke",
"a",
"callback",
"for",
"each",
"line",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java#L370-L378 |
136,873 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java | CSVReader.readNext | @Nullable
public ICommonsList <String> readNext () throws IOException
{
ICommonsList <String> ret = null;
do
{
final String sNextLine = _getNextLine ();
if (!m_bHasNext)
{
// should throw if still pending?
return ret;
}
final ICommonsList <String> r = m_aParser.parseLineMulti (sNextLine);
if (ret == null)
ret = r;
else
ret.addAll (r);
} while (m_aParser.isPending ());
return ret;
} | java | @Nullable
public ICommonsList <String> readNext () throws IOException
{
ICommonsList <String> ret = null;
do
{
final String sNextLine = _getNextLine ();
if (!m_bHasNext)
{
// should throw if still pending?
return ret;
}
final ICommonsList <String> r = m_aParser.parseLineMulti (sNextLine);
if (ret == null)
ret = r;
else
ret.addAll (r);
} while (m_aParser.isPending ());
return ret;
} | [
"@",
"Nullable",
"public",
"ICommonsList",
"<",
"String",
">",
"readNext",
"(",
")",
"throws",
"IOException",
"{",
"ICommonsList",
"<",
"String",
">",
"ret",
"=",
"null",
";",
"do",
"{",
"final",
"String",
"sNextLine",
"=",
"_getNextLine",
"(",
")",
";",
... | Reads the next line from the buffer and converts to a string array.
@return a string array with each comma-separated element as a separate
entry.
@throws IOException
if bad things happen during the read | [
"Reads",
"the",
"next",
"line",
"from",
"the",
"buffer",
"and",
"converts",
"to",
"a",
"string",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java#L388-L407 |
136,874 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java | CSVReader.iterator | @Nonnull
public Iterator <ICommonsList <String>> iterator ()
{
try
{
return new CSVIterator (this);
}
catch (final IOException e)
{
throw new UncheckedIOException ("Error creating CSVIterator", e);
}
} | java | @Nonnull
public Iterator <ICommonsList <String>> iterator ()
{
try
{
return new CSVIterator (this);
}
catch (final IOException e)
{
throw new UncheckedIOException ("Error creating CSVIterator", e);
}
} | [
"@",
"Nonnull",
"public",
"Iterator",
"<",
"ICommonsList",
"<",
"String",
">",
">",
"iterator",
"(",
")",
"{",
"try",
"{",
"return",
"new",
"CSVIterator",
"(",
"this",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"throw",
"new",
... | Creates an Iterator for processing the csv data.
@return an ICommonsList<String> iterator. | [
"Creates",
"an",
"Iterator",
"for",
"processing",
"the",
"csv",
"data",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/csv/CSVReader.java#L479-L490 |
136,875 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/resource/ClassPathResource.java | ClassPathResource.getWithoutClassPathPrefix | @Nullable
public static String getWithoutClassPathPrefix (@Nullable final String sPath)
{
if (StringHelper.startsWith (sPath, CLASSPATH_PREFIX_LONG))
return sPath.substring (CLASSPATH_PREFIX_LONG.length ());
if (StringHelper.startsWith (sPath, CLASSPATH_PREFIX_SHORT))
return sPath.substring (CLASSPATH_PREFIX_SHORT.length ());
return sPath;
} | java | @Nullable
public static String getWithoutClassPathPrefix (@Nullable final String sPath)
{
if (StringHelper.startsWith (sPath, CLASSPATH_PREFIX_LONG))
return sPath.substring (CLASSPATH_PREFIX_LONG.length ());
if (StringHelper.startsWith (sPath, CLASSPATH_PREFIX_SHORT))
return sPath.substring (CLASSPATH_PREFIX_SHORT.length ());
return sPath;
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getWithoutClassPathPrefix",
"(",
"@",
"Nullable",
"final",
"String",
"sPath",
")",
"{",
"if",
"(",
"StringHelper",
".",
"startsWith",
"(",
"sPath",
",",
"CLASSPATH_PREFIX_LONG",
")",
")",
"return",
"sPath",
".",
... | Remove any leading explicit classpath resource prefixes.
@param sPath
The source path to strip the class path prefixes from. May be
<code>null</code>.
@return <code>null</code> if the parameter was <code>null</code>.
@see #CLASSPATH_PREFIX_LONG
@see #CLASSPATH_PREFIX_SHORT | [
"Remove",
"any",
"leading",
"explicit",
"classpath",
"resource",
"prefixes",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/resource/ClassPathResource.java#L150-L158 |
136,876 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/resource/ClassPathResource.java | ClassPathResource.getInputStream | @Nullable
public static InputStream getInputStream (@Nonnull @Nonempty final String sPath,
@Nonnull final ClassLoader aClassLoader)
{
final URL aURL = ClassLoaderHelper.getResource (aClassLoader, sPath);
return _getInputStream (sPath, aURL, (ClassLoader) null);
} | java | @Nullable
public static InputStream getInputStream (@Nonnull @Nonempty final String sPath,
@Nonnull final ClassLoader aClassLoader)
{
final URL aURL = ClassLoaderHelper.getResource (aClassLoader, sPath);
return _getInputStream (sPath, aURL, (ClassLoader) null);
} | [
"@",
"Nullable",
"public",
"static",
"InputStream",
"getInputStream",
"(",
"@",
"Nonnull",
"@",
"Nonempty",
"final",
"String",
"sPath",
",",
"@",
"Nonnull",
"final",
"ClassLoader",
"aClassLoader",
")",
"{",
"final",
"URL",
"aURL",
"=",
"ClassLoaderHelper",
".",
... | Get the input stream of the passed resource using the specified class
loader only.
@param sPath
The path to be resolved. May neither be <code>null</code> nor empty.
@param aClassLoader
The class loader to be used. May not be <code>null</code>.
@return <code>null</code> if the path could not be resolved using the
specified class loader. | [
"Get",
"the",
"input",
"stream",
"of",
"the",
"passed",
"resource",
"using",
"the",
"specified",
"class",
"loader",
"only",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/resource/ClassPathResource.java#L250-L256 |
136,877 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/io/resource/ClassPathResource.java | ClassPathResource.getInputStreamNoCache | @Nullable
public InputStream getInputStreamNoCache (@Nonnull final ClassLoader aClassLoader)
{
final URL aURL = getAsURLNoCache (aClassLoader);
return _getInputStream (m_sPath, aURL, aClassLoader);
} | java | @Nullable
public InputStream getInputStreamNoCache (@Nonnull final ClassLoader aClassLoader)
{
final URL aURL = getAsURLNoCache (aClassLoader);
return _getInputStream (m_sPath, aURL, aClassLoader);
} | [
"@",
"Nullable",
"public",
"InputStream",
"getInputStreamNoCache",
"(",
"@",
"Nonnull",
"final",
"ClassLoader",
"aClassLoader",
")",
"{",
"final",
"URL",
"aURL",
"=",
"getAsURLNoCache",
"(",
"aClassLoader",
")",
";",
"return",
"_getInputStream",
"(",
"m_sPath",
",... | Get the input stream to the this resource, using the passed class loader
only.
@param aClassLoader
The class loader to be used. May not be <code>null</code>.
@return <code>null</code> if the path could not be resolved. | [
"Get",
"the",
"input",
"stream",
"to",
"the",
"this",
"resource",
"using",
"the",
"passed",
"class",
"loader",
"only",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/io/resource/ClassPathResource.java#L290-L295 |
136,878 | phax/ph-commons | ph-tree/src/main/java/com/helger/tree/util/TreeWithIDSearcher.java | TreeWithIDSearcher.findAllItemsWithIDRecursive | @Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> ICommonsList <ITEMTYPE> findAllItemsWithIDRecursive (@Nonnull final IBasicTree <DATATYPE, ITEMTYPE> aTree,
@Nullable final KEYTYPE aSearchID)
{
return findAllItemsWithIDRecursive (aTree.getRootItem (), aSearchID);
} | java | @Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> ICommonsList <ITEMTYPE> findAllItemsWithIDRecursive (@Nonnull final IBasicTree <DATATYPE, ITEMTYPE> aTree,
@Nullable final KEYTYPE aSearchID)
{
return findAllItemsWithIDRecursive (aTree.getRootItem (), aSearchID);
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"KEYTYPE",
",",
"DATATYPE",
",",
"ITEMTYPE",
"extends",
"ITreeItemWithID",
"<",
"KEYTYPE",
",",
"DATATYPE",
",",
"ITEMTYPE",
">",
">",
"ICommonsList",
"<",
"ITEMTYPE",
">",
"findAllItemsWithIDRecu... | Fill all items with the same ID by linearly scanning of the tree.
@param <KEYTYPE>
tree ID type
@param <DATATYPE>
tree data type
@param <ITEMTYPE>
tree item type
@param aTree
The tree to search. May not be <code>null</code>.
@param aSearchID
The ID to search. May not be <code>null</code>.
@return A non-<code>null</code> list with all matching items. | [
"Fill",
"all",
"items",
"with",
"the",
"same",
"ID",
"by",
"linearly",
"scanning",
"of",
"the",
"tree",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-tree/src/main/java/com/helger/tree/util/TreeWithIDSearcher.java#L61-L67 |
136,879 | phax/ph-commons | ph-tree/src/main/java/com/helger/tree/util/TreeWithIDSearcher.java | TreeWithIDSearcher.findAllItemsWithIDRecursive | @Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> ICommonsList <ITEMTYPE> findAllItemsWithIDRecursive (@Nonnull final ITEMTYPE aTreeItem,
@Nullable final KEYTYPE aSearchID)
{
final ICommonsList <ITEMTYPE> aRetList = new CommonsArrayList <> ();
TreeVisitor.visitTreeItem (aTreeItem, new DefaultHierarchyVisitorCallback <ITEMTYPE> ()
{
@Override
@Nonnull
public EHierarchyVisitorReturn onItemBeforeChildren (@Nullable final ITEMTYPE aItem)
{
if (aItem != null && aItem.getID ().equals (aSearchID))
aRetList.add (aItem);
return EHierarchyVisitorReturn.CONTINUE;
}
});
return aRetList;
} | java | @Nonnull
@ReturnsMutableCopy
public static <KEYTYPE, DATATYPE, ITEMTYPE extends ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE>> ICommonsList <ITEMTYPE> findAllItemsWithIDRecursive (@Nonnull final ITEMTYPE aTreeItem,
@Nullable final KEYTYPE aSearchID)
{
final ICommonsList <ITEMTYPE> aRetList = new CommonsArrayList <> ();
TreeVisitor.visitTreeItem (aTreeItem, new DefaultHierarchyVisitorCallback <ITEMTYPE> ()
{
@Override
@Nonnull
public EHierarchyVisitorReturn onItemBeforeChildren (@Nullable final ITEMTYPE aItem)
{
if (aItem != null && aItem.getID ().equals (aSearchID))
aRetList.add (aItem);
return EHierarchyVisitorReturn.CONTINUE;
}
});
return aRetList;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"KEYTYPE",
",",
"DATATYPE",
",",
"ITEMTYPE",
"extends",
"ITreeItemWithID",
"<",
"KEYTYPE",
",",
"DATATYPE",
",",
"ITEMTYPE",
">",
">",
"ICommonsList",
"<",
"ITEMTYPE",
">",
"findAllItemsWithIDRecu... | Fill all items with the same ID by linearly scanning the tree.
@param <KEYTYPE>
tree ID type
@param <DATATYPE>
tree data type
@param <ITEMTYPE>
tree item type
@param aTreeItem
The tree item to search. May not be <code>null</code>.
@param aSearchID
The ID to search. May not be <code>null</code>.
@return A non-<code>null</code> list with all matching items. | [
"Fill",
"all",
"items",
"with",
"the",
"same",
"ID",
"by",
"linearly",
"scanning",
"the",
"tree",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-tree/src/main/java/com/helger/tree/util/TreeWithIDSearcher.java#L84-L102 |
136,880 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java | TypeConverter.convert | @Nullable
public static <DSTTYPE> DSTTYPE convert (@Nullable final Object aSrcValue, @Nonnull final Class <DSTTYPE> aDstClass)
{
return convert (TypeConverterProviderBestMatch.getInstance (), aSrcValue, aDstClass);
} | java | @Nullable
public static <DSTTYPE> DSTTYPE convert (@Nullable final Object aSrcValue, @Nonnull final Class <DSTTYPE> aDstClass)
{
return convert (TypeConverterProviderBestMatch.getInstance (), aSrcValue, aDstClass);
} | [
"@",
"Nullable",
"public",
"static",
"<",
"DSTTYPE",
">",
"DSTTYPE",
"convert",
"(",
"@",
"Nullable",
"final",
"Object",
"aSrcValue",
",",
"@",
"Nonnull",
"final",
"Class",
"<",
"DSTTYPE",
">",
"aDstClass",
")",
"{",
"return",
"convert",
"(",
"TypeConverterP... | Convert the passed source value to the destination class using the best
match type converter provider, if a conversion is necessary.
@param <DSTTYPE>
The destination type.
@param aSrcValue
The source value. May be <code>null</code>.
@param aDstClass
The destination class to use.
@return <code>null</code> if the source value was <code>null</code>.
@throws TypeConverterException
If no converter was found or if the converter returned a
<code>null</code> object.
@throws RuntimeException
If the converter itself throws an exception
@see TypeConverterProviderBestMatch | [
"Convert",
"the",
"passed",
"source",
"value",
"to",
"the",
"destination",
"class",
"using",
"the",
"best",
"match",
"type",
"converter",
"provider",
"if",
"a",
"conversion",
"is",
"necessary",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java#L439-L443 |
136,881 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java | TypeConverter._getUsableClass | @Nullable
private static Class <?> _getUsableClass (@Nullable final Class <?> aClass)
{
final Class <?> aPrimitiveWrapperType = ClassHelper.getPrimitiveWrapperClass (aClass);
return aPrimitiveWrapperType != null ? aPrimitiveWrapperType : aClass;
} | java | @Nullable
private static Class <?> _getUsableClass (@Nullable final Class <?> aClass)
{
final Class <?> aPrimitiveWrapperType = ClassHelper.getPrimitiveWrapperClass (aClass);
return aPrimitiveWrapperType != null ? aPrimitiveWrapperType : aClass;
} | [
"@",
"Nullable",
"private",
"static",
"Class",
"<",
"?",
">",
"_getUsableClass",
"(",
"@",
"Nullable",
"final",
"Class",
"<",
"?",
">",
"aClass",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"aPrimitiveWrapperType",
"=",
"ClassHelper",
".",
"getPrimitiveWrappe... | Get the class to use. In case the passed class is a primitive type, the
corresponding wrapper class is used.
@param aClass
The class to check. Can be <code>null</code> but should not be
<code>null</code>.
@return <code>null</code> if the parameter is <code>null</code>. | [
"Get",
"the",
"class",
"to",
"use",
".",
"In",
"case",
"the",
"passed",
"class",
"is",
"a",
"primitive",
"type",
"the",
"corresponding",
"wrapper",
"class",
"is",
"used",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/typeconvert/TypeConverter.java#L454-L459 |
136,882 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/mime/MimeTypeHelper.java | MimeTypeHelper.getCharsetNameFromMimeType | @Nullable
public static String getCharsetNameFromMimeType (@Nullable final IMimeType aMimeType)
{
return aMimeType == null ? null : aMimeType.getParameterValueWithName (CMimeType.PARAMETER_NAME_CHARSET);
} | java | @Nullable
public static String getCharsetNameFromMimeType (@Nullable final IMimeType aMimeType)
{
return aMimeType == null ? null : aMimeType.getParameterValueWithName (CMimeType.PARAMETER_NAME_CHARSET);
} | [
"@",
"Nullable",
"public",
"static",
"String",
"getCharsetNameFromMimeType",
"(",
"@",
"Nullable",
"final",
"IMimeType",
"aMimeType",
")",
"{",
"return",
"aMimeType",
"==",
"null",
"?",
"null",
":",
"aMimeType",
".",
"getParameterValueWithName",
"(",
"CMimeType",
... | Determine the charset name from the provided MIME type.
@param aMimeType
The MIME type to query. May be <code>null</code>.
@return <code>null</code> if no MIME type was provided or if the MIME type
does not contain a "charset" parameter | [
"Determine",
"the",
"charset",
"name",
"from",
"the",
"provided",
"MIME",
"type",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/mime/MimeTypeHelper.java#L45-L49 |
136,883 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/mime/MimeTypeHelper.java | MimeTypeHelper.getCharsetFromMimeType | @Nullable
public static Charset getCharsetFromMimeType (@Nullable final IMimeType aMimeType)
{
final String sCharsetName = getCharsetNameFromMimeType (aMimeType);
return CharsetHelper.getCharsetFromNameOrNull (sCharsetName);
} | java | @Nullable
public static Charset getCharsetFromMimeType (@Nullable final IMimeType aMimeType)
{
final String sCharsetName = getCharsetNameFromMimeType (aMimeType);
return CharsetHelper.getCharsetFromNameOrNull (sCharsetName);
} | [
"@",
"Nullable",
"public",
"static",
"Charset",
"getCharsetFromMimeType",
"(",
"@",
"Nullable",
"final",
"IMimeType",
"aMimeType",
")",
"{",
"final",
"String",
"sCharsetName",
"=",
"getCharsetNameFromMimeType",
"(",
"aMimeType",
")",
";",
"return",
"CharsetHelper",
... | Determine the charset from the provided MIME type.
@param aMimeType
The MIME type to query. May be <code>null</code>.
@return <code>null</code> if no MIME type was provided or if the MIME type
does not contain a "charset" parameter or if the provided charset
name is invalid. | [
"Determine",
"the",
"charset",
"from",
"the",
"provided",
"MIME",
"type",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/mime/MimeTypeHelper.java#L60-L65 |
136,884 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.isArray | public static boolean isArray (@Nullable final Object aObject)
{
return aObject != null && ClassHelper.isArrayClass (aObject.getClass ());
} | java | public static boolean isArray (@Nullable final Object aObject)
{
return aObject != null && ClassHelper.isArrayClass (aObject.getClass ());
} | [
"public",
"static",
"boolean",
"isArray",
"(",
"@",
"Nullable",
"final",
"Object",
"aObject",
")",
"{",
"return",
"aObject",
"!=",
"null",
"&&",
"ClassHelper",
".",
"isArrayClass",
"(",
"aObject",
".",
"getClass",
"(",
")",
")",
";",
"}"
] | Check if the passed object is an array or not.
@param aObject
The object to be checked. May be <code>null</code>.
@return <code>true</code> if the passed object is not <code>null</code> and
represents an array. | [
"Check",
"if",
"the",
"passed",
"object",
"is",
"an",
"array",
"or",
"not",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L117-L120 |
136,885 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.getFirstIndex | public static <ELEMENTTYPE> int getFirstIndex (@Nullable final ELEMENTTYPE [] aValues,
@Nullable final ELEMENTTYPE aSearchValue)
{
final int nLength = getSize (aValues);
if (nLength > 0)
for (int nIndex = 0; nIndex < nLength; ++nIndex)
if (EqualsHelper.equals (aValues[nIndex], aSearchValue))
return nIndex;
return CGlobal.ILLEGAL_UINT;
} | java | public static <ELEMENTTYPE> int getFirstIndex (@Nullable final ELEMENTTYPE [] aValues,
@Nullable final ELEMENTTYPE aSearchValue)
{
final int nLength = getSize (aValues);
if (nLength > 0)
for (int nIndex = 0; nIndex < nLength; ++nIndex)
if (EqualsHelper.equals (aValues[nIndex], aSearchValue))
return nIndex;
return CGlobal.ILLEGAL_UINT;
} | [
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"int",
"getFirstIndex",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"[",
"]",
"aValues",
",",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"aSearchValue",
")",
"{",
"final",
"int",
"nLength",
"=",
"getSize",
"(",
"a... | Get the index of the passed search value in the passed value array.
@param <ELEMENTTYPE>
Array element type
@param aValues
The value array to be searched. May be <code>null</code>.
@param aSearchValue
The value to be searched. May be <code>null</code>.
@return <code>-1</code> if the searched value is not contained, a value
≥ 0 otherwise. | [
"Get",
"the",
"index",
"of",
"the",
"passed",
"search",
"value",
"in",
"the",
"passed",
"value",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L440-L449 |
136,886 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.contains | public static <ELEMENTTYPE> boolean contains (@Nullable final ELEMENTTYPE [] aValues,
@Nullable final ELEMENTTYPE aSearchValue)
{
return getFirstIndex (aValues, aSearchValue) >= 0;
} | java | public static <ELEMENTTYPE> boolean contains (@Nullable final ELEMENTTYPE [] aValues,
@Nullable final ELEMENTTYPE aSearchValue)
{
return getFirstIndex (aValues, aSearchValue) >= 0;
} | [
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"boolean",
"contains",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"[",
"]",
"aValues",
",",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"aSearchValue",
")",
"{",
"return",
"getFirstIndex",
"(",
"aValues",
",",
"aSea... | Check if the passed search value is contained in the passed value array.
@param <ELEMENTTYPE>
Array element type
@param aValues
The value array to be searched. May be <code>null</code>.
@param aSearchValue
The value to be searched. May be <code>null</code>.
@return <code>true</code> if the value array is not empty and the search
value is contained - false otherwise. | [
"Check",
"if",
"the",
"passed",
"search",
"value",
"is",
"contained",
"in",
"the",
"passed",
"value",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L806-L810 |
136,887 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.getFirst | @Nullable
public static <ELEMENTTYPE> ELEMENTTYPE getFirst (@Nullable final ELEMENTTYPE [] aArray,
@Nullable final ELEMENTTYPE aDefaultValue)
{
return isEmpty (aArray) ? aDefaultValue : aArray[0];
} | java | @Nullable
public static <ELEMENTTYPE> ELEMENTTYPE getFirst (@Nullable final ELEMENTTYPE [] aArray,
@Nullable final ELEMENTTYPE aDefaultValue)
{
return isEmpty (aArray) ? aDefaultValue : aArray[0];
} | [
"@",
"Nullable",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"getFirst",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"[",
"]",
"aArray",
",",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"aDefaultValue",
")",
"{",
"return",
"isEmpty",
"(",
"aArra... | Get the first element of the array or the passed default if the passed
array is empty.
@param <ELEMENTTYPE>
Array element type
@param aArray
The array who's first element is to be retrieved. May be
<code>null</code> or empty.
@param aDefaultValue
The default value to be returned if the array is empty
@return the first element if the passed array is not empty, the default
value if the passed array is empty. | [
"Get",
"the",
"first",
"element",
"of",
"the",
"array",
"or",
"the",
"passed",
"default",
"if",
"the",
"passed",
"array",
"is",
"empty",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L1101-L1106 |
136,888 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.getConcatenated | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] getConcatenated (@Nullable final ELEMENTTYPE aHead,
@Nullable final ELEMENTTYPE [] aTailArray,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
if (isEmpty (aTailArray))
return newArraySingleElement (aHead, aClass);
// Start concatenating
final ELEMENTTYPE [] ret = newArray (aClass, 1 + aTailArray.length);
ret[0] = aHead;
System.arraycopy (aTailArray, 0, ret, 1, aTailArray.length);
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] getConcatenated (@Nullable final ELEMENTTYPE aHead,
@Nullable final ELEMENTTYPE [] aTailArray,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
if (isEmpty (aTailArray))
return newArraySingleElement (aHead, aClass);
// Start concatenating
final ELEMENTTYPE [] ret = newArray (aClass, 1 + aTailArray.length);
ret[0] = aHead;
System.arraycopy (aTailArray, 0, ret, 1, aTailArray.length);
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"getConcatenated",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"aHead",
",",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"[",
"]",
"aTailArray",
",",
... | Get a new array that combines the passed head and the array. The head
element will be the first element of the created array.
@param <ELEMENTTYPE>
Array element type
@param aHead
The first element of the result array. If this element is
<code>null</code> it will be inserted as such into the array!
@param aTailArray
The tail array. May be <code>null</code>.
@param aClass
The element class. Must be present, because in case both elements
are <code>null</code> there would be no way to create a new array.
May not be <code>null</code>.
@return <code>null</code> if both array parameters are <code>null</code> -
a non-<code>null</code> array with all elements in the correct
order otherwise. | [
"Get",
"a",
"new",
"array",
"that",
"combines",
"the",
"passed",
"head",
"and",
"the",
"array",
".",
"The",
"head",
"element",
"will",
"be",
"the",
"first",
"element",
"of",
"the",
"created",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L1961-L1975 |
136,889 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.getConcatenated | @Nonnull
@ReturnsMutableCopy
public static float [] getConcatenated (final float aHead, @Nullable final float... aTailArray)
{
if (isEmpty (aTailArray))
return new float [] { aHead };
final float [] ret = new float [1 + aTailArray.length];
ret[0] = aHead;
System.arraycopy (aTailArray, 0, ret, 1, aTailArray.length);
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static float [] getConcatenated (final float aHead, @Nullable final float... aTailArray)
{
if (isEmpty (aTailArray))
return new float [] { aHead };
final float [] ret = new float [1 + aTailArray.length];
ret[0] = aHead;
System.arraycopy (aTailArray, 0, ret, 1, aTailArray.length);
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"float",
"[",
"]",
"getConcatenated",
"(",
"final",
"float",
"aHead",
",",
"@",
"Nullable",
"final",
"float",
"...",
"aTailArray",
")",
"{",
"if",
"(",
"isEmpty",
"(",
"aTailArray",
")",
")",
"... | Get a new array that combines the passed head element and the array. The
head element will be the first element of the created array.
@param aHead
The first element of the result array.
@param aTailArray
The tail array. May be <code>null</code>.
@return A non-<code>null</code> array with all elements in the correct
order. | [
"Get",
"a",
"new",
"array",
"that",
"combines",
"the",
"passed",
"head",
"element",
"and",
"the",
"array",
".",
"The",
"head",
"element",
"will",
"be",
"the",
"first",
"element",
"of",
"the",
"created",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L2385-L2396 |
136,890 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.getAllExceptFirst | @Nullable
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> ELEMENTTYPE [] getAllExceptFirst (@Nullable final ELEMENTTYPE... aArray)
{
return getAllExceptFirst (aArray, 1);
} | java | @Nullable
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> ELEMENTTYPE [] getAllExceptFirst (@Nullable final ELEMENTTYPE... aArray)
{
return getAllExceptFirst (aArray, 1);
} | [
"@",
"Nullable",
"@",
"ReturnsMutableCopy",
"@",
"SafeVarargs",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"getAllExceptFirst",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"...",
"aArray",
")",
"{",
"return",
"getAllExceptFirst",
"(",
... | Get an array that contains all elements, except for the first element.
@param <ELEMENTTYPE>
Array element type
@param aArray
The source array. May be <code>null</code>.
@return <code>null</code> if the passed array is <code>null</code> or has
less than one element. A non-<code>null</code> copy of the array
without the first element otherwise. | [
"Get",
"an",
"array",
"that",
"contains",
"all",
"elements",
"except",
"for",
"the",
"first",
"element",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L2737-L2743 |
136,891 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.getAllExcept | @Nullable
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> ELEMENTTYPE [] getAllExcept (@Nullable final ELEMENTTYPE [] aArray,
@Nullable final ELEMENTTYPE... aElementsToRemove)
{
if (isEmpty (aArray) || isEmpty (aElementsToRemove))
return aArray;
final ELEMENTTYPE [] tmp = getCopy (aArray);
int nDst = 0;
for (int nSrc = 0; nSrc < tmp.length; ++nSrc)
if (!contains (aElementsToRemove, tmp[nSrc]))
tmp[nDst++] = tmp[nSrc];
return getCopy (tmp, 0, nDst);
} | java | @Nullable
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> ELEMENTTYPE [] getAllExcept (@Nullable final ELEMENTTYPE [] aArray,
@Nullable final ELEMENTTYPE... aElementsToRemove)
{
if (isEmpty (aArray) || isEmpty (aElementsToRemove))
return aArray;
final ELEMENTTYPE [] tmp = getCopy (aArray);
int nDst = 0;
for (int nSrc = 0; nSrc < tmp.length; ++nSrc)
if (!contains (aElementsToRemove, tmp[nSrc]))
tmp[nDst++] = tmp[nSrc];
return getCopy (tmp, 0, nDst);
} | [
"@",
"Nullable",
"@",
"ReturnsMutableCopy",
"@",
"SafeVarargs",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"getAllExcept",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"[",
"]",
"aArray",
",",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
... | Get an array that contains all elements, except for the passed elements.
@param <ELEMENTTYPE>
Array element type
@param aArray
The source array. May be <code>null</code>.
@param aElementsToRemove
The elements to skip.
@return <code>null</code> if the passed array is <code>null</code>. The
original array, if no elements need to be skipped. A non-
<code>null</code> copy of the array without the passed elements
otherwise. | [
"Get",
"an",
"array",
"that",
"contains",
"all",
"elements",
"except",
"for",
"the",
"passed",
"elements",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L2787-L2802 |
136,892 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.getAllExceptLast | @Nullable
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> ELEMENTTYPE [] getAllExceptLast (@Nullable final ELEMENTTYPE... aArray)
{
return getAllExceptLast (aArray, 1);
} | java | @Nullable
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> ELEMENTTYPE [] getAllExceptLast (@Nullable final ELEMENTTYPE... aArray)
{
return getAllExceptLast (aArray, 1);
} | [
"@",
"Nullable",
"@",
"ReturnsMutableCopy",
"@",
"SafeVarargs",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"getAllExceptLast",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"...",
"aArray",
")",
"{",
"return",
"getAllExceptLast",
"(",
... | Get an array that contains all elements, except for the last element.
@param <ELEMENTTYPE>
Array element type
@param aArray
The source array. May be <code>null</code>.
@return <code>null</code> if the passed array is <code>null</code> or has
less than one element. A non-<code>null</code> copy of the array
without the last element otherwise. | [
"Get",
"an",
"array",
"that",
"contains",
"all",
"elements",
"except",
"for",
"the",
"last",
"element",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L3360-L3366 |
136,893 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.newArraySameType | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArraySameType (@Nonnull final ELEMENTTYPE [] aArray,
@Nonnegative final int nSize)
{
return newArray (getComponentType (aArray), nSize);
} | java | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArraySameType (@Nonnull final ELEMENTTYPE [] aArray,
@Nonnegative final int nSize)
{
return newArray (getComponentType (aArray), nSize);
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"newArraySameType",
"(",
"@",
"Nonnull",
"final",
"ELEMENTTYPE",
"[",
"]",
"aArray",
",",
"@",
"Nonnegative",
"final",
"int",
"nSize",
")",
"{",
... | Create a new empty array with the same type as the passed array.
@param <ELEMENTTYPE>
Type of element
@param aArray
Source array. May not be <code>null</code>.
@param nSize
Destination size. Must be ≥ 0.
@return Never <code>null</code>. | [
"Create",
"a",
"new",
"empty",
"array",
"with",
"the",
"same",
"type",
"as",
"the",
"passed",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L3869-L3875 |
136,894 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.newArray | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArray (@Nullable final Collection <? extends ELEMENTTYPE> aCollection,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.notNull (aClass, "class");
if (CollectionHelper.isEmpty (aCollection))
return newArray (aClass, 0);
final ELEMENTTYPE [] ret = newArray (aClass, aCollection.size ());
return aCollection.toArray (ret);
} | java | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArray (@Nullable final Collection <? extends ELEMENTTYPE> aCollection,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.notNull (aClass, "class");
if (CollectionHelper.isEmpty (aCollection))
return newArray (aClass, 0);
final ELEMENTTYPE [] ret = newArray (aClass, aCollection.size ());
return aCollection.toArray (ret);
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"newArray",
"(",
"@",
"Nullable",
"final",
"Collection",
"<",
"?",
"extends",
"ELEMENTTYPE",
">",
"aCollection",
",",
"@",
"Nonnull",
"final",
"Cla... | Create a new array with the elements in the passed collection..
@param <ELEMENTTYPE>
Type of element
@param aCollection
The collection to be converted to an array. May be <code>null</code>
.
@param aClass
The class of the elements inside the collection. May not be
<code>null</code>.
@return <code>null</code> if the passed collection is empty, a non-
<code>null</code> array with all elements of the collection
otherwise. | [
"Create",
"a",
"new",
"array",
"with",
"the",
"elements",
"in",
"the",
"passed",
"collection",
".."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L3892-L3904 |
136,895 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.newArraySingleElement | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArraySingleElement (@Nullable final ELEMENTTYPE aElement,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.notNull (aClass, "class");
final ELEMENTTYPE [] ret = newArray (aClass, 1);
ret[0] = aElement;
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArraySingleElement (@Nullable final ELEMENTTYPE aElement,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.notNull (aClass, "class");
final ELEMENTTYPE [] ret = newArray (aClass, 1);
ret[0] = aElement;
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"newArraySingleElement",
"(",
"@",
"Nullable",
"final",
"ELEMENTTYPE",
"aElement",
",",
"@",
"Nonnull",
"final",
"Class",
"<",
"ELEMENTTYPE",
">",
"a... | Wrapper that allows a single argument to be treated as an array.
@param <ELEMENTTYPE>
Type of element
@param aElement
The element to be converted to an array. May be <code>null</code>.
@param aClass
The class of the element. May not be <code>null</code>. Must be
present because in case the passed element is <code>null</code>
there is no way to determine the array component type!
@return The created array and never <code>null</code>. | [
"Wrapper",
"that",
"allows",
"a",
"single",
"argument",
"to",
"be",
"treated",
"as",
"an",
"array",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L3919-L3929 |
136,896 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.newArray | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArray (@Nonnegative final int nArraySize,
@Nonnull final ELEMENTTYPE aValue,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.isGE0 (nArraySize, "ArraySize");
ValueEnforcer.notNull (aClass, "class");
final ELEMENTTYPE [] ret = newArray (aClass, nArraySize);
Arrays.fill (ret, aValue);
return ret;
} | java | @Nonnull
@ReturnsMutableCopy
public static <ELEMENTTYPE> ELEMENTTYPE [] newArray (@Nonnegative final int nArraySize,
@Nonnull final ELEMENTTYPE aValue,
@Nonnull final Class <ELEMENTTYPE> aClass)
{
ValueEnforcer.isGE0 (nArraySize, "ArraySize");
ValueEnforcer.notNull (aClass, "class");
final ELEMENTTYPE [] ret = newArray (aClass, nArraySize);
Arrays.fill (ret, aValue);
return ret;
} | [
"@",
"Nonnull",
"@",
"ReturnsMutableCopy",
"public",
"static",
"<",
"ELEMENTTYPE",
">",
"ELEMENTTYPE",
"[",
"]",
"newArray",
"(",
"@",
"Nonnegative",
"final",
"int",
"nArraySize",
",",
"@",
"Nonnull",
"final",
"ELEMENTTYPE",
"aValue",
",",
"@",
"Nonnull",
"fin... | Create a new array with a predefined number of elements containing the
passed value.
@param <ELEMENTTYPE>
The type of the array to be created.
@param nArraySize
The size of the array to be created.
@param aValue
The value to be set into each array element. May be
<code>null</code>.
@param aClass
The value class. May not be <code>null</code>. Must be present in
case the passed value is <code>null</code>.
@return The created array filled with the given value. | [
"Create",
"a",
"new",
"array",
"with",
"a",
"predefined",
"number",
"of",
"elements",
"containing",
"the",
"passed",
"value",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L3968-L3980 |
136,897 | phax/ph-commons | ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java | ArrayHelper.isArrayEquals | public static boolean isArrayEquals (@Nullable final Object aHeadArray, @Nullable final Object aTailArray)
{
// Same objects?
if (EqualsHelper.identityEqual (aHeadArray, aTailArray))
return true;
// Any of the null -> different because they are not both null
if (aHeadArray == null || aTailArray == null)
return false;
// If any of the passed object is not an array -> not equal as an array,
// even if they are equal!
if (!isArray (aHeadArray) || !isArray (aTailArray))
return false;
// Different component type?
if (!aHeadArray.getClass ().getComponentType ().equals (aTailArray.getClass ().getComponentType ()))
return false;
// Different length?
final int nLength = Array.getLength (aHeadArray);
if (nLength != Array.getLength (aTailArray))
return false;
// Compare step by step
for (int i = 0; i < nLength; i++)
{
final Object aItem1 = Array.get (aHeadArray, i);
final Object aItem2 = Array.get (aTailArray, i);
if (isArray (aItem1) && isArray (aItem2))
{
// Recursive call
if (!isArrayEquals (aItem1, aItem2))
return false;
}
else
{
// Use equals implementation
if (!EqualsHelper.equals (aItem1, aItem2))
return false;
}
}
// No differences found!
return true;
} | java | public static boolean isArrayEquals (@Nullable final Object aHeadArray, @Nullable final Object aTailArray)
{
// Same objects?
if (EqualsHelper.identityEqual (aHeadArray, aTailArray))
return true;
// Any of the null -> different because they are not both null
if (aHeadArray == null || aTailArray == null)
return false;
// If any of the passed object is not an array -> not equal as an array,
// even if they are equal!
if (!isArray (aHeadArray) || !isArray (aTailArray))
return false;
// Different component type?
if (!aHeadArray.getClass ().getComponentType ().equals (aTailArray.getClass ().getComponentType ()))
return false;
// Different length?
final int nLength = Array.getLength (aHeadArray);
if (nLength != Array.getLength (aTailArray))
return false;
// Compare step by step
for (int i = 0; i < nLength; i++)
{
final Object aItem1 = Array.get (aHeadArray, i);
final Object aItem2 = Array.get (aTailArray, i);
if (isArray (aItem1) && isArray (aItem2))
{
// Recursive call
if (!isArrayEquals (aItem1, aItem2))
return false;
}
else
{
// Use equals implementation
if (!EqualsHelper.equals (aItem1, aItem2))
return false;
}
}
// No differences found!
return true;
} | [
"public",
"static",
"boolean",
"isArrayEquals",
"(",
"@",
"Nullable",
"final",
"Object",
"aHeadArray",
",",
"@",
"Nullable",
"final",
"Object",
"aTailArray",
")",
"{",
"// Same objects?",
"if",
"(",
"EqualsHelper",
".",
"identityEqual",
"(",
"aHeadArray",
",",
"... | Recursive equal comparison for arrays.
@param aHeadArray
First array. May be <code>null</code>.
@param aTailArray
Second array. May be <code>null</code>.
@return <code>true</code> only if the arrays and all contained elements are
recursively equal. | [
"Recursive",
"equal",
"comparison",
"for",
"arrays",
"."
] | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-commons/src/main/java/com/helger/commons/collection/ArrayHelper.java#L4061-L4106 |
136,898 | phax/ph-commons | ph-less-commons/src/main/java/com/helger/lesscommons/charset/StringEncoder.java | StringEncoder.encode | @Nonnull
public EContinue encode (@Nonnull final String sSource, @Nonnull final ByteBuffer aDestBuffer)
{
ValueEnforcer.notNull (sSource, "Source");
ValueEnforcer.notNull (aDestBuffer, "DestBuffer");
// We need to special case the empty string
if (sSource.length () == 0)
return EContinue.BREAK;
// read data in, if needed
if (!m_aInChar.hasRemaining () && m_nReadOffset < sSource.length ())
_readInputChunk (sSource);
// if flush() overflows the destination, skip the encode loop and re-try the
// flush()
if (m_aInChar.hasRemaining ())
{
while (true)
{
assert m_aInChar.hasRemaining ();
final boolean bEndOfInput = m_nReadOffset == sSource.length ();
final CoderResult aResult = m_aEncoder.encode (m_aInChar, aDestBuffer, bEndOfInput);
if (aResult == CoderResult.OVERFLOW)
{
// NOTE: destination could space remaining, in case of a multi-byte
// sequence
if (aDestBuffer.remaining () >= m_aEncoder.maxBytesPerChar ())
throw new IllegalStateException ();
return EContinue.CONTINUE;
}
assert aResult == CoderResult.UNDERFLOW;
// If we split a surrogate char (inBuffer.remaining() == 1), back up and
// re-copy
// from the source. avoid a branch by always subtracting
assert m_aInChar.remaining () <= 1;
m_nReadOffset -= m_aInChar.remaining ();
assert m_nReadOffset > 0;
// If we are done, break. Otherwise, read the next chunk
if (m_nReadOffset == sSource.length ())
break;
_readInputChunk (sSource);
}
}
if (m_aInChar.hasRemaining ())
throw new IllegalStateException ();
assert m_nReadOffset == sSource.length ();
final CoderResult aResult = m_aEncoder.flush (aDestBuffer);
if (aResult == CoderResult.OVERFLOW)
{
// I don't think this can happen. If it does, assert so we can figure it
// out
assert false;
// We attempt to handle it anyway
return EContinue.CONTINUE;
}
assert aResult == CoderResult.UNDERFLOW;
// done!
reset ();
return EContinue.BREAK;
} | java | @Nonnull
public EContinue encode (@Nonnull final String sSource, @Nonnull final ByteBuffer aDestBuffer)
{
ValueEnforcer.notNull (sSource, "Source");
ValueEnforcer.notNull (aDestBuffer, "DestBuffer");
// We need to special case the empty string
if (sSource.length () == 0)
return EContinue.BREAK;
// read data in, if needed
if (!m_aInChar.hasRemaining () && m_nReadOffset < sSource.length ())
_readInputChunk (sSource);
// if flush() overflows the destination, skip the encode loop and re-try the
// flush()
if (m_aInChar.hasRemaining ())
{
while (true)
{
assert m_aInChar.hasRemaining ();
final boolean bEndOfInput = m_nReadOffset == sSource.length ();
final CoderResult aResult = m_aEncoder.encode (m_aInChar, aDestBuffer, bEndOfInput);
if (aResult == CoderResult.OVERFLOW)
{
// NOTE: destination could space remaining, in case of a multi-byte
// sequence
if (aDestBuffer.remaining () >= m_aEncoder.maxBytesPerChar ())
throw new IllegalStateException ();
return EContinue.CONTINUE;
}
assert aResult == CoderResult.UNDERFLOW;
// If we split a surrogate char (inBuffer.remaining() == 1), back up and
// re-copy
// from the source. avoid a branch by always subtracting
assert m_aInChar.remaining () <= 1;
m_nReadOffset -= m_aInChar.remaining ();
assert m_nReadOffset > 0;
// If we are done, break. Otherwise, read the next chunk
if (m_nReadOffset == sSource.length ())
break;
_readInputChunk (sSource);
}
}
if (m_aInChar.hasRemaining ())
throw new IllegalStateException ();
assert m_nReadOffset == sSource.length ();
final CoderResult aResult = m_aEncoder.flush (aDestBuffer);
if (aResult == CoderResult.OVERFLOW)
{
// I don't think this can happen. If it does, assert so we can figure it
// out
assert false;
// We attempt to handle it anyway
return EContinue.CONTINUE;
}
assert aResult == CoderResult.UNDERFLOW;
// done!
reset ();
return EContinue.BREAK;
} | [
"@",
"Nonnull",
"public",
"EContinue",
"encode",
"(",
"@",
"Nonnull",
"final",
"String",
"sSource",
",",
"@",
"Nonnull",
"final",
"ByteBuffer",
"aDestBuffer",
")",
"{",
"ValueEnforcer",
".",
"notNull",
"(",
"sSource",
",",
"\"Source\"",
")",
";",
"ValueEnforce... | Encodes string into destination. This must be called multiple times with
the same string until it returns true. When this returns false, it must be
called again with larger destination buffer space. It is possible that
there are a few bytes of space remaining in the destination buffer, even
though it must be refreshed. For example, if a UTF-8 3 byte sequence needs
to be written, but there is only 1 or 2 bytes of space, this will leave the
last couple bytes unused.
@param sSource
Source string
@param aDestBuffer
a ByteBuffer that will be filled with data.
@return {@link EContinue} | [
"Encodes",
"string",
"into",
"destination",
".",
"This",
"must",
"be",
"called",
"multiple",
"times",
"with",
"the",
"same",
"string",
"until",
"it",
"returns",
"true",
".",
"When",
"this",
"returns",
"false",
"it",
"must",
"be",
"called",
"again",
"with",
... | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-less-commons/src/main/java/com/helger/lesscommons/charset/StringEncoder.java#L112-L176 |
136,899 | phax/ph-commons | ph-less-commons/src/main/java/com/helger/lesscommons/charset/StringEncoder.java | StringEncoder.getAsNewByteBuffer | @Nonnull
public ByteBuffer getAsNewByteBuffer (@Nonnull final String sSource)
{
// Optimized for 1 byte per character strings (ASCII)
ByteBuffer ret = ByteBuffer.allocate (sSource.length () + BUFFER_EXTRA_BYTES);
while (encode (sSource, ret).isContinue ())
{
// need a larger buffer
// estimate the average bytes per character from the current sample
final int nCharsConverted = _getCharsConverted ();
double dBytesPerChar;
if (nCharsConverted > 0)
{
dBytesPerChar = ret.position () / (double) nCharsConverted;
}
else
{
// charsConverted can be 0 if the initial buffer is smaller than one
// character
dBytesPerChar = m_aEncoder.averageBytesPerChar ();
}
final int nCharsRemaining = sSource.length () - nCharsConverted;
assert nCharsRemaining > 0;
final int nBytesRemaining = (int) (nCharsRemaining * dBytesPerChar + 0.5);
final int nPos = ret.position ();
final ByteBuffer aNewBuffer = ByteBuffer.allocate (ret.position () + nBytesRemaining + BUFFER_EXTRA_BYTES);
ret.flip ();
aNewBuffer.put (ret);
aNewBuffer.position (nPos);
ret = aNewBuffer;
}
// Set the buffer for reading and finish
ret.flip ();
return ret;
} | java | @Nonnull
public ByteBuffer getAsNewByteBuffer (@Nonnull final String sSource)
{
// Optimized for 1 byte per character strings (ASCII)
ByteBuffer ret = ByteBuffer.allocate (sSource.length () + BUFFER_EXTRA_BYTES);
while (encode (sSource, ret).isContinue ())
{
// need a larger buffer
// estimate the average bytes per character from the current sample
final int nCharsConverted = _getCharsConverted ();
double dBytesPerChar;
if (nCharsConverted > 0)
{
dBytesPerChar = ret.position () / (double) nCharsConverted;
}
else
{
// charsConverted can be 0 if the initial buffer is smaller than one
// character
dBytesPerChar = m_aEncoder.averageBytesPerChar ();
}
final int nCharsRemaining = sSource.length () - nCharsConverted;
assert nCharsRemaining > 0;
final int nBytesRemaining = (int) (nCharsRemaining * dBytesPerChar + 0.5);
final int nPos = ret.position ();
final ByteBuffer aNewBuffer = ByteBuffer.allocate (ret.position () + nBytesRemaining + BUFFER_EXTRA_BYTES);
ret.flip ();
aNewBuffer.put (ret);
aNewBuffer.position (nPos);
ret = aNewBuffer;
}
// Set the buffer for reading and finish
ret.flip ();
return ret;
} | [
"@",
"Nonnull",
"public",
"ByteBuffer",
"getAsNewByteBuffer",
"(",
"@",
"Nonnull",
"final",
"String",
"sSource",
")",
"{",
"// Optimized for 1 byte per character strings (ASCII)",
"ByteBuffer",
"ret",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"sSource",
".",
"length",
... | Returns a ByteBuffer containing the encoded version of source. The position
of the ByteBuffer will be 0, the limit is the length of the string. The
capacity of the ByteBuffer may be larger than the string.
@param sSource
Source string
@return The new byte buffer | [
"Returns",
"a",
"ByteBuffer",
"containing",
"the",
"encoded",
"version",
"of",
"source",
".",
"The",
"position",
"of",
"the",
"ByteBuffer",
"will",
"be",
"0",
"the",
"limit",
"is",
"the",
"length",
"of",
"the",
"string",
".",
"The",
"capacity",
"of",
"the"... | d28c03565f44a0b804d96028d0969f9bb38c4313 | https://github.com/phax/ph-commons/blob/d28c03565f44a0b804d96028d0969f9bb38c4313/ph-less-commons/src/main/java/com/helger/lesscommons/charset/StringEncoder.java#L195-L233 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.