repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
probedock/probedock-java | src/main/java/io/probedock/client/common/utils/PackageMatcher.java | PackageMatcher.match | public static Map.Entry<String, String> match(Map<String, String> categoriesByPackage, String pkg) {
if (categoriesByPackage != null && pkg != null) {
for (Map.Entry<String, String> e : categoriesByPackage.entrySet()) {
if (Minimatch.minimatch(pkg.replaceAll("\\.", "/"), e.getKey().replaceAll("\\.", "/"))) {
return e;
}
}
}
return null;
} | java | public static Map.Entry<String, String> match(Map<String, String> categoriesByPackage, String pkg) {
if (categoriesByPackage != null && pkg != null) {
for (Map.Entry<String, String> e : categoriesByPackage.entrySet()) {
if (Minimatch.minimatch(pkg.replaceAll("\\.", "/"), e.getKey().replaceAll("\\.", "/"))) {
return e;
}
}
}
return null;
} | [
"public",
"static",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"match",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"categoriesByPackage",
",",
"String",
"pkg",
")",
"{",
"if",
"(",
"categoriesByPackage",
"!=",
"null",
"&&",
"pkg",
"!=",
... | Check if there is a pattern in the map that match the given package
@param categoriesByPackage The map of package patterns
@param pkg The package to check against
@return The entry with the corresponding match or null if no match | [
"Check",
"if",
"there",
"is",
"a",
"pattern",
"in",
"the",
"map",
"that",
"match",
"the",
"given",
"package"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/common/utils/PackageMatcher.java#L20-L30 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/LastModifiedServlet.java | LastModifiedServlet.getCachedLastModified | private static long getCachedLastModified(ServletContext servletContext, HeaderAndPath hap) {
// Get the cache
@SuppressWarnings("unchecked")
Map<HeaderAndPath,GetLastModifiedCacheValue> cache = (Map<HeaderAndPath,GetLastModifiedCacheValue>)servletContext.getAttribute(GET_LAST_MODIFIED_CACHE_ATTRIBUTE_NAME);
if(cache == null) {
// Create new cache
cache = new HashMap<>();
servletContext.setAttribute(GET_LAST_MODIFIED_CACHE_ATTRIBUTE_NAME, cache);
}
GetLastModifiedCacheValue cacheValue;
synchronized(cache) {
// Get the cache entry
cacheValue = cache.get(hap);
if(cacheValue==null) {
cacheValue = new GetLastModifiedCacheValue();
cache.put(hap, cacheValue);
}
}
synchronized(cacheValue) {
final long currentTime = System.currentTimeMillis();
if(cacheValue.isValid(currentTime)) {
return cacheValue.lastModified;
} else {
ServletContextCache servletContextCache = ServletContextCache.getCache(servletContext);
long lastModified = 0;
String realPath = servletContextCache.getRealPath(hap.path);
if(realPath != null) {
// Use File first
lastModified = new File(realPath).lastModified();
}
if(lastModified == 0) {
// Try URL
try {
URL resourceUrl = servletContextCache.getResource(hap.path);
if(resourceUrl != null) {
URLConnection conn = resourceUrl.openConnection();
conn.setAllowUserInteraction(false);
conn.setConnectTimeout(10);
conn.setDoInput(false);
conn.setDoOutput(false);
conn.setReadTimeout(10);
conn.setUseCaches(false);
lastModified = conn.getLastModified();
}
} catch(IOException e) {
// lastModified stays unmodified
}
}
// Store in cache
cacheValue.cacheTime = currentTime;
cacheValue.lastModified = lastModified;
return lastModified;
}
}
} | java | private static long getCachedLastModified(ServletContext servletContext, HeaderAndPath hap) {
// Get the cache
@SuppressWarnings("unchecked")
Map<HeaderAndPath,GetLastModifiedCacheValue> cache = (Map<HeaderAndPath,GetLastModifiedCacheValue>)servletContext.getAttribute(GET_LAST_MODIFIED_CACHE_ATTRIBUTE_NAME);
if(cache == null) {
// Create new cache
cache = new HashMap<>();
servletContext.setAttribute(GET_LAST_MODIFIED_CACHE_ATTRIBUTE_NAME, cache);
}
GetLastModifiedCacheValue cacheValue;
synchronized(cache) {
// Get the cache entry
cacheValue = cache.get(hap);
if(cacheValue==null) {
cacheValue = new GetLastModifiedCacheValue();
cache.put(hap, cacheValue);
}
}
synchronized(cacheValue) {
final long currentTime = System.currentTimeMillis();
if(cacheValue.isValid(currentTime)) {
return cacheValue.lastModified;
} else {
ServletContextCache servletContextCache = ServletContextCache.getCache(servletContext);
long lastModified = 0;
String realPath = servletContextCache.getRealPath(hap.path);
if(realPath != null) {
// Use File first
lastModified = new File(realPath).lastModified();
}
if(lastModified == 0) {
// Try URL
try {
URL resourceUrl = servletContextCache.getResource(hap.path);
if(resourceUrl != null) {
URLConnection conn = resourceUrl.openConnection();
conn.setAllowUserInteraction(false);
conn.setConnectTimeout(10);
conn.setDoInput(false);
conn.setDoOutput(false);
conn.setReadTimeout(10);
conn.setUseCaches(false);
lastModified = conn.getLastModified();
}
} catch(IOException e) {
// lastModified stays unmodified
}
}
// Store in cache
cacheValue.cacheTime = currentTime;
cacheValue.lastModified = lastModified;
return lastModified;
}
}
} | [
"private",
"static",
"long",
"getCachedLastModified",
"(",
"ServletContext",
"servletContext",
",",
"HeaderAndPath",
"hap",
")",
"{",
"// Get the cache",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"HeaderAndPath",
",",
"GetLastModifiedCacheValue",
"... | Gets a modified time from either a file or URL.
Caches results for up to a second. | [
"Gets",
"a",
"modified",
"time",
"from",
"either",
"a",
"file",
"or",
"URL",
".",
"Caches",
"results",
"for",
"up",
"to",
"a",
"second",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/LastModifiedServlet.java#L331-L385 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/LastModifiedServlet.java | LastModifiedServlet.getLastModified | public static long getLastModified(ServletContext servletContext, HttpServletRequest request, String path) {
return getLastModified(
servletContext,
request,
path,
FileUtils.getExtension(path)
);
} | java | public static long getLastModified(ServletContext servletContext, HttpServletRequest request, String path) {
return getLastModified(
servletContext,
request,
path,
FileUtils.getExtension(path)
);
} | [
"public",
"static",
"long",
"getLastModified",
"(",
"ServletContext",
"servletContext",
",",
"HttpServletRequest",
"request",
",",
"String",
"path",
")",
"{",
"return",
"getLastModified",
"(",
"servletContext",
",",
"request",
",",
"path",
",",
"FileUtils",
".",
"... | Automatically determines extension from path.
@see #getLastModified(javax.servlet.ServletContext, java.lang.String, java.lang.String) | [
"Automatically",
"determines",
"extension",
"from",
"path",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/LastModifiedServlet.java#L421-L428 | train |
aoindustries/semanticcms-core-sitemap | src/main/java/com/semanticcms/core/sitemap/SiteMapIndexServlet.java | SiteMapIndexServlet.getLastModified | @Override
protected long getLastModified(HttpServletRequest req) {
try {
ReadableInstant mostRecent = null;
for(
Tuple2<Book,ReadableInstant> sitemapBook
: getSitemapBooks(
getServletContext(),
req,
(HttpServletResponse)req.getAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE)
)
) {
ReadableInstant lastModified = sitemapBook.getElement2();
// If any single book is unknown, the overall result is unknown
if(lastModified == null) {
mostRecent = null;
break;
}
if(
mostRecent == null
|| (lastModified.compareTo(mostRecent) > 0)
) {
mostRecent = lastModified;
}
}
return mostRecent == null ? -1 : mostRecent.getMillis();
} catch(ServletException | IOException e) {
log("getLastModified failed", e);
return -1;
}
} | java | @Override
protected long getLastModified(HttpServletRequest req) {
try {
ReadableInstant mostRecent = null;
for(
Tuple2<Book,ReadableInstant> sitemapBook
: getSitemapBooks(
getServletContext(),
req,
(HttpServletResponse)req.getAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE)
)
) {
ReadableInstant lastModified = sitemapBook.getElement2();
// If any single book is unknown, the overall result is unknown
if(lastModified == null) {
mostRecent = null;
break;
}
if(
mostRecent == null
|| (lastModified.compareTo(mostRecent) > 0)
) {
mostRecent = lastModified;
}
}
return mostRecent == null ? -1 : mostRecent.getMillis();
} catch(ServletException | IOException e) {
log("getLastModified failed", e);
return -1;
}
} | [
"@",
"Override",
"protected",
"long",
"getLastModified",
"(",
"HttpServletRequest",
"req",
")",
"{",
"try",
"{",
"ReadableInstant",
"mostRecent",
"=",
"null",
";",
"for",
"(",
"Tuple2",
"<",
"Book",
",",
"ReadableInstant",
">",
"sitemapBook",
":",
"getSitemapBoo... | Last modified is known only when the last modified is known for all books,
and it is the most recent of all the per-book last modified. | [
"Last",
"modified",
"is",
"known",
"only",
"when",
"the",
"last",
"modified",
"is",
"known",
"for",
"all",
"books",
"and",
"it",
"is",
"the",
"most",
"recent",
"of",
"all",
"the",
"per",
"-",
"book",
"last",
"modified",
"."
] | 564f77bc8b14572942903126dfd99e400bc11f85 | https://github.com/aoindustries/semanticcms-core-sitemap/blob/564f77bc8b14572942903126dfd99e400bc11f85/src/main/java/com/semanticcms/core/sitemap/SiteMapIndexServlet.java#L318-L348 | train |
aoindustries/semanticcms-core-sitemap | src/main/java/com/semanticcms/core/sitemap/SiteMapIndexServlet.java | SiteMapIndexServlet.hasSiteMapUrl | private static boolean hasSiteMapUrl(
final ServletContext servletContext,
final HttpServletRequest req,
final HttpServletResponse resp,
final SortedSet<View> views,
final Book book,
PageRef pageRef
) throws ServletException, IOException {
Boolean result = CapturePage.traversePagesAnyOrder(
servletContext,
req,
resp,
pageRef,
CaptureLevel.META,
new CapturePage.PageHandler<Boolean>() {
@Override
public Boolean handlePage(Page page) throws ServletException, IOException {
// TODO: Chance for more concurrency here by view?
for(View view : views) {
if(
view.getAllowRobots(servletContext, req, resp, page)
&& view.isApplicable(servletContext, req, resp, page)
) {
return true;
}
}
return null;
}
},
new CapturePage.TraversalEdges() {
@Override
public Set<ChildRef> getEdges(Page page) {
return page.getChildRefs();
}
},
new CapturePage.EdgeFilter() {
@Override
public boolean applyEdge(PageRef childPage) {
return book.getBookRef().equals(childPage.getBookRef());
}
}
);
assert result == null || result : "Should always be null or true";
return result != null;
} | java | private static boolean hasSiteMapUrl(
final ServletContext servletContext,
final HttpServletRequest req,
final HttpServletResponse resp,
final SortedSet<View> views,
final Book book,
PageRef pageRef
) throws ServletException, IOException {
Boolean result = CapturePage.traversePagesAnyOrder(
servletContext,
req,
resp,
pageRef,
CaptureLevel.META,
new CapturePage.PageHandler<Boolean>() {
@Override
public Boolean handlePage(Page page) throws ServletException, IOException {
// TODO: Chance for more concurrency here by view?
for(View view : views) {
if(
view.getAllowRobots(servletContext, req, resp, page)
&& view.isApplicable(servletContext, req, resp, page)
) {
return true;
}
}
return null;
}
},
new CapturePage.TraversalEdges() {
@Override
public Set<ChildRef> getEdges(Page page) {
return page.getChildRefs();
}
},
new CapturePage.EdgeFilter() {
@Override
public boolean applyEdge(PageRef childPage) {
return book.getBookRef().equals(childPage.getBookRef());
}
}
);
assert result == null || result : "Should always be null or true";
return result != null;
} | [
"private",
"static",
"boolean",
"hasSiteMapUrl",
"(",
"final",
"ServletContext",
"servletContext",
",",
"final",
"HttpServletRequest",
"req",
",",
"final",
"HttpServletResponse",
"resp",
",",
"final",
"SortedSet",
"<",
"View",
">",
"views",
",",
"final",
"Book",
"... | Checks if the sitemap has at least one page.
This version implemented as a traversal. | [
"Checks",
"if",
"the",
"sitemap",
"has",
"at",
"least",
"one",
"page",
".",
"This",
"version",
"implemented",
"as",
"a",
"traversal",
"."
] | 564f77bc8b14572942903126dfd99e400bc11f85 | https://github.com/aoindustries/semanticcms-core-sitemap/blob/564f77bc8b14572942903126dfd99e400bc11f85/src/main/java/com/semanticcms/core/sitemap/SiteMapIndexServlet.java#L378-L422 | train |
bremersee/sms | src/main/java/org/bremersee/sms/GoyyaSmsService.java | GoyyaSmsService.getMessageType | protected String getMessageType(final String message) {
if (StringUtils.isBlank(defaultMessageType) || MESSAGE_TYPE_TEXT_VALUE
.equalsIgnoreCase(defaultMessageType)
|| MESSAGE_TYPE_LONG_TEXT_VALUE.equalsIgnoreCase(defaultMessageType)) {
return message.length() > getMaxLengthOfOneSms() ? MESSAGE_TYPE_LONG_TEXT_VALUE
: MESSAGE_TYPE_TEXT_VALUE;
}
return defaultMessageType;
} | java | protected String getMessageType(final String message) {
if (StringUtils.isBlank(defaultMessageType) || MESSAGE_TYPE_TEXT_VALUE
.equalsIgnoreCase(defaultMessageType)
|| MESSAGE_TYPE_LONG_TEXT_VALUE.equalsIgnoreCase(defaultMessageType)) {
return message.length() > getMaxLengthOfOneSms() ? MESSAGE_TYPE_LONG_TEXT_VALUE
: MESSAGE_TYPE_TEXT_VALUE;
}
return defaultMessageType;
} | [
"protected",
"String",
"getMessageType",
"(",
"final",
"String",
"message",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"defaultMessageType",
")",
"||",
"MESSAGE_TYPE_TEXT_VALUE",
".",
"equalsIgnoreCase",
"(",
"defaultMessageType",
")",
"||",
"MESSAGE_T... | Returns the message type.
@param message the message
@return the message type | [
"Returns",
"the",
"message",
"type",
"."
] | 4e5e87ea98616dd316573b544f54cac56750d2f9 | https://github.com/bremersee/sms/blob/4e5e87ea98616dd316573b544f54cac56750d2f9/src/main/java/org/bremersee/sms/GoyyaSmsService.java#L376-L384 | train |
bremersee/sms | src/main/java/org/bremersee/sms/GoyyaSmsService.java | GoyyaSmsService.createSendTime | protected String createSendTime(final Date sendTime) {
if (sendTime == null || new Date(System.currentTimeMillis() + 1000L * 60L).after(sendTime)) {
return null;
}
String customSendTimePattern =
StringUtils.isBlank(this.sendTimePattern) ? DEFAULT_SEND_TIME_PATTERN
: this.sendTimePattern;
SimpleDateFormat sdf = new SimpleDateFormat(customSendTimePattern, Locale.GERMANY);
sdf.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
return sdf.format(sendTime);
} | java | protected String createSendTime(final Date sendTime) {
if (sendTime == null || new Date(System.currentTimeMillis() + 1000L * 60L).after(sendTime)) {
return null;
}
String customSendTimePattern =
StringUtils.isBlank(this.sendTimePattern) ? DEFAULT_SEND_TIME_PATTERN
: this.sendTimePattern;
SimpleDateFormat sdf = new SimpleDateFormat(customSendTimePattern, Locale.GERMANY);
sdf.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
return sdf.format(sendTime);
} | [
"protected",
"String",
"createSendTime",
"(",
"final",
"Date",
"sendTime",
")",
"{",
"if",
"(",
"sendTime",
"==",
"null",
"||",
"new",
"Date",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"1000L",
"*",
"60L",
")",
".",
"after",
"(",
"sendTime"... | Creates the send time URL parameter value.
@param sendTime the send time as {@link Date}
@return the send time URL parameter value | [
"Creates",
"the",
"send",
"time",
"URL",
"parameter",
"value",
"."
] | 4e5e87ea98616dd316573b544f54cac56750d2f9 | https://github.com/bremersee/sms/blob/4e5e87ea98616dd316573b544f54cac56750d2f9/src/main/java/org/bremersee/sms/GoyyaSmsService.java#L392-L402 | train |
bremersee/sms | src/main/java/org/bremersee/sms/GoyyaSmsService.java | GoyyaSmsService.createTrustAllManagers | protected TrustManager[] createTrustAllManagers() {
return new TrustManager[]{
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}};
} | java | protected TrustManager[] createTrustAllManagers() {
return new TrustManager[]{
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}};
} | [
"protected",
"TrustManager",
"[",
"]",
"createTrustAllManagers",
"(",
")",
"{",
"return",
"new",
"TrustManager",
"[",
"]",
"{",
"new",
"X509TrustManager",
"(",
")",
"{",
"@",
"Override",
"public",
"X509Certificate",
"[",
"]",
"getAcceptedIssuers",
"(",
")",
"{... | Creates an array of trust managers which trusts all X509 certificates.
@return the trust manager [ ] | [
"Creates",
"an",
"array",
"of",
"trust",
"managers",
"which",
"trusts",
"all",
"X509",
"certificates",
"."
] | 4e5e87ea98616dd316573b544f54cac56750d2f9 | https://github.com/bremersee/sms/blob/4e5e87ea98616dd316573b544f54cac56750d2f9/src/main/java/org/bremersee/sms/GoyyaSmsService.java#L464-L482 | train |
bremersee/sms | src/main/java/org/bremersee/sms/GoyyaSmsService.java | GoyyaSmsService.encode | private String encode(final String value, final Charset charset) {
if (StringUtils.isBlank(value)) {
return "";
}
try {
return URLEncoder.encode(value, charset.name());
} catch (UnsupportedEncodingException e) {
return value;
}
} | java | private String encode(final String value, final Charset charset) {
if (StringUtils.isBlank(value)) {
return "";
}
try {
return URLEncoder.encode(value, charset.name());
} catch (UnsupportedEncodingException e) {
return value;
}
} | [
"private",
"String",
"encode",
"(",
"final",
"String",
"value",
",",
"final",
"Charset",
"charset",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"value",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"try",
"{",
"return",
"URLEncoder",
".",
"e... | Encode query parameter.
@param value the parameter value
@param charset the charset
@return the encoded parameter value | [
"Encode",
"query",
"parameter",
"."
] | 4e5e87ea98616dd316573b544f54cac56750d2f9 | https://github.com/bremersee/sms/blob/4e5e87ea98616dd316573b544f54cac56750d2f9/src/main/java/org/bremersee/sms/GoyyaSmsService.java#L491-L501 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java | SourceMapGenerator.fromSourceMap | public static SourceMapGenerator fromSourceMap(SourceMapConsumer aSourceMapConsumer) {
String sourceRoot = aSourceMapConsumer.sourceRoot;
SourceMapGenerator generator = new SourceMapGenerator(aSourceMapConsumer.file, sourceRoot);
aSourceMapConsumer.eachMapping().forEach(mapping -> {
Mapping newMapping = new Mapping(mapping.generated);
if (mapping.source != null) {
newMapping.source = mapping.source;
if (sourceRoot != null) {
newMapping.source = Util.relative(sourceRoot, newMapping.source);
}
newMapping.original = mapping.original;
if (mapping.name != null) {
newMapping.name = mapping.name;
}
}
generator.addMapping(newMapping);
});
aSourceMapConsumer.sources().stream().forEach(sourceFile -> {
String content = aSourceMapConsumer.sourceContentFor(sourceFile, null);
if (content != null) {
generator.setSourceContent(sourceFile, content);
}
});
return generator;
} | java | public static SourceMapGenerator fromSourceMap(SourceMapConsumer aSourceMapConsumer) {
String sourceRoot = aSourceMapConsumer.sourceRoot;
SourceMapGenerator generator = new SourceMapGenerator(aSourceMapConsumer.file, sourceRoot);
aSourceMapConsumer.eachMapping().forEach(mapping -> {
Mapping newMapping = new Mapping(mapping.generated);
if (mapping.source != null) {
newMapping.source = mapping.source;
if (sourceRoot != null) {
newMapping.source = Util.relative(sourceRoot, newMapping.source);
}
newMapping.original = mapping.original;
if (mapping.name != null) {
newMapping.name = mapping.name;
}
}
generator.addMapping(newMapping);
});
aSourceMapConsumer.sources().stream().forEach(sourceFile -> {
String content = aSourceMapConsumer.sourceContentFor(sourceFile, null);
if (content != null) {
generator.setSourceContent(sourceFile, content);
}
});
return generator;
} | [
"public",
"static",
"SourceMapGenerator",
"fromSourceMap",
"(",
"SourceMapConsumer",
"aSourceMapConsumer",
")",
"{",
"String",
"sourceRoot",
"=",
"aSourceMapConsumer",
".",
"sourceRoot",
";",
"SourceMapGenerator",
"generator",
"=",
"new",
"SourceMapGenerator",
"(",
"aSour... | Creates a new SourceMapGenerator based on a SourceMapConsumer
@param aSourceMapConsumer
The SourceMap. | [
"Creates",
"a",
"new",
"SourceMapGenerator",
"based",
"on",
"a",
"SourceMapConsumer"
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java#L57-L81 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java | SourceMapGenerator.setSourceContent | public void setSourceContent(String aSourceFile, String aSourceContent) {
String source = aSourceFile;
if (this._sourceRoot != null) {
source = Util.relative(this._sourceRoot, source);
}
if (aSourceContent != null) {
// Add the source content to the _sourcesContents map.
// Create a new _sourcesContents map if the property is null.
if (this._sourcesContents == null) {
this._sourcesContents = new HashMap<>();
}
this._sourcesContents.put(source, aSourceContent);
} else if (this._sourcesContents != null) {
// Remove the source file from the _sourcesContents map.
// If the _sourcesContents map is empty, set the property to null.
this._sourcesContents.remove(source);
if (this._sourcesContents.isEmpty()) {
this._sourcesContents = null;
}
}
} | java | public void setSourceContent(String aSourceFile, String aSourceContent) {
String source = aSourceFile;
if (this._sourceRoot != null) {
source = Util.relative(this._sourceRoot, source);
}
if (aSourceContent != null) {
// Add the source content to the _sourcesContents map.
// Create a new _sourcesContents map if the property is null.
if (this._sourcesContents == null) {
this._sourcesContents = new HashMap<>();
}
this._sourcesContents.put(source, aSourceContent);
} else if (this._sourcesContents != null) {
// Remove the source file from the _sourcesContents map.
// If the _sourcesContents map is empty, set the property to null.
this._sourcesContents.remove(source);
if (this._sourcesContents.isEmpty()) {
this._sourcesContents = null;
}
}
} | [
"public",
"void",
"setSourceContent",
"(",
"String",
"aSourceFile",
",",
"String",
"aSourceContent",
")",
"{",
"String",
"source",
"=",
"aSourceFile",
";",
"if",
"(",
"this",
".",
"_sourceRoot",
"!=",
"null",
")",
"{",
"source",
"=",
"Util",
".",
"relative",... | Set the source content for a source file. | [
"Set",
"the",
"source",
"content",
"for",
"a",
"source",
"file",
"."
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java#L111-L132 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java | SourceMapGenerator.serializeMappings | private String serializeMappings() {
int previousGeneratedColumn = 0;
int previousGeneratedLine = 1;
int previousOriginalColumn = 0;
int previousOriginalLine = 0;
int previousName = 0;
int previousSource = 0;
String result = "";
Mapping mapping;
int nameIdx;
int sourceIdx;
List<Mapping> mappings = this._mappings.toArray();
for (int i = 0, len = mappings.size(); i < len; i++) {
mapping = mappings.get(i);
if (mapping.generated.line != previousGeneratedLine) {
previousGeneratedColumn = 0;
while (mapping.generated.line != previousGeneratedLine) {
result += ';';
previousGeneratedLine++;
}
} else {
if (i > 0) {
if (Util.compareByGeneratedPositionsInflated(mapping, mappings.get(i - 1)) == 0) {
continue;
}
result += ',';
}
}
result += Base64VLQ.encode(mapping.generated.column - previousGeneratedColumn);
previousGeneratedColumn = mapping.generated.column;
if (mapping.source != null) {
sourceIdx = this._sources.indexOf(mapping.source);
result += Base64VLQ.encode(sourceIdx - previousSource);
previousSource = sourceIdx;
// lines are stored 0-based in SourceMap spec version 3
result += Base64VLQ.encode(mapping.original.line - 1 - previousOriginalLine);
previousOriginalLine = mapping.original.line - 1;
result += Base64VLQ.encode(mapping.original.column - previousOriginalColumn);
previousOriginalColumn = mapping.original.column;
if (mapping.name != null) {
nameIdx = this._names.indexOf(mapping.name);
result += Base64VLQ.encode(nameIdx - previousName);
previousName = nameIdx;
}
}
}
return result;
} | java | private String serializeMappings() {
int previousGeneratedColumn = 0;
int previousGeneratedLine = 1;
int previousOriginalColumn = 0;
int previousOriginalLine = 0;
int previousName = 0;
int previousSource = 0;
String result = "";
Mapping mapping;
int nameIdx;
int sourceIdx;
List<Mapping> mappings = this._mappings.toArray();
for (int i = 0, len = mappings.size(); i < len; i++) {
mapping = mappings.get(i);
if (mapping.generated.line != previousGeneratedLine) {
previousGeneratedColumn = 0;
while (mapping.generated.line != previousGeneratedLine) {
result += ';';
previousGeneratedLine++;
}
} else {
if (i > 0) {
if (Util.compareByGeneratedPositionsInflated(mapping, mappings.get(i - 1)) == 0) {
continue;
}
result += ',';
}
}
result += Base64VLQ.encode(mapping.generated.column - previousGeneratedColumn);
previousGeneratedColumn = mapping.generated.column;
if (mapping.source != null) {
sourceIdx = this._sources.indexOf(mapping.source);
result += Base64VLQ.encode(sourceIdx - previousSource);
previousSource = sourceIdx;
// lines are stored 0-based in SourceMap spec version 3
result += Base64VLQ.encode(mapping.original.line - 1 - previousOriginalLine);
previousOriginalLine = mapping.original.line - 1;
result += Base64VLQ.encode(mapping.original.column - previousOriginalColumn);
previousOriginalColumn = mapping.original.column;
if (mapping.name != null) {
nameIdx = this._names.indexOf(mapping.name);
result += Base64VLQ.encode(nameIdx - previousName);
previousName = nameIdx;
}
}
}
return result;
} | [
"private",
"String",
"serializeMappings",
"(",
")",
"{",
"int",
"previousGeneratedColumn",
"=",
"0",
";",
"int",
"previousGeneratedLine",
"=",
"1",
";",
"int",
"previousOriginalColumn",
"=",
"0",
";",
"int",
"previousOriginalLine",
"=",
"0",
";",
"int",
"previou... | Serialize the accumulated mappings in to the stream of base 64 VLQs specified by the source map format. | [
"Serialize",
"the",
"accumulated",
"mappings",
"in",
"to",
"the",
"stream",
"of",
"base",
"64",
"VLQs",
"specified",
"by",
"the",
"source",
"map",
"format",
"."
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java#L221-L275 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java | SourceMapGenerator.toJSON | public SourceMap toJSON() {
SourceMap map = new SourceMap();
map.version = this._version;
map.sources = this._sources.toArray();
map.names = this._names.toArray();
map.mappings = serializeMappings();
map.file = this._file;
map.sourceRoot = this._sourceRoot;
if (this._sourcesContents != null) {
map.sourcesContent = _generateSourcesContent(map.sources, this._sourceRoot);
}
return map;
} | java | public SourceMap toJSON() {
SourceMap map = new SourceMap();
map.version = this._version;
map.sources = this._sources.toArray();
map.names = this._names.toArray();
map.mappings = serializeMappings();
map.file = this._file;
map.sourceRoot = this._sourceRoot;
if (this._sourcesContents != null) {
map.sourcesContent = _generateSourcesContent(map.sources, this._sourceRoot);
}
return map;
} | [
"public",
"SourceMap",
"toJSON",
"(",
")",
"{",
"SourceMap",
"map",
"=",
"new",
"SourceMap",
"(",
")",
";",
"map",
".",
"version",
"=",
"this",
".",
"_version",
";",
"map",
".",
"sources",
"=",
"this",
".",
"_sources",
".",
"toArray",
"(",
")",
";",
... | Externalize the source map. | [
"Externalize",
"the",
"source",
"map",
"."
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/SourceMapGenerator.java#L292-L304 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/cache/BackgroundCache.java | BackgroundCache.get | public Result<V,E> get(
K key,
Refresher<? super K,? extends V,? extends E> refresher
) {
Result<V,E> result = get(key);
if(result == null) result = put(key, refresher);
return result;
} | java | public Result<V,E> get(
K key,
Refresher<? super K,? extends V,? extends E> refresher
) {
Result<V,E> result = get(key);
if(result == null) result = put(key, refresher);
return result;
} | [
"public",
"Result",
"<",
"V",
",",
"E",
">",
"get",
"(",
"K",
"key",
",",
"Refresher",
"<",
"?",
"super",
"K",
",",
"?",
"extends",
"V",
",",
"?",
"extends",
"E",
">",
"refresher",
")",
"{",
"Result",
"<",
"V",
",",
"E",
">",
"result",
"=",
"... | Gets the value if currently in the cache. If not,
Runs the refresher immediately to obtain the result, then
places an entry into the cache.
@return The result obtained from either the cache or this refresher
@see #get(java.lang.Object)
@see #put(java.lang.Object, com.aoindustries.cache.BackgroundCache.Refresher) | [
"Gets",
"the",
"value",
"if",
"currently",
"in",
"the",
"cache",
".",
"If",
"not",
"Runs",
"the",
"refresher",
"immediately",
"to",
"obtain",
"the",
"result",
"then",
"places",
"an",
"entry",
"into",
"the",
"cache",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/cache/BackgroundCache.java#L288-L295 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/cache/BackgroundCache.java | BackgroundCache.get | public Result<V,E> get(K key) {
CacheEntry entry = map.get(key);
if(entry == null) {
return null;
} else {
return entry.getResult();
}
} | java | public Result<V,E> get(K key) {
CacheEntry entry = map.get(key);
if(entry == null) {
return null;
} else {
return entry.getResult();
}
} | [
"public",
"Result",
"<",
"V",
",",
"E",
">",
"get",
"(",
"K",
"key",
")",
"{",
"CacheEntry",
"entry",
"=",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
... | Gets a cached result for the given key, null if not cached.
Extends the expiration of the cache entry. | [
"Gets",
"a",
"cached",
"result",
"for",
"the",
"given",
"key",
"null",
"if",
"not",
"cached",
".",
"Extends",
"the",
"expiration",
"of",
"the",
"cache",
"entry",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/cache/BackgroundCache.java#L301-L308 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/cache/BackgroundCache.java | BackgroundCache.put | public Result<V,E> put(
K key,
Refresher<? super K,? extends V,? extends E> refresher
) {
Result<V,E> result = runRefresher(refresher, key);
put(key, refresher, result);
return result;
} | java | public Result<V,E> put(
K key,
Refresher<? super K,? extends V,? extends E> refresher
) {
Result<V,E> result = runRefresher(refresher, key);
put(key, refresher, result);
return result;
} | [
"public",
"Result",
"<",
"V",
",",
"E",
">",
"put",
"(",
"K",
"key",
",",
"Refresher",
"<",
"?",
"super",
"K",
",",
"?",
"extends",
"V",
",",
"?",
"extends",
"E",
">",
"refresher",
")",
"{",
"Result",
"<",
"V",
",",
"E",
">",
"result",
"=",
"... | Runs the refresher immediately to obtain the result, then
places an entry into the cache, replacing any existing entry under this key.
@return The result obtained from this refresher | [
"Runs",
"the",
"refresher",
"immediately",
"to",
"obtain",
"the",
"result",
"then",
"places",
"an",
"entry",
"into",
"the",
"cache",
"replacing",
"any",
"existing",
"entry",
"under",
"this",
"key",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/cache/BackgroundCache.java#L333-L340 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/cache/BackgroundCache.java | BackgroundCache.put | public void put(
K key,
Refresher<? super K,? extends V,? extends E> refresher,
V value
) {
put(key, refresher, new Result<V,E>(value));
} | java | public void put(
K key,
Refresher<? super K,? extends V,? extends E> refresher,
V value
) {
put(key, refresher, new Result<V,E>(value));
} | [
"public",
"void",
"put",
"(",
"K",
"key",
",",
"Refresher",
"<",
"?",
"super",
"K",
",",
"?",
"extends",
"V",
",",
"?",
"extends",
"E",
">",
"refresher",
",",
"V",
"value",
")",
"{",
"put",
"(",
"key",
",",
"refresher",
",",
"new",
"Result",
"<",... | Places a result into the cache, replacing any existing entry under this key. | [
"Places",
"a",
"result",
"into",
"the",
"cache",
"replacing",
"any",
"existing",
"entry",
"under",
"this",
"key",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/cache/BackgroundCache.java#L345-L351 | train |
aoindustries/semanticcms-core-taglib | src/main/java/com/semanticcms/core/taglib/NavigationTreeTag.java | NavigationTreeTag.doTag | @Override
public void doTag() throws JspTagException, IOException {
try {
final PageContext pageContext = (PageContext)getJspContext();
NavigationTreeRenderer.writeNavigationTree(
pageContext.getServletContext(),
pageContext.getELContext(),
(HttpServletRequest)pageContext.getRequest(),
(HttpServletResponse)pageContext.getResponse(),
pageContext.getOut(),
root,
skipRoot,
yuiConfig,
includeElements,
target,
thisDomain,
thisBook,
thisPage,
linksToDomain,
linksToBook,
linksToPage,
maxDepth
);
} catch(ServletException e) {
throw new JspTagException(e);
}
} | java | @Override
public void doTag() throws JspTagException, IOException {
try {
final PageContext pageContext = (PageContext)getJspContext();
NavigationTreeRenderer.writeNavigationTree(
pageContext.getServletContext(),
pageContext.getELContext(),
(HttpServletRequest)pageContext.getRequest(),
(HttpServletResponse)pageContext.getResponse(),
pageContext.getOut(),
root,
skipRoot,
yuiConfig,
includeElements,
target,
thisDomain,
thisBook,
thisPage,
linksToDomain,
linksToBook,
linksToPage,
maxDepth
);
} catch(ServletException e) {
throw new JspTagException(e);
}
} | [
"@",
"Override",
"public",
"void",
"doTag",
"(",
")",
"throws",
"JspTagException",
",",
"IOException",
"{",
"try",
"{",
"final",
"PageContext",
"pageContext",
"=",
"(",
"PageContext",
")",
"getJspContext",
"(",
")",
";",
"NavigationTreeRenderer",
".",
"writeNavi... | Creates the nested <ul> and <li> tags used by TreeView.
The first level is expanded.
<a href="http://developer.yahoo.com/yui/treeview/#start">http://developer.yahoo.com/yui/treeview/#start</a> | [
"Creates",
"the",
"nested",
"<",
";",
"ul>",
";",
"and",
"<",
";",
"li>",
";",
"tags",
"used",
"by",
"TreeView",
".",
"The",
"first",
"level",
"is",
"expanded",
"."
] | 2e6c5dd3b1299c6cc6a87a335302460c5c69c539 | https://github.com/aoindustries/semanticcms-core-taglib/blob/2e6c5dd3b1299c6cc6a87a335302460c5c69c539/src/main/java/com/semanticcms/core/taglib/NavigationTreeTag.java#L103-L129 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/BasicSourceMapConsumer.java | BasicSourceMapConsumer.fromSourceMap | public static BasicSourceMapConsumer fromSourceMap(SourceMapGenerator aSourceMap) {
BasicSourceMapConsumer smc = new BasicSourceMapConsumer();
ArraySet<String> names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
ArraySet<String> sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
smc.sourceRoot = aSourceMap._sourceRoot;
smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), smc.sourceRoot);
smc.file = aSourceMap._file;
// Because we are modifying the entries (by converting string sources and
// names to indices into the sources and names ArraySets), we have to make
// a copy of the entry or else bad things happen. Shared mutable state
// strikes again! See github issue #191.
List<Mapping> generatedMappings = new ArrayList<>(aSourceMap._mappings.toArray());
List<ParsedMapping> destGeneratedMappings = smc.__generatedMappings = new ArrayList<>();
List<ParsedMapping> destOriginalMappings = smc.__originalMappings = new ArrayList<>();
for (int i = 0, length = generatedMappings.size(); i < length; i++) {
Mapping srcMapping = generatedMappings.get(i);
ParsedMapping destMapping = new ParsedMapping();
destMapping.generatedLine = srcMapping.generated.line;
destMapping.generatedColumn = srcMapping.generated.column;
if (srcMapping.source != null) {
destMapping.source = sources.indexOf(srcMapping.source);
destMapping.originalLine = srcMapping.original.line;
destMapping.originalColumn = srcMapping.original.column;
if (srcMapping.name != null) {
destMapping.name = names.indexOf(srcMapping.name);
}
destOriginalMappings.add(destMapping);
}
destGeneratedMappings.add(destMapping);
}
Collections.sort(smc.__originalMappings, Util::compareByOriginalPositions);
return smc;
} | java | public static BasicSourceMapConsumer fromSourceMap(SourceMapGenerator aSourceMap) {
BasicSourceMapConsumer smc = new BasicSourceMapConsumer();
ArraySet<String> names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
ArraySet<String> sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
smc.sourceRoot = aSourceMap._sourceRoot;
smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), smc.sourceRoot);
smc.file = aSourceMap._file;
// Because we are modifying the entries (by converting string sources and
// names to indices into the sources and names ArraySets), we have to make
// a copy of the entry or else bad things happen. Shared mutable state
// strikes again! See github issue #191.
List<Mapping> generatedMappings = new ArrayList<>(aSourceMap._mappings.toArray());
List<ParsedMapping> destGeneratedMappings = smc.__generatedMappings = new ArrayList<>();
List<ParsedMapping> destOriginalMappings = smc.__originalMappings = new ArrayList<>();
for (int i = 0, length = generatedMappings.size(); i < length; i++) {
Mapping srcMapping = generatedMappings.get(i);
ParsedMapping destMapping = new ParsedMapping();
destMapping.generatedLine = srcMapping.generated.line;
destMapping.generatedColumn = srcMapping.generated.column;
if (srcMapping.source != null) {
destMapping.source = sources.indexOf(srcMapping.source);
destMapping.originalLine = srcMapping.original.line;
destMapping.originalColumn = srcMapping.original.column;
if (srcMapping.name != null) {
destMapping.name = names.indexOf(srcMapping.name);
}
destOriginalMappings.add(destMapping);
}
destGeneratedMappings.add(destMapping);
}
Collections.sort(smc.__originalMappings, Util::compareByOriginalPositions);
return smc;
} | [
"public",
"static",
"BasicSourceMapConsumer",
"fromSourceMap",
"(",
"SourceMapGenerator",
"aSourceMap",
")",
"{",
"BasicSourceMapConsumer",
"smc",
"=",
"new",
"BasicSourceMapConsumer",
"(",
")",
";",
"ArraySet",
"<",
"String",
">",
"names",
"=",
"smc",
".",
"_names"... | Create a BasicSourceMapConsumer from a SourceMapGenerator.
@param SourceMapGenerator
aSourceMap The source map that will be consumed.
@returns BasicSourceMapConsumer | [
"Create",
"a",
"BasicSourceMapConsumer",
"from",
"a",
"SourceMapGenerator",
"."
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/BasicSourceMapConsumer.java#L115-L155 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/BasicSourceMapConsumer.java | BasicSourceMapConsumer.computeColumnSpans | void computeColumnSpans() {
for (int index = 0; index < _generatedMappings().size(); ++index) {
ParsedMapping mapping = _generatedMappings().get(index);
// Mappings do not contain a field for the last generated columnt. We
// can come up with an optimistic estimate, however, by assuming that
// mappings are contiguous (i.e. given two consecutive mappings, the
// first mapping ends where the second one starts).
if (index + 1 < _generatedMappings().size()) {
ParsedMapping nextMapping = _generatedMappings().get(index + 1);
if (mapping.generatedLine == nextMapping.generatedLine) {
mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
continue;
}
}
// The last mapping for each line spans the entire line.
mapping.lastGeneratedColumn = Integer.MAX_VALUE;
}
} | java | void computeColumnSpans() {
for (int index = 0; index < _generatedMappings().size(); ++index) {
ParsedMapping mapping = _generatedMappings().get(index);
// Mappings do not contain a field for the last generated columnt. We
// can come up with an optimistic estimate, however, by assuming that
// mappings are contiguous (i.e. given two consecutive mappings, the
// first mapping ends where the second one starts).
if (index + 1 < _generatedMappings().size()) {
ParsedMapping nextMapping = _generatedMappings().get(index + 1);
if (mapping.generatedLine == nextMapping.generatedLine) {
mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
continue;
}
}
// The last mapping for each line spans the entire line.
mapping.lastGeneratedColumn = Integer.MAX_VALUE;
}
} | [
"void",
"computeColumnSpans",
"(",
")",
"{",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"_generatedMappings",
"(",
")",
".",
"size",
"(",
")",
";",
"++",
"index",
")",
"{",
"ParsedMapping",
"mapping",
"=",
"_generatedMappings",
"(",
")",
... | Compute the last column for each generated mapping. The last column is inclusive. | [
"Compute",
"the",
"last",
"column",
"for",
"each",
"generated",
"mapping",
".",
"The",
"last",
"column",
"is",
"inclusive",
"."
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/BasicSourceMapConsumer.java#L280-L300 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/BasicSourceMapConsumer.java | BasicSourceMapConsumer.hasContentsOfAllSources | @Override
public boolean hasContentsOfAllSources() {
if (sourcesContent == null) {
return false;
}
return this.sourcesContent.size() >= this._sources.size() && !this.sourcesContent.stream().anyMatch(sc -> sc == null);
} | java | @Override
public boolean hasContentsOfAllSources() {
if (sourcesContent == null) {
return false;
}
return this.sourcesContent.size() >= this._sources.size() && !this.sourcesContent.stream().anyMatch(sc -> sc == null);
} | [
"@",
"Override",
"public",
"boolean",
"hasContentsOfAllSources",
"(",
")",
"{",
"if",
"(",
"sourcesContent",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"this",
".",
"sourcesContent",
".",
"size",
"(",
")",
">=",
"this",
".",
"_sources",... | Return true if we have the source content for every source in the source map, false otherwise. | [
"Return",
"true",
"if",
"we",
"have",
"the",
"source",
"content",
"for",
"every",
"source",
"in",
"the",
"source",
"map",
"false",
"otherwise",
"."
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/BasicSourceMapConsumer.java#L358-L364 | train |
probedock/probedock-java | src/main/java/io/probedock/client/common/model/v1/ModelFactory.java | ModelFactory.createFingerprint | public static String createFingerprint(Class cl, Method m) {
return FingerprintGenerator.fingerprint(cl, m);
} | java | public static String createFingerprint(Class cl, Method m) {
return FingerprintGenerator.fingerprint(cl, m);
} | [
"public",
"static",
"String",
"createFingerprint",
"(",
"Class",
"cl",
",",
"Method",
"m",
")",
"{",
"return",
"FingerprintGenerator",
".",
"fingerprint",
"(",
"cl",
",",
"m",
")",
";",
"}"
] | Create fingerprint for java test method
@param cl The test class
@param m The test method
@return The fingerprint generated | [
"Create",
"fingerprint",
"for",
"java",
"test",
"method"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/common/model/v1/ModelFactory.java#L32-L34 | train |
probedock/probedock-java | src/main/java/io/probedock/client/common/model/v1/ModelFactory.java | ModelFactory.enrichContext | public static void enrichContext(Context context) {
context.setPostProperty(Context.MEMORY_TOTAL, Runtime.getRuntime().totalMemory());
context.setPostProperty(Context.MEMORY_FREE, Runtime.getRuntime().freeMemory());
context.setPostProperty(Context.MEMORY_USED, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
} | java | public static void enrichContext(Context context) {
context.setPostProperty(Context.MEMORY_TOTAL, Runtime.getRuntime().totalMemory());
context.setPostProperty(Context.MEMORY_FREE, Runtime.getRuntime().freeMemory());
context.setPostProperty(Context.MEMORY_USED, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
} | [
"public",
"static",
"void",
"enrichContext",
"(",
"Context",
"context",
")",
"{",
"context",
".",
"setPostProperty",
"(",
"Context",
".",
"MEMORY_TOTAL",
",",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"totalMemory",
"(",
")",
")",
";",
"context",
".",
"... | Enrich a context | [
"Enrich",
"a",
"context"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/common/model/v1/ModelFactory.java#L100-L104 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/version/PropertiesVersions.java | PropertiesVersions.getVersion | public Version getVersion(String product) throws IllegalArgumentException {
String three = properties.getProperty(product);
if(three==null) throw new IllegalArgumentException(accessor.getMessage("PropertiesVersions.getVersion.productNotFound", product));
return Version.valueOf(three+"."+getBuild());
} | java | public Version getVersion(String product) throws IllegalArgumentException {
String three = properties.getProperty(product);
if(three==null) throw new IllegalArgumentException(accessor.getMessage("PropertiesVersions.getVersion.productNotFound", product));
return Version.valueOf(three+"."+getBuild());
} | [
"public",
"Version",
"getVersion",
"(",
"String",
"product",
")",
"throws",
"IllegalArgumentException",
"{",
"String",
"three",
"=",
"properties",
".",
"getProperty",
"(",
"product",
")",
";",
"if",
"(",
"three",
"==",
"null",
")",
"throw",
"new",
"IllegalArgu... | Gets the version number for the provided product. | [
"Gets",
"the",
"version",
"number",
"for",
"the",
"provided",
"product",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/version/PropertiesVersions.java#L73-L77 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/version/PropertiesVersions.java | PropertiesVersions.getBuild | public int getBuild() throws IllegalArgumentException {
String build = properties.getProperty("build.number");
if(build==null) throw new IllegalArgumentException(accessor.getMessage("PropertiesVersions.getVersion.buildNotFound"));
return Integer.parseInt(build);
} | java | public int getBuild() throws IllegalArgumentException {
String build = properties.getProperty("build.number");
if(build==null) throw new IllegalArgumentException(accessor.getMessage("PropertiesVersions.getVersion.buildNotFound"));
return Integer.parseInt(build);
} | [
"public",
"int",
"getBuild",
"(",
")",
"throws",
"IllegalArgumentException",
"{",
"String",
"build",
"=",
"properties",
".",
"getProperty",
"(",
"\"build.number\"",
")",
";",
"if",
"(",
"build",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",... | Gets the build number that is applied to all products. | [
"Gets",
"the",
"build",
"number",
"that",
"is",
"applied",
"to",
"all",
"products",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/version/PropertiesVersions.java#L82-L86 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/io/FilesystemIterator.java | FilesystemIterator.getNextFiles | public int getNextFiles(final File[] files, final int batchSize) throws IOException {
int c=0;
while(c<batchSize) {
File file=getNextFile();
if(file==null) break;
files[c++]=file;
}
return c;
} | java | public int getNextFiles(final File[] files, final int batchSize) throws IOException {
int c=0;
while(c<batchSize) {
File file=getNextFile();
if(file==null) break;
files[c++]=file;
}
return c;
} | [
"public",
"int",
"getNextFiles",
"(",
"final",
"File",
"[",
"]",
"files",
",",
"final",
"int",
"batchSize",
")",
"throws",
"IOException",
"{",
"int",
"c",
"=",
"0",
";",
"while",
"(",
"c",
"<",
"batchSize",
")",
"{",
"File",
"file",
"=",
"getNextFile",... | Gets the next files, up to batchSize.
@return the number of files in the array, zero (0) indicates iteration has completed
@throws java.io.IOException | [
"Gets",
"the",
"next",
"files",
"up",
"to",
"batchSize",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/io/FilesystemIterator.java#L260-L268 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/io/FilesystemIterator.java | FilesystemIterator.isFilesystemRoot | protected boolean isFilesystemRoot(String filename) throws IOException {
String[] roots=getFilesystemRoots();
for(int c=0, len=roots.length;c<len;c++) {
if(roots[c].equals(filename)) return true;
}
return false;
} | java | protected boolean isFilesystemRoot(String filename) throws IOException {
String[] roots=getFilesystemRoots();
for(int c=0, len=roots.length;c<len;c++) {
if(roots[c].equals(filename)) return true;
}
return false;
} | [
"protected",
"boolean",
"isFilesystemRoot",
"(",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"String",
"[",
"]",
"roots",
"=",
"getFilesystemRoots",
"(",
")",
";",
"for",
"(",
"int",
"c",
"=",
"0",
",",
"len",
"=",
"roots",
".",
"length",
";... | Determines if a path is a possible file system root | [
"Determines",
"if",
"a",
"path",
"is",
"a",
"possible",
"file",
"system",
"root"
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/io/FilesystemIterator.java#L293-L299 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/io/FilesystemIterator.java | FilesystemIterator.getBestRule | private FilesystemIteratorRule getBestRule(final String filename) {
String longestPrefix = null;
FilesystemIteratorRule rule = null;
// First search the path and all of its parents for the first regular rule
String path = filename;
while(true) {
// Check the current path for an exact match
//System.out.println("DEBUG: Checking "+path);
rule = rules.get(path);
if(rule!=null) {
longestPrefix = path;
break;
}
// If done, break the loop
int pathLen = path.length();
if(pathLen==0) break;
int lastSlashPos = path.lastIndexOf(File.separatorChar);
if(lastSlashPos==-1) {
path = "";
} else if(lastSlashPos==(pathLen-1)) {
// If ends with a slash, remove that slash
path = path.substring(0, lastSlashPos);
} else {
// Otherwise, remove and leave the last slash
path = path.substring(0, lastSlashPos+1);
}
}
if(prefixRules!=null) {
// TODO: If there are many more prefix rules than the length of this filename, it will at some threshold
// be faster to do a map lookup for each possible length of the string.
// Would also only need to look down to longestPrefix
for(Map.Entry<String,FilesystemIteratorRule> entry : prefixRules.entrySet()) {
String prefix = entry.getKey();
if(
(longestPrefix==null || prefix.length()>longestPrefix.length())
&& filename.startsWith(prefix)
) {
//System.err.println("DEBUG: FilesystemIterator: getBestRule: filename="+filename+", prefix="+prefix+", longestPrefix="+longestPrefix);
longestPrefix = prefix;
rule = entry.getValue();
}
}
}
return rule;
} | java | private FilesystemIteratorRule getBestRule(final String filename) {
String longestPrefix = null;
FilesystemIteratorRule rule = null;
// First search the path and all of its parents for the first regular rule
String path = filename;
while(true) {
// Check the current path for an exact match
//System.out.println("DEBUG: Checking "+path);
rule = rules.get(path);
if(rule!=null) {
longestPrefix = path;
break;
}
// If done, break the loop
int pathLen = path.length();
if(pathLen==0) break;
int lastSlashPos = path.lastIndexOf(File.separatorChar);
if(lastSlashPos==-1) {
path = "";
} else if(lastSlashPos==(pathLen-1)) {
// If ends with a slash, remove that slash
path = path.substring(0, lastSlashPos);
} else {
// Otherwise, remove and leave the last slash
path = path.substring(0, lastSlashPos+1);
}
}
if(prefixRules!=null) {
// TODO: If there are many more prefix rules than the length of this filename, it will at some threshold
// be faster to do a map lookup for each possible length of the string.
// Would also only need to look down to longestPrefix
for(Map.Entry<String,FilesystemIteratorRule> entry : prefixRules.entrySet()) {
String prefix = entry.getKey();
if(
(longestPrefix==null || prefix.length()>longestPrefix.length())
&& filename.startsWith(prefix)
) {
//System.err.println("DEBUG: FilesystemIterator: getBestRule: filename="+filename+", prefix="+prefix+", longestPrefix="+longestPrefix);
longestPrefix = prefix;
rule = entry.getValue();
}
}
}
return rule;
} | [
"private",
"FilesystemIteratorRule",
"getBestRule",
"(",
"final",
"String",
"filename",
")",
"{",
"String",
"longestPrefix",
"=",
"null",
";",
"FilesystemIteratorRule",
"rule",
"=",
"null",
";",
"// First search the path and all of its parents for the first regular rule",
"St... | Gets the rule that best suits the provided filename. The rule is the longer
rule between the regular rules and the prefix rules.
The regular rules are scanned first by looking through the filename and then
all parents up to the root for the first match. These use Map lookups in the
set of rules so this should still perform well when there are many rules.
For example, when searching for the rule for /home/u/username/tmp/, this
will search:
<ol>
<li>/home/u/username/tmp/</li>
<li>/home/u/username/tmp</li>
<li>/home/u/username/</li>
<li>/home/u/username</li>
<li>/home/u/</li>
<li>/home/u</li>
<li>/home/</li>
<li>/home</li>
<li>/</li>
<li></li>
</ol>
Next, the entire list of prefix rules is searched, with the longest rule
being used if it is a longer match than that found in the regular rules. | [
"Gets",
"the",
"rule",
"that",
"best",
"suits",
"the",
"provided",
"filename",
".",
"The",
"rule",
"is",
"the",
"longer",
"rule",
"between",
"the",
"regular",
"rules",
"and",
"the",
"prefix",
"rules",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/io/FilesystemIterator.java#L326-L372 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/ServletContextCache.java | ServletContextCache.getCache | public static ServletContextCache getCache(ServletContext servletContext) {
ServletContextCache cache = (ServletContextCache)servletContext.getAttribute(ATTRIBUTE_KEY);
if(cache == null) {
// It is possible this is called during context initialization before the listener
cache = new ServletContextCache(servletContext);
servletContext.setAttribute(ATTRIBUTE_KEY, cache);
//throw new IllegalStateException("ServletContextCache not active in the provided ServletContext. Add context listener to web.xml?");
} else {
assert cache.servletContext == servletContext;
}
return cache;
} | java | public static ServletContextCache getCache(ServletContext servletContext) {
ServletContextCache cache = (ServletContextCache)servletContext.getAttribute(ATTRIBUTE_KEY);
if(cache == null) {
// It is possible this is called during context initialization before the listener
cache = new ServletContextCache(servletContext);
servletContext.setAttribute(ATTRIBUTE_KEY, cache);
//throw new IllegalStateException("ServletContextCache not active in the provided ServletContext. Add context listener to web.xml?");
} else {
assert cache.servletContext == servletContext;
}
return cache;
} | [
"public",
"static",
"ServletContextCache",
"getCache",
"(",
"ServletContext",
"servletContext",
")",
"{",
"ServletContextCache",
"cache",
"=",
"(",
"ServletContextCache",
")",
"servletContext",
".",
"getAttribute",
"(",
"ATTRIBUTE_KEY",
")",
";",
"if",
"(",
"cache",
... | Gets or creates the cache for the provided servlet context. | [
"Gets",
"or",
"creates",
"the",
"cache",
"for",
"the",
"provided",
"servlet",
"context",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/ServletContextCache.java#L52-L63 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/ServletContextCache.java | ServletContextCache.getResource | public URL getResource(String path) throws MalformedURLException {
Result<URL,MalformedURLException> result = getResourceCache.get(path, getResourceRefresher);
MalformedURLException exception = result.getException();
if(exception != null) throw exception;
return result.getValue();
} | java | public URL getResource(String path) throws MalformedURLException {
Result<URL,MalformedURLException> result = getResourceCache.get(path, getResourceRefresher);
MalformedURLException exception = result.getException();
if(exception != null) throw exception;
return result.getValue();
} | [
"public",
"URL",
"getResource",
"(",
"String",
"path",
")",
"throws",
"MalformedURLException",
"{",
"Result",
"<",
"URL",
",",
"MalformedURLException",
">",
"result",
"=",
"getResourceCache",
".",
"get",
"(",
"path",
",",
"getResourceRefresher",
")",
";",
"Malfo... | Gets the possibly cached URL. This URL is not copied and caller should not fiddle with
its state. Thank you Java for this not being immutable.
@see ServletContext#getResource(java.lang.String) | [
"Gets",
"the",
"possibly",
"cached",
"URL",
".",
"This",
"URL",
"is",
"not",
"copied",
"and",
"caller",
"should",
"not",
"fiddle",
"with",
"its",
"state",
".",
"Thank",
"you",
"Java",
"for",
"this",
"not",
"being",
"immutable",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/ServletContextCache.java#L98-L103 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/SortedIntArrayList.java | SortedIntArrayList.binarySearch | protected int binarySearch(int value) {
int left = 0;
int right = size-1;
while(left <= right) {
int mid = (left + right)>>1;
int midValue = elementData[mid];
if(value==midValue) return mid;
if(value<midValue) right = mid-1;
else left = mid+1;
}
return -(left+1);
} | java | protected int binarySearch(int value) {
int left = 0;
int right = size-1;
while(left <= right) {
int mid = (left + right)>>1;
int midValue = elementData[mid];
if(value==midValue) return mid;
if(value<midValue) right = mid-1;
else left = mid+1;
}
return -(left+1);
} | [
"protected",
"int",
"binarySearch",
"(",
"int",
"value",
")",
"{",
"int",
"left",
"=",
"0",
";",
"int",
"right",
"=",
"size",
"-",
"1",
";",
"while",
"(",
"left",
"<=",
"right",
")",
"{",
"int",
"mid",
"=",
"(",
"left",
"+",
"right",
")",
">>",
... | Performs a binary search for the provide value.
It will return any matching element, not necessarily
the first or the last. | [
"Performs",
"a",
"binary",
"search",
"for",
"the",
"provide",
"value",
".",
"It",
"will",
"return",
"any",
"matching",
"element",
"not",
"necessarily",
"the",
"first",
"or",
"the",
"last",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/SortedIntArrayList.java#L62-L73 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/SortedIntArrayList.java | SortedIntArrayList.indexOf | @Override
public int indexOf(int elem) {
// Find the location to insert the object at
int pos=binarySearch(elem);
// Not found
if(pos<0) return -1;
// Found one, iterate backwards to the first one
while(pos>0 && elementData[pos-1]==elem) pos--;
return pos;
} | java | @Override
public int indexOf(int elem) {
// Find the location to insert the object at
int pos=binarySearch(elem);
// Not found
if(pos<0) return -1;
// Found one, iterate backwards to the first one
while(pos>0 && elementData[pos-1]==elem) pos--;
return pos;
} | [
"@",
"Override",
"public",
"int",
"indexOf",
"(",
"int",
"elem",
")",
"{",
"// Find the location to insert the object at",
"int",
"pos",
"=",
"binarySearch",
"(",
"elem",
")",
";",
"// Not found",
"if",
"(",
"pos",
"<",
"0",
")",
"return",
"-",
"1",
";",
"... | Searches for the first occurrence of the given value.
@param elem the value
@return the index of the first occurrence of the argument in this
list; returns <tt>-1</tt> if the object is not found. | [
"Searches",
"for",
"the",
"first",
"occurrence",
"of",
"the",
"given",
"value",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/SortedIntArrayList.java#L82-L93 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/SortedIntArrayList.java | SortedIntArrayList.add | @Override
public boolean add(int o) {
// Shortcut for empty
int mySize=size();
if(mySize==0) {
super.add(o);
} else {
// Shortcut for adding to end (makes imports of already-sorted data operate at constant-time instead of logarithmic complexity)
if(o>=elementData[mySize-1]) {
super.add(o);
} else {
int index=binarySearch(o);
if(index<0) {
// Not found in list
super.add(-(index+1), o);
} else {
// Add after existing
super.add(index+1, o);
}
}
}
return true;
} | java | @Override
public boolean add(int o) {
// Shortcut for empty
int mySize=size();
if(mySize==0) {
super.add(o);
} else {
// Shortcut for adding to end (makes imports of already-sorted data operate at constant-time instead of logarithmic complexity)
if(o>=elementData[mySize-1]) {
super.add(o);
} else {
int index=binarySearch(o);
if(index<0) {
// Not found in list
super.add(-(index+1), o);
} else {
// Add after existing
super.add(index+1, o);
}
}
}
return true;
} | [
"@",
"Override",
"public",
"boolean",
"add",
"(",
"int",
"o",
")",
"{",
"// Shortcut for empty",
"int",
"mySize",
"=",
"size",
"(",
")",
";",
"if",
"(",
"mySize",
"==",
"0",
")",
"{",
"super",
".",
"add",
"(",
"o",
")",
";",
"}",
"else",
"{",
"//... | Adds the specified element in sorted position within this list.
@param o element to be appended to this list.
@return <tt>true</tt> (as per the general contract of Collection.add). | [
"Adds",
"the",
"specified",
"element",
"in",
"sorted",
"position",
"within",
"this",
"list",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/SortedIntArrayList.java#L130-L153 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/SortedIntArrayList.java | SortedIntArrayList.addAll | @Override
public boolean addAll(Collection<? extends Integer> c) {
Iterator<? extends Integer> iter=c.iterator();
boolean didOne=false;
while(iter.hasNext()) {
add(iter.next().intValue());
didOne=true;
}
return didOne;
} | java | @Override
public boolean addAll(Collection<? extends Integer> c) {
Iterator<? extends Integer> iter=c.iterator();
boolean didOne=false;
while(iter.hasNext()) {
add(iter.next().intValue());
didOne=true;
}
return didOne;
} | [
"@",
"Override",
"public",
"boolean",
"addAll",
"(",
"Collection",
"<",
"?",
"extends",
"Integer",
">",
"c",
")",
"{",
"Iterator",
"<",
"?",
"extends",
"Integer",
">",
"iter",
"=",
"c",
".",
"iterator",
"(",
")",
";",
"boolean",
"didOne",
"=",
"false",... | Adds all of the elements in the specified Collection and sorts during
the add. This may operate slowly as it is the same as individual
calls to the add method. | [
"Adds",
"all",
"of",
"the",
"elements",
"in",
"the",
"specified",
"Collection",
"and",
"sorts",
"during",
"the",
"add",
".",
"This",
"may",
"operate",
"slowly",
"as",
"it",
"is",
"the",
"same",
"as",
"individual",
"calls",
"to",
"the",
"add",
"method",
"... | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/SortedIntArrayList.java#L188-L197 | train |
bremersee/sms | src/main/java/org/bremersee/sms/model/SmsSendResponseDto.java | SmsSendResponseDto.isSuccessfullySent | @XmlElement(name = "successfullySent", required = true)
@JsonProperty(value = "successfullySent", required = true)
public boolean isSuccessfullySent() {
return successfullySent;
} | java | @XmlElement(name = "successfullySent", required = true)
@JsonProperty(value = "successfullySent", required = true)
public boolean isSuccessfullySent() {
return successfullySent;
} | [
"@",
"XmlElement",
"(",
"name",
"=",
"\"successfullySent\"",
",",
"required",
"=",
"true",
")",
"@",
"JsonProperty",
"(",
"value",
"=",
"\"successfullySent\"",
",",
"required",
"=",
"true",
")",
"public",
"boolean",
"isSuccessfullySent",
"(",
")",
"{",
"return... | Is successfully sent boolean.
@return the boolean | [
"Is",
"successfully",
"sent",
"boolean",
"."
] | 4e5e87ea98616dd316573b544f54cac56750d2f9 | https://github.com/bremersee/sms/blob/4e5e87ea98616dd316573b544f54cac56750d2f9/src/main/java/org/bremersee/sms/model/SmsSendResponseDto.java#L136-L140 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/persistent/LargeMappedPersistentBuffer.java | LargeMappedPersistentBuffer.get | @Override
// @NotThreadSafe
public byte get(long position) throws IOException {
return mappedBuffers.get(getBufferNum(position)).get(getIndex(position));
} | java | @Override
// @NotThreadSafe
public byte get(long position) throws IOException {
return mappedBuffers.get(getBufferNum(position)).get(getIndex(position));
} | [
"@",
"Override",
"// @NotThreadSafe",
"public",
"byte",
"get",
"(",
"long",
"position",
")",
"throws",
"IOException",
"{",
"return",
"mappedBuffers",
".",
"get",
"(",
"getBufferNum",
"(",
"position",
")",
")",
".",
"get",
"(",
"getIndex",
"(",
"position",
")... | Gets a single byte from the buffer. | [
"Gets",
"a",
"single",
"byte",
"from",
"the",
"buffer",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/persistent/LargeMappedPersistentBuffer.java#L251-L255 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/Includer.java | Includer.dispatchInclude | public static void dispatchInclude(RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SkipPageException {
final boolean isOutmostInclude = request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null;
if(logger.isLoggable(Level.FINE)) logger.log(
Level.FINE, "request={0}, isOutmostInclude={1}",
new Object[] {
request,
isOutmostInclude
}
);
try {
if(isOutmostInclude) request.setAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME, true);
dispatcher.include(request, response);
if(isOutmostInclude) {
// Set location header if set in attribute
String location = (String)request.getAttribute(LOCATION_REQUEST_ATTRIBUTE_NAME);
if(location != null) response.setHeader("Location", location);
// Call sendError from here if set in attributes
Integer status = (Integer)request.getAttribute(STATUS_REQUEST_ATTRIBUTE_NAME);
if(status != null) {
String message = (String)request.getAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME);
if(message == null) {
response.sendError(status);
} else {
response.sendError(status, message);
}
}
}
// Propagate effects of SkipPageException
if(request.getAttribute(PAGE_SKIPPED_REQUEST_ATTRIBUTE_NAME) != null) throw ServletUtil.SKIP_PAGE_EXCEPTION;
} finally {
if(isOutmostInclude) {
request.removeAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME);
request.removeAttribute(LOCATION_REQUEST_ATTRIBUTE_NAME);
request.removeAttribute(STATUS_REQUEST_ATTRIBUTE_NAME);
request.removeAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME);
// PAGE_SKIPPED_REQUEST_ATTRIBUTE_NAME not removed to propagate fully up the stack
}
}
} | java | public static void dispatchInclude(RequestDispatcher dispatcher, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SkipPageException {
final boolean isOutmostInclude = request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null;
if(logger.isLoggable(Level.FINE)) logger.log(
Level.FINE, "request={0}, isOutmostInclude={1}",
new Object[] {
request,
isOutmostInclude
}
);
try {
if(isOutmostInclude) request.setAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME, true);
dispatcher.include(request, response);
if(isOutmostInclude) {
// Set location header if set in attribute
String location = (String)request.getAttribute(LOCATION_REQUEST_ATTRIBUTE_NAME);
if(location != null) response.setHeader("Location", location);
// Call sendError from here if set in attributes
Integer status = (Integer)request.getAttribute(STATUS_REQUEST_ATTRIBUTE_NAME);
if(status != null) {
String message = (String)request.getAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME);
if(message == null) {
response.sendError(status);
} else {
response.sendError(status, message);
}
}
}
// Propagate effects of SkipPageException
if(request.getAttribute(PAGE_SKIPPED_REQUEST_ATTRIBUTE_NAME) != null) throw ServletUtil.SKIP_PAGE_EXCEPTION;
} finally {
if(isOutmostInclude) {
request.removeAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME);
request.removeAttribute(LOCATION_REQUEST_ATTRIBUTE_NAME);
request.removeAttribute(STATUS_REQUEST_ATTRIBUTE_NAME);
request.removeAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME);
// PAGE_SKIPPED_REQUEST_ATTRIBUTE_NAME not removed to propagate fully up the stack
}
}
} | [
"public",
"static",
"void",
"dispatchInclude",
"(",
"RequestDispatcher",
"dispatcher",
",",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
",",
"SkipPageException",
"{",
"final",
"boolean",
... | Performs the actual include, supporting propagation of SkipPageException and sendError. | [
"Performs",
"the",
"actual",
"include",
"supporting",
"propagation",
"of",
"SkipPageException",
"and",
"sendError",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/Includer.java#L82-L121 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/Includer.java | Includer.setLocation | public static void setLocation(HttpServletRequest request, HttpServletResponse response, String location) {
if(request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null) {
// Not included, setHeader directly
response.setHeader("Location", location);
} else {
// Is included, set attribute so top level tag can perform actual setHeader call
request.setAttribute(LOCATION_REQUEST_ATTRIBUTE_NAME, location);
}
} | java | public static void setLocation(HttpServletRequest request, HttpServletResponse response, String location) {
if(request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null) {
// Not included, setHeader directly
response.setHeader("Location", location);
} else {
// Is included, set attribute so top level tag can perform actual setHeader call
request.setAttribute(LOCATION_REQUEST_ATTRIBUTE_NAME, location);
}
} | [
"public",
"static",
"void",
"setLocation",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"location",
")",
"{",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"IS_INCLUDED_REQUEST_ATTRIBUTE_NAME",
")",
"==",
"null",
")"... | Sets a Location header. When not in an included page, calls setHeader directly.
When inside of an include will set request attribute so outermost include can call setHeader. | [
"Sets",
"a",
"Location",
"header",
".",
"When",
"not",
"in",
"an",
"included",
"page",
"calls",
"setHeader",
"directly",
".",
"When",
"inside",
"of",
"an",
"include",
"will",
"set",
"request",
"attribute",
"so",
"outermost",
"include",
"can",
"call",
"setHea... | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/Includer.java#L127-L135 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/Includer.java | Includer.sendError | public static void sendError(HttpServletRequest request, HttpServletResponse response, int status, String message) throws IOException {
if(request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null) {
// Not included, sendError directly
if(message == null) {
response.sendError(status);
} else {
response.sendError(status, message);
}
} else {
// Is included, set attributes so top level tag can perform actual sendError call
request.setAttribute(STATUS_REQUEST_ATTRIBUTE_NAME, status);
request.setAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME, message);
}
} | java | public static void sendError(HttpServletRequest request, HttpServletResponse response, int status, String message) throws IOException {
if(request.getAttribute(IS_INCLUDED_REQUEST_ATTRIBUTE_NAME) == null) {
// Not included, sendError directly
if(message == null) {
response.sendError(status);
} else {
response.sendError(status, message);
}
} else {
// Is included, set attributes so top level tag can perform actual sendError call
request.setAttribute(STATUS_REQUEST_ATTRIBUTE_NAME, status);
request.setAttribute(MESSAGE_REQUEST_ATTRIBUTE_NAME, message);
}
} | [
"public",
"static",
"void",
"sendError",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"int",
"status",
",",
"String",
"message",
")",
"throws",
"IOException",
"{",
"if",
"(",
"request",
".",
"getAttribute",
"(",
"IS_INCLUDED_R... | Sends an error. When not in an included page, calls sendError directly.
When inside of an include will set request attribute so outermost include can call sendError. | [
"Sends",
"an",
"error",
".",
"When",
"not",
"in",
"an",
"included",
"page",
"calls",
"sendError",
"directly",
".",
"When",
"inside",
"of",
"an",
"include",
"will",
"set",
"request",
"attribute",
"so",
"outermost",
"include",
"can",
"call",
"sendError",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/Includer.java#L141-L154 | train |
probedock/probedock-junit | src/main/java/io/probedock/client/junit/AbstractProbeListener.java | AbstractProbeListener.createAndlogStackTrace | protected String createAndlogStackTrace(Failure failure) {
StringBuilder sb = new StringBuilder();
if (failure.getMessage() != null && !failure.getMessage().isEmpty()) {
sb.append("Failure message: ").append(failure.getMessage());
}
if (failure.getException() != null) {
sb.append("\n\n");
sb.append(failure.getException().getClass().getCanonicalName()).append(": ").append(failure.getMessage()).append("\n");
for (StackTraceElement ste : failure.getException().getStackTrace()) {
sb.append("\tat ").append(ste.getClassName()).append(".").append(ste.getMethodName()).
append("(").append(ste.getFileName()).append(":").append(ste.getLineNumber()).append(")\n");
if (!fullStackTraces && ste.getClassName().equals(failure.getDescription().getClassName())) {
sb.append("\t...\n");
break;
}
}
if (fullStackTraces && failure.getException().getCause() != null) {
sb.append("Cause: ").append(failure.getException().getCause().getMessage()).append("\n");
for (StackTraceElement ste : failure.getException().getCause().getStackTrace()) {
sb.append("\tat ").append(ste.getClassName()).append(".").append(ste.getMethodName()).
append("(").append(ste.getFileName()).append(":").append(ste.getLineNumber()).append(")\n");
}
}
LOGGER.info("\n" + failure.getTestHeader() + "\n" + sb.toString());
}
return sb.toString();
} | java | protected String createAndlogStackTrace(Failure failure) {
StringBuilder sb = new StringBuilder();
if (failure.getMessage() != null && !failure.getMessage().isEmpty()) {
sb.append("Failure message: ").append(failure.getMessage());
}
if (failure.getException() != null) {
sb.append("\n\n");
sb.append(failure.getException().getClass().getCanonicalName()).append(": ").append(failure.getMessage()).append("\n");
for (StackTraceElement ste : failure.getException().getStackTrace()) {
sb.append("\tat ").append(ste.getClassName()).append(".").append(ste.getMethodName()).
append("(").append(ste.getFileName()).append(":").append(ste.getLineNumber()).append(")\n");
if (!fullStackTraces && ste.getClassName().equals(failure.getDescription().getClassName())) {
sb.append("\t...\n");
break;
}
}
if (fullStackTraces && failure.getException().getCause() != null) {
sb.append("Cause: ").append(failure.getException().getCause().getMessage()).append("\n");
for (StackTraceElement ste : failure.getException().getCause().getStackTrace()) {
sb.append("\tat ").append(ste.getClassName()).append(".").append(ste.getMethodName()).
append("(").append(ste.getFileName()).append(":").append(ste.getLineNumber()).append(")\n");
}
}
LOGGER.info("\n" + failure.getTestHeader() + "\n" + sb.toString());
}
return sb.toString();
} | [
"protected",
"String",
"createAndlogStackTrace",
"(",
"Failure",
"failure",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"failure",
".",
"getMessage",
"(",
")",
"!=",
"null",
"&&",
"!",
"failure",
".",
"getMessage",... | Build a stack trace string
@param failure The failure to get the exceptions and so on
@return The stack trace stringified | [
"Build",
"a",
"stack",
"trace",
"string"
] | a2163dfcb10e94f30d5cd20bca6c62e6e3cd1d46 | https://github.com/probedock/probedock-junit/blob/a2163dfcb10e94f30d5cd20bca6c62e6e3cd1d46/src/main/java/io/probedock/client/junit/AbstractProbeListener.java#L176-L210 | train |
probedock/probedock-junit | src/main/java/io/probedock/client/junit/AbstractProbeListener.java | AbstractProbeListener.getFingerprint | protected final String getFingerprint(Description description) {
return TestResultDataUtils.getFingerprint(description.getTestClass(), description.getMethodName());
} | java | protected final String getFingerprint(Description description) {
return TestResultDataUtils.getFingerprint(description.getTestClass(), description.getMethodName());
} | [
"protected",
"final",
"String",
"getFingerprint",
"(",
"Description",
"description",
")",
"{",
"return",
"TestResultDataUtils",
".",
"getFingerprint",
"(",
"description",
".",
"getTestClass",
"(",
")",
",",
"description",
".",
"getMethodName",
"(",
")",
")",
";",
... | Retrieve the fingerprint of a test based on its description
@param description The description
@return The fingerprint | [
"Retrieve",
"the",
"fingerprint",
"of",
"a",
"test",
"based",
"on",
"its",
"description"
] | a2163dfcb10e94f30d5cd20bca6c62e6e3cd1d46 | https://github.com/probedock/probedock-junit/blob/a2163dfcb10e94f30d5cd20bca6c62e6e3cd1d46/src/main/java/io/probedock/client/junit/AbstractProbeListener.java#L218-L220 | train |
probedock/probedock-junit | src/main/java/io/probedock/client/junit/AbstractProbeListener.java | AbstractProbeListener.getPackage | protected final String getPackage(Class cls) {
return cls.getPackage() != null ? cls.getPackage().getName() : "defaultPackage";
} | java | protected final String getPackage(Class cls) {
return cls.getPackage() != null ? cls.getPackage().getName() : "defaultPackage";
} | [
"protected",
"final",
"String",
"getPackage",
"(",
"Class",
"cls",
")",
"{",
"return",
"cls",
".",
"getPackage",
"(",
")",
"!=",
"null",
"?",
"cls",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
":",
"\"defaultPackage\"",
";",
"}"
] | Retrieve the package name if available, if not, default package name is used.
@param cls The class to extract the package name
@return The package name if found, "defaultPackage" if not found | [
"Retrieve",
"the",
"package",
"name",
"if",
"available",
"if",
"not",
"default",
"package",
"name",
"is",
"used",
"."
] | a2163dfcb10e94f30d5cd20bca6c62e6e3cd1d46 | https://github.com/probedock/probedock-junit/blob/a2163dfcb10e94f30d5cd20bca6c62e6e3cd1d46/src/main/java/io/probedock/client/junit/AbstractProbeListener.java#L237-L239 | train |
probedock/probedock-java | src/main/java/io/probedock/client/common/utils/Inflector.java | Inflector.getHumanName | public static String getHumanName(String methodName) {
char[] name = methodName.toCharArray();
StringBuilder humanName = new StringBuilder();
boolean digit = false;
boolean upper = true;
int upCount = 0;
for (int i = 0; i < name.length; i++) {
if (i == 0) {
humanName.append(Character.toUpperCase(name[i]));
} else {
humanName.append(Character.toLowerCase(name[i]));
}
if (i < name.length - 1) {
if (!digit && Character.isDigit(name[i + 1])) {
digit = true;
humanName.append(" ");
} else if (digit && !Character.isDigit(name[i + 1])) {
digit = false;
humanName.append(" ");
} else if (upper && !Character.isUpperCase(name[i + 1])) {
if (upCount == 2) {
humanName.insert(humanName.length() - 2, " ");
}
upper = false;
upCount = 0;
humanName.insert(humanName.length() - 1, " ");
} else if (Character.isUpperCase(name[i + 1])) {
upCount++;
upper = true;
}
}
}
return humanName.toString().replaceAll("^ ", "");
} | java | public static String getHumanName(String methodName) {
char[] name = methodName.toCharArray();
StringBuilder humanName = new StringBuilder();
boolean digit = false;
boolean upper = true;
int upCount = 0;
for (int i = 0; i < name.length; i++) {
if (i == 0) {
humanName.append(Character.toUpperCase(name[i]));
} else {
humanName.append(Character.toLowerCase(name[i]));
}
if (i < name.length - 1) {
if (!digit && Character.isDigit(name[i + 1])) {
digit = true;
humanName.append(" ");
} else if (digit && !Character.isDigit(name[i + 1])) {
digit = false;
humanName.append(" ");
} else if (upper && !Character.isUpperCase(name[i + 1])) {
if (upCount == 2) {
humanName.insert(humanName.length() - 2, " ");
}
upper = false;
upCount = 0;
humanName.insert(humanName.length() - 1, " ");
} else if (Character.isUpperCase(name[i + 1])) {
upCount++;
upper = true;
}
}
}
return humanName.toString().replaceAll("^ ", "");
} | [
"public",
"static",
"String",
"getHumanName",
"(",
"String",
"methodName",
")",
"{",
"char",
"[",
"]",
"name",
"=",
"methodName",
".",
"toCharArray",
"(",
")",
";",
"StringBuilder",
"humanName",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"digit",... | Create a human name from a method name
@param methodName The method name to get a human name
@return The human name created | [
"Create",
"a",
"human",
"name",
"from",
"a",
"method",
"name"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/common/utils/Inflector.java#L60-L100 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/sort/IntegerRadixSort.java | IntegerRadixSort.waitForAll | private static void waitForAll(Iterable<? extends Future<?>> futures) throws InterruptedException, ExecutionException {
for(Future<?> future : futures) {
future.get();
}
} | java | private static void waitForAll(Iterable<? extends Future<?>> futures) throws InterruptedException, ExecutionException {
for(Future<?> future : futures) {
future.get();
}
} | [
"private",
"static",
"void",
"waitForAll",
"(",
"Iterable",
"<",
"?",
"extends",
"Future",
"<",
"?",
">",
">",
"futures",
")",
"throws",
"InterruptedException",
",",
"ExecutionException",
"{",
"for",
"(",
"Future",
"<",
"?",
">",
"future",
":",
"futures",
... | Waits for all futures to complete, discarding any results.
Note: This method is cloned from ConcurrentUtils.java to avoid package dependency. | [
"Waits",
"for",
"all",
"futures",
"to",
"complete",
"discarding",
"any",
"results",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/sort/IntegerRadixSort.java#L142-L146 | train |
aoindustries/ao-messaging-api | src/main/java/com/aoindustries/messaging/StringMessage.java | StringMessage.decode | public static StringMessage decode(ByteArray encodedMessage) {
if(encodedMessage.size == 0) return EMPTY_STRING_MESSAGE;
return new StringMessage(new String(encodedMessage.array, 0, encodedMessage.size, CHARSET));
} | java | public static StringMessage decode(ByteArray encodedMessage) {
if(encodedMessage.size == 0) return EMPTY_STRING_MESSAGE;
return new StringMessage(new String(encodedMessage.array, 0, encodedMessage.size, CHARSET));
} | [
"public",
"static",
"StringMessage",
"decode",
"(",
"ByteArray",
"encodedMessage",
")",
"{",
"if",
"(",
"encodedMessage",
".",
"size",
"==",
"0",
")",
"return",
"EMPTY_STRING_MESSAGE",
";",
"return",
"new",
"StringMessage",
"(",
"new",
"String",
"(",
"encodedMes... | UTF-8 decodes the message. | [
"UTF",
"-",
"8",
"decodes",
"the",
"message",
"."
] | dbe4d3baefcc846f99b7eeab42646057e99729f0 | https://github.com/aoindustries/ao-messaging-api/blob/dbe4d3baefcc846f99b7eeab42646057e99729f0/src/main/java/com/aoindustries/messaging/StringMessage.java#L40-L44 | train |
aoindustries/ao-messaging-api | src/main/java/com/aoindustries/messaging/StringMessage.java | StringMessage.encodeAsByteArray | @Override
public ByteArray encodeAsByteArray() {
if(message.isEmpty()) return ByteArray.EMPTY_BYTE_ARRAY;
return new ByteArray(message.getBytes(CHARSET));
} | java | @Override
public ByteArray encodeAsByteArray() {
if(message.isEmpty()) return ByteArray.EMPTY_BYTE_ARRAY;
return new ByteArray(message.getBytes(CHARSET));
} | [
"@",
"Override",
"public",
"ByteArray",
"encodeAsByteArray",
"(",
")",
"{",
"if",
"(",
"message",
".",
"isEmpty",
"(",
")",
")",
"return",
"ByteArray",
".",
"EMPTY_BYTE_ARRAY",
";",
"return",
"new",
"ByteArray",
"(",
"message",
".",
"getBytes",
"(",
"CHARSET... | UTF-8 encodes the message. | [
"UTF",
"-",
"8",
"encodes",
"the",
"message",
"."
] | dbe4d3baefcc846f99b7eeab42646057e99729f0 | https://github.com/aoindustries/ao-messaging-api/blob/dbe4d3baefcc846f99b7eeab42646057e99729f0/src/main/java/com/aoindustries/messaging/StringMessage.java#L87-L92 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/io/CompressedDataInputStream.java | CompressedDataInputStream.readCompressedInt | public static int readCompressedInt(InputStream in) throws IOException {
int b1=in.read();
if(b1==-1) throw new EOFException();
if((b1&0x80)!=0) {
// 31 bit
int b2=in.read();
if(b2==-1) throw new EOFException();
int b3=in.read();
if(b3==-1) throw new EOFException();
int b4=in.read();
if(b4==-1) throw new EOFException();
return
((b1&0x40)==0 ? 0 : 0xc0000000)
| ((b1&0x3f)<<24)
| (b2<<16)
| (b3<<8)
| b4
;
} else if((b1&0x40)!=0) {
// 22 bit
int b2=in.read();
if(b2==-1) throw new EOFException();
int b3=in.read();
if(b3==-1) throw new EOFException();
return
((b1&0x20)==0 ? 0 : 0xffe00000)
| ((b1&0x1f)<<16)
| (b2<<8)
| b3
;
} else if((b1&0x20)!=0) {
// 13 bit
int b2=in.read();
if(b2==-1) throw new EOFException();
return
((b1&0x10)==0 ? 0 : 0xfffff000)
| ((b1&0x0f)<<8)
| b2
;
} else {
// 5 bit
return
((b1&0x10)==0 ? 0 : 0xfffffff0)
| (b1&0x0f)
;
}
} | java | public static int readCompressedInt(InputStream in) throws IOException {
int b1=in.read();
if(b1==-1) throw new EOFException();
if((b1&0x80)!=0) {
// 31 bit
int b2=in.read();
if(b2==-1) throw new EOFException();
int b3=in.read();
if(b3==-1) throw new EOFException();
int b4=in.read();
if(b4==-1) throw new EOFException();
return
((b1&0x40)==0 ? 0 : 0xc0000000)
| ((b1&0x3f)<<24)
| (b2<<16)
| (b3<<8)
| b4
;
} else if((b1&0x40)!=0) {
// 22 bit
int b2=in.read();
if(b2==-1) throw new EOFException();
int b3=in.read();
if(b3==-1) throw new EOFException();
return
((b1&0x20)==0 ? 0 : 0xffe00000)
| ((b1&0x1f)<<16)
| (b2<<8)
| b3
;
} else if((b1&0x20)!=0) {
// 13 bit
int b2=in.read();
if(b2==-1) throw new EOFException();
return
((b1&0x10)==0 ? 0 : 0xfffff000)
| ((b1&0x0f)<<8)
| b2
;
} else {
// 5 bit
return
((b1&0x10)==0 ? 0 : 0xfffffff0)
| (b1&0x0f)
;
}
} | [
"public",
"static",
"int",
"readCompressedInt",
"(",
"InputStream",
"in",
")",
"throws",
"IOException",
"{",
"int",
"b1",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b1",
"==",
"-",
"1",
")",
"throw",
"new",
"EOFException",
"(",
")",
";",
"if"... | Reads a compressed integer from the stream.
The 31 bit pattern is as follows:
<pre>
5 bit - 000SXXXX
13 bit - 001SXXXX XXXXXXXX
22 bit - 01SXXXXX XXXXXXXX XXXXXXXX
31 bit - 1SXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
</pre>
@exception EOFException if the end of file is reached | [
"Reads",
"a",
"compressed",
"integer",
"from",
"the",
"stream",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/io/CompressedDataInputStream.java#L54-L100 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/io/CompressedDataInputStream.java | CompressedDataInputStream.readLongUTF | public String readLongUTF() throws IOException {
int length = readCompressedInt();
StringBuilder SB = new StringBuilder(length);
for(int position = 0; position<length; position+=20480) {
int expectedLen = length - position;
if(expectedLen>20480) expectedLen = 20480;
String block = readUTF();
if(block.length()!=expectedLen) throw new IOException("Block has unexpected length: expected "+expectedLen+", got "+block.length());
SB.append(block);
}
if(SB.length()!=length) throw new IOException("StringBuilder has unexpected length: expected "+length+", got "+SB.length());
return SB.toString();
} | java | public String readLongUTF() throws IOException {
int length = readCompressedInt();
StringBuilder SB = new StringBuilder(length);
for(int position = 0; position<length; position+=20480) {
int expectedLen = length - position;
if(expectedLen>20480) expectedLen = 20480;
String block = readUTF();
if(block.length()!=expectedLen) throw new IOException("Block has unexpected length: expected "+expectedLen+", got "+block.length());
SB.append(block);
}
if(SB.length()!=length) throw new IOException("StringBuilder has unexpected length: expected "+length+", got "+SB.length());
return SB.toString();
} | [
"public",
"String",
"readLongUTF",
"(",
")",
"throws",
"IOException",
"{",
"int",
"length",
"=",
"readCompressedInt",
"(",
")",
";",
"StringBuilder",
"SB",
"=",
"new",
"StringBuilder",
"(",
"length",
")",
";",
"for",
"(",
"int",
"position",
"=",
"0",
";",
... | Reads a string of any length. | [
"Reads",
"a",
"string",
"of",
"any",
"length",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/io/CompressedDataInputStream.java#L173-L185 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/swing/SynchronizingMutableTreeNode.java | SynchronizingMutableTreeNode.synchronize | public void synchronize(DefaultTreeModel treeModel, Tree<E> tree) throws IOException, SQLException {
assert SwingUtilities.isEventDispatchThread() : ApplicationResources.accessor.getMessage("assert.notRunningInSwingEventThread");
synchronize(treeModel, tree.getRootNodes());
} | java | public void synchronize(DefaultTreeModel treeModel, Tree<E> tree) throws IOException, SQLException {
assert SwingUtilities.isEventDispatchThread() : ApplicationResources.accessor.getMessage("assert.notRunningInSwingEventThread");
synchronize(treeModel, tree.getRootNodes());
} | [
"public",
"void",
"synchronize",
"(",
"DefaultTreeModel",
"treeModel",
",",
"Tree",
"<",
"E",
">",
"tree",
")",
"throws",
"IOException",
",",
"SQLException",
"{",
"assert",
"SwingUtilities",
".",
"isEventDispatchThread",
"(",
")",
":",
"ApplicationResources",
".",... | Synchronizes the children of this node with the roots of the provided
tree while adding and removing only a minimum number of nodes.
Comparisons are performed using equals on the value objects. This must
be called from the Swing event dispatch thread. | [
"Synchronizes",
"the",
"children",
"of",
"this",
"node",
"with",
"the",
"roots",
"of",
"the",
"provided",
"tree",
"while",
"adding",
"and",
"removing",
"only",
"a",
"minimum",
"number",
"of",
"nodes",
".",
"Comparisons",
"are",
"performed",
"using",
"equals",
... | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/swing/SynchronizingMutableTreeNode.java#L69-L72 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/swing/SynchronizingMutableTreeNode.java | SynchronizingMutableTreeNode.synchronize | @SuppressWarnings("unchecked")
public void synchronize(DefaultTreeModel treeModel, List<Node<E>> children) throws IOException, SQLException {
assert SwingUtilities.isEventDispatchThread() : ApplicationResources.accessor.getMessage("assert.notRunningInSwingEventThread");
if(children==null) {
// No children allowed
while(getChildCount()>0) treeModel.removeNodeFromParent((MutableTreeNode)getChildAt(getChildCount()-1));
if(getAllowsChildren()) {
setAllowsChildren(false);
treeModel.reload(this);
}
} else {
// Children allowed
if(!getAllowsChildren()) {
setAllowsChildren(true);
treeModel.reload(this);
}
// Update the children minimally
int size = children.size();
for(int index=0; index<size; index++) {
Node<E> child = children.get(index);
E value = child.getValue();
SynchronizingMutableTreeNode<E> synchronizingNode;
if(index>=getChildCount()) {
synchronizingNode = new SynchronizingMutableTreeNode<>(value);
treeModel.insertNodeInto(synchronizingNode, this, index);
} else {
synchronizingNode = (SynchronizingMutableTreeNode<E>)getChildAt(index);
if(!synchronizingNode.getUserObject().equals(value)) {
// Objects don't match
// If this object is found further down the list, then delete up to that object
int foundIndex = -1;
for(int searchIndex = index+1, count=getChildCount(); searchIndex<count; searchIndex++) {
synchronizingNode = (SynchronizingMutableTreeNode<E>)getChildAt(searchIndex);
if(synchronizingNode.getUserObject().equals(value)) {
foundIndex = searchIndex;
break;
}
}
if(foundIndex!=-1) {
for(int removeIndex=foundIndex-1; removeIndex>=index; removeIndex--) {
treeModel.removeNodeFromParent((MutableTreeNode)getChildAt(removeIndex));
}
// synchronizingNode already contains the right node
} else {
// Otherwise, insert in the current index
synchronizingNode = new SynchronizingMutableTreeNode<>(value);
treeModel.insertNodeInto(synchronizingNode, this, index);
}
}
}
// Recursively synchronize the children
synchronizingNode.synchronize(treeModel, child.getChildren());
}
// Remove any extra children
while(getChildCount() > size) {
treeModel.removeNodeFromParent((MutableTreeNode)getChildAt(getChildCount()-1));
}
}
} | java | @SuppressWarnings("unchecked")
public void synchronize(DefaultTreeModel treeModel, List<Node<E>> children) throws IOException, SQLException {
assert SwingUtilities.isEventDispatchThread() : ApplicationResources.accessor.getMessage("assert.notRunningInSwingEventThread");
if(children==null) {
// No children allowed
while(getChildCount()>0) treeModel.removeNodeFromParent((MutableTreeNode)getChildAt(getChildCount()-1));
if(getAllowsChildren()) {
setAllowsChildren(false);
treeModel.reload(this);
}
} else {
// Children allowed
if(!getAllowsChildren()) {
setAllowsChildren(true);
treeModel.reload(this);
}
// Update the children minimally
int size = children.size();
for(int index=0; index<size; index++) {
Node<E> child = children.get(index);
E value = child.getValue();
SynchronizingMutableTreeNode<E> synchronizingNode;
if(index>=getChildCount()) {
synchronizingNode = new SynchronizingMutableTreeNode<>(value);
treeModel.insertNodeInto(synchronizingNode, this, index);
} else {
synchronizingNode = (SynchronizingMutableTreeNode<E>)getChildAt(index);
if(!synchronizingNode.getUserObject().equals(value)) {
// Objects don't match
// If this object is found further down the list, then delete up to that object
int foundIndex = -1;
for(int searchIndex = index+1, count=getChildCount(); searchIndex<count; searchIndex++) {
synchronizingNode = (SynchronizingMutableTreeNode<E>)getChildAt(searchIndex);
if(synchronizingNode.getUserObject().equals(value)) {
foundIndex = searchIndex;
break;
}
}
if(foundIndex!=-1) {
for(int removeIndex=foundIndex-1; removeIndex>=index; removeIndex--) {
treeModel.removeNodeFromParent((MutableTreeNode)getChildAt(removeIndex));
}
// synchronizingNode already contains the right node
} else {
// Otherwise, insert in the current index
synchronizingNode = new SynchronizingMutableTreeNode<>(value);
treeModel.insertNodeInto(synchronizingNode, this, index);
}
}
}
// Recursively synchronize the children
synchronizingNode.synchronize(treeModel, child.getChildren());
}
// Remove any extra children
while(getChildCount() > size) {
treeModel.removeNodeFromParent((MutableTreeNode)getChildAt(getChildCount()-1));
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"synchronize",
"(",
"DefaultTreeModel",
"treeModel",
",",
"List",
"<",
"Node",
"<",
"E",
">",
">",
"children",
")",
"throws",
"IOException",
",",
"SQLException",
"{",
"assert",
"SwingUtilities... | Synchronizes the children of this node with the provided children
while adding and removing only a minimum number of nodes.
Comparisons are performed using equals on the value objects. This must
be called from the Swing event dispatch thread.
@param children If children is null, then doesn't allow children. | [
"Synchronizes",
"the",
"children",
"of",
"this",
"node",
"with",
"the",
"provided",
"children",
"while",
"adding",
"and",
"removing",
"only",
"a",
"minimum",
"number",
"of",
"nodes",
".",
"Comparisons",
"are",
"performed",
"using",
"equals",
"on",
"the",
"valu... | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/swing/SynchronizingMutableTreeNode.java#L82-L141 | train |
aoindustries/semanticcms-core-model | src/main/java/com/semanticcms/core/model/Page.java | Page.checkDates | private void checkDates() {
DateTime created = this.dateCreated;
DateTime published = this.datePublished;
DateTime modified = this.dateModified;
DateTime reviewed = this.dateReviewed;
if(
created != null
&& published != null
&& published.compareTo(created) < 0
) throw new IllegalArgumentException("published may not be before created");
if(
created != null
&& modified != null
&& modified.compareTo(created) < 0
) throw new IllegalArgumentException("modified may not be before created");
if(
created != null
&& reviewed != null
&& reviewed.compareTo(created) < 0
) throw new IllegalArgumentException("reviewed may not be before created");
} | java | private void checkDates() {
DateTime created = this.dateCreated;
DateTime published = this.datePublished;
DateTime modified = this.dateModified;
DateTime reviewed = this.dateReviewed;
if(
created != null
&& published != null
&& published.compareTo(created) < 0
) throw new IllegalArgumentException("published may not be before created");
if(
created != null
&& modified != null
&& modified.compareTo(created) < 0
) throw new IllegalArgumentException("modified may not be before created");
if(
created != null
&& reviewed != null
&& reviewed.compareTo(created) < 0
) throw new IllegalArgumentException("reviewed may not be before created");
} | [
"private",
"void",
"checkDates",
"(",
")",
"{",
"DateTime",
"created",
"=",
"this",
".",
"dateCreated",
";",
"DateTime",
"published",
"=",
"this",
".",
"datePublished",
";",
"DateTime",
"modified",
"=",
"this",
".",
"dateModified",
";",
"DateTime",
"reviewed",... | Checks the dates for consistency. | [
"Checks",
"the",
"dates",
"for",
"consistency",
"."
] | 14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624 | https://github.com/aoindustries/semanticcms-core-model/blob/14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624/src/main/java/com/semanticcms/core/model/Page.java#L233-L253 | train |
aoindustries/semanticcms-core-model | src/main/java/com/semanticcms/core/model/Page.java | Page.getElementsById | public Map<String,Element> getElementsById() {
synchronized(lock) {
if(elementsById == null) return Collections.emptyMap();
if(frozen) return elementsById;
return AoCollections.unmodifiableCopyMap(elementsById);
}
} | java | public Map<String,Element> getElementsById() {
synchronized(lock) {
if(elementsById == null) return Collections.emptyMap();
if(frozen) return elementsById;
return AoCollections.unmodifiableCopyMap(elementsById);
}
} | [
"public",
"Map",
"<",
"String",
",",
"Element",
">",
"getElementsById",
"(",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"elementsById",
"==",
"null",
")",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"if",
"(",
"frozen",
")... | Gets the elements indexed by id, in no particular order.
Note, while the page is being created, elements with automatic IDs will not be in
this map. However, once frozen, every element will have an ID.
@see #freeze() | [
"Gets",
"the",
"elements",
"indexed",
"by",
"id",
"in",
"no",
"particular",
"order",
".",
"Note",
"while",
"the",
"page",
"is",
"being",
"created",
"elements",
"with",
"automatic",
"IDs",
"will",
"not",
"be",
"in",
"this",
"map",
".",
"However",
"once",
... | 14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624 | https://github.com/aoindustries/semanticcms-core-model/blob/14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624/src/main/java/com/semanticcms/core/model/Page.java#L428-L434 | train |
aoindustries/semanticcms-core-model | src/main/java/com/semanticcms/core/model/Page.java | Page.getGeneratedIds | public Set<String> getGeneratedIds() {
synchronized(lock) {
if(generatedIds == null) return Collections.emptySet();
if(frozen) return generatedIds;
return AoCollections.unmodifiableCopySet(generatedIds);
}
} | java | public Set<String> getGeneratedIds() {
synchronized(lock) {
if(generatedIds == null) return Collections.emptySet();
if(frozen) return generatedIds;
return AoCollections.unmodifiableCopySet(generatedIds);
}
} | [
"public",
"Set",
"<",
"String",
">",
"getGeneratedIds",
"(",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"generatedIds",
"==",
"null",
")",
"return",
"Collections",
".",
"emptySet",
"(",
")",
";",
"if",
"(",
"frozen",
")",
"return",
"ge... | Gets which element IDs were generated. | [
"Gets",
"which",
"element",
"IDs",
"were",
"generated",
"."
] | 14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624 | https://github.com/aoindustries/semanticcms-core-model/blob/14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624/src/main/java/com/semanticcms/core/model/Page.java#L439-L445 | train |
aoindustries/semanticcms-core-model | src/main/java/com/semanticcms/core/model/Page.java | Page.addElement | public void addElement(Element element) {
synchronized(lock) {
checkNotFrozen();
element.setPage(this);
// elements
if(elements == null) elements = new ArrayList<>();
elements.add(element);
// elementsById
addToElementsById(element, false);
}
} | java | public void addElement(Element element) {
synchronized(lock) {
checkNotFrozen();
element.setPage(this);
// elements
if(elements == null) elements = new ArrayList<>();
elements.add(element);
// elementsById
addToElementsById(element, false);
}
} | [
"public",
"void",
"addElement",
"(",
"Element",
"element",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"checkNotFrozen",
"(",
")",
";",
"element",
".",
"setPage",
"(",
"this",
")",
";",
"// elements",
"if",
"(",
"elements",
"==",
"null",
")",
"eleme... | Adds an element to this page. | [
"Adds",
"an",
"element",
"to",
"this",
"page",
"."
] | 14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624 | https://github.com/aoindustries/semanticcms-core-model/blob/14bdbe3f3d69b2b337129c5b1afcaa9e87cb5624/src/main/java/com/semanticcms/core/model/Page.java#L450-L460 | train |
NessComputing/components-ness-jms | src/main/java/com/nesscomputing/jms/JmsUtils.java | JmsUtils.closeQuietly | public static void closeQuietly(final MessageConsumer consumer)
{
if (consumer != null) {
try {
consumer.close();
}
catch (JMSException je) {
if (je.getCause() instanceof InterruptedException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedException");
}
if (je.getCause() instanceof InterruptedIOException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
}
else {
LOG.warnDebug(je, "While closing consumer");
}
}
}
} | java | public static void closeQuietly(final MessageConsumer consumer)
{
if (consumer != null) {
try {
consumer.close();
}
catch (JMSException je) {
if (je.getCause() instanceof InterruptedException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedException");
}
if (je.getCause() instanceof InterruptedIOException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
}
else {
LOG.warnDebug(je, "While closing consumer");
}
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"MessageConsumer",
"consumer",
")",
"{",
"if",
"(",
"consumer",
"!=",
"null",
")",
"{",
"try",
"{",
"consumer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"JMSException",
"je",
")",
"{",
"i... | Close a message consumer.
@param consumer | [
"Close",
"a",
"message",
"consumer",
"."
] | 29e0d320ada3a1a375483437a9f3ff629822b714 | https://github.com/NessComputing/components-ness-jms/blob/29e0d320ada3a1a375483437a9f3ff629822b714/src/main/java/com/nesscomputing/jms/JmsUtils.java#L44-L62 | train |
NessComputing/components-ness-jms | src/main/java/com/nesscomputing/jms/JmsUtils.java | JmsUtils.closeQuietly | public static void closeQuietly(final MessageProducer producer)
{
if (producer != null) {
try {
producer.close();
}
catch (JMSException je) {
if (je.getCause() instanceof InterruptedException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedException");
}
if (je.getCause() instanceof InterruptedIOException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
}
else {
LOG.warnDebug(je, "While closing producer");
}
}
}
} | java | public static void closeQuietly(final MessageProducer producer)
{
if (producer != null) {
try {
producer.close();
}
catch (JMSException je) {
if (je.getCause() instanceof InterruptedException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedException");
}
if (je.getCause() instanceof InterruptedIOException) {
LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
}
else {
LOG.warnDebug(je, "While closing producer");
}
}
}
} | [
"public",
"static",
"void",
"closeQuietly",
"(",
"final",
"MessageProducer",
"producer",
")",
"{",
"if",
"(",
"producer",
"!=",
"null",
")",
"{",
"try",
"{",
"producer",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"JMSException",
"je",
")",
"{",
"i... | Close a message producer.
@param producer | [
"Close",
"a",
"message",
"producer",
"."
] | 29e0d320ada3a1a375483437a9f3ff629822b714 | https://github.com/NessComputing/components-ness-jms/blob/29e0d320ada3a1a375483437a9f3ff629822b714/src/main/java/com/nesscomputing/jms/JmsUtils.java#L69-L87 | train |
aoindustries/ao-messaging-api | src/main/java/com/aoindustries/messaging/ByteArrayMessage.java | ByteArrayMessage.decode | public static ByteArrayMessage decode(String encodedMessage) {
if(encodedMessage.isEmpty()) return EMPTY_BYTE_ARRAY_MESSAGE;
return new ByteArrayMessage(Base64Coder.decode(encodedMessage));
} | java | public static ByteArrayMessage decode(String encodedMessage) {
if(encodedMessage.isEmpty()) return EMPTY_BYTE_ARRAY_MESSAGE;
return new ByteArrayMessage(Base64Coder.decode(encodedMessage));
} | [
"public",
"static",
"ByteArrayMessage",
"decode",
"(",
"String",
"encodedMessage",
")",
"{",
"if",
"(",
"encodedMessage",
".",
"isEmpty",
"(",
")",
")",
"return",
"EMPTY_BYTE_ARRAY_MESSAGE",
";",
"return",
"new",
"ByteArrayMessage",
"(",
"Base64Coder",
".",
"decod... | base-64 decodes the message. | [
"base",
"-",
"64",
"decodes",
"the",
"message",
"."
] | dbe4d3baefcc846f99b7eeab42646057e99729f0 | https://github.com/aoindustries/ao-messaging-api/blob/dbe4d3baefcc846f99b7eeab42646057e99729f0/src/main/java/com/aoindustries/messaging/ByteArrayMessage.java#L37-L41 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/ws/WsEncoder.java | WsEncoder.encode | public static String encode(String value) {
if(value==null) return null;
StringBuilder encoded=null;
int len=value.length();
for(int c=0;c<len;c++) {
char ch=value.charAt(c);
if(
(ch<' ' && ch!='\n' && ch!='\r')
|| ch=='\\'
) {
if(encoded==null) {
encoded=new StringBuilder();
if(c>0) encoded.append(value, 0, c);
}
if(ch=='\\') encoded.append("\\\\");
else if(ch=='\b') encoded.append("\\b");
else if(ch=='\f') encoded.append("\\f");
else if(ch=='\t') encoded.append("\\t");
else {
int ich=ch;
encoded
.append("\\u")
.append(hexChars[(ich>>>12)&15])
.append(hexChars[(ich>>>8)&15])
.append(hexChars[(ich>>>4)&15])
.append(hexChars[ich&15])
;
}
} else {
if(encoded!=null) encoded.append(ch);
}
}
return encoded==null ? value : encoded.toString();
} | java | public static String encode(String value) {
if(value==null) return null;
StringBuilder encoded=null;
int len=value.length();
for(int c=0;c<len;c++) {
char ch=value.charAt(c);
if(
(ch<' ' && ch!='\n' && ch!='\r')
|| ch=='\\'
) {
if(encoded==null) {
encoded=new StringBuilder();
if(c>0) encoded.append(value, 0, c);
}
if(ch=='\\') encoded.append("\\\\");
else if(ch=='\b') encoded.append("\\b");
else if(ch=='\f') encoded.append("\\f");
else if(ch=='\t') encoded.append("\\t");
else {
int ich=ch;
encoded
.append("\\u")
.append(hexChars[(ich>>>12)&15])
.append(hexChars[(ich>>>8)&15])
.append(hexChars[(ich>>>4)&15])
.append(hexChars[ich&15])
;
}
} else {
if(encoded!=null) encoded.append(ch);
}
}
return encoded==null ? value : encoded.toString();
} | [
"public",
"static",
"String",
"encode",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"null",
";",
"StringBuilder",
"encoded",
"=",
"null",
";",
"int",
"len",
"=",
"value",
".",
"length",
"(",
")",
";",
"for",
"("... | Encodes string for binary transparency over SOAP. | [
"Encodes",
"string",
"for",
"binary",
"transparency",
"over",
"SOAP",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/ws/WsEncoder.java#L64-L98 | train |
buschmais/jqa-javaee6-plugin | src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/XmlDescriptorHelper.java | XmlDescriptorHelper.createDescription | public static DescriptionDescriptor createDescription(DescriptionType descriptionType, Store store) {
DescriptionDescriptor descriptionDescriptor = store.create(DescriptionDescriptor.class);
descriptionDescriptor.setLang(descriptionType.getLang());
descriptionDescriptor.setValue(descriptionType.getValue());
return descriptionDescriptor;
} | java | public static DescriptionDescriptor createDescription(DescriptionType descriptionType, Store store) {
DescriptionDescriptor descriptionDescriptor = store.create(DescriptionDescriptor.class);
descriptionDescriptor.setLang(descriptionType.getLang());
descriptionDescriptor.setValue(descriptionType.getValue());
return descriptionDescriptor;
} | [
"public",
"static",
"DescriptionDescriptor",
"createDescription",
"(",
"DescriptionType",
"descriptionType",
",",
"Store",
"store",
")",
"{",
"DescriptionDescriptor",
"descriptionDescriptor",
"=",
"store",
".",
"create",
"(",
"DescriptionDescriptor",
".",
"class",
")",
... | Create a description descriptor.
@param descriptionType
The XML description type.
@param store
The store.
@return The description descriptor. | [
"Create",
"a",
"description",
"descriptor",
"."
] | f5776604d9255206807e5aca90b8767bde494e14 | https://github.com/buschmais/jqa-javaee6-plugin/blob/f5776604d9255206807e5aca90b8767bde494e14/src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/XmlDescriptorHelper.java#L22-L27 | train |
buschmais/jqa-javaee6-plugin | src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/XmlDescriptorHelper.java | XmlDescriptorHelper.createIcon | public static IconDescriptor createIcon(IconType iconType, Store store) {
IconDescriptor iconDescriptor = store.create(IconDescriptor.class);
iconDescriptor.setLang(iconType.getLang());
PathType largeIcon = iconType.getLargeIcon();
if (largeIcon != null) {
iconDescriptor.setLargeIcon(largeIcon.getValue());
}
PathType smallIcon = iconType.getSmallIcon();
if (smallIcon != null) {
iconDescriptor.setSmallIcon(smallIcon.getValue());
}
return iconDescriptor;
} | java | public static IconDescriptor createIcon(IconType iconType, Store store) {
IconDescriptor iconDescriptor = store.create(IconDescriptor.class);
iconDescriptor.setLang(iconType.getLang());
PathType largeIcon = iconType.getLargeIcon();
if (largeIcon != null) {
iconDescriptor.setLargeIcon(largeIcon.getValue());
}
PathType smallIcon = iconType.getSmallIcon();
if (smallIcon != null) {
iconDescriptor.setSmallIcon(smallIcon.getValue());
}
return iconDescriptor;
} | [
"public",
"static",
"IconDescriptor",
"createIcon",
"(",
"IconType",
"iconType",
",",
"Store",
"store",
")",
"{",
"IconDescriptor",
"iconDescriptor",
"=",
"store",
".",
"create",
"(",
"IconDescriptor",
".",
"class",
")",
";",
"iconDescriptor",
".",
"setLang",
"(... | Create an icon descriptor.
@param iconType
The XML icon type.
@param store
The store
@return The icon descriptor. | [
"Create",
"an",
"icon",
"descriptor",
"."
] | f5776604d9255206807e5aca90b8767bde494e14 | https://github.com/buschmais/jqa-javaee6-plugin/blob/f5776604d9255206807e5aca90b8767bde494e14/src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/XmlDescriptorHelper.java#L38-L50 | train |
buschmais/jqa-javaee6-plugin | src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/XmlDescriptorHelper.java | XmlDescriptorHelper.createDisplayName | public static DisplayNameDescriptor createDisplayName(DisplayNameType displayNameType, Store store) {
DisplayNameDescriptor displayNameDescriptor = store.create(DisplayNameDescriptor.class);
displayNameDescriptor.setLang(displayNameType.getLang());
displayNameDescriptor.setValue(displayNameType.getValue());
return displayNameDescriptor;
} | java | public static DisplayNameDescriptor createDisplayName(DisplayNameType displayNameType, Store store) {
DisplayNameDescriptor displayNameDescriptor = store.create(DisplayNameDescriptor.class);
displayNameDescriptor.setLang(displayNameType.getLang());
displayNameDescriptor.setValue(displayNameType.getValue());
return displayNameDescriptor;
} | [
"public",
"static",
"DisplayNameDescriptor",
"createDisplayName",
"(",
"DisplayNameType",
"displayNameType",
",",
"Store",
"store",
")",
"{",
"DisplayNameDescriptor",
"displayNameDescriptor",
"=",
"store",
".",
"create",
"(",
"DisplayNameDescriptor",
".",
"class",
")",
... | Create a display name descriptor.
@param displayNameType
The XML display name type.
@param store
The store.
@return The display name descriptor. | [
"Create",
"a",
"display",
"name",
"descriptor",
"."
] | f5776604d9255206807e5aca90b8767bde494e14 | https://github.com/buschmais/jqa-javaee6-plugin/blob/f5776604d9255206807e5aca90b8767bde494e14/src/main/java/com/buschmais/jqassistant/plugin/javaee6/impl/scanner/XmlDescriptorHelper.java#L61-L66 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/ServletUtil.java | ServletUtil.getRequestEncoding | public static String getRequestEncoding(ServletRequest request) {
String requestEncoding = request.getCharacterEncoding();
return requestEncoding != null ? requestEncoding : DEFAULT_REQUEST_ENCODING;
} | java | public static String getRequestEncoding(ServletRequest request) {
String requestEncoding = request.getCharacterEncoding();
return requestEncoding != null ? requestEncoding : DEFAULT_REQUEST_ENCODING;
} | [
"public",
"static",
"String",
"getRequestEncoding",
"(",
"ServletRequest",
"request",
")",
"{",
"String",
"requestEncoding",
"=",
"request",
".",
"getCharacterEncoding",
"(",
")",
";",
"return",
"requestEncoding",
"!=",
"null",
"?",
"requestEncoding",
":",
"DEFAULT_... | Gets the request encoding or ISO-8859-1 when not available. | [
"Gets",
"the",
"request",
"encoding",
"or",
"ISO",
"-",
"8859",
"-",
"1",
"when",
"not",
"available",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/ServletUtil.java#L80-L83 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/ServletUtil.java | ServletUtil.getAbsoluteURL | public static void getAbsoluteURL(HttpServletRequest request, String relPath, Appendable out) throws IOException {
out.append(request.isSecure() ? "https://" : "http://");
out.append(request.getServerName());
int port = request.getServerPort();
if(port!=(request.isSecure() ? 443 : 80)) out.append(':').append(Integer.toString(port));
out.append(request.getContextPath());
out.append(relPath);
} | java | public static void getAbsoluteURL(HttpServletRequest request, String relPath, Appendable out) throws IOException {
out.append(request.isSecure() ? "https://" : "http://");
out.append(request.getServerName());
int port = request.getServerPort();
if(port!=(request.isSecure() ? 443 : 80)) out.append(':').append(Integer.toString(port));
out.append(request.getContextPath());
out.append(relPath);
} | [
"public",
"static",
"void",
"getAbsoluteURL",
"(",
"HttpServletRequest",
"request",
",",
"String",
"relPath",
",",
"Appendable",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"append",
"(",
"request",
".",
"isSecure",
"(",
")",
"?",
"\"https://\"",
":"... | Gets an absolute URL for the given context-relative path. This includes
protocol, port, context path, and relative path.
No URL rewriting is performed. | [
"Gets",
"an",
"absolute",
"URL",
"for",
"the",
"given",
"context",
"-",
"relative",
"path",
".",
"This",
"includes",
"protocol",
"port",
"context",
"path",
"and",
"relative",
"path",
".",
"No",
"URL",
"rewriting",
"is",
"performed",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/ServletUtil.java#L265-L272 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/ServletUtil.java | ServletUtil.getRedirectLocation | public static String getRedirectLocation(
HttpServletRequest request,
HttpServletResponse response,
String servletPath,
String href
) throws MalformedURLException, UnsupportedEncodingException {
// Convert page-relative paths to context-relative path, resolving ./ and ../
href = getAbsolutePath(servletPath, href);
// Encode URL path elements (like Japanese filenames)
href = UrlUtils.encodeUrlPath(href, response.getCharacterEncoding());
// Perform URL rewriting
href = response.encodeRedirectURL(href);
// Convert to absolute URL if needed. This will also add the context path.
if(href.startsWith("/")) href = getAbsoluteURL(request, href);
return href;
} | java | public static String getRedirectLocation(
HttpServletRequest request,
HttpServletResponse response,
String servletPath,
String href
) throws MalformedURLException, UnsupportedEncodingException {
// Convert page-relative paths to context-relative path, resolving ./ and ../
href = getAbsolutePath(servletPath, href);
// Encode URL path elements (like Japanese filenames)
href = UrlUtils.encodeUrlPath(href, response.getCharacterEncoding());
// Perform URL rewriting
href = response.encodeRedirectURL(href);
// Convert to absolute URL if needed. This will also add the context path.
if(href.startsWith("/")) href = getAbsoluteURL(request, href);
return href;
} | [
"public",
"static",
"String",
"getRedirectLocation",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"servletPath",
",",
"String",
"href",
")",
"throws",
"MalformedURLException",
",",
"UnsupportedEncodingException",
"{",
"// Co... | Gets the absolute URL that should be used for a redirect.
@param href The absolute, context-relative, or page-relative path to redirect to.
The following actions are performed on the provided href:
<ol>
<li>Convert page-relative paths to context-relative path, resolving ./ and ../</li>
<li>Encode URL path elements (like Japanese filenames)</li>
<li>Perform URL rewriting (response.encodeRedirectURL)</li>
<li>Convert to absolute URL if needed. This will also add the context path.</li>
</ol>
@see #sendRedirect(javax.servlet.http.HttpServletResponse, java.lang.String, int) | [
"Gets",
"the",
"absolute",
"URL",
"that",
"should",
"be",
"used",
"for",
"a",
"redirect",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/ServletUtil.java#L306-L325 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/ServletUtil.java | ServletUtil.sendRedirect | public static void sendRedirect(
HttpServletResponse response,
String location,
int status
) throws IllegalStateException, IOException {
// Response must not be committed
if(response.isCommitted()) throw new IllegalStateException("Unable to redirect: Response already committed");
response.setHeader("Location", location);
response.sendError(status);
} | java | public static void sendRedirect(
HttpServletResponse response,
String location,
int status
) throws IllegalStateException, IOException {
// Response must not be committed
if(response.isCommitted()) throw new IllegalStateException("Unable to redirect: Response already committed");
response.setHeader("Location", location);
response.sendError(status);
} | [
"public",
"static",
"void",
"sendRedirect",
"(",
"HttpServletResponse",
"response",
",",
"String",
"location",
",",
"int",
"status",
")",
"throws",
"IllegalStateException",
",",
"IOException",
"{",
"// Response must not be committed",
"if",
"(",
"response",
".",
"isCo... | Sends a redirect to the provided absolute URL location.
@see #getRedirectLocation(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.String) | [
"Sends",
"a",
"redirect",
"to",
"the",
"provided",
"absolute",
"URL",
"location",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/ServletUtil.java#L332-L342 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/ServletUtil.java | ServletUtil.sendRedirect | public static void sendRedirect(
HttpServletRequest request,
HttpServletResponse response,
String href,
int status
) throws IllegalStateException, IOException {
sendRedirect(
response,
getRedirectLocation(
request,
response,
request.getServletPath(),
href
),
status
);
} | java | public static void sendRedirect(
HttpServletRequest request,
HttpServletResponse response,
String href,
int status
) throws IllegalStateException, IOException {
sendRedirect(
response,
getRedirectLocation(
request,
response,
request.getServletPath(),
href
),
status
);
} | [
"public",
"static",
"void",
"sendRedirect",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"href",
",",
"int",
"status",
")",
"throws",
"IllegalStateException",
",",
"IOException",
"{",
"sendRedirect",
"(",
"response",
"... | Sends a redirect with relative paths determined from the request servlet path.
@see #getRedirectLocation(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.String) for transformations applied to the href | [
"Sends",
"a",
"redirect",
"with",
"relative",
"paths",
"determined",
"from",
"the",
"request",
"servlet",
"path",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/ServletUtil.java#L349-L365 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/ServletUtil.java | ServletUtil.getContextRequestUri | public static String getContextRequestUri(HttpServletRequest request) {
String requestUri = request.getRequestURI();
String contextPath = request.getContextPath();
int cpLen = contextPath.length();
if(cpLen > 0) {
assert requestUri.startsWith(contextPath);
return requestUri.substring(cpLen);
} else {
return requestUri;
}
} | java | public static String getContextRequestUri(HttpServletRequest request) {
String requestUri = request.getRequestURI();
String contextPath = request.getContextPath();
int cpLen = contextPath.length();
if(cpLen > 0) {
assert requestUri.startsWith(contextPath);
return requestUri.substring(cpLen);
} else {
return requestUri;
}
} | [
"public",
"static",
"String",
"getContextRequestUri",
"(",
"HttpServletRequest",
"request",
")",
"{",
"String",
"requestUri",
"=",
"request",
".",
"getRequestURI",
"(",
")",
";",
"String",
"contextPath",
"=",
"request",
".",
"getContextPath",
"(",
")",
";",
"int... | Gets the current request URI in context-relative form. The contextPath stripped. | [
"Gets",
"the",
"current",
"request",
"URI",
"in",
"context",
"-",
"relative",
"form",
".",
"The",
"contextPath",
"stripped",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/ServletUtil.java#L370-L380 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/ServletUtil.java | ServletUtil.doOptions | public static <S extends HttpServlet> void doOptions(
HttpServletResponse response,
Class<S> stopClass,
Class<? extends S> thisClass,
String doGet,
String doPost,
String doPut,
String doDelete,
Class<?>[] paramTypes
) {
boolean ALLOW_GET = false;
boolean ALLOW_HEAD = false;
boolean ALLOW_POST = false;
boolean ALLOW_PUT = false;
boolean ALLOW_DELETE = false;
boolean ALLOW_TRACE = true;
boolean ALLOW_OPTIONS = true;
for (
Method method
: getAllDeclaredMethods(stopClass, thisClass)
) {
if(Arrays.equals(paramTypes, method.getParameterTypes())) {
String methodName = method.getName();
if (doGet.equals(methodName)) {
ALLOW_GET = true;
ALLOW_HEAD = true;
} else if (doPost.equals(methodName)) {
ALLOW_POST = true;
} else if (doPut.equals(methodName)) {
ALLOW_PUT = true;
} else if (doDelete.equals(methodName)) {
ALLOW_DELETE = true;
}
}
}
StringBuilder allow = new StringBuilder();
if (ALLOW_GET) {
// if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_GET);
}
if (ALLOW_HEAD) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_HEAD);
}
if (ALLOW_POST) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_POST);
}
if (ALLOW_PUT) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_PUT);
}
if (ALLOW_DELETE) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_DELETE);
}
if (ALLOW_TRACE) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_TRACE);
}
if (ALLOW_OPTIONS) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_OPTIONS);
}
response.setHeader("Allow", allow.toString());
} | java | public static <S extends HttpServlet> void doOptions(
HttpServletResponse response,
Class<S> stopClass,
Class<? extends S> thisClass,
String doGet,
String doPost,
String doPut,
String doDelete,
Class<?>[] paramTypes
) {
boolean ALLOW_GET = false;
boolean ALLOW_HEAD = false;
boolean ALLOW_POST = false;
boolean ALLOW_PUT = false;
boolean ALLOW_DELETE = false;
boolean ALLOW_TRACE = true;
boolean ALLOW_OPTIONS = true;
for (
Method method
: getAllDeclaredMethods(stopClass, thisClass)
) {
if(Arrays.equals(paramTypes, method.getParameterTypes())) {
String methodName = method.getName();
if (doGet.equals(methodName)) {
ALLOW_GET = true;
ALLOW_HEAD = true;
} else if (doPost.equals(methodName)) {
ALLOW_POST = true;
} else if (doPut.equals(methodName)) {
ALLOW_PUT = true;
} else if (doDelete.equals(methodName)) {
ALLOW_DELETE = true;
}
}
}
StringBuilder allow = new StringBuilder();
if (ALLOW_GET) {
// if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_GET);
}
if (ALLOW_HEAD) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_HEAD);
}
if (ALLOW_POST) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_POST);
}
if (ALLOW_PUT) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_PUT);
}
if (ALLOW_DELETE) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_DELETE);
}
if (ALLOW_TRACE) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_TRACE);
}
if (ALLOW_OPTIONS) {
if(allow.length() != 0) allow.append(", ");
allow.append(METHOD_OPTIONS);
}
response.setHeader("Allow", allow.toString());
} | [
"public",
"static",
"<",
"S",
"extends",
"HttpServlet",
">",
"void",
"doOptions",
"(",
"HttpServletResponse",
"response",
",",
"Class",
"<",
"S",
">",
"stopClass",
",",
"Class",
"<",
"?",
"extends",
"S",
">",
"thisClass",
",",
"String",
"doGet",
",",
"Stri... | A reusable doOptions implementation for servlets. | [
"A",
"reusable",
"doOptions",
"implementation",
"for",
"servlets",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/ServletUtil.java#L416-L481 | train |
NessComputing/components-ness-httpserver | src/main/java/com/nesscomputing/httpserver/HttpConnector.java | HttpConnector.getPort | public int getPort()
{
if (port != 0) {
return port;
}
else {
final Connector connector = connectorHolder.get();
if (connector != null) {
Preconditions.checkState(connector.getLocalPort() > 0, "no port was set and the connector is not yet started!");
return connector.getLocalPort();
}
else {
return 0;
}
}
} | java | public int getPort()
{
if (port != 0) {
return port;
}
else {
final Connector connector = connectorHolder.get();
if (connector != null) {
Preconditions.checkState(connector.getLocalPort() > 0, "no port was set and the connector is not yet started!");
return connector.getLocalPort();
}
else {
return 0;
}
}
} | [
"public",
"int",
"getPort",
"(",
")",
"{",
"if",
"(",
"port",
"!=",
"0",
")",
"{",
"return",
"port",
";",
"}",
"else",
"{",
"final",
"Connector",
"connector",
"=",
"connectorHolder",
".",
"get",
"(",
")",
";",
"if",
"(",
"connector",
"!=",
"null",
... | Returns the system port for this connector. | [
"Returns",
"the",
"system",
"port",
"for",
"this",
"connector",
"."
] | 6a26bb852e8408e3499ad5d139961cdc6a96e857 | https://github.com/NessComputing/components-ness-httpserver/blob/6a26bb852e8408e3499ad5d139961cdc6a96e857/src/main/java/com/nesscomputing/httpserver/HttpConnector.java#L74-L89 | train |
aoindustries/semanticcms-openfile-servlet | src/main/java/com/semanticcms/openfile/servlet/OpenFile.java | OpenFile.isAllowed | public static boolean isAllowed(ServletContext servletContext, ServletRequest request) {
return
Boolean.parseBoolean(servletContext.getInitParameter(ENABLE_INIT_PARAM))
&& isAllowedAddr(request.getRemoteAddr())
;
} | java | public static boolean isAllowed(ServletContext servletContext, ServletRequest request) {
return
Boolean.parseBoolean(servletContext.getInitParameter(ENABLE_INIT_PARAM))
&& isAllowedAddr(request.getRemoteAddr())
;
} | [
"public",
"static",
"boolean",
"isAllowed",
"(",
"ServletContext",
"servletContext",
",",
"ServletRequest",
"request",
")",
"{",
"return",
"Boolean",
".",
"parseBoolean",
"(",
"servletContext",
".",
"getInitParameter",
"(",
"ENABLE_INIT_PARAM",
")",
")",
"&&",
"isAl... | Checks if the given request is allowed to open files on the server.
The servlet init param must have it enabled, as well as be from an allowed IP. | [
"Checks",
"if",
"the",
"given",
"request",
"is",
"allowed",
"to",
"open",
"files",
"on",
"the",
"server",
".",
"The",
"servlet",
"init",
"param",
"must",
"have",
"it",
"enabled",
"as",
"well",
"as",
"be",
"from",
"an",
"allowed",
"IP",
"."
] | d22b2580b57708311949ac1088e3275355774921 | https://github.com/aoindustries/semanticcms-openfile-servlet/blob/d22b2580b57708311949ac1088e3275355774921/src/main/java/com/semanticcms/openfile/servlet/OpenFile.java#L70-L75 | train |
aoindustries/semanticcms-openfile-servlet | src/main/java/com/semanticcms/openfile/servlet/OpenFile.java | OpenFile.addFileOpener | public static void addFileOpener(ServletContext servletContext, FileOpener fileOpener, String ... extensions) {
synchronized(fileOpenersLock) {
@SuppressWarnings("unchecked")
Map<String,FileOpener> fileOpeners = (Map<String,FileOpener>)servletContext.getAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
if(fileOpeners == null) {
fileOpeners = new HashMap<>();
servletContext.setAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME, fileOpeners);
}
for(String extension : extensions) {
if(fileOpeners.containsKey(extension)) throw new IllegalStateException("File opener already registered: " + extension);
fileOpeners.put(extension, fileOpener);
}
}
} | java | public static void addFileOpener(ServletContext servletContext, FileOpener fileOpener, String ... extensions) {
synchronized(fileOpenersLock) {
@SuppressWarnings("unchecked")
Map<String,FileOpener> fileOpeners = (Map<String,FileOpener>)servletContext.getAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
if(fileOpeners == null) {
fileOpeners = new HashMap<>();
servletContext.setAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME, fileOpeners);
}
for(String extension : extensions) {
if(fileOpeners.containsKey(extension)) throw new IllegalStateException("File opener already registered: " + extension);
fileOpeners.put(extension, fileOpener);
}
}
} | [
"public",
"static",
"void",
"addFileOpener",
"(",
"ServletContext",
"servletContext",
",",
"FileOpener",
"fileOpener",
",",
"String",
"...",
"extensions",
")",
"{",
"synchronized",
"(",
"fileOpenersLock",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",... | Registers a file opener.
@param extensions The simple extensions, in lowercase, not including the dot, such as "dia" | [
"Registers",
"a",
"file",
"opener",
"."
] | d22b2580b57708311949ac1088e3275355774921 | https://github.com/aoindustries/semanticcms-openfile-servlet/blob/d22b2580b57708311949ac1088e3275355774921/src/main/java/com/semanticcms/openfile/servlet/OpenFile.java#L115-L128 | train |
aoindustries/semanticcms-openfile-servlet | src/main/java/com/semanticcms/openfile/servlet/OpenFile.java | OpenFile.removeFileOpener | public static void removeFileOpener(ServletContext servletContext, String ... extensions) {
synchronized(fileOpenersLock) {
@SuppressWarnings("unchecked")
Map<String,FileOpener> fileOpeners = (Map<String,FileOpener>)servletContext.getAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
if(fileOpeners != null) {
for(String extension : extensions) {
fileOpeners.remove(extension);
}
if(fileOpeners.isEmpty()) {
servletContext.removeAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
}
}
}
} | java | public static void removeFileOpener(ServletContext servletContext, String ... extensions) {
synchronized(fileOpenersLock) {
@SuppressWarnings("unchecked")
Map<String,FileOpener> fileOpeners = (Map<String,FileOpener>)servletContext.getAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
if(fileOpeners != null) {
for(String extension : extensions) {
fileOpeners.remove(extension);
}
if(fileOpeners.isEmpty()) {
servletContext.removeAttribute(FILE_OPENERS_REQUEST_ATTRIBUTE_NAME);
}
}
}
} | [
"public",
"static",
"void",
"removeFileOpener",
"(",
"ServletContext",
"servletContext",
",",
"String",
"...",
"extensions",
")",
"{",
"synchronized",
"(",
"fileOpenersLock",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"String",
",",
... | Removes file openers.
@param extensions The simple extensions, in lowercase, not including the dot, such as "dia" | [
"Removes",
"file",
"openers",
"."
] | d22b2580b57708311949ac1088e3275355774921 | https://github.com/aoindustries/semanticcms-openfile-servlet/blob/d22b2580b57708311949ac1088e3275355774921/src/main/java/com/semanticcms/openfile/servlet/OpenFile.java#L135-L148 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/Cookies.java | Cookies.addCookie | public static void addCookie(
HttpServletRequest request,
HttpServletResponse response,
String cookieName,
String value,
String comment,
int maxAge,
boolean secure,
boolean contextOnlyPath
) {
Cookie newCookie = new Cookie(cookieName, value);
if(comment!=null) newCookie.setComment(comment);
newCookie.setMaxAge(maxAge);
newCookie.setSecure(secure && request.isSecure());
String path;
if(contextOnlyPath) {
path = request.getContextPath() + "/";
//if(path.length()==0) path = "/";
} else {
path = "/";
}
newCookie.setPath(path);
response.addCookie(newCookie);
} | java | public static void addCookie(
HttpServletRequest request,
HttpServletResponse response,
String cookieName,
String value,
String comment,
int maxAge,
boolean secure,
boolean contextOnlyPath
) {
Cookie newCookie = new Cookie(cookieName, value);
if(comment!=null) newCookie.setComment(comment);
newCookie.setMaxAge(maxAge);
newCookie.setSecure(secure && request.isSecure());
String path;
if(contextOnlyPath) {
path = request.getContextPath() + "/";
//if(path.length()==0) path = "/";
} else {
path = "/";
}
newCookie.setPath(path);
response.addCookie(newCookie);
} | [
"public",
"static",
"void",
"addCookie",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"cookieName",
",",
"String",
"value",
",",
"String",
"comment",
",",
"int",
"maxAge",
",",
"boolean",
"secure",
",",
"boolean",
... | Adds a cookie. | [
"Adds",
"a",
"cookie",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/Cookies.java#L43-L66 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/servlet/http/Cookies.java | Cookies.removeCookie | public static void removeCookie(
HttpServletRequest request,
HttpServletResponse response,
String cookieName,
boolean secure,
boolean contextOnlyPath
) {
addCookie(request, response, cookieName, "Removed", null, 0, secure, contextOnlyPath);
} | java | public static void removeCookie(
HttpServletRequest request,
HttpServletResponse response,
String cookieName,
boolean secure,
boolean contextOnlyPath
) {
addCookie(request, response, cookieName, "Removed", null, 0, secure, contextOnlyPath);
} | [
"public",
"static",
"void",
"removeCookie",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
",",
"String",
"cookieName",
",",
"boolean",
"secure",
",",
"boolean",
"contextOnlyPath",
")",
"{",
"addCookie",
"(",
"request",
",",
"response"... | Removes a cookie by adding it with maxAge of zero. | [
"Removes",
"a",
"cookie",
"by",
"adding",
"it",
"with",
"maxAge",
"of",
"zero",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/servlet/http/Cookies.java#L85-L93 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/table/Column.java | Column.compareTo | @Override
public int compareTo(Column o) {
int diff = name.compareToIgnoreCase(o.name);
if(diff!=0) return diff;
return name.compareTo(o.name);
} | java | @Override
public int compareTo(Column o) {
int diff = name.compareToIgnoreCase(o.name);
if(diff!=0) return diff;
return name.compareTo(o.name);
} | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"Column",
"o",
")",
"{",
"int",
"diff",
"=",
"name",
".",
"compareToIgnoreCase",
"(",
"o",
".",
"name",
")",
";",
"if",
"(",
"diff",
"!=",
"0",
")",
"return",
"diff",
";",
"return",
"name",
".",
"... | Ordered by column name only. | [
"Ordered",
"by",
"column",
"name",
"only",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/table/Column.java#L61-L66 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/md5/MD5InputStream.java | MD5InputStream.read | @Override
public int read() throws IOException {
int c = in.read();
if (c == -1) return -1;
md5.Update(c);
return c;
} | java | @Override
public int read() throws IOException {
int c = in.read();
if (c == -1) return -1;
md5.Update(c);
return c;
} | [
"@",
"Override",
"public",
"int",
"read",
"(",
")",
"throws",
"IOException",
"{",
"int",
"c",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"c",
"==",
"-",
"1",
")",
"return",
"-",
"1",
";",
"md5",
".",
"Update",
"(",
"c",
")",
";",
"retu... | Read a byte of data.
@see java.io.FilterInputStream | [
"Read",
"a",
"byte",
"of",
"data",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/md5/MD5InputStream.java#L102-L110 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/md5/MD5InputStream.java | MD5InputStream.read | @Override
public int read (byte bytes[], int offset, int length) throws IOException {
int r;
if ((r = in.read(bytes, offset, length)) == -1) return -1;
md5.Update(bytes, offset, r);
return r;
} | java | @Override
public int read (byte bytes[], int offset, int length) throws IOException {
int r;
if ((r = in.read(bytes, offset, length)) == -1) return -1;
md5.Update(bytes, offset, r);
return r;
} | [
"@",
"Override",
"public",
"int",
"read",
"(",
"byte",
"bytes",
"[",
"]",
",",
"int",
"offset",
",",
"int",
"length",
")",
"throws",
"IOException",
"{",
"int",
"r",
";",
"if",
"(",
"(",
"r",
"=",
"in",
".",
"read",
"(",
"bytes",
",",
"offset",
",... | Reads into an array of bytes. | [
"Reads",
"into",
"an",
"array",
"of",
"bytes",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/md5/MD5InputStream.java#L115-L124 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/i18n/EditableResourceBundleSet.java | EditableResourceBundleSet.addBundle | void addBundle(EditableResourceBundle bundle) {
Locale locale = bundle.getBundleLocale();
if(!locales.contains(locale)) throw new AssertionError("locale not in locales: "+locale);
bundles.put(locale, bundle);
} | java | void addBundle(EditableResourceBundle bundle) {
Locale locale = bundle.getBundleLocale();
if(!locales.contains(locale)) throw new AssertionError("locale not in locales: "+locale);
bundles.put(locale, bundle);
} | [
"void",
"addBundle",
"(",
"EditableResourceBundle",
"bundle",
")",
"{",
"Locale",
"locale",
"=",
"bundle",
".",
"getBundleLocale",
"(",
")",
";",
"if",
"(",
"!",
"locales",
".",
"contains",
"(",
"locale",
")",
")",
"throw",
"new",
"AssertionError",
"(",
"\... | The constructor of EditableResourceBundle adds itself here. | [
"The",
"constructor",
"of",
"EditableResourceBundle",
"adds",
"itself",
"here",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/i18n/EditableResourceBundleSet.java#L75-L79 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/util/i18n/EditableResourceBundleSet.java | EditableResourceBundleSet.getResourceBundle | public EditableResourceBundle getResourceBundle(Locale locale) {
EditableResourceBundle localeBundle = bundles.get(locale);
if(localeBundle==null) {
ResourceBundle resourceBundle = ResourceBundle.getBundle(baseName, locale);
if(!resourceBundle.getLocale().equals(locale)) throw new AssertionError("ResourceBundle not for this locale: "+locale);
if(!(resourceBundle instanceof EditableResourceBundle)) throw new AssertionError("ResourceBundle is not a EditableResourceBundle: "+resourceBundle);
localeBundle = (EditableResourceBundle)resourceBundle;
if(localeBundle.getBundleSet()!=this) throw new AssertionError("EditableResourceBundle not for this EditableResourceBundleSet: "+localeBundle);
if(!localeBundle.getBundleLocale().equals(locale)) throw new AssertionError("EditableResourceBundle not for this locale: "+locale);
// EditableResourceBundle will have added the bundle to the bundles map.
}
return localeBundle;
} | java | public EditableResourceBundle getResourceBundle(Locale locale) {
EditableResourceBundle localeBundle = bundles.get(locale);
if(localeBundle==null) {
ResourceBundle resourceBundle = ResourceBundle.getBundle(baseName, locale);
if(!resourceBundle.getLocale().equals(locale)) throw new AssertionError("ResourceBundle not for this locale: "+locale);
if(!(resourceBundle instanceof EditableResourceBundle)) throw new AssertionError("ResourceBundle is not a EditableResourceBundle: "+resourceBundle);
localeBundle = (EditableResourceBundle)resourceBundle;
if(localeBundle.getBundleSet()!=this) throw new AssertionError("EditableResourceBundle not for this EditableResourceBundleSet: "+localeBundle);
if(!localeBundle.getBundleLocale().equals(locale)) throw new AssertionError("EditableResourceBundle not for this locale: "+locale);
// EditableResourceBundle will have added the bundle to the bundles map.
}
return localeBundle;
} | [
"public",
"EditableResourceBundle",
"getResourceBundle",
"(",
"Locale",
"locale",
")",
"{",
"EditableResourceBundle",
"localeBundle",
"=",
"bundles",
".",
"get",
"(",
"locale",
")",
";",
"if",
"(",
"localeBundle",
"==",
"null",
")",
"{",
"ResourceBundle",
"resourc... | Gets the editable bundle for the provided locale. | [
"Gets",
"the",
"editable",
"bundle",
"for",
"the",
"provided",
"locale",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/util/i18n/EditableResourceBundleSet.java#L95-L107 | train |
probedock/probedock-java | src/main/java/io/probedock/client/utils/EnvironmentUtils.java | EnvironmentUtils.getEnvironmentBoolean | public static Boolean getEnvironmentBoolean(String name, Boolean defaultValue) {
if (envVars == null) {
throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentBoolean.");
}
String value = getEnvironmentString(name, null);
if (value == null) {
return defaultValue;
}
else {
return BOOLEAN_PATTERN.matcher(value).matches();
}
} | java | public static Boolean getEnvironmentBoolean(String name, Boolean defaultValue) {
if (envVars == null) {
throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentBoolean.");
}
String value = getEnvironmentString(name, null);
if (value == null) {
return defaultValue;
}
else {
return BOOLEAN_PATTERN.matcher(value).matches();
}
} | [
"public",
"static",
"Boolean",
"getEnvironmentBoolean",
"(",
"String",
"name",
",",
"Boolean",
"defaultValue",
")",
"{",
"if",
"(",
"envVars",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The environment vars must be provided before calling g... | Retrieve boolean value for the environment variable name
@param name The name of the variable without prefix
@param defaultValue The default value if not found
@return The value found, or the default if not found | [
"Retrieve",
"boolean",
"value",
"for",
"the",
"environment",
"variable",
"name"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/utils/EnvironmentUtils.java#L32-L45 | train |
probedock/probedock-java | src/main/java/io/probedock/client/utils/EnvironmentUtils.java | EnvironmentUtils.getEnvironmentInteger | public static Integer getEnvironmentInteger(String name, Integer defaultValue) {
if (envVars == null) {
throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentInteger.");
}
String value = getEnvironmentString(name, null);
if (value == null) {
return defaultValue;
}
else {
return Integer.parseInt(value);
}
} | java | public static Integer getEnvironmentInteger(String name, Integer defaultValue) {
if (envVars == null) {
throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentInteger.");
}
String value = getEnvironmentString(name, null);
if (value == null) {
return defaultValue;
}
else {
return Integer.parseInt(value);
}
} | [
"public",
"static",
"Integer",
"getEnvironmentInteger",
"(",
"String",
"name",
",",
"Integer",
"defaultValue",
")",
"{",
"if",
"(",
"envVars",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The environment vars must be provided before calling g... | Retrieve integer value for the environment variable name
@param name The name of the variable without prefix
@param defaultValue The default value if not found
@return The value found, or the default if not found | [
"Retrieve",
"integer",
"value",
"for",
"the",
"environment",
"variable",
"name"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/utils/EnvironmentUtils.java#L54-L67 | train |
probedock/probedock-java | src/main/java/io/probedock/client/utils/EnvironmentUtils.java | EnvironmentUtils.getEnvironmentString | public static String getEnvironmentString(String name, String defaultValue) {
if (envVars == null) {
throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentString.");
}
return envVars.get(ENV_PREFIX + name) != null ? envVars.get(ENV_PREFIX + name) : defaultValue;
} | java | public static String getEnvironmentString(String name, String defaultValue) {
if (envVars == null) {
throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentString.");
}
return envVars.get(ENV_PREFIX + name) != null ? envVars.get(ENV_PREFIX + name) : defaultValue;
} | [
"public",
"static",
"String",
"getEnvironmentString",
"(",
"String",
"name",
",",
"String",
"defaultValue",
")",
"{",
"if",
"(",
"envVars",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"The environment vars must be provided before calling getE... | Retrieve string value for the environment variable name
@param name The name of the variable without prefix
@param defaultValue The default value if not found
@return The value found, or the default if not found | [
"Retrieve",
"string",
"value",
"for",
"the",
"environment",
"variable",
"name"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/utils/EnvironmentUtils.java#L76-L82 | train |
aoindustries/ao-messaging-api | src/main/java/com/aoindustries/messaging/MultiMessage.java | MultiMessage.encodeAsString | @Override
public String encodeAsString() throws IOException {
final int size = messages.size();
if(size == 0) return "";
StringBuilder sb = new StringBuilder();
sb.append(size).append(DELIMITER);
int count = 0;
for(Message message : messages) {
count++;
String str = message.encodeAsString();
sb
.append(message.getMessageType().getTypeChar())
.append(str.length())
.append(DELIMITER)
.append(str)
;
}
if(count != size) throw new ConcurrentModificationException();
return sb.toString();
} | java | @Override
public String encodeAsString() throws IOException {
final int size = messages.size();
if(size == 0) return "";
StringBuilder sb = new StringBuilder();
sb.append(size).append(DELIMITER);
int count = 0;
for(Message message : messages) {
count++;
String str = message.encodeAsString();
sb
.append(message.getMessageType().getTypeChar())
.append(str.length())
.append(DELIMITER)
.append(str)
;
}
if(count != size) throw new ConcurrentModificationException();
return sb.toString();
} | [
"@",
"Override",
"public",
"String",
"encodeAsString",
"(",
")",
"throws",
"IOException",
"{",
"final",
"int",
"size",
"=",
"messages",
".",
"size",
"(",
")",
";",
"if",
"(",
"size",
"==",
"0",
")",
"return",
"\"\"",
";",
"StringBuilder",
"sb",
"=",
"n... | Encodes the messages into a single string. | [
"Encodes",
"the",
"messages",
"into",
"a",
"single",
"string",
"."
] | dbe4d3baefcc846f99b7eeab42646057e99729f0 | https://github.com/aoindustries/ao-messaging-api/blob/dbe4d3baefcc846f99b7eeab42646057e99729f0/src/main/java/com/aoindustries/messaging/MultiMessage.java#L191-L211 | train |
aoindustries/ao-messaging-api | src/main/java/com/aoindustries/messaging/MultiMessage.java | MultiMessage.encodeAsByteArray | @Override
public ByteArray encodeAsByteArray() throws IOException {
final int size = messages.size();
if(size == 0) return ByteArray.EMPTY_BYTE_ARRAY;
AoByteArrayOutputStream bout = new AoByteArrayOutputStream();
try {
try (DataOutputStream out = new DataOutputStream(bout)) {
out.writeInt(size);
int count = 0;
for(Message message : messages) {
count++;
ByteArray byteArray = message.encodeAsByteArray();
final int capacity = byteArray.size;
out.writeByte(message.getMessageType().getTypeByte());
out.writeInt(capacity);
out.write(byteArray.array, 0, capacity);
}
if(count != size) throw new ConcurrentModificationException();
}
} finally {
bout.close();
}
return new ByteArray(bout.getInternalByteArray(), bout.size());
} | java | @Override
public ByteArray encodeAsByteArray() throws IOException {
final int size = messages.size();
if(size == 0) return ByteArray.EMPTY_BYTE_ARRAY;
AoByteArrayOutputStream bout = new AoByteArrayOutputStream();
try {
try (DataOutputStream out = new DataOutputStream(bout)) {
out.writeInt(size);
int count = 0;
for(Message message : messages) {
count++;
ByteArray byteArray = message.encodeAsByteArray();
final int capacity = byteArray.size;
out.writeByte(message.getMessageType().getTypeByte());
out.writeInt(capacity);
out.write(byteArray.array, 0, capacity);
}
if(count != size) throw new ConcurrentModificationException();
}
} finally {
bout.close();
}
return new ByteArray(bout.getInternalByteArray(), bout.size());
} | [
"@",
"Override",
"public",
"ByteArray",
"encodeAsByteArray",
"(",
")",
"throws",
"IOException",
"{",
"final",
"int",
"size",
"=",
"messages",
".",
"size",
"(",
")",
";",
"if",
"(",
"size",
"==",
"0",
")",
"return",
"ByteArray",
".",
"EMPTY_BYTE_ARRAY",
";"... | Encodes the messages into a single ByteArray.
There is likely a more efficient implementation that reads-through, but this
is a simple implementation. | [
"Encodes",
"the",
"messages",
"into",
"a",
"single",
"ByteArray",
".",
"There",
"is",
"likely",
"a",
"more",
"efficient",
"implementation",
"that",
"reads",
"-",
"through",
"but",
"this",
"is",
"a",
"simple",
"implementation",
"."
] | dbe4d3baefcc846f99b7eeab42646057e99729f0 | https://github.com/aoindustries/ao-messaging-api/blob/dbe4d3baefcc846f99b7eeab42646057e99729f0/src/main/java/com/aoindustries/messaging/MultiMessage.java#L218-L242 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/io/FifoFile.java | FifoFile.setLength | protected void setLength(long length) throws IOException {
if(length<0) throw new IllegalArgumentException("Invalid length: "+length);
synchronized(this) {
file.seek(8);
file.writeLong(length);
if(length==0) setFirstIndex(0);
}
} | java | protected void setLength(long length) throws IOException {
if(length<0) throw new IllegalArgumentException("Invalid length: "+length);
synchronized(this) {
file.seek(8);
file.writeLong(length);
if(length==0) setFirstIndex(0);
}
} | [
"protected",
"void",
"setLength",
"(",
"long",
"length",
")",
"throws",
"IOException",
"{",
"if",
"(",
"length",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid length: \"",
"+",
"length",
")",
";",
"synchronized",
"(",
"this",
")",
... | Sets the number of bytes currently contained by the FIFO. | [
"Sets",
"the",
"number",
"of",
"bytes",
"currently",
"contained",
"by",
"the",
"FIFO",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/io/FifoFile.java#L141-L148 | train |
NessComputing/components-ness-httpserver | src/main/java/com/nesscomputing/httpserver/jetty/TransparentCompressionFilter.java | TransparentCompressionFilter.isExcludedPath | private boolean isExcludedPath(String requestURI)
{
if (requestURI == null)
return false;
if (_excludedPaths != null)
{
for (String excludedPath : _excludedPaths)
{
if (requestURI.startsWith(excludedPath))
{
return true;
}
}
}
if (_excludedPathPatterns != null)
{
for (Pattern pattern : _excludedPathPatterns)
{
if (pattern.matcher(requestURI).matches())
{
return true;
}
}
}
return false;
} | java | private boolean isExcludedPath(String requestURI)
{
if (requestURI == null)
return false;
if (_excludedPaths != null)
{
for (String excludedPath : _excludedPaths)
{
if (requestURI.startsWith(excludedPath))
{
return true;
}
}
}
if (_excludedPathPatterns != null)
{
for (Pattern pattern : _excludedPathPatterns)
{
if (pattern.matcher(requestURI).matches())
{
return true;
}
}
}
return false;
} | [
"private",
"boolean",
"isExcludedPath",
"(",
"String",
"requestURI",
")",
"{",
"if",
"(",
"requestURI",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"_excludedPaths",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"excludedPath",
":",
"_excludedPaths... | Checks to see if the path is excluded
@param requestURI
the request uri
@return boolean true if excluded | [
"Checks",
"to",
"see",
"if",
"the",
"path",
"is",
"excluded"
] | 6a26bb852e8408e3499ad5d139961cdc6a96e857 | https://github.com/NessComputing/components-ness-httpserver/blob/6a26bb852e8408e3499ad5d139961cdc6a96e857/src/main/java/com/nesscomputing/httpserver/jetty/TransparentCompressionFilter.java#L362-L387 | train |
probedock/probedock-java | src/main/java/io/probedock/client/core/filters/FilterUtils.java | FilterUtils.isRunnable | @SuppressWarnings("unchecked")
public static boolean isRunnable(Class cl, Method method, List<FilterDefinition> filters) {
// Get the ROX annotations
ProbeTest mAnnotation = method.getAnnotation(ProbeTest.class);
ProbeTestClass cAnnotation = method.getDeclaringClass().getAnnotation(ProbeTestClass.class);
String fingerprint = FingerprintGenerator.fingerprint(cl, method);
if (mAnnotation != null || cAnnotation != null) {
return isRunnable(new FilterTargetData(fingerprint, method, mAnnotation, cAnnotation), filters);
} else {
return isRunnable(new FilterTargetData(fingerprint, method), filters);
}
} | java | @SuppressWarnings("unchecked")
public static boolean isRunnable(Class cl, Method method, List<FilterDefinition> filters) {
// Get the ROX annotations
ProbeTest mAnnotation = method.getAnnotation(ProbeTest.class);
ProbeTestClass cAnnotation = method.getDeclaringClass().getAnnotation(ProbeTestClass.class);
String fingerprint = FingerprintGenerator.fingerprint(cl, method);
if (mAnnotation != null || cAnnotation != null) {
return isRunnable(new FilterTargetData(fingerprint, method, mAnnotation, cAnnotation), filters);
} else {
return isRunnable(new FilterTargetData(fingerprint, method), filters);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"boolean",
"isRunnable",
"(",
"Class",
"cl",
",",
"Method",
"method",
",",
"List",
"<",
"FilterDefinition",
">",
"filters",
")",
"{",
"// Get the ROX annotations",
"ProbeTest",
"mAnnotation",
... | Define if a test is runnable or not based on a method and class
@param cl Class
@param method The method
@param filters The filters to apply
@return True if the test can be run | [
"Define",
"if",
"a",
"test",
"is",
"runnable",
"or",
"not",
"based",
"on",
"a",
"method",
"and",
"class"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/core/filters/FilterUtils.java#L44-L57 | train |
probedock/probedock-java | src/main/java/io/probedock/client/common/config/Configuration.java | Configuration.readUid | private String readUid(File uidFile) {
String uid = null;
// Try to read the shared UID
try (BufferedReader br = new BufferedReader(new FileReader(uidFile))) {
String line;
while ((line = br.readLine()) != null) {
uid = line;
}
} catch (IOException ioe) {
}
return uid;
} | java | private String readUid(File uidFile) {
String uid = null;
// Try to read the shared UID
try (BufferedReader br = new BufferedReader(new FileReader(uidFile))) {
String line;
while ((line = br.readLine()) != null) {
uid = line;
}
} catch (IOException ioe) {
}
return uid;
} | [
"private",
"String",
"readUid",
"(",
"File",
"uidFile",
")",
"{",
"String",
"uid",
"=",
"null",
";",
"// Try to read the shared UID",
"try",
"(",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"uidFile",
")",
")",
")",
"... | Read a UID file
@param uidFile The UID file to read
@return The UID read | [
"Read",
"a",
"UID",
"file"
] | 92ee6634ba4fe3fdffeb4e202f5372ef947a67c3 | https://github.com/probedock/probedock-java/blob/92ee6634ba4fe3fdffeb4e202f5372ef947a67c3/src/main/java/io/probedock/client/common/config/Configuration.java#L450-L464 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/version/Version.java | Version.getInstance | public static Version getInstance(
int major,
int minor,
int release,
int build
) {
return new Version(major, minor, release, build);
} | java | public static Version getInstance(
int major,
int minor,
int release,
int build
) {
return new Version(major, minor, release, build);
} | [
"public",
"static",
"Version",
"getInstance",
"(",
"int",
"major",
",",
"int",
"minor",
",",
"int",
"release",
",",
"int",
"build",
")",
"{",
"return",
"new",
"Version",
"(",
"major",
",",
"minor",
",",
"release",
",",
"build",
")",
";",
"}"
] | Gets a version number instance from its component parts. | [
"Gets",
"a",
"version",
"number",
"instance",
"from",
"its",
"component",
"parts",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/version/Version.java#L37-L44 | train |
aoindustries/aocode-public | src/main/java/com/aoindustries/version/Version.java | Version.valueOf | public static Version valueOf(String version) throws IllegalArgumentException {
NullArgumentException.checkNotNull(version, "version");
int dot1Pos = version.indexOf('.');
if(dot1Pos==-1) throw new IllegalArgumentException(version);
int dot2Pos = version.indexOf('.', dot1Pos+1);
if(dot2Pos==-1) throw new IllegalArgumentException(version);
int dot3Pos = version.indexOf('.', dot2Pos+1);
if(dot3Pos==-1) throw new IllegalArgumentException(version);
return getInstance(
Integer.parseInt(version.substring(0, dot1Pos)),
Integer.parseInt(version.substring(dot1Pos+1, dot2Pos)),
Integer.parseInt(version.substring(dot2Pos+1, dot3Pos)),
Integer.parseInt(version.substring(dot3Pos+1))
);
} | java | public static Version valueOf(String version) throws IllegalArgumentException {
NullArgumentException.checkNotNull(version, "version");
int dot1Pos = version.indexOf('.');
if(dot1Pos==-1) throw new IllegalArgumentException(version);
int dot2Pos = version.indexOf('.', dot1Pos+1);
if(dot2Pos==-1) throw new IllegalArgumentException(version);
int dot3Pos = version.indexOf('.', dot2Pos+1);
if(dot3Pos==-1) throw new IllegalArgumentException(version);
return getInstance(
Integer.parseInt(version.substring(0, dot1Pos)),
Integer.parseInt(version.substring(dot1Pos+1, dot2Pos)),
Integer.parseInt(version.substring(dot2Pos+1, dot3Pos)),
Integer.parseInt(version.substring(dot3Pos+1))
);
} | [
"public",
"static",
"Version",
"valueOf",
"(",
"String",
"version",
")",
"throws",
"IllegalArgumentException",
"{",
"NullArgumentException",
".",
"checkNotNull",
"(",
"version",
",",
"\"version\"",
")",
";",
"int",
"dot1Pos",
"=",
"version",
".",
"indexOf",
"(",
... | Parses a version number from its string representation.
@see #toString() | [
"Parses",
"a",
"version",
"number",
"from",
"its",
"string",
"representation",
"."
] | c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3 | https://github.com/aoindustries/aocode-public/blob/c7bc1d08aee1d02dfaeeb1421fad21aca1aad4c3/src/main/java/com/aoindustries/version/Version.java#L51-L65 | train |
NessComputing/components-ness-config | src/main/java/com/nesscomputing/config/Config.java | Config.getConfig | public static Config getConfig()
{
final Configuration systemConfig = new SystemConfiguration();
final String configName = systemConfig.getString(CONFIG_PROPERTY_NAME);
final String configLocation = systemConfig.getString(CONFIG_LOCATION_PROPERTY_NAME);
Preconditions.checkState(configLocation != null, "Config location must be set!");
final ConfigFactory configFactory = new ConfigFactory(URI.create(configLocation), configName);
return new Config(configFactory.load());
} | java | public static Config getConfig()
{
final Configuration systemConfig = new SystemConfiguration();
final String configName = systemConfig.getString(CONFIG_PROPERTY_NAME);
final String configLocation = systemConfig.getString(CONFIG_LOCATION_PROPERTY_NAME);
Preconditions.checkState(configLocation != null, "Config location must be set!");
final ConfigFactory configFactory = new ConfigFactory(URI.create(configLocation), configName);
return new Config(configFactory.load());
} | [
"public",
"static",
"Config",
"getConfig",
"(",
")",
"{",
"final",
"Configuration",
"systemConfig",
"=",
"new",
"SystemConfiguration",
"(",
")",
";",
"final",
"String",
"configName",
"=",
"systemConfig",
".",
"getString",
"(",
"CONFIG_PROPERTY_NAME",
")",
";",
"... | Loads the configuration. The no-args method uses system properties to determine which configurations
to load.
-Dness.config=x/y/z defines a hierarchy of configurations from general
to detail.
The ness.config.location variable must be set.
If the ness.config variable is unset, the default value "default" is used.
@throws IllegalStateException If the ness.config.location variable is not set. | [
"Loads",
"the",
"configuration",
".",
"The",
"no",
"-",
"args",
"method",
"uses",
"system",
"properties",
"to",
"determine",
"which",
"configurations",
"to",
"load",
"."
] | eb9b37327a9e612a097f1258eb09d288f475e2cb | https://github.com/NessComputing/components-ness-config/blob/eb9b37327a9e612a097f1258eb09d288f475e2cb/src/main/java/com/nesscomputing/config/Config.java#L143-L151 | train |
NessComputing/components-ness-config | src/main/java/com/nesscomputing/config/Config.java | Config.getConfig | public static Config getConfig(@Nonnull final URI configLocation, @Nullable final String configName)
{
final ConfigFactory configFactory = new ConfigFactory(configLocation, configName);
return new Config(configFactory.load());
} | java | public static Config getConfig(@Nonnull final URI configLocation, @Nullable final String configName)
{
final ConfigFactory configFactory = new ConfigFactory(configLocation, configName);
return new Config(configFactory.load());
} | [
"public",
"static",
"Config",
"getConfig",
"(",
"@",
"Nonnull",
"final",
"URI",
"configLocation",
",",
"@",
"Nullable",
"final",
"String",
"configName",
")",
"{",
"final",
"ConfigFactory",
"configFactory",
"=",
"new",
"ConfigFactory",
"(",
"configLocation",
",",
... | Load Configuration, using the supplied URI as base. The loaded configuration can be overridden using
system properties. | [
"Load",
"Configuration",
"using",
"the",
"supplied",
"URI",
"as",
"base",
".",
"The",
"loaded",
"configuration",
"can",
"be",
"overridden",
"using",
"system",
"properties",
"."
] | eb9b37327a9e612a097f1258eb09d288f475e2cb | https://github.com/NessComputing/components-ness-config/blob/eb9b37327a9e612a097f1258eb09d288f475e2cb/src/main/java/com/nesscomputing/config/Config.java#L157-L161 | train |
NessComputing/components-ness-config | src/main/java/com/nesscomputing/config/Config.java | Config.getOverriddenConfig | public static Config getOverriddenConfig(@Nonnull final Config config, @Nullable final AbstractConfiguration ... overrideConfigurations)
{
if (overrideConfigurations == null || overrideConfigurations.length == 0) {
return config;
}
final CombinedConfiguration cc = new CombinedConfiguration(new OverrideCombiner());
int index = 0;
final AbstractConfiguration first = config.config.getNumberOfConfigurations() > 0 ?
AbstractConfiguration.class.cast(config.config.getConfiguration(index)) // cast always succeeds, internally this returns cd.getConfiguration() which is AbstractConfiguration
: null;
// If the passed in configuration has a system config, add this as the very first one so
// that system properties override still works.
if(first != null && first.getClass() == SystemConfiguration.class) {
cc.addConfiguration(first);
index++;
}
else {
// Otherwise, if any of the passed in configuration objects is a SystemConfiguration,
// put that at the very beginning.
for (AbstractConfiguration c : overrideConfigurations) {
if (c.getClass() == SystemConfiguration.class) {
cc.addConfiguration(c);
}
}
}
for (AbstractConfiguration c : overrideConfigurations) {
if (c.getClass() != SystemConfiguration.class) {
cc.addConfiguration(c); // Skip system configuration objects, they have been added earlier.
}
}
// Finally, add the existing configuration elements at lowest priority.
while (index < config.config.getNumberOfConfigurations()) {
final AbstractConfiguration c = AbstractConfiguration.class.cast(config.config.getConfiguration(index++));
if (c.getClass() != SystemConfiguration.class) {
cc.addConfiguration(c);
}
}
return new Config(cc);
} | java | public static Config getOverriddenConfig(@Nonnull final Config config, @Nullable final AbstractConfiguration ... overrideConfigurations)
{
if (overrideConfigurations == null || overrideConfigurations.length == 0) {
return config;
}
final CombinedConfiguration cc = new CombinedConfiguration(new OverrideCombiner());
int index = 0;
final AbstractConfiguration first = config.config.getNumberOfConfigurations() > 0 ?
AbstractConfiguration.class.cast(config.config.getConfiguration(index)) // cast always succeeds, internally this returns cd.getConfiguration() which is AbstractConfiguration
: null;
// If the passed in configuration has a system config, add this as the very first one so
// that system properties override still works.
if(first != null && first.getClass() == SystemConfiguration.class) {
cc.addConfiguration(first);
index++;
}
else {
// Otherwise, if any of the passed in configuration objects is a SystemConfiguration,
// put that at the very beginning.
for (AbstractConfiguration c : overrideConfigurations) {
if (c.getClass() == SystemConfiguration.class) {
cc.addConfiguration(c);
}
}
}
for (AbstractConfiguration c : overrideConfigurations) {
if (c.getClass() != SystemConfiguration.class) {
cc.addConfiguration(c); // Skip system configuration objects, they have been added earlier.
}
}
// Finally, add the existing configuration elements at lowest priority.
while (index < config.config.getNumberOfConfigurations()) {
final AbstractConfiguration c = AbstractConfiguration.class.cast(config.config.getConfiguration(index++));
if (c.getClass() != SystemConfiguration.class) {
cc.addConfiguration(c);
}
}
return new Config(cc);
} | [
"public",
"static",
"Config",
"getOverriddenConfig",
"(",
"@",
"Nonnull",
"final",
"Config",
"config",
",",
"@",
"Nullable",
"final",
"AbstractConfiguration",
"...",
"overrideConfigurations",
")",
"{",
"if",
"(",
"overrideConfigurations",
"==",
"null",
"||",
"overri... | Create a new configuration object from an existing object using overrides. If no overrides are passed in, the same object is returned.
the | [
"Create",
"a",
"new",
"configuration",
"object",
"from",
"an",
"existing",
"object",
"using",
"overrides",
".",
"If",
"no",
"overrides",
"are",
"passed",
"in",
"the",
"same",
"object",
"is",
"returned",
"."
] | eb9b37327a9e612a097f1258eb09d288f475e2cb | https://github.com/NessComputing/components-ness-config/blob/eb9b37327a9e612a097f1258eb09d288f475e2cb/src/main/java/com/nesscomputing/config/Config.java#L168-L213 | train |
attribyte/metrics-reporting | src/main/java/org/attribyte/metrics/Reporting.java | Reporting.start | public int start() throws Exception {
if(isStarted.compareAndSet(false, true)) {
try {
for(Reporter reporter : reporters) {
reporter.start();
}
} catch(Exception e) {
stop();
throw e;
}
}
return reporters.size();
} | java | public int start() throws Exception {
if(isStarted.compareAndSet(false, true)) {
try {
for(Reporter reporter : reporters) {
reporter.start();
}
} catch(Exception e) {
stop();
throw e;
}
}
return reporters.size();
} | [
"public",
"int",
"start",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"isStarted",
".",
"compareAndSet",
"(",
"false",
",",
"true",
")",
")",
"{",
"try",
"{",
"for",
"(",
"Reporter",
"reporter",
":",
"reporters",
")",
"{",
"reporter",
".",
"start"... | Starts all reporters.
@return The number of configured reporters.
@throws Exception on start error. | [
"Starts",
"all",
"reporters",
"."
] | f7420264cc124598dc93aedbd902267dab2d1c02 | https://github.com/attribyte/metrics-reporting/blob/f7420264cc124598dc93aedbd902267dab2d1c02/src/main/java/org/attribyte/metrics/Reporting.java#L88-L100 | train |
attribyte/metrics-reporting | src/main/java/org/attribyte/metrics/Reporting.java | Reporting.stop | public void stop() {
if(isStarted.compareAndSet(true, false)) {
for(Reporter reporter : reporters) {
reporter.stop();
}
}
} | java | public void stop() {
if(isStarted.compareAndSet(true, false)) {
for(Reporter reporter : reporters) {
reporter.stop();
}
}
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"if",
"(",
"isStarted",
".",
"compareAndSet",
"(",
"true",
",",
"false",
")",
")",
"{",
"for",
"(",
"Reporter",
"reporter",
":",
"reporters",
")",
"{",
"reporter",
".",
"stop",
"(",
")",
";",
"}",
"}",
"}"
] | Stops all reporting. | [
"Stops",
"all",
"reporting",
"."
] | f7420264cc124598dc93aedbd902267dab2d1c02 | https://github.com/attribyte/metrics-reporting/blob/f7420264cc124598dc93aedbd902267dab2d1c02/src/main/java/org/attribyte/metrics/Reporting.java#L105-L111 | train |
bremersee/sms | src/main/java/org/bremersee/sms/ExtensionUtils.java | ExtensionUtils.xmlNodeToObject | public static <T> T xmlNodeToObject(final Node node, final Class<T> valueType,
final JAXBContext jaxbContext)
throws JAXBException {
if (node == null) {
return null;
}
Validate.notNull(valueType, "valueType must not be null");
if (jaxbContext == null) {
return valueType.cast(getJaxbContext(valueType).createUnmarshaller().unmarshal(node));
}
return valueType.cast(jaxbContext.createUnmarshaller().unmarshal(node));
} | java | public static <T> T xmlNodeToObject(final Node node, final Class<T> valueType,
final JAXBContext jaxbContext)
throws JAXBException {
if (node == null) {
return null;
}
Validate.notNull(valueType, "valueType must not be null");
if (jaxbContext == null) {
return valueType.cast(getJaxbContext(valueType).createUnmarshaller().unmarshal(node));
}
return valueType.cast(jaxbContext.createUnmarshaller().unmarshal(node));
} | [
"public",
"static",
"<",
"T",
">",
"T",
"xmlNodeToObject",
"(",
"final",
"Node",
"node",
",",
"final",
"Class",
"<",
"T",
">",
"valueType",
",",
"final",
"JAXBContext",
"jaxbContext",
")",
"throws",
"JAXBException",
"{",
"if",
"(",
"node",
"==",
"null",
... | Transforms a XML node into an object.
@param <T> the type parameter
@param node the XML node
@param valueType the class of the target object
@param jaxbContext the {@link JAXBContext} (can be null)
@return the target object
@throws JAXBException if transformation fails | [
"Transforms",
"a",
"XML",
"node",
"into",
"an",
"object",
"."
] | 4e5e87ea98616dd316573b544f54cac56750d2f9 | https://github.com/bremersee/sms/blob/4e5e87ea98616dd316573b544f54cac56750d2f9/src/main/java/org/bremersee/sms/ExtensionUtils.java#L109-L121 | train |
bremersee/sms | src/main/java/org/bremersee/sms/ExtensionUtils.java | ExtensionUtils.jsonMapToObject | public static <T> T jsonMapToObject(final Map<String, Object> map, final Class<T> valueType,
final ObjectMapper objectMapper) throws IOException {
if (map == null) {
return null;
}
Validate.notNull(valueType, "valueType must not be null");
if (objectMapper == null) {
return DEFAULT_OBJECT_MAPPER
.readValue(DEFAULT_OBJECT_MAPPER.writeValueAsBytes(map), valueType);
}
return objectMapper.readValue(objectMapper.writeValueAsBytes(map), valueType);
} | java | public static <T> T jsonMapToObject(final Map<String, Object> map, final Class<T> valueType,
final ObjectMapper objectMapper) throws IOException {
if (map == null) {
return null;
}
Validate.notNull(valueType, "valueType must not be null");
if (objectMapper == null) {
return DEFAULT_OBJECT_MAPPER
.readValue(DEFAULT_OBJECT_MAPPER.writeValueAsBytes(map), valueType);
}
return objectMapper.readValue(objectMapper.writeValueAsBytes(map), valueType);
} | [
"public",
"static",
"<",
"T",
">",
"T",
"jsonMapToObject",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
",",
"final",
"Class",
"<",
"T",
">",
"valueType",
",",
"final",
"ObjectMapper",
"objectMapper",
")",
"throws",
"IOException",
"{",
... | Transforms a JSON map into an object.
@param <T> the type parameter
@param map the JSON map
@param valueType the class of the target object
@param objectMapper the JSON object mapper (can be null)
@return the target object
@throws IOException if transformation fails | [
"Transforms",
"a",
"JSON",
"map",
"into",
"an",
"object",
"."
] | 4e5e87ea98616dd316573b544f54cac56750d2f9 | https://github.com/bremersee/sms/blob/4e5e87ea98616dd316573b544f54cac56750d2f9/src/main/java/org/bremersee/sms/ExtensionUtils.java#L133-L144 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/ArraySet.java | ArraySet.fromArray | static <T> ArraySet<T> fromArray(List<T> aArray, Boolean aAllowDuplicates) {
ArraySet<T> set = new ArraySet<>();
for (int i = 0, len = aArray.size(); i < len; i++) {
set.add(aArray.get(i), aAllowDuplicates);
}
return set;
} | java | static <T> ArraySet<T> fromArray(List<T> aArray, Boolean aAllowDuplicates) {
ArraySet<T> set = new ArraySet<>();
for (int i = 0, len = aArray.size(); i < len; i++) {
set.add(aArray.get(i), aAllowDuplicates);
}
return set;
} | [
"static",
"<",
"T",
">",
"ArraySet",
"<",
"T",
">",
"fromArray",
"(",
"List",
"<",
"T",
">",
"aArray",
",",
"Boolean",
"aAllowDuplicates",
")",
"{",
"ArraySet",
"<",
"T",
">",
"set",
"=",
"new",
"ArraySet",
"<>",
"(",
")",
";",
"for",
"(",
"int",
... | Static method for creating ArraySet instances from an existing array. | [
"Static",
"method",
"for",
"creating",
"ArraySet",
"instances",
"from",
"an",
"existing",
"array",
"."
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/ArraySet.java#L40-L46 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/ArraySet.java | ArraySet.indexOf | Integer indexOf(T t) {
if (t == null) {
return null;
}
Integer i = _set.get(t);
if (i == null) {
return -1;
}
return i;
} | java | Integer indexOf(T t) {
if (t == null) {
return null;
}
Integer i = _set.get(t);
if (i == null) {
return -1;
}
return i;
} | [
"Integer",
"indexOf",
"(",
"T",
"t",
")",
"{",
"if",
"(",
"t",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Integer",
"i",
"=",
"_set",
".",
"get",
"(",
"t",
")",
";",
"if",
"(",
"i",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",... | What is the index of the given string in the array?
@param String
aStr | [
"What",
"is",
"the",
"index",
"of",
"the",
"given",
"string",
"in",
"the",
"array?"
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/ArraySet.java#L100-L109 | train |
nlalevee/jsourcemap | jsourcemap/src/java/org/hibnet/jsourcemap/ArraySet.java | ArraySet.at | T at(Integer i) {
if (i == null) {
return null;
}
if (i >= _array.size()) {
return null;
}
return _array.get(i);
} | java | T at(Integer i) {
if (i == null) {
return null;
}
if (i >= _array.size()) {
return null;
}
return _array.get(i);
} | [
"T",
"at",
"(",
"Integer",
"i",
")",
"{",
"if",
"(",
"i",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"i",
">=",
"_array",
".",
"size",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"_array",
".",
"get",
"(",
... | What is the element at the given index?
@param Number
aIdx | [
"What",
"is",
"the",
"element",
"at",
"the",
"given",
"index?"
] | 361a99c73d51c11afa5579dd83d477c4d0345599 | https://github.com/nlalevee/jsourcemap/blob/361a99c73d51c11afa5579dd83d477c4d0345599/jsourcemap/src/java/org/hibnet/jsourcemap/ArraySet.java#L117-L125 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.