tianyang/repobench-c · Datasets at Fast360
{
// 获取包含Hugging Face文本的span元素
const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap');
spans.forEach(span => {
if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) {
span.textContent = 'AI快站';
}
});
});
// 替换logo图片的alt属性
document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => {
if (img.alt.match(/Hugging\s*Face/i)) {
img.alt = 'AI快站 logo';
}
});
}
// 替换导航栏中的链接
function replaceNavigationLinks() {
// 已替换标记,防止重复运行
if (window._navLinksReplaced) {
return;
}
// 已经替换过的链接集合,防止重复替换
const replacedLinks = new Set();
// 只在导航栏区域查找和替换链接
const headerArea = document.querySelector('header') || document.querySelector('nav');
if (!headerArea) {
return;
}
// 在导航区域内查找链接
const navLinks = headerArea.querySelectorAll('a');
navLinks.forEach(link => {
// 如果已经替换过,跳过
if (replacedLinks.has(link)) return;
const linkText = link.textContent.trim();
const linkHref = link.getAttribute('href') || '';
// 替换Spaces链接 - 仅替换一次
if (
(linkHref.includes('/spaces') || linkHref === '/spaces' ||
linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) &&
linkText !== 'PDF TO Markdown' &&
linkText !== 'PDF TO Markdown'
) {
link.textContent = 'PDF TO Markdown';
link.href = 'https://fast360.xyz';
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener noreferrer');
replacedLinks.add(link);
}
// 删除Posts链接
else if (
(linkHref.includes('/posts') || linkHref === '/posts' ||
linkText === 'Posts' || linkText.match(/^s*Postss*$/i))
) {
if (link.parentNode) {
link.parentNode.removeChild(link);
}
replacedLinks.add(link);
}
// 替换Docs链接 - 仅替换一次
else if (
(linkHref.includes('/docs') || linkHref === '/docs' ||
linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) &&
linkText !== 'Voice Cloning'
) {
link.textContent = 'Voice Cloning';
link.href = 'https://vibevoice.info/';
replacedLinks.add(link);
}
// 删除Enterprise链接
else if (
(linkHref.includes('/enterprise') || linkHref === '/enterprise' ||
linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i))
) {
if (link.parentNode) {
link.parentNode.removeChild(link);
}
replacedLinks.add(link);
}
});
// 查找可能嵌套的Spaces和Posts文本
const textNodes = [];
function findTextNodes(element) {
if (element.nodeType === Node.TEXT_NODE) {
const text = element.textContent.trim();
if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') {
textNodes.push(element);
}
} else {
for (const child of element.childNodes) {
findTextNodes(child);
}
}
}
// 只在导航区域内查找文本节点
findTextNodes(headerArea);
// 替换找到的文本节点
textNodes.forEach(node => {
const text = node.textContent.trim();
if (text === 'Spaces') {
node.textContent = node.textContent.replace(/Spaces/g, 'PDF TO Markdown');
} else if (text === 'Posts') {
// 删除Posts文本节点
if (node.parentNode) {
node.parentNode.removeChild(node);
}
} else if (text === 'Enterprise') {
// 删除Enterprise文本节点
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
});
// 标记已替换完成
window._navLinksReplaced = true;
}
// 替换代码区域中的域名
function replaceCodeDomains() {
// 特别处理span.hljs-string和span.njs-string元素
document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => {
if (span.textContent && span.textContent.includes('huggingface.co')) {
span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
});
// 替换hljs-string类的span中的域名(移除多余的转义符号)
document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => {
if (span.textContent && span.textContent.includes('huggingface.co')) {
span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
});
// 替换pre和code标签中包含git clone命令的域名
document.querySelectorAll('pre, code').forEach(element => {
if (element.textContent && element.textContent.includes('git clone')) {
const text = element.innerHTML;
if (text.includes('huggingface.co')) {
element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
// 处理特定的命令行示例
document.querySelectorAll('pre, code').forEach(element => {
const text = element.innerHTML;
if (text.includes('huggingface.co')) {
// 针对git clone命令的专门处理
if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) {
element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
// 特别处理模型下载页面上的代码片段
document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => {
const content = container.innerHTML;
if (content && content.includes('huggingface.co')) {
container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com');
}
});
// 特别处理模型仓库克隆对话框中的代码片段
try {
// 查找包含"Clone this model repository"标题的对话框
const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]');
if (cloneDialog) {
// 查找对话框中所有的代码片段和命令示例
const codeElements = cloneDialog.querySelectorAll('pre, code, span');
codeElements.forEach(element => {
if (element.textContent && element.textContent.includes('huggingface.co')) {
if (element.innerHTML.includes('huggingface.co')) {
element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com');
} else {
element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
}
// 更精确地定位克隆命令中的域名
document.querySelectorAll('[data-target]').forEach(container => {
const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string');
codeBlocks.forEach(block => {
if (block.textContent && block.textContent.includes('huggingface.co')) {
if (block.innerHTML.includes('huggingface.co')) {
block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com');
} else {
block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com');
}
}
});
});
} catch (e) {
// 错误处理但不打印日志
}
}
// 当DOM加载完成后执行替换
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
replaceHeaderBranding();
replaceNavigationLinks();
replaceCodeDomains();
// 只在必要时执行替换 - 3秒后再次检查
setTimeout(() => {
if (!window._navLinksReplaced) {
console.log('[Client] 3秒后重新检查导航链接');
replaceNavigationLinks();
}
}, 3000);
});
} else {
replaceHeaderBranding();
replaceNavigationLinks();
replaceCodeDomains();
// 只在必要时执行替换 - 3秒后再次检查
setTimeout(() => {
if (!window._navLinksReplaced) {
console.log('[Client] 3秒后重新检查导航链接');
replaceNavigationLinks();
}
}, 3000);
}
// 增加一个MutationObserver来处理可能的动态元素加载
const observer = new MutationObserver(mutations => {
// 检查是否导航区域有变化
const hasNavChanges = mutations.some(mutation => {
// 检查是否存在header或nav元素变化
return Array.from(mutation.addedNodes).some(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
// 检查是否是导航元素或其子元素
if (node.tagName === 'HEADER' || node.tagName === 'NAV' ||
node.querySelector('header, nav')) {
return true;
}
// 检查是否在导航元素内部
let parent = node.parentElement;
while (parent) {
if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') {
return true;
}
parent = parent.parentElement;
}
}
return false;
});
});
// 只在导航区域有变化时执行替换
if (hasNavChanges) {
// 重置替换状态,允许再次替换
window._navLinksReplaced = false;
replaceHeaderBranding();
replaceNavigationLinks();
}
});
// 开始观察document.body的变化,包括子节点
if (document.body) {
observer.observe(document.body, { childList: true, subtree: true });
} else {
document.addEventListener('DOMContentLoaded', () => {
observer.observe(document.body, { childList: true, subtree: true });
});
}
})();
\");\n\t}\n"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/template/TemplateException.java\n// public class TemplateException extends RuntimeException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \n// \tpublic TemplateException() {\n// \t\tsuper();\n// \t}\n// \n// \tpublic TemplateException(String message, Throwable cause) {\n// \t\tsuper(message, cause);\n// \t}\n// \n// \tpublic TemplateException(String message) {\n// \t\tsuper(message);\n// \t}\n// \n// \tpublic TemplateException(Throwable cause) {\n// \t\tsuper(cause);\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/template/JadeTemplateEngine.java\n// public class JadeTemplateEngine implements TemplateEngine {\n// \n// \tprivate JadeConfiguration jadeConfig;\n// \n// \tpublic JadeTemplateEngine() {\n// \t\tthis(new JadeConfiguration());\n// \t}\n// \n// \tpublic JadeTemplateEngine(JadeConfiguration jadeConfig) {\n// \t\tthis.jadeConfig = jadeConfig;\n// \t}\n// \n// \t@Override\n// \tpublic void render(String templateName, Map root, Writer writer) throws TemplateException {\n// \t\ttry {\n// \t\t\tJadeTemplate template = jadeConfig.getTemplate(templateName);\n// \t\t\tjadeConfig.renderTemplate(template, root, writer);\n// \t\t} catch(Exception e) {\n// \t\t\tthrow new TemplateException(e);\n// \t\t}\n// \t}\n// \n// }\n\n\n// Path: src/test/java/com/elibom/jogger/template/JadeTemplateEngineTest.java\nimport com.elibom.jogger.template.TemplateException;\nimport com.elibom.jogger.template.JadeTemplateEngine;\nimport java.io.StringWriter;\nimport java.util.HashMap;\nimport java.util.Map;\nimport org.testng.Assert;\nimport org.testng.annotations.Test;\n\npackage com.elibom.jogger.template;\n\n\n\npublic class JadeTemplateEngineTest {\n\n\t@Test\n\tpublic void shouldRenderExistingTemplate() throws Exception {\n\t\tJadeTemplateEngine templateEngine = new JadeTemplateEngine();\n\n\t\tMap root = new HashMap();\n\t\troot.put(\"title\", \"This is a test\");\n\n\t\tStringWriter writer = new StringWriter();\n\t\ttemplateEngine.render(\"src/test/resources/templates/jade/template.jade\", root, writer);\n\n\t\tAssert.assertEquals(writer.toString(), \"This is a test\");\n\t}\n"},"next_line":{"kind":"string","value":"\t@Test(expectedExceptions=TemplateException.class)"}}},{"rowIdx":100029,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/main/java/com/elibom/jogger/middleware/router/loader/ClassPathControllerLoader.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/middleware/router/RoutesException.java\n// public class RoutesException extends RuntimeException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \n// \tpublic RoutesException(String message) {\n// \t\tsuper(message);\n// \t}\n// \n// \tpublic RoutesException(String message, Throwable cause) {\n// \t\tsuper(message, cause);\n// \t}\n// \n// \tpublic RoutesException(Throwable cause) {\n// \t\tsuper(cause);\n// \t}\n// \n// }\n\n"},"import_statement":{"kind":"string","value":"import com.elibom.jogger.middleware.router.RoutesException;"},"code":{"kind":"string","value":"package com.elibom.jogger.middleware.router.loader;\n\n\n/**\n * A concrete implementation of {@link ControllerLoader} that loads controllers from the classpath using a\n * ClassLoader
. You can specified a basePackage
to avoid repeating the package in the routes\n * file.\n *\n * @author German Escobar\n */\npublic class ClassPathControllerLoader implements ControllerLoader {\n\n\tprivate String basePackage;\n\n\tprivate ClassLoader classLoader = ClassPathControllerLoader.class.getClassLoader();\n\n\t/**\n\t * Constructor. Initializes the object with an empty basePackage
.\n\t */\n\tpublic ClassPathControllerLoader() {\n\t\tthis(\"\");\n\t}\n\n\t/**\n\t * Constructor. Initializes the object with the specified basePackage
.\n\t * @param basePackage\n\t */\n\tpublic ClassPathControllerLoader(String basePackage) {\n\t\tthis.basePackage = basePackage;\n\n\t\tif (this.basePackage != null && !\"\".equals(this.basePackage)) {\n\t\t\tif (!this.basePackage.endsWith(\".\")) {\n\t\t\t\tthis.basePackage += \".\";\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/middleware/router/RoutesException.java\n// public class RoutesException extends RuntimeException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \n// \tpublic RoutesException(String message) {\n// \t\tsuper(message);\n// \t}\n// \n// \tpublic RoutesException(String message, Throwable cause) {\n// \t\tsuper(message, cause);\n// \t}\n// \n// \tpublic RoutesException(Throwable cause) {\n// \t\tsuper(cause);\n// \t}\n// \n// }\n\n\n// Path: src/main/java/com/elibom/jogger/middleware/router/loader/ClassPathControllerLoader.java\nimport com.elibom.jogger.middleware.router.RoutesException;\n\npackage com.elibom.jogger.middleware.router.loader;\n\n\n/**\n * A concrete implementation of {@link ControllerLoader} that loads controllers from the classpath using a\n * ClassLoader
. You can specified a basePackage
to avoid repeating the package in the routes\n * file.\n *\n * @author German Escobar\n */\npublic class ClassPathControllerLoader implements ControllerLoader {\n\n\tprivate String basePackage;\n\n\tprivate ClassLoader classLoader = ClassPathControllerLoader.class.getClassLoader();\n\n\t/**\n\t * Constructor. Initializes the object with an empty basePackage
.\n\t */\n\tpublic ClassPathControllerLoader() {\n\t\tthis(\"\");\n\t}\n\n\t/**\n\t * Constructor. Initializes the object with the specified basePackage
.\n\t * @param basePackage\n\t */\n\tpublic ClassPathControllerLoader(String basePackage) {\n\t\tthis.basePackage = basePackage;\n\n\t\tif (this.basePackage != null && !\"\".equals(this.basePackage)) {\n\t\t\tif (!this.basePackage.endsWith(\".\")) {\n\t\t\t\tthis.basePackage += \".\";\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override"},"next_line":{"kind":"string","value":"\tpublic Object load(String controllerName) throws RoutesException {"}}},{"rowIdx":100030,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/main/java/com/elibom/jogger/http/servlet/multipart/PartHandler.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/FileItem.java\n// public class FileItem {\n// \n// \t/**\n// \t * The name of the field to which this file was associated in the HTTP request\n// \t */\n// \tprivate String name;\n// \n// \t/**\n// \t * The name of the file taken from the HTTP part (in the filename attribute of the Content-Disposition header)\n// \t */\n// \tprivate String fileName;\n// \n// \t/**\n// \t * The content type of the file taken from the Content-Type header of the part, null if not specified\n// \t */\n// \tprivate String contentType;\n// \n// \t/**\n// \t * The content length of the file taken from the Content-Length header of the part, -1 if not specified\n// \t */\n// \tprivate long contentLength;\n// \n// \t/**\n// \t * The file.\n// \t */\n// \tprivate File file;\n// \n// \t/**\n// \t * The headers of the file part\n// \t */\n// \tprivate Map headers;\n// \n// \t/**\n// \t * Constructor.\n// \t *\n// \t * @param fieldName the name of the field that holds the file.\n// \t * @param fileName the name of the file.\n// \t * @param contentType\n// \t * @param contentLength\n// \t * @param file\n// \t * @param headers\n// \t */\n// \tpublic FileItem(String fieldName, String fileName, String contentType, long contentLength, File file, Map headers) {\n// \t\tPreconditions.notNull(fieldName, \"no fieldName provided.\");\n// \t\tPreconditions.notNull(fileName, \"no fileName provided.\");\n// \t\tPreconditions.notNull(file, \"no inputStream provided\");\n// \n// \t\tthis.fileName = fileName;\n// \t\tthis.contentType = contentType;\n// \t\tthis.contentLength = contentLength;\n// \t\tthis.file = file;\n// \t\tthis.headers = headers;\n// \t\tif (headers == null) {\n// \t\t\tthis.headers = new HashMap();\n// \t\t}\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// \tpublic String getFileName() {\n// \t\treturn fileName;\n// \t}\n// \n// \tpublic String getContentType() {\n// \t\treturn contentType;\n// \t}\n// \n// \tpublic long getContentLength() {\n// \t\treturn contentLength;\n// \t}\n// \n// \tpublic File getFile() {\n// \t\treturn file;\n// \t}\n// \n// \tpublic Map getHeaders() {\n// \t\treturn headers;\n// \t}\n// \n// }\n\n"},"import_statement":{"kind":"string","value":"import com.elibom.jogger.http.FileItem;"},"code":{"kind":"string","value":"package com.elibom.jogger.http.servlet.multipart;\n\n\n/**\n * Implementations of this interface are passed to the\n * {@link Multipart#parse(javax.servlet.http.HttpServletRequest, PartHandler)} method and handle the request parts.\n *\n * @author German Escobar\n */\npublic interface PartHandler {\n\n\t/**\n\t * Called when a form item part is found.\n\t *\n\t * @param name the name of the field to which this part is associated.\n\t * @param value the value of the field.\n\t */\n\tvoid handleFormItem(String name, String value);\n\n\t/**\n\t * Called when a file item part (or subpart) is found.\n\t *\n\t * @param name the name of the field to which this part is associated.\n\t * @param fileItem the {@link FileItem} that holds the data and input stream of the file.\n\t */"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/FileItem.java\n// public class FileItem {\n// \n// \t/**\n// \t * The name of the field to which this file was associated in the HTTP request\n// \t */\n// \tprivate String name;\n// \n// \t/**\n// \t * The name of the file taken from the HTTP part (in the filename attribute of the Content-Disposition header)\n// \t */\n// \tprivate String fileName;\n// \n// \t/**\n// \t * The content type of the file taken from the Content-Type header of the part, null if not specified\n// \t */\n// \tprivate String contentType;\n// \n// \t/**\n// \t * The content length of the file taken from the Content-Length header of the part, -1 if not specified\n// \t */\n// \tprivate long contentLength;\n// \n// \t/**\n// \t * The file.\n// \t */\n// \tprivate File file;\n// \n// \t/**\n// \t * The headers of the file part\n// \t */\n// \tprivate Map headers;\n// \n// \t/**\n// \t * Constructor.\n// \t *\n// \t * @param fieldName the name of the field that holds the file.\n// \t * @param fileName the name of the file.\n// \t * @param contentType\n// \t * @param contentLength\n// \t * @param file\n// \t * @param headers\n// \t */\n// \tpublic FileItem(String fieldName, String fileName, String contentType, long contentLength, File file, Map headers) {\n// \t\tPreconditions.notNull(fieldName, \"no fieldName provided.\");\n// \t\tPreconditions.notNull(fileName, \"no fileName provided.\");\n// \t\tPreconditions.notNull(file, \"no inputStream provided\");\n// \n// \t\tthis.fileName = fileName;\n// \t\tthis.contentType = contentType;\n// \t\tthis.contentLength = contentLength;\n// \t\tthis.file = file;\n// \t\tthis.headers = headers;\n// \t\tif (headers == null) {\n// \t\t\tthis.headers = new HashMap();\n// \t\t}\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// \tpublic String getFileName() {\n// \t\treturn fileName;\n// \t}\n// \n// \tpublic String getContentType() {\n// \t\treturn contentType;\n// \t}\n// \n// \tpublic long getContentLength() {\n// \t\treturn contentLength;\n// \t}\n// \n// \tpublic File getFile() {\n// \t\treturn file;\n// \t}\n// \n// \tpublic Map getHeaders() {\n// \t\treturn headers;\n// \t}\n// \n// }\n\n\n// Path: src/main/java/com/elibom/jogger/http/servlet/multipart/PartHandler.java\nimport com.elibom.jogger.http.FileItem;\n\npackage com.elibom.jogger.http.servlet.multipart;\n\n\n/**\n * Implementations of this interface are passed to the\n * {@link Multipart#parse(javax.servlet.http.HttpServletRequest, PartHandler)} method and handle the request parts.\n *\n * @author German Escobar\n */\npublic interface PartHandler {\n\n\t/**\n\t * Called when a form item part is found.\n\t *\n\t * @param name the name of the field to which this part is associated.\n\t * @param value the value of the field.\n\t */\n\tvoid handleFormItem(String name, String value);\n\n\t/**\n\t * Called when a file item part (or subpart) is found.\n\t *\n\t * @param name the name of the field to which this part is associated.\n\t * @param fileItem the {@link FileItem} that holds the data and input stream of the file.\n\t */"},"next_line":{"kind":"string","value":"\tvoid handleFileItem(String name, FileItem fileItem);"}}},{"rowIdx":100031,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/FileItem.java\n// public class FileItem {\n// \n// \t/**\n// \t * The name of the field to which this file was associated in the HTTP request\n// \t */\n// \tprivate String name;\n// \n// \t/**\n// \t * The name of the file taken from the HTTP part (in the filename attribute of the Content-Disposition header)\n// \t */\n// \tprivate String fileName;\n// \n// \t/**\n// \t * The content type of the file taken from the Content-Type header of the part, null if not specified\n// \t */\n// \tprivate String contentType;\n// \n// \t/**\n// \t * The content length of the file taken from the Content-Length header of the part, -1 if not specified\n// \t */\n// \tprivate long contentLength;\n// \n// \t/**\n// \t * The file.\n// \t */\n// \tprivate File file;\n// \n// \t/**\n// \t * The headers of the file part\n// \t */\n// \tprivate Map headers;\n// \n// \t/**\n// \t * Constructor.\n// \t *\n// \t * @param fieldName the name of the field that holds the file.\n// \t * @param fileName the name of the file.\n// \t * @param contentType\n// \t * @param contentLength\n// \t * @param file\n// \t * @param headers\n// \t */\n// \tpublic FileItem(String fieldName, String fileName, String contentType, long contentLength, File file, Map headers) {\n// \t\tPreconditions.notNull(fieldName, \"no fieldName provided.\");\n// \t\tPreconditions.notNull(fileName, \"no fileName provided.\");\n// \t\tPreconditions.notNull(file, \"no inputStream provided\");\n// \n// \t\tthis.fileName = fileName;\n// \t\tthis.contentType = contentType;\n// \t\tthis.contentLength = contentLength;\n// \t\tthis.file = file;\n// \t\tthis.headers = headers;\n// \t\tif (headers == null) {\n// \t\t\tthis.headers = new HashMap();\n// \t\t}\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// \tpublic String getFileName() {\n// \t\treturn fileName;\n// \t}\n// \n// \tpublic String getContentType() {\n// \t\treturn contentType;\n// \t}\n// \n// \tpublic long getContentLength() {\n// \t\treturn contentLength;\n// \t}\n// \n// \tpublic File getFile() {\n// \t\treturn file;\n// \t}\n// \n// \tpublic Map getHeaders() {\n// \t\treturn headers;\n// \t}\n// \n// }\n\n"},"import_statement":{"kind":"string","value":"import java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.UnsupportedEncodingException;\nimport java.util.HashMap;\nimport java.util.Map;\nimport javax.servlet.http.HttpServletRequest;\nimport com.elibom.jogger.http.FileItem;"},"code":{"kind":"string","value":"\t\t\tMap headers = getHeadersMap(headersString);\n\n\t\t\tif (currentFieldName == null) {\n\n\t\t\t\t// we're parsing the outer multipart\n\t\t\t\tString fieldName = getFieldName( headers.get(CONTENT_DISPOSITION) );\n\t\t\t\tif (fieldName != null) {\n\n\t\t\t\t\tString partContentType = headers.get(CONTENT_TYPE);\n\t\t\t\t\tif (partContentType != null && partContentType.toLowerCase().startsWith(MULTIPART_MIXED)) {\n\n\t\t\t\t\t\t// multiple files associated with this field name\n\t\t\t\t\t\tcurrentFieldName = fieldName;\n\t\t\t\t\t\tmultipartReader.setBoundary( getBoundary(partContentType));\n\t\t\t\t\t\tskipPreamble = true;\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tString fileName = getFileName( headers.get(CONTENT_DISPOSITION) );\n\t\t\t\t\tif (fileName == null) {\n\t\t\t\t\t\t// call the part handler\n\t\t\t\t\t\tString value = Streams.asString( multipartReader.newInputStream() );\n\t\t\t\t\t\tpartHandler.handleFormItem(fieldName, value);\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// create the temp file\n\t\t\t\t\t\tFile tempFile = createTempFile(multipartReader);\n\n\t\t\t\t\t\t// call the part handler"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/FileItem.java\n// public class FileItem {\n// \n// \t/**\n// \t * The name of the field to which this file was associated in the HTTP request\n// \t */\n// \tprivate String name;\n// \n// \t/**\n// \t * The name of the file taken from the HTTP part (in the filename attribute of the Content-Disposition header)\n// \t */\n// \tprivate String fileName;\n// \n// \t/**\n// \t * The content type of the file taken from the Content-Type header of the part, null if not specified\n// \t */\n// \tprivate String contentType;\n// \n// \t/**\n// \t * The content length of the file taken from the Content-Length header of the part, -1 if not specified\n// \t */\n// \tprivate long contentLength;\n// \n// \t/**\n// \t * The file.\n// \t */\n// \tprivate File file;\n// \n// \t/**\n// \t * The headers of the file part\n// \t */\n// \tprivate Map headers;\n// \n// \t/**\n// \t * Constructor.\n// \t *\n// \t * @param fieldName the name of the field that holds the file.\n// \t * @param fileName the name of the file.\n// \t * @param contentType\n// \t * @param contentLength\n// \t * @param file\n// \t * @param headers\n// \t */\n// \tpublic FileItem(String fieldName, String fileName, String contentType, long contentLength, File file, Map headers) {\n// \t\tPreconditions.notNull(fieldName, \"no fieldName provided.\");\n// \t\tPreconditions.notNull(fileName, \"no fileName provided.\");\n// \t\tPreconditions.notNull(file, \"no inputStream provided\");\n// \n// \t\tthis.fileName = fileName;\n// \t\tthis.contentType = contentType;\n// \t\tthis.contentLength = contentLength;\n// \t\tthis.file = file;\n// \t\tthis.headers = headers;\n// \t\tif (headers == null) {\n// \t\t\tthis.headers = new HashMap();\n// \t\t}\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// \tpublic String getFileName() {\n// \t\treturn fileName;\n// \t}\n// \n// \tpublic String getContentType() {\n// \t\treturn contentType;\n// \t}\n// \n// \tpublic long getContentLength() {\n// \t\treturn contentLength;\n// \t}\n// \n// \tpublic File getFile() {\n// \t\treturn file;\n// \t}\n// \n// \tpublic Map getHeaders() {\n// \t\treturn headers;\n// \t}\n// \n// }\n\n\n// Path: src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.io.UnsupportedEncodingException;\nimport java.util.HashMap;\nimport java.util.Map;\nimport javax.servlet.http.HttpServletRequest;\nimport com.elibom.jogger.http.FileItem;\n\n\t\t\tMap headers = getHeadersMap(headersString);\n\n\t\t\tif (currentFieldName == null) {\n\n\t\t\t\t// we're parsing the outer multipart\n\t\t\t\tString fieldName = getFieldName( headers.get(CONTENT_DISPOSITION) );\n\t\t\t\tif (fieldName != null) {\n\n\t\t\t\t\tString partContentType = headers.get(CONTENT_TYPE);\n\t\t\t\t\tif (partContentType != null && partContentType.toLowerCase().startsWith(MULTIPART_MIXED)) {\n\n\t\t\t\t\t\t// multiple files associated with this field name\n\t\t\t\t\t\tcurrentFieldName = fieldName;\n\t\t\t\t\t\tmultipartReader.setBoundary( getBoundary(partContentType));\n\t\t\t\t\t\tskipPreamble = true;\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tString fileName = getFileName( headers.get(CONTENT_DISPOSITION) );\n\t\t\t\t\tif (fileName == null) {\n\t\t\t\t\t\t// call the part handler\n\t\t\t\t\t\tString value = Streams.asString( multipartReader.newInputStream() );\n\t\t\t\t\t\tpartHandler.handleFormItem(fieldName, value);\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// create the temp file\n\t\t\t\t\t\tFile tempFile = createTempFile(multipartReader);\n\n\t\t\t\t\t\t// call the part handler"},"next_line":{"kind":"string","value":"\t\t\t\t\t\tFileItem fileItem = new FileItem(fieldName, fileName, partContentType, tempFile.length(), tempFile, headers);"}}},{"rowIdx":100032,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/test/java/com/elibom/jogger/exceptions/NotFoundExceptionTest.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/exception/NotFoundException.java\n// public class NotFoundException extends WebApplicationException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprivate static final int STATUS = 404;\n// \tprivate static final String NAME = \"Not Found\";\n// \t\n// \tpublic NotFoundException() {\n// \t\tsuper(STATUS, NAME);\n// \t}\n// \t\n// \tpublic NotFoundException(String message) {\n// \t\tsuper(STATUS, NAME, message);\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/exception/WebApplicationException.java\n// public abstract class WebApplicationException extends RuntimeException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprotected int status;\n// \t\n// \tprotected String name;\n// \n// \tpublic WebApplicationException(int status, String name) {\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message) {\n// \t\tsuper(message);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, Throwable cause) {\n// \t\tsuper(cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message, Throwable cause) {\n// \t\tsuper(message, cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic static long getSerialversionuid() {\n// \t\treturn serialVersionUID;\n// \t}\n// \n// \tpublic int getStatus() {\n// \t\treturn status;\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// }\n\n"},"import_statement":{"kind":"string","value":"import com.elibom.jogger.exception.NotFoundException;\nimport com.elibom.jogger.exception.WebApplicationException;\nimport org.testng.Assert;\nimport org.testng.annotations.Test;"},"code":{"kind":"string","value":"package com.elibom.jogger.exceptions;\n\n\npublic class NotFoundExceptionTest {\n\n\t@Test\n\tpublic void shouldCreateNotFoundException() throws Exception {\n\t\ttry {"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/exception/NotFoundException.java\n// public class NotFoundException extends WebApplicationException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprivate static final int STATUS = 404;\n// \tprivate static final String NAME = \"Not Found\";\n// \t\n// \tpublic NotFoundException() {\n// \t\tsuper(STATUS, NAME);\n// \t}\n// \t\n// \tpublic NotFoundException(String message) {\n// \t\tsuper(STATUS, NAME, message);\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/exception/WebApplicationException.java\n// public abstract class WebApplicationException extends RuntimeException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprotected int status;\n// \t\n// \tprotected String name;\n// \n// \tpublic WebApplicationException(int status, String name) {\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message) {\n// \t\tsuper(message);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, Throwable cause) {\n// \t\tsuper(cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message, Throwable cause) {\n// \t\tsuper(message, cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic static long getSerialversionuid() {\n// \t\treturn serialVersionUID;\n// \t}\n// \n// \tpublic int getStatus() {\n// \t\treturn status;\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// }\n\n\n// Path: src/test/java/com/elibom/jogger/exceptions/NotFoundExceptionTest.java\nimport com.elibom.jogger.exception.NotFoundException;\nimport com.elibom.jogger.exception.WebApplicationException;\nimport org.testng.Assert;\nimport org.testng.annotations.Test;\n\npackage com.elibom.jogger.exceptions;\n\n\npublic class NotFoundExceptionTest {\n\n\t@Test\n\tpublic void shouldCreateNotFoundException() throws Exception {\n\t\ttry {"},"next_line":{"kind":"string","value":"\t\t\tthrow new NotFoundException();"}}},{"rowIdx":100033,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/test/java/com/elibom/jogger/exceptions/NotFoundExceptionTest.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/exception/NotFoundException.java\n// public class NotFoundException extends WebApplicationException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprivate static final int STATUS = 404;\n// \tprivate static final String NAME = \"Not Found\";\n// \t\n// \tpublic NotFoundException() {\n// \t\tsuper(STATUS, NAME);\n// \t}\n// \t\n// \tpublic NotFoundException(String message) {\n// \t\tsuper(STATUS, NAME, message);\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/exception/WebApplicationException.java\n// public abstract class WebApplicationException extends RuntimeException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprotected int status;\n// \t\n// \tprotected String name;\n// \n// \tpublic WebApplicationException(int status, String name) {\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message) {\n// \t\tsuper(message);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, Throwable cause) {\n// \t\tsuper(cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message, Throwable cause) {\n// \t\tsuper(message, cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic static long getSerialversionuid() {\n// \t\treturn serialVersionUID;\n// \t}\n// \n// \tpublic int getStatus() {\n// \t\treturn status;\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// }\n\n"},"import_statement":{"kind":"string","value":"import com.elibom.jogger.exception.NotFoundException;\nimport com.elibom.jogger.exception.WebApplicationException;\nimport org.testng.Assert;\nimport org.testng.annotations.Test;"},"code":{"kind":"string","value":"package com.elibom.jogger.exceptions;\n\n\npublic class NotFoundExceptionTest {\n\n\t@Test\n\tpublic void shouldCreateNotFoundException() throws Exception {\n\t\ttry {\n\t\t\tthrow new NotFoundException();"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/exception/NotFoundException.java\n// public class NotFoundException extends WebApplicationException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprivate static final int STATUS = 404;\n// \tprivate static final String NAME = \"Not Found\";\n// \t\n// \tpublic NotFoundException() {\n// \t\tsuper(STATUS, NAME);\n// \t}\n// \t\n// \tpublic NotFoundException(String message) {\n// \t\tsuper(STATUS, NAME, message);\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/exception/WebApplicationException.java\n// public abstract class WebApplicationException extends RuntimeException {\n// \n// \tprivate static final long serialVersionUID = 1L;\n// \t\n// \tprotected int status;\n// \t\n// \tprotected String name;\n// \n// \tpublic WebApplicationException(int status, String name) {\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message) {\n// \t\tsuper(message);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, Throwable cause) {\n// \t\tsuper(cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic WebApplicationException(int status, String name, String message, Throwable cause) {\n// \t\tsuper(message, cause);\n// \t\tthis.status = status;\n// \t\tthis.name = name;\n// \t}\n// \n// \tpublic static long getSerialversionuid() {\n// \t\treturn serialVersionUID;\n// \t}\n// \n// \tpublic int getStatus() {\n// \t\treturn status;\n// \t}\n// \n// \tpublic String getName() {\n// \t\treturn name;\n// \t}\n// \n// }\n\n\n// Path: src/test/java/com/elibom/jogger/exceptions/NotFoundExceptionTest.java\nimport com.elibom.jogger.exception.NotFoundException;\nimport com.elibom.jogger.exception.WebApplicationException;\nimport org.testng.Assert;\nimport org.testng.annotations.Test;\n\npackage com.elibom.jogger.exceptions;\n\n\npublic class NotFoundExceptionTest {\n\n\t@Test\n\tpublic void shouldCreateNotFoundException() throws Exception {\n\t\ttry {\n\t\t\tthrow new NotFoundException();"},"next_line":{"kind":"string","value":"\t\t} catch (WebApplicationException e) {"}}},{"rowIdx":100034,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/main/java/com/elibom/jogger/asset/FileAssetLoader.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/util/Preconditions.java\n// public final class Preconditions {\n// \n// \t/**\n// \t * Hide constructor.\n// \t */\n// \tprivate Preconditions() {}\n// \n// \t/**\n// \t * Checks that an object is not null.\n// \t *\n// \t * @param object the object to be tested\n// \t * @param message the message for the exception in case the object is null.\n// \t *\n// \t * @throws IllegalArgumentException if the object is null.\n// \t */\n// \tpublic static void notNull(Object object, String message) throws IllegalArgumentException {\n// \t\tif (object == null) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// \n// \t/**\n// \t * Checks that a string is not null or empty.\n// \t *\n// \t * @param value the string to be tested.\n// \t * @param message the message for the exception in case the string is empty.\n// \t *\n// \t * @throws IllegalArgumentException if the string is empty.\n// \t */\n// \tpublic static void notEmpty(String value, String message) throws IllegalArgumentException {\n// \t\tif (value == null || \"\".equals(value.trim())) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// }\n\n"},"import_statement":{"kind":"string","value":"import java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport org.eclipse.jetty.http.MimeTypes;\nimport org.eclipse.jetty.io.Buffer;\nimport com.elibom.jogger.util.Preconditions;"},"code":{"kind":"string","value":"package com.elibom.jogger.asset;\n\n\n\n/**\n * An {@link AssetLoader} implementation that uses the file system to retrieve assets.\n *\n * @author German Escobar\n */\npublic class FileAssetLoader implements AssetLoader {\n\n\tprivate static final String DEFAULT_BASE_DIRECTORY = \"assets\";\n\n\tprivate File parent;\n\n\t/**\n\t * Constructor. Initializes the object with the default base directory.\n\t */\n\tpublic FileAssetLoader() {\n\t\tthis(DEFAULT_BASE_DIRECTORY);\n\t}\n\n\t/**\n\t * Constructor. Initializes the object with the specified base directory
.\n\t *\n\t * @param directory\n\t */\n\tpublic FileAssetLoader(String directory) {"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/util/Preconditions.java\n// public final class Preconditions {\n// \n// \t/**\n// \t * Hide constructor.\n// \t */\n// \tprivate Preconditions() {}\n// \n// \t/**\n// \t * Checks that an object is not null.\n// \t *\n// \t * @param object the object to be tested\n// \t * @param message the message for the exception in case the object is null.\n// \t *\n// \t * @throws IllegalArgumentException if the object is null.\n// \t */\n// \tpublic static void notNull(Object object, String message) throws IllegalArgumentException {\n// \t\tif (object == null) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// \n// \t/**\n// \t * Checks that a string is not null or empty.\n// \t *\n// \t * @param value the string to be tested.\n// \t * @param message the message for the exception in case the string is empty.\n// \t *\n// \t * @throws IllegalArgumentException if the string is empty.\n// \t */\n// \tpublic static void notEmpty(String value, String message) throws IllegalArgumentException {\n// \t\tif (value == null || \"\".equals(value.trim())) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// }\n\n\n// Path: src/main/java/com/elibom/jogger/asset/FileAssetLoader.java\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport org.eclipse.jetty.http.MimeTypes;\nimport org.eclipse.jetty.io.Buffer;\nimport com.elibom.jogger.util.Preconditions;\n\npackage com.elibom.jogger.asset;\n\n\n\n/**\n * An {@link AssetLoader} implementation that uses the file system to retrieve assets.\n *\n * @author German Escobar\n */\npublic class FileAssetLoader implements AssetLoader {\n\n\tprivate static final String DEFAULT_BASE_DIRECTORY = \"assets\";\n\n\tprivate File parent;\n\n\t/**\n\t * Constructor. Initializes the object with the default base directory.\n\t */\n\tpublic FileAssetLoader() {\n\t\tthis(DEFAULT_BASE_DIRECTORY);\n\t}\n\n\t/**\n\t * Constructor. Initializes the object with the specified base directory
.\n\t *\n\t * @param directory\n\t */\n\tpublic FileAssetLoader(String directory) {"},"next_line":{"kind":"string","value":"\t\tPreconditions.notEmpty(directory, \"no directory provided\");"}}},{"rowIdx":100035,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/main/java/com/elibom/jogger/middleware/router/Route.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/Path.java\n// public class Path {\n// \n// \t/**\n// \t * The regular expression to find holders in a path (e.g. {userId}).\n// \t */\n// \tpublic static final String VAR_REGEXP = \"\\\\{([^{}]+)\\\\}\";\n// \n// \tpublic static final String VAR_REPLACE = \"([^#/?]+)\";\n// \n// \tpublic static String fixPath(String path) {\n// \t\tif (path == null) {\n// \t\t\treturn \"/\";\n// \t\t}\n// \n// \t\tif (!path.startsWith(\"/\")) {\n// \t\t\tpath = \"/\" + path;\n// \t\t}\n// \n// \t\tif (path.length() > 1 && path.endsWith(\"/\")) {\n// \t\t\tpath = path.substring(0, path.length() - 1);\n// \t\t}\n// \n// \t\treturn path;\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/util/Preconditions.java\n// public final class Preconditions {\n// \n// \t/**\n// \t * Hide constructor.\n// \t */\n// \tprivate Preconditions() {}\n// \n// \t/**\n// \t * Checks that an object is not null.\n// \t *\n// \t * @param object the object to be tested\n// \t * @param message the message for the exception in case the object is null.\n// \t *\n// \t * @throws IllegalArgumentException if the object is null.\n// \t */\n// \tpublic static void notNull(Object object, String message) throws IllegalArgumentException {\n// \t\tif (object == null) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// \n// \t/**\n// \t * Checks that a string is not null or empty.\n// \t *\n// \t * @param value the string to be tested.\n// \t * @param message the message for the exception in case the string is empty.\n// \t *\n// \t * @throws IllegalArgumentException if the string is empty.\n// \t */\n// \tpublic static void notEmpty(String value, String message) throws IllegalArgumentException {\n// \t\tif (value == null || \"\".equals(value.trim())) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// }\n\n"},"import_statement":{"kind":"string","value":"import java.lang.reflect.Method;\nimport com.elibom.jogger.http.Path;\nimport com.elibom.jogger.util.Preconditions;"},"code":{"kind":"string","value":"package com.elibom.jogger.middleware.router;\n\n\n\n/**\n * Holds the information of a route.\n *\n * @author German Escobar\n */\npublic class Route {\n\n\tpublic enum HttpMethod {\n\t\tGET,\n\t\tPOST,\n\t\tPUT,\n\t\tDELETE,\n\t\tOPTIONS,\n\t\tHEAD,\n\t\tPATCH\n\t}\n\n\tprivate final HttpMethod httpMethod;\n\n\tprivate final String path;\n\n\tprivate final Object controller;\n\n\tprivate final Method action;\n\n\tpublic Route(HttpMethod httpMethod, String path, Object controller, Method action) {"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/Path.java\n// public class Path {\n// \n// \t/**\n// \t * The regular expression to find holders in a path (e.g. {userId}).\n// \t */\n// \tpublic static final String VAR_REGEXP = \"\\\\{([^{}]+)\\\\}\";\n// \n// \tpublic static final String VAR_REPLACE = \"([^#/?]+)\";\n// \n// \tpublic static String fixPath(String path) {\n// \t\tif (path == null) {\n// \t\t\treturn \"/\";\n// \t\t}\n// \n// \t\tif (!path.startsWith(\"/\")) {\n// \t\t\tpath = \"/\" + path;\n// \t\t}\n// \n// \t\tif (path.length() > 1 && path.endsWith(\"/\")) {\n// \t\t\tpath = path.substring(0, path.length() - 1);\n// \t\t}\n// \n// \t\treturn path;\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/util/Preconditions.java\n// public final class Preconditions {\n// \n// \t/**\n// \t * Hide constructor.\n// \t */\n// \tprivate Preconditions() {}\n// \n// \t/**\n// \t * Checks that an object is not null.\n// \t *\n// \t * @param object the object to be tested\n// \t * @param message the message for the exception in case the object is null.\n// \t *\n// \t * @throws IllegalArgumentException if the object is null.\n// \t */\n// \tpublic static void notNull(Object object, String message) throws IllegalArgumentException {\n// \t\tif (object == null) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// \n// \t/**\n// \t * Checks that a string is not null or empty.\n// \t *\n// \t * @param value the string to be tested.\n// \t * @param message the message for the exception in case the string is empty.\n// \t *\n// \t * @throws IllegalArgumentException if the string is empty.\n// \t */\n// \tpublic static void notEmpty(String value, String message) throws IllegalArgumentException {\n// \t\tif (value == null || \"\".equals(value.trim())) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// }\n\n\n// Path: src/main/java/com/elibom/jogger/middleware/router/Route.java\nimport java.lang.reflect.Method;\nimport com.elibom.jogger.http.Path;\nimport com.elibom.jogger.util.Preconditions;\n\npackage com.elibom.jogger.middleware.router;\n\n\n\n/**\n * Holds the information of a route.\n *\n * @author German Escobar\n */\npublic class Route {\n\n\tpublic enum HttpMethod {\n\t\tGET,\n\t\tPOST,\n\t\tPUT,\n\t\tDELETE,\n\t\tOPTIONS,\n\t\tHEAD,\n\t\tPATCH\n\t}\n\n\tprivate final HttpMethod httpMethod;\n\n\tprivate final String path;\n\n\tprivate final Object controller;\n\n\tprivate final Method action;\n\n\tpublic Route(HttpMethod httpMethod, String path, Object controller, Method action) {"},"next_line":{"kind":"string","value":"\t\tPreconditions.notNull(httpMethod, \"no httpMethod provided\");"}}},{"rowIdx":100036,"cells":{"repo_name":{"kind":"string","value":"elibom/jogger"},"file_path":{"kind":"string","value":"src/main/java/com/elibom/jogger/middleware/router/Route.java"},"context":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/Path.java\n// public class Path {\n// \n// \t/**\n// \t * The regular expression to find holders in a path (e.g. {userId}).\n// \t */\n// \tpublic static final String VAR_REGEXP = \"\\\\{([^{}]+)\\\\}\";\n// \n// \tpublic static final String VAR_REPLACE = \"([^#/?]+)\";\n// \n// \tpublic static String fixPath(String path) {\n// \t\tif (path == null) {\n// \t\t\treturn \"/\";\n// \t\t}\n// \n// \t\tif (!path.startsWith(\"/\")) {\n// \t\t\tpath = \"/\" + path;\n// \t\t}\n// \n// \t\tif (path.length() > 1 && path.endsWith(\"/\")) {\n// \t\t\tpath = path.substring(0, path.length() - 1);\n// \t\t}\n// \n// \t\treturn path;\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/util/Preconditions.java\n// public final class Preconditions {\n// \n// \t/**\n// \t * Hide constructor.\n// \t */\n// \tprivate Preconditions() {}\n// \n// \t/**\n// \t * Checks that an object is not null.\n// \t *\n// \t * @param object the object to be tested\n// \t * @param message the message for the exception in case the object is null.\n// \t *\n// \t * @throws IllegalArgumentException if the object is null.\n// \t */\n// \tpublic static void notNull(Object object, String message) throws IllegalArgumentException {\n// \t\tif (object == null) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// \n// \t/**\n// \t * Checks that a string is not null or empty.\n// \t *\n// \t * @param value the string to be tested.\n// \t * @param message the message for the exception in case the string is empty.\n// \t *\n// \t * @throws IllegalArgumentException if the string is empty.\n// \t */\n// \tpublic static void notEmpty(String value, String message) throws IllegalArgumentException {\n// \t\tif (value == null || \"\".equals(value.trim())) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// }\n\n"},"import_statement":{"kind":"string","value":"import java.lang.reflect.Method;\nimport com.elibom.jogger.http.Path;\nimport com.elibom.jogger.util.Preconditions;"},"code":{"kind":"string","value":"package com.elibom.jogger.middleware.router;\n\n\n\n/**\n * Holds the information of a route.\n *\n * @author German Escobar\n */\npublic class Route {\n\n\tpublic enum HttpMethod {\n\t\tGET,\n\t\tPOST,\n\t\tPUT,\n\t\tDELETE,\n\t\tOPTIONS,\n\t\tHEAD,\n\t\tPATCH\n\t}\n\n\tprivate final HttpMethod httpMethod;\n\n\tprivate final String path;\n\n\tprivate final Object controller;\n\n\tprivate final Method action;\n\n\tpublic Route(HttpMethod httpMethod, String path, Object controller, Method action) {\n\t\tPreconditions.notNull(httpMethod, \"no httpMethod provided\");\n\t\tPreconditions.notNull(path, \"no path provided\");\n\t\tPreconditions.notNull(controller, \"no controller provided\");\n\t\tPreconditions.notNull(action, \"no action provided\");\n\n\t\tthis.httpMethod = httpMethod;"},"prompt":{"kind":"string","value":"// Path: src/main/java/com/elibom/jogger/http/Path.java\n// public class Path {\n// \n// \t/**\n// \t * The regular expression to find holders in a path (e.g. {userId}).\n// \t */\n// \tpublic static final String VAR_REGEXP = \"\\\\{([^{}]+)\\\\}\";\n// \n// \tpublic static final String VAR_REPLACE = \"([^#/?]+)\";\n// \n// \tpublic static String fixPath(String path) {\n// \t\tif (path == null) {\n// \t\t\treturn \"/\";\n// \t\t}\n// \n// \t\tif (!path.startsWith(\"/\")) {\n// \t\t\tpath = \"/\" + path;\n// \t\t}\n// \n// \t\tif (path.length() > 1 && path.endsWith(\"/\")) {\n// \t\t\tpath = path.substring(0, path.length() - 1);\n// \t\t}\n// \n// \t\treturn path;\n// \t}\n// \n// }\n// \n// Path: src/main/java/com/elibom/jogger/util/Preconditions.java\n// public final class Preconditions {\n// \n// \t/**\n// \t * Hide constructor.\n// \t */\n// \tprivate Preconditions() {}\n// \n// \t/**\n// \t * Checks that an object is not null.\n// \t *\n// \t * @param object the object to be tested\n// \t * @param message the message for the exception in case the object is null.\n// \t *\n// \t * @throws IllegalArgumentException if the object is null.\n// \t */\n// \tpublic static void notNull(Object object, String message) throws IllegalArgumentException {\n// \t\tif (object == null) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// \n// \t/**\n// \t * Checks that a string is not null or empty.\n// \t *\n// \t * @param value the string to be tested.\n// \t * @param message the message for the exception in case the string is empty.\n// \t *\n// \t * @throws IllegalArgumentException if the string is empty.\n// \t */\n// \tpublic static void notEmpty(String value, String message) throws IllegalArgumentException {\n// \t\tif (value == null || \"\".equals(value.trim())) {\n// \t\t\tthrow new IllegalArgumentException(\"A precondition failed: \" + message);\n// \t\t}\n// \t}\n// }\n\n\n// Path: src/main/java/com/elibom/jogger/middleware/router/Route.java\nimport java.lang.reflect.Method;\nimport com.elibom.jogger.http.Path;\nimport com.elibom.jogger.util.Preconditions;\n\npackage com.elibom.jogger.middleware.router;\n\n\n\n/**\n * Holds the information of a route.\n *\n * @author German Escobar\n */\npublic class Route {\n\n\tpublic enum HttpMethod {\n\t\tGET,\n\t\tPOST,\n\t\tPUT,\n\t\tDELETE,\n\t\tOPTIONS,\n\t\tHEAD,\n\t\tPATCH\n\t}\n\n\tprivate final HttpMethod httpMethod;\n\n\tprivate final String path;\n\n\tprivate final Object controller;\n\n\tprivate final Method action;\n\n\tpublic Route(HttpMethod httpMethod, String path, Object controller, Method action) {\n\t\tPreconditions.notNull(httpMethod, \"no httpMethod provided\");\n\t\tPreconditions.notNull(path, \"no path provided\");\n\t\tPreconditions.notNull(controller, \"no controller provided\");\n\t\tPreconditions.notNull(action, \"no action provided\");\n\n\t\tthis.httpMethod = httpMethod;"},"next_line":{"kind":"string","value":"\t\tthis.path = Path.fixPath(path);"}}},{"rowIdx":100037,"cells":{"repo_name":{"kind":"string","value":"houkx/nettythrift"},"file_path":{"kind":"string","value":"client.json/src/io/client/thrift/ClientInterfaceFactory.java"},"context":{"kind":"string","value":"// Path: client.json/src/io/client/thrift/Json.java\n// public static class Strategy {\n// \tint excludeModifiers = Modifier.TRANSIENT | Modifier.STATIC;\n// \n// \t/**\n// \t * 返回字段名,如果返回null,则表示忽略这个字段\n// \t * \n// \t * @param field\n// \t * @return\n// \t */\n// \tpublic String fieldName(Field field) {\n// \t\tif (excludeClass(field.getType(), true))\n// \t\t\treturn null;\n// \t\treturn field.getName();\n// \t}\n// \n// \tpublic Field field(Class> cls, String fieldName) throws NoSuchFieldException, SecurityException {\n// \t\tif (excludeClass(cls, false))\n// \t\t\treturn null;\n// \t\tField f = cls.getDeclaredField(fieldName);\n// \t\tif ((f.getModifiers() & excludeModifiers) != 0) {\n// \t\t\treturn null;\n// \t\t}\n// \t\tf.setAccessible(true);\n// \t\treturn f;\n// \t}\n// \n// \t/**\n// \t * 是否忽略指定class\n// \t * \n// \t * @param clazz\n// \t * @param serialize\n// \t * - 是否在序列化过程中(Object to JSON)\n// \t * @return\n// \t */\n// \tpublic boolean excludeClass(Class> clazz, boolean serialize) {\n// \t\treturn false;\n// \t}\n// \n// \tpublic void excludeFieldsWithModifiers(int... modifiers) {\n// \t\texcludeModifiers = 0;\n// \t\tfor (int modifier : modifiers) {\n// \t\t\texcludeModifiers |= modifier;\n// \t\t}\n// \t}\n// \n// \tpublic void publicFieldsOnly() {\n// \t\texcludeFieldsWithModifiers(Modifier.PRIVATE, Modifier.PROTECTED, Modifier.STATIC, Modifier.TRANSIENT);\n// \t}\n// }\n\n"},"import_statement":{"kind":"string","value":"import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.OutputStream;\nimport java.io.Reader;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.InvocationHandler;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Proxy;\nimport java.lang.reflect.Type;\nimport java.net.ProtocolException;\nimport java.net.Socket;\nimport java.net.URL;\nimport java.net.URLConnection;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport javax.net.SocketFactory;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\nimport io.client.thrift.Json.Strategy;\nimport io.client.thrift.annotaion.Index;"},"code":{"kind":"string","value":"/**\n * \n */\npackage io.client.thrift;\n\n\n\n\n\n/**\n * 使用 HTTP + JSON 协议\n * \n * 只有这一个文件,适合轻量级通信,如单一接口。由于依赖的 org.json 包 在 android.jar中 已存在,代码整体尺寸很小。\n * \n * @author HouKangxi\n *\n */\npublic class ClientInterfaceFactory {\n\n\tprivate ClientInterfaceFactory() {\n\t}\n\n\tprivate static ConcurrentHashMap ifaceCache = new ConcurrentHashMap();\n\n\t/**\n\t * 获得与服务端通信的接口对象\n\t * \n\t * 调用者可以实现自定义的 SocketFactory来内部配置Socket参数(如超时时间,SSL等),也可以通过返回包装的Socket来实现连接池
\n\t * SocketFactory::createSocket(String host,int ip)//NOTE: 实际传入createSocket(methodName,flag)\n\t * \n\t * @param ifaceClass\n\t * - 接口class\n\t * @param factory\n\t * - 套接字工厂类, 注意:需要实现 createSocket() 方法,需要实现hashCode()方法来区分factory\n\t * @return 接口对象\n\t */\n\t@SuppressWarnings(\"unchecked\")\n\tpublic static INTERFACE getClientInterface(Class ifaceClass, SocketFactory factory) {\n\t\tlong part1 = ifaceClass.getName().hashCode();\n\t\tfinal Long KEY = (part1 << 32) | factory.hashCode();\n\t\tINTERFACE iface = (INTERFACE) ifaceCache.get(KEY);\n\t\tif (iface == null) {\n\t\t\tiface = (INTERFACE) Proxy.newProxyInstance(ifaceClass.getClassLoader(), new Class[] { ifaceClass },\n\t\t\t\t\tnew Handler(factory));\n\t\t\tifaceCache.putIfAbsent(KEY, iface);\n\t\t}\n\t\treturn iface;\n\t}\n \n\t@SuppressWarnings(\"unchecked\")\n\tpublic static INTERFACE getClientInterface(Class ifaceClass, String host) {\n\t\tlong part1 = ifaceClass.getName().hashCode();\n\t\tfinal Long KEY = (part1 << 32) | host.hashCode();\n\t\tINTERFACE iface = (INTERFACE) ifaceCache.get(KEY);\n\t\tif (iface == null) {\n\t\t\tiface = (INTERFACE) Proxy.newProxyInstance(ifaceClass.getClassLoader(), new Class[] { ifaceClass },\n\t\t\t\t\tnew Handler(host));\n\t\t\tifaceCache.putIfAbsent(KEY, iface);\n\t\t}\n\t\treturn iface;\n\t}\n\n\tprivate static ConcurrentHashMap, Map