{ // 获取包含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 !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转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 !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; 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, 'OCR模型免费转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\n"},"max_stars_repo_name":{"kind":"string","value":"thomas159/laravel-shared"}}},{"rowIdx":38514,"cells":{"content":{"kind":"string","value":"<|start_filename|>actions/index.js<|end_filename|>\nexport const ACTION_SHOW_ALERT = 'SHOW-ALERT';\nexport const ACTION_PUT = 'PUT';\nexport const ACTION_CALL = 'CALL';\n\n\n<|start_filename|>reducer/alert.js<|end_filename|>\nimport {ACTION_SHOW_ALERT} from '../actions';\n\nexport default function alertReducer(state = {\n message: '',\n active: false,\n}, action) {\n switch(action.type) {\n\n case ACTION_SHOW_ALERT: {\n const { message } = action.payload;\n\n return {\n ...state,\n message,\n active: true,\n }\n }\n\n default: {\n return state;\n }\n }\n}\n\n\n<|start_filename|>index.js<|end_filename|>\n/**\n * redux-saga-rn-alert\n * @flow\n */\n\n'use strict';\n\nexport { watchAlertChannel, alert } from './saga/alert';\nexport { default as alertReducer } from './reducer/alert';\n"},"max_stars_repo_name":{"kind":"string","value":"jacobkring/redux-saga-rn-alert"}}},{"rowIdx":38515,"cells":{"content":{"kind":"string","value":"<|start_filename|>ext/common/Bfm.h<|end_filename|>\n/******************************************************************************\n * Copyright cocotb contributors\n * Licensed under the Revised BSD License, see LICENSE for details.\n * SPDX-License-Identifier: BSD-3-Clause\n ******************************************************************************/\n#ifndef INCLUDED_BFM_H\n#define INCLUDED_BFM_H\n#include \n#include \n#include \n#include \"BfmMsg.h\"\n\ntypedef void (*bfm_recv_msg_f)(\n\t\tuint32_t\t\tbfm_id,\n\t\tBfmMsg\t\t\t*msg);\n\ntypedef void (*bfm_notify_f)(void *);\n\n\nclass Bfm {\npublic:\n\n Bfm(\n const std::string &inst_name,\n const std::string &cls_name,\n bfm_notify_f notify_f,\n void *notify_data\n );\n\n virtual ~Bfm();\n\n static uint32_t add_bfm(Bfm *bfm);\n\n static const std::vector &get_bfms() { return m_bfm_l; }\n\n const std::string &get_instname() const { return m_instname; }\n\n const std::string &get_clsname() const { return m_clsname; }\n\n void send_msg(BfmMsg *msg);\n\n int claim_msg();\n\n BfmMsg *active_msg() const { return m_active_msg; }\n\n void begin_inbound_msg(uint32_t msg_id);\n\n BfmMsg *active_inbound_msg() const { return m_active_inbound_msg; }\n\n void send_inbound_msg();\n\n static void set_recv_msg_f(bfm_recv_msg_f f);\n\nprotected:\n\nprivate:\n /**\n * Index (ID) of the BFM. Used in routing messages\n * to the appropriate BFM in Python\n */\n uint32_t m_bfm_id;\n /**\n * Instance name of the BFM from simulation\n */\n std::string m_instname;\n /**\n * Python class typename used for this BFM\n */\n std::string m_clsname;\n\n /**\n * Callback function that the BFM calls when\n * an outbound (Python->HDL) message is available\n */\n bfm_notify_f m_notify_f;\n /**\n * User data passed to the notify callback function\n */\n void *m_notify_data;\n /**\n * List of queued output (Python->HDL) messages\n */\n std::vector m_msg_queue;\n\n /**\n * The HDL tasks used for processing messages\n * work on a single message at a time. This is\n * the message currently being processed\n */\n BfmMsg *m_active_msg;\n\n /**\n * The HDL tasks used to build an inbound\n * (HDL->Python) build up a message iteratively.\n * This is a pointer to the message currently\n * being built.\n */\n BfmMsg *m_active_inbound_msg;\n\n /**\n * Callback function to handle inbound (HDL->Python)\n * messages. This function is called by the BFM\n * whenever the HDL BFM sends a message\n */\n static bfm_recv_msg_f m_recv_msg_f;\n\n /**\n * List of BFM class instances.\n */\n static std::vector m_bfm_l;\n\n\n};\n\n#endif /* INCLUDED_BFM_H */\n\n\n<|start_filename|>ve/sys/simple_bfm/Makefile<|end_filename|>\n\nSIMPLE_BFM_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))\nVE_SYS_DIR:=$(abspath $(SIMPLE_BFM_DIR)/..)\nPYBFMS_DIR:=$(abspath $(VE_SYS_DIR)/../..)\n\nPYTHONPATH:=$(PYBFMS_DIR)/src:$(SIMPLE_BFM_DIR)/build/lib.linux-x86_64-3.6:$(PYTHONPATH) \n#PYTHONPATH:=$(PYBFMS_DIR)/src:$(SIMPLE_BFM_DIR)/build:$(PYTHONPATH) \nexport PYTHONPATH\n\n# TODO: Icarus Specific\nSIM_FLAGS += -m $(shell python3 -m pybfms lib --vpi)\n\nifeq ($(SIM),verilator)\n COMPILE_ARGS += -Wno-fatal\nendif\n\n\nTOPLEVEL_LANG ?= verilog\n\nifneq ($(TOPLEVEL_LANG),verilog)\n\nall :\n\t@echo \"Skipping test due to TOPLEVEL_LANG=$(TOPLEVEL_LANG) not being verilog\"\n\nclean::\n\t\nelse\n\nCOCOTB:=$(shell cocotb-config --share)\n\nVERILOG_SOURCES = simple_bfm_top.sv pybfms.v\nTOPLEVEL=simple_bfm_top\n\nMODULE=simple_bfm_test\n\nall : prereqs\n\t$(MAKE) $(COCOTB_RESULTS_FILE)\n\nprereqs :\n\tpython3 $(PYBFMS_DIR)/setup.py build_ext\n\tpython3 -m pybfms generate -l vlog -m simple_bfm\n\nclean::\n\t@rm -rf pybfms.*\n\n\ninclude $(COCOTB)/makefiles/Makefile.inc\ninclude $(VE_SYS_DIR)/common/cocotb/Makefile.sim\n\nendif\n\n\n\n\n<|start_filename|>ext/common/Bfm.cpp<|end_filename|>\n/******************************************************************************\n * Copyright cocotb contributors\n * Licensed under the Revised BSD License, see LICENSE for details.\n * SPDX-License-Identifier: BSD-3-Clause\n ******************************************************************************/\n#include \"Bfm.h\"\n#include \n\n#define EXTERN_C extern \"C\"\n\nBfm::Bfm(\n const std::string &inst_name,\n const std::string &cls_name,\n bfm_notify_f notify_f,\n void *notify_data) :\n m_instname(inst_name),\n m_clsname(cls_name),\n m_notify_f(notify_f),\n m_notify_data(notify_data) {\n m_active_msg = 0;\n m_active_inbound_msg = 0;\n}\n\nBfm::~Bfm() {\n if (m_active_msg) {\n delete m_active_msg;\n m_active_msg = 0;\n }\n if (m_active_inbound_msg) {\n \t delete m_active_inbound_msg;\n }\n}\n\nuint32_t Bfm::add_bfm(Bfm *bfm) {\n bfm->m_bfm_id = static_cast(m_bfm_l.size());\n\n m_bfm_l.push_back(bfm);\n\n return bfm->m_bfm_id;\n}\n\nvoid Bfm::send_msg(BfmMsg *msg) {\n m_msg_queue.push_back(msg);\n if (m_notify_f) {\n m_notify_f(m_notify_data);\n }\n}\n\nint Bfm::claim_msg() {\n if (m_active_msg) {\n delete m_active_msg;\n m_active_msg = 0;\n }\n if (m_msg_queue.size() > 0) {\n m_active_msg = m_msg_queue.at(0);\n m_msg_queue.erase(m_msg_queue.begin());\n int32_t msg_id = static_cast(m_active_msg->id());\n return msg_id;\n } else {\n return -1;\n }\n}\n\nvoid Bfm::begin_inbound_msg(uint32_t msg_id) {\n m_active_inbound_msg = new BfmMsg(msg_id);\n}\n\nvoid Bfm::send_inbound_msg() {\n if (m_recv_msg_f) {\n m_recv_msg_f(m_bfm_id, m_active_inbound_msg);\n } else {\n fprintf(stdout, \"Error: Attempting to send a message (%d) before initialization\\n\",\n m_active_inbound_msg->id());\n fflush(stdout);\n }\n\n // Clean up\n delete m_active_inbound_msg;\n m_active_inbound_msg = 0;\n}\n\nvoid Bfm::set_recv_msg_f(bfm_recv_msg_f f) {\n\tm_recv_msg_f = f;\n}\n\nstd::vector Bfm::m_bfm_l;\nbfm_recv_msg_f Bfm::m_recv_msg_f = 0;\n\n\nEXTERN_C uint32_t bfm_get_count() {\n\treturn Bfm::get_bfms().size();\n}\n\nEXTERN_C const char *bfm_get_instname(uint32_t bfm_id) {\n\treturn Bfm::get_bfms().at(bfm_id)->get_instname().c_str();\n}\n\nEXTERN_C const char *bfm_get_clsname(uint32_t bfm_id) {\n\treturn Bfm::get_bfms().at(bfm_id)->get_clsname().c_str();\n}\n\nEXTERN_C void bfm_send_msg(uint32_t bfm_id, BfmMsg *msg) {\n\tBfm::get_bfms().at(bfm_id)->send_msg(msg);\n}\n\nEXTERN_C void bfm_set_recv_msg_callback(bfm_recv_msg_f f) {\n\tBfm::set_recv_msg_f(f);\n}\n\n\n<|start_filename|>ext/common/BfmMsg.h<|end_filename|>\n/******************************************************************************\n * Copyright cocotb contributors\n * Licensed under the Revised BSD License, see LICENSE for details.\n * SPDX-License-Identifier: BSD-3-Clause\n ******************************************************************************/\n#ifndef INCLUDED_BFM_MSG_H\n#define INCLUDED_BFM_MSG_H\n#include \n#include \n#include \n#include \n\nenum MsgParamType {\n ParamType_Str,\n ParamType_Si,\n ParamType_Ui\n};\n\nstruct MsgParam {\n MsgParamType ptype;\n std::string str;\n union {\n uint64_t ui64;\n int64_t i64;\n const char *str;\n } pval;\n};\n\nstruct BfmMsg {\npublic:\n\n BfmMsg(uint32_t id);\n\n virtual ~BfmMsg();\n\n uint32_t id() const { return m_id; }\n\n void add_param_ui(uint64_t p);\n\n void add_param_si(int64_t p);\n\n void add_param_s(const char *p);\n\n void add_param(const MsgParam &p);\n\n uint32_t num_params() const { return m_param_l.size(); }\n\n const MsgParam *get_param();\n\n const MsgParam *get_param(uint32_t idx) const;\n\n uint64_t get_param_ui();\n\n int64_t get_param_si();\n\n const char *get_param_str();\n\nprotected:\n\nprivate:\n /**\n * Identifies the index of the inbound or outbound\n * task to call. An outbound (Python->HDL) message\n * with id=0 will call the first (0th) task marked\n * with the cocotb.bfm_import decorator.\n */\n uint32_t m_id;\n\n std::vector\t\t\t\t\tm_param_l;\n\n#ifdef UNDEFINED\n /**\n * List of message parameters.\n */\n cocotb_bfm_msg_param_t *m_param_l;\n /**\n * Insert index into the parameter list. Adding\n * new parameters to the message increases _idx\n */\n uint32_t m_param_l_idx;\n /**\n * Maximum size of the parameter list. The parameter\n * list is expanded when _idx >= _max\n */\n uint32_t m_param_l_max;\n#endif\n\n /**\n * The value of string parameters is stored in this\n * list. The parameter-list entry holds a pointer\n * to an element in this list.\n */\n std::vector m_str_l;\n\n /**\n * Read index into the parameter list. _idx is\n * increased when the BFM reads a parameter from\n * the message.\n */\n uint32_t m_idx;\n\n};\n\n\n#endif /* INCLUDED_BFM_MSG_H */\n\n\n\n<|start_filename|>templates/bfm/gvm/bfm_rsp_if.h<|end_filename|>\n/****************************************************************************\n * ${bfm}_rsp_if.h\n *\n ****************************************************************************/\n#pragma once\n#include \n\nclass ${bfm}_rsp_if {\npublic:\n\n\tvirtual ~${bfm}_rsp_if() { }\n\n${bfm_rsp_if_api}\n\n};\n\n\n<|start_filename|>ext/common/BfmMsg.cpp<|end_filename|>\n/******************************************************************************\n * Copyright cocotb contributors\n * Licensed under the Revised BSD License, see LICENSE for details.\n * SPDX-License-Identifier: BSD-3-Clause\n ******************************************************************************/\n#include \"BfmMsg.h\"\n#include \n#include \n\n#define EXTERN_C extern \"C\"\n\nBfmMsg::BfmMsg(uint32_t id) {\n m_id = id;\n m_idx = 0;\n}\n\nBfmMsg::~BfmMsg() {\n}\n\nvoid BfmMsg::add_param_ui(uint64_t p) {\n\tMsgParam param;\n param.ptype = ParamType_Ui;\n param.pval.ui64 = p;\n add_param(param);\n}\n\nvoid BfmMsg::add_param_si(int64_t p) {\n MsgParam param;\n param.ptype = ParamType_Si;\n param.pval.i64 = p;\n add_param(param);\n}\n\nvoid BfmMsg::add_param(const MsgParam &p) {\n\tm_param_l.push_back(p);\n}\n\nvoid BfmMsg::add_param_s(const char *p) {\n\tMsgParam param;\n param.ptype = ParamType_Str;\n m_str_l.push_back(p);\n param.pval.str = m_str_l.at(m_str_l.size()-1).c_str();\n add_param(param);\n}\n\nconst MsgParam *BfmMsg::get_param() {\n MsgParam *ret = 0;\n if (m_idx < m_param_l.size()) {\n ret = &m_param_l[m_idx];\n m_idx++;\n }\n return ret;\n}\n\nconst MsgParam *BfmMsg::get_param(uint32_t idx) const {\n const MsgParam *ret = 0;\n if (idx < m_param_l.size()) {\n ret = &m_param_l[idx];\n }\n return ret;\n}\n\nuint64_t BfmMsg::get_param_ui() {\n uint64_t ret = 0;\n if (m_idx < m_param_l.size()) {\n ret = m_param_l[m_idx].pval.ui64;\n m_idx++;\n } else {\n fprintf(stdout, \"Error: Out-of-bound request\\n\");\n }\n return ret;\n}\n\nint64_t BfmMsg::get_param_si() {\n int64_t ret = 0;\n if (m_idx < m_param_l.size()) {\n ret = m_param_l[m_idx].pval.i64;\n m_idx++;\n }\n return ret;\n}\n\nconst char *BfmMsg::get_param_str() {\n const char *ret = \"\";\n if (m_idx < m_param_l.size()) {\n ret = m_param_l[m_idx].pval.str;\n m_idx++;\n }\n return ret;\n}\n\nEXTERN_C void *bfm_msg_new(uint32_t msg_id) {\n\tBfmMsg *ret = new BfmMsg(msg_id);\n\n\treturn ret;\n}\n\nEXTERN_C void bfm_msg_add_param_ui(BfmMsg *msg, uint64_t p) {\n\tmsg->add_param_ui(p);\n}\n\nEXTERN_C void bfm_msg_add_param_si(BfmMsg *msg, int64_t p) {\n\tmsg->add_param_si(p);\n}\n\nEXTERN_C uint32_t bfm_msg_id(BfmMsg *msg) {\n\treturn msg->id();\n}\n\nEXTERN_C const MsgParam *bfm_msg_get_param(BfmMsg *msg) {\n\treturn msg->get_param();\n}\n\nEXTERN_C uint32_t bfm_msg_param_type(MsgParam *p) {\n\treturn p->ptype;\n}\n\nEXTERN_C uint64_t bfm_msg_param_ui(MsgParam *p) {\n\treturn p->pval.ui64;\n}\n\nEXTERN_C int64_t bfm_msg_param_si(MsgParam *p) {\n\treturn p->pval.i64;\n}\n\n\n\n\n<|start_filename|>templates/bfm/gvm/bfm_dpi.cpp<|end_filename|>\n/****************************************************************************\n * ${bfm}_dpi.cpp\n *\n * Warning: This file is generated and should not be hand modified\n ****************************************************************************/\n#include \"${bfm}.h\"\n\n/********************************************************************\n * ${bfm}_register()\n *\n ********************************************************************/\nextern \"C\" uint32_t ${bfm}_register(const char *path) {\n\treturn ${bfm}_t::register_bfm(path);\n}\n\n${bfm_dpi_imports}\n\n${bfm}_t\t\t\t\t\t${bfm}_type;\n\n\n\n<|start_filename|>Dockerfile<|end_filename|>\nFROM quay.io/pypa/manylinux2010_x86_64\n\n#RUN /opt/python/cp35-cp35m/bin/pip install --upgrade pip \n#RUN /opt/python/cp35-cp35m/bin/pip install cython wheel twine\nRUN /opt/python/cp36-cp36m/bin/pip install --upgrade pip\nRUN /opt/python/cp36-cp36m/bin/pip install cython wheel twine\nRUN /opt/python/cp37-cp37m/bin/pip install --upgrade pip\nRUN /opt/python/cp37-cp37m/bin/pip install cython wheel twine\nRUN /opt/python/cp38-cp38/bin/pip install --upgrade pip\nRUN /opt/python/cp38-cp38/bin/pip install cython wheel twine\nRUN /opt/python/cp39-cp39/bin/pip install --upgrade pip\nRUN /opt/python/cp39-cp39/bin/pip install cython wheel twine\n\nCMD /pybfms/build.sh\n\n\n\n\n<|start_filename|>ext/hdl_sim/dpi_if.cpp<|end_filename|>\n/******************************************************************************\n * dpi_if.cpp\n ******************************************************************************/\n#include \n#include \"Bfm.h\"\n\n#define EXTERN_C extern \"C\"\n\nEXTERN_C int pybfms_claim_msg(uint32_t id);\nEXTERN_C int pybfms_end_msg(uint32_t bfm_id);\n\nEXTERN_C uint32_t pybfms_register(\n const char *inst_name,\n const char *cls_name,\n bfm_notify_f notify_f,\n void *notify_data) {\n\n return Bfm::add_bfm(new Bfm(\n inst_name,\n cls_name,\n notify_f,\n notify_data\n ));\n}\n\n// Returns the number of registered BFMs\nEXTERN_C uint32_t pybfms_num_registered(void) {\n return static_cast(Bfm::get_bfms().size());\n}\n\n// Returns the instance name of the specified BFM\nEXTERN_C const char *pybfms_instname(uint32_t id) {\n return Bfm::get_bfms().at(id)->get_instname().c_str();\n}\n\n// Returns the class name of the specified BFM\nEXTERN_C const char *pybfms_clsname(uint32_t id) {\n return Bfm::get_bfms().at(id)->get_clsname().c_str();\n}\n\n//\nEXTERN_C int pybfms_claim_msg(uint32_t id) {\n return Bfm::get_bfms().at(id)->claim_msg();\n}\n\nEXTERN_C uint64_t pybfms_get_ui_param(uint32_t id) {\n Bfm *bfm = Bfm::get_bfms().at(id);\n BfmMsg *msg = bfm->active_msg();\n\n if (msg) {\n return msg->get_param_ui();\n } else {\n return 0;\n }\n}\n\nEXTERN_C int64_t pybfms_get_si_param(uint32_t id) {\n Bfm *bfm = Bfm::get_bfms().at(id);\n BfmMsg *msg = bfm->active_msg();\n\n if (msg) {\n return msg->get_param_si();\n } else {\n return 0;\n }\n}\n\nEXTERN_C const char *pybfms_get_str_param(uint32_t id) {\n Bfm *bfm = Bfm::get_bfms().at(id);\n BfmMsg *msg = bfm->active_msg();\n\n if (msg) {\n return msg->get_param_str();\n } else {\n return 0;\n }\n}\n\nEXTERN_C void pybfms_begin_msg(uint32_t bfm_id, uint32_t msg_id) {\n Bfm *bfm = Bfm::get_bfms().at(bfm_id);\n\n bfm->begin_inbound_msg(msg_id);\n}\n\nEXTERN_C void pybfms_add_si_param(uint32_t bfm_id, int64_t pval) {\n Bfm *bfm = Bfm::get_bfms().at(bfm_id);\n BfmMsg *msg = bfm->active_inbound_msg();\n\n if (msg) {\n msg->add_param_si(pval);\n } else {\n fprintf(stdout, \"Error: attempting to add a signed parameter to a NULL message\\n\");\n }\n}\n\nEXTERN_C void pybfms_add_ui_param(uint32_t bfm_id, uint64_t pval) {\n Bfm *bfm = Bfm::get_bfms().at(bfm_id);\n BfmMsg *msg = bfm->active_inbound_msg();\n\n if (msg) {\n msg->add_param_ui(pval);\n } else {\n fprintf(stdout, \"Error: attempting to add an unsigned parameter to a NULL message\\n\");\n }\n}\n\nEXTERN_C int pybfms_end_msg(uint32_t bfm_id) {\n Bfm *bfm = Bfm::get_bfms().at(bfm_id);\n\n bfm->send_inbound_msg();\n return 0;\n}\n\n#ifdef UNDEFINED\nEXTERN_C void pybfms_send_msg(uint32_t bfm_id,\n uint32_t msg_id,\n uint32_t paramc,\n pybfms_msg_param_t *paramv) {\n Bfm *bfm = Bfm::get_bfms().at(bfm_id);\n BfmMsg *msg = new BfmMsg(msg_id, static_cast(paramc), paramv);\n bfm->send_msg(msg);\n}\n#endif\n\nEXTERN_C void pybfms_set_recv_msg_f(bfm_recv_msg_f recv_msg_f) {\n Bfm::set_recv_msg_f(recv_msg_f);\n}\n\n\n<|start_filename|>templates/bfm/gvm/bfm_base.cpp<|end_filename|>\n/****************************************************************************\n * ${bfm}_base.cpp\n *\n ****************************************************************************/\n#include \"${bfm}_base.h\"\n#include \"GoogletestHdl.h\"\n\n${bfm_dpi_export_func_decl}\n\n${bfm}_base::${bfm}_base(${bfm}_rsp_if *rsp_if) : GvmBfm(rsp_if) {\n\n}\n\n${bfm}_base::~${bfm}_base() {\n\n}\n\n${bfm_dpi_export_method_def}\n\n\n\n<|start_filename|>templates/bfm/gvm/bfm_base.h<|end_filename|>\n/****************************************************************************\n * ${bfm}_base.h\n *\n ****************************************************************************/\n#pragma once\n#include \n#include \"${bfm}_rsp_if.h\"\n#include \"GvmBfm.h\"\n\nclass ${bfm}_base : public GvmBfm<${bfm}_rsp_if> {\npublic:\n\n\t${bfm}_base(${bfm}_rsp_if *rsp_if=0);\n\n\tvirtual ~${bfm}_base();\n\n${bfm_dpi_export_method_decl}\n\n\n};\n\n\n\n<|start_filename|>mkfiles/bfm-tools.mk<|end_filename|>\n\nBFM_TOOLS_MKFILES_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))\n\nifneq (1,$(BFM_TOOLS_MKFILES_DIR))\n\nBFM_TOOLS := $(abspath $(BFM_TOOLS_MKFILES_DIR)/..)\nexport BFM_TOOLS\n\nBFM_TOOLS_GEN_FILES = $(1)/$(2)_api_pkg.sv $(1)/$(2)_api.svh $(1)/gvm/$(2)_bfm_base.h $(1)/gvm/$(2)_bfm_base.cpp $(1)/gvm/$(2)_rsp_if.h $(1)/gvm/$(2)_dpi.cpp\n\nelse # Rules\n\nendif\n"},"max_stars_repo_name":{"kind":"string","value":"sv-bfms/bfm_core"}}},{"rowIdx":38516,"cells":{"content":{"kind":"string","value":"<|start_filename|>main.go<|end_filename|>\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"github.com/EDDYCJY/fake-useragent\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"math\"\n\t\"math/rand\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/apoorvam/goterminal\"\n\t\"github.com/shirou/gopsutil/cpu\"\n\t\"github.com/shirou/gopsutil/load\"\n\t\"github.com/shirou/gopsutil/mem\"\n\t\"github.com/shirou/gopsutil/net\"\n)\n\nconst (\n\tletterIdxBits = 6\n\tletterIdxMask = 1<= 0; {\n\t\tif remain == 0 {\n\t\t\tcache, remain = rand.Int63(), letterIdxMax\n\t\t}\n\t\tif idx := int(cache & letterIdxMask); idx < len(letterBytes) {\n\t\t\tb[i] = letterBytes[idx]\n\t\t\ti--\n\t\t}\n\t\tcache >>= letterIdxBits\n\t\tremain--\n\t}\n\treturn string(b)\n}\n\nfunc generateRandomIPAddress() string {\n\trand.Seed(time.Now().Unix())\n\tip := fmt.Sprintf(\"%d.%d.%d.%d\", rand.Intn(255), rand.Intn(255), rand.Intn(255), rand.Intn(255))\n\treturn ip\n}\n\nfunc showStat() {\n\tinitialNetCounter, _ := net.IOCounters(true)\n\tfor true {\n\t\tpercent, _ := cpu.Percent(time.Second, false)\n\t\tmemStat, _ := mem.VirtualMemory()\n\t\tnetCounter, _ := net.IOCounters(true)\n\t\tloadStat, _ := load.Avg()\n\n\t\tfmt.Fprintf(TerminalWriter, \"cpu percent:%.3f%% \\n\", percent)\n\t\tfmt.Fprintf(TerminalWriter, \"mem percent:%v%% \\n\", memStat.UsedPercent)\n\t\tfmt.Fprintf(TerminalWriter, \"load info:%.3f %.3f %.3f\\n\", loadStat.Load1, loadStat.Load5, loadStat.Load15)\n\t\tfor i := 0; i < len(netCounter); i++ {\n\t\t\tif netCounter[i].BytesRecv == 0 && netCounter[i].BytesSent == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfmt.Fprintf(TerminalWriter, \"Nic:%v %s/s %s/s\\n\", netCounter[i].Name,\n\t\t\t\treadableBytes(float64(netCounter[i].BytesRecv-initialNetCounter[i].BytesRecv)),\n\t\t\t\treadableBytes(float64(netCounter[i].BytesSent-initialNetCounter[i].BytesSent)))\n\t\t}\n\t\tinitialNetCounter = netCounter\n\t\tTerminalWriter.Clear()\n\t\tTerminalWriter.Print()\n\t\ttime.Sleep(1 * time.Millisecond)\n\t}\n}\n\nfunc readableBytes(bytes float64) (expression string) {\n\tif bytes == 0 {\n\t\treturn \"0B\"\n\t}\n\tvar i = math.Floor(math.Log(bytes) / math.Log(1024))\n\tvar sizes = []string{\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"}\n\treturn fmt.Sprintf(\"%.3f%s\", bytes/math.Pow(1024, i), sizes[int(i)])\n}\n\nfunc goFun(Url string, postContent string, Referer string, XforwardFor bool, wg *sync.WaitGroup) {\n\tfor true {\n\t\tvar request *http.Request\n\t\tvar err1 error = nil\n\t\tclient := &http.Client{}\n\t\tif len(postContent) > 0 {\n\t\t\trequest, err1 = http.NewRequest(\"POST\", Url, strings.NewReader(postContent))\n\t\t} else {\n\t\t\trequest, err1 = http.NewRequest(\"GET\", Url, nil)\n\t\t}\n\t\tif err1 != nil {\n\t\t\tcontinue\n\t\t}\n\t\tif len(Referer) == 0 {\n\t\t\tReferer = Url\n\t\t}\n\t\trequest.Header.Add(\"Cookie\", RandStringBytesMaskImpr(12))\n\t\trequest.Header.Add(\"User-Agent\", browser.Random())\n\t\trequest.Header.Add(\"Referer\", Referer)\n\t\tif XforwardFor {\n\t\t\trandomip := generateRandomIPAddress()\n\t\t\trequest.Header.Add(\"X-Forwarded-For\", randomip)\n\t\t\trequest.Header.Add(\"X-Real-IP\", randomip)\n\t\t}\n\t\tresp, err2 := client.Do(request)\n\t\tif err2 != nil {\n\t\t\tcontinue\n\t\t}\n\t\t_, err3 := io.Copy(ioutil.Discard, resp.Body)\n\t\tif err3 != nil {\n\t\t\tcontinue\n\t\t}\n\t}\n\twg.Done()\n}\n\nvar count = flag.Int(\"c\", 16, \"cocurrent thread for download\")\nvar url = flag.String(\"s\", \"https://baidu.com\", \"target url\")\nvar postContent = flag.String(\"p\", \"\", \"post content\")\nvar referer = flag.String(\"r\", \"\", \"referer url\")\nvar xforwardfor = flag.Bool(\"f\", false, \"random X-Forwarded-For ip address\")\nvar TerminalWriter = goterminal.New(os.Stdout)\n\nfunc main() {\n\tflag.Parse()\n\tgo showStat()\n\tvar waitgroup sync.WaitGroup\n\tif *count <= 0 {\n\t\t*count = 16\n\t}\n\tfor i := 0; i < *count; i++ {\n\t\twaitgroup.Add(1)\n\t\tgo goFun(*url, *postContent, *referer, *xforwardfor, &waitgroup)\n\t}\n\twaitgroup.Wait()\n\tTerminalWriter.Reset()\n}\n"},"max_stars_repo_name":{"kind":"string","value":"Droid-MAX/webBenchmark"}}},{"rowIdx":38517,"cells":{"content":{"kind":"string","value":"<|start_filename|>src/test/java/org/simpleframework/xml/core/PathParserTest.java<|end_filename|>\npackage org.simpleframework.xml.core;\r\n\r\nimport junit.framework.TestCase;\r\n\r\nimport org.simpleframework.xml.strategy.Type;\r\nimport org.simpleframework.xml.stream.CamelCaseStyle;\r\nimport org.simpleframework.xml.stream.Format;\r\n\r\npublic class PathParserTest extends TestCase {\r\n \r\n public void testStyledPath() throws Exception {\r\n Type type = new ClassType(PathParserTest.class);\r\n Expression expression = new PathParser( \"this/is/a/path\", type, new Format(new CamelCaseStyle()));\r\n String attributePath = expression.getAttribute(\"final\");\r\n assertEquals(attributePath, \"This[1]/Is[1]/A[1]/Path[1]/@final\");\r\n String elementPath = expression.getElement(\"final\");\r\n assertEquals(elementPath, \"This[1]/Is[1]/A[1]/Path[1]/Final[1]\");\r\n }\r\n \r\n public void testStyledPathWithPrefixes() throws Exception {\r\n Type type = new ClassType(PathParserTest.class);\r\n Expression expression = new PathParser(\"pre:this/is/a/pre:path\", type, new Format(new CamelCaseStyle()));\r\n String attributePath = expression.getAttribute(\"final\");\r\n assertEquals(attributePath, \"pre:This[1]/Is[1]/A[1]/pre:Path[1]/@final\");\r\n String elementPath = expression.getElement(\"final\");\r\n assertEquals(elementPath, \"pre:This[1]/Is[1]/A[1]/pre:Path[1]/Final[1]\");\r\n }\r\n \r\n \r\n public void testEmptyPath() throws Exception {\r\n Type type = new ClassType(PathParserTest.class);\r\n Expression expression = new PathParser( \".\", type, new Format());\r\n String element = expression.getElement(\"a\");\r\n assertEquals(expression.getPath(), \"\");\r\n assertEquals(element, \"a\");\r\n String attribute = expression.getAttribute(\"a\");\r\n assertEquals(attribute, \"a\");\r\n assertTrue(expression.isEmpty());\r\n Expression single = new PathParser(\"name\", type, new Format());\r\n Expression empty = single.getPath(1);\r\n assertTrue(empty.isEmpty());\r\n }\r\n \r\n public void testAttributePath() throws Exception {\r\n Type type = new ClassType(PathParserTest.class);\r\n Expression expression = new PathParser(\"some/path\", type, new Format());\r\n String element = expression.getElement(\"element\");\r\n assertEquals(element, \"some[1]/path[1]/element[1]\");\r\n String attribute = expression.getAttribute(\"attribute\");\r\n assertEquals(attribute, \"some[1]/path[1]/@attribute\");\r\n assertFalse(expression.isEmpty());\r\n Expression attr = new PathParser(attribute, type, new Format());\r\n assertFalse(attr.isEmpty()); \r\n assertTrue(attr.isAttribute());\r\n assertEquals(attr.getLast(), \"attribute\");\r\n assertEquals(attr.getFirst(), \"some\");\r\n Expression ending = new PathParser(\"a/b@c\", type, new Format());\r\n assertTrue(ending.isAttribute());\r\n assertEquals(ending.getFirst(), \"a\");\r\n assertEquals(ending.getLast(), \"c\");\r\n \r\n }\r\n \r\n public void testSimplePath() throws Exception {\r\n Expression expression = new PathParser(\"path1/path2/path3/path4\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"path1\");\r\n assertEquals(expression.getPrefix(), null);\r\n assertEquals(expression.getLast(), \"path4\");\r\n assertEquals(expression.toString(), \"path1/path2/path3/path4\");\r\n assertTrue(expression.isPath());\r\n assertFalse(expression.isAttribute());\r\n \r\n expression = expression.getPath(1);\r\n assertEquals(expression.getFirst(), \"path2\");\r\n assertEquals(expression.getPrefix(), null);\r\n assertEquals(expression.getLast(), \"path4\");\r\n assertEquals(expression.toString(), \"path2/path3/path4\");\r\n assertTrue(expression.isPath());\r\n assertFalse(expression.isAttribute());\r\n }\r\n \r\n public void testPathPrefix() throws Exception {\r\n Expression expression = new PathParser(\"ns1:path1/ns2:path2/path3/ns3:path4[2]\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"path1\");\r\n assertEquals(expression.getPrefix(), \"ns1\");\r\n assertEquals(expression.getLast(), \"path4\");\r\n assertEquals(expression.toString(), \"ns1:path1/ns2:path2/path3/ns3:path4[2]\");\r\n assertTrue(expression.isPath());\r\n assertFalse(expression.isAttribute());\r\n \r\n expression = expression.getPath(1);\r\n assertEquals(expression.getFirst(), \"path2\");\r\n assertEquals(expression.getPrefix(), \"ns2\");\r\n assertEquals(expression.getLast(), \"path4\");\r\n assertEquals(expression.toString(), \"ns2:path2/path3/ns3:path4[2]\");\r\n assertTrue(expression.isPath());\r\n assertFalse(expression.isAttribute());\r\n \r\n expression = expression.getPath(1);\r\n assertEquals(expression.getFirst(), \"path3\");\r\n assertEquals(expression.getPrefix(), null);\r\n assertEquals(expression.getLast(), \"path4\");\r\n assertEquals(expression.toString(), \"path3/ns3:path4[2]\");\r\n assertTrue(expression.isPath());\r\n assertFalse(expression.isAttribute());\r\n \r\n expression = expression.getPath(1);\r\n assertEquals(expression.getFirst(), \"path4\");\r\n assertEquals(expression.getPrefix(), \"ns3\");\r\n assertEquals(expression.getLast(), \"path4\");\r\n assertEquals(expression.getIndex(), 2);\r\n assertEquals(expression.toString(), \"ns3:path4[2]\");\r\n assertFalse(expression.isPath());\r\n assertFalse(expression.isAttribute());\r\n }\r\n \r\n public void testAttribute() throws Exception {\r\n Expression expression = new PathParser(\"./some[3]/path[2]/to/parse/@attribute\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"some\");\r\n assertEquals(expression.getIndex(), 3);\r\n assertEquals(expression.getLast(), \"attribute\");\r\n assertEquals(expression.toString(), \"some[3]/path[2]/to/parse/@attribute\");\r\n assertTrue(expression.isPath());\r\n assertTrue(expression.isAttribute());\r\n \r\n expression = expression.getPath(2);\r\n assertEquals(expression.getFirst(), \"to\");\r\n assertEquals(expression.getIndex(), 1);\r\n assertEquals(expression.getLast(), \"attribute\");\r\n assertEquals(expression.toString(), \"to/parse/@attribute\");\r\n assertTrue(expression.isPath());\r\n assertTrue(expression.isAttribute());\r\n \r\n expression = expression.getPath(2);\r\n assertEquals(expression.getFirst(), \"attribute\");\r\n assertEquals(expression.getIndex(), 1);\r\n assertEquals(expression.getLast(), \"attribute\");\r\n assertEquals(expression.toString(), \"@attribute\");\r\n assertFalse(expression.isPath());\r\n assertTrue(expression.isAttribute());\r\n }\r\n\r\n public void testIndex() throws Exception {\r\n Expression expression = new PathParser(\"./some[3]/path[2]/to/parse\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"some\");\r\n assertEquals(expression.getIndex(), 3);\r\n assertEquals(expression.getLast(), \"parse\");\r\n assertEquals(expression.toString(), \"some[3]/path[2]/to/parse\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(1);\r\n assertEquals(expression.getFirst(), \"path\");\r\n assertEquals(expression.getIndex(), 2);\r\n assertEquals(expression.getLast(), \"parse\");\r\n assertEquals(expression.toString(), \"path[2]/to/parse\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(0, 1);\r\n assertEquals(expression.getFirst(), \"path\");\r\n assertEquals(expression.getIndex(), 2);\r\n assertEquals(expression.getLast(), \"to\");\r\n assertEquals(expression.toString(), \"path[2]/to\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(0, 1);\r\n assertEquals(expression.getFirst(), \"path\");\r\n assertEquals(expression.getIndex(), 2);\r\n assertEquals(expression.getLast(), \"path\");\r\n assertEquals(expression.toString(), \"path[2]\");\r\n assertFalse(expression.isPath());\r\n \r\n expression = new PathParser( \"./a[10]/b[2]/c/d\", new ClassType(PathParserTest.class), new Format()); \r\n assertEquals(expression.getFirst(), \"a\");\r\n assertEquals(expression.getIndex(), 10);\r\n assertEquals(expression.getLast(), \"d\");\r\n assertEquals(expression.toString(), \"a[10]/b[2]/c/d\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(1, 1);\r\n assertEquals(expression.getFirst(), \"b\");\r\n assertEquals(expression.getIndex(), 2);\r\n assertEquals(expression.getLast(), \"c\");\r\n assertEquals(expression.toString(), \"b[2]/c\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = new PathParser( \"a[10]/b[2]/c/d[300]\", new ClassType(PathParserTest.class), new Format()); \r\n assertEquals(expression.getFirst(), \"a\");\r\n assertEquals(expression.getIndex(), 10);\r\n assertEquals(expression.getLast(), \"d\");\r\n assertEquals(expression.toString(), \"a[10]/b[2]/c/d[300]\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(3); \r\n assertEquals(expression.getFirst(), \"d\");\r\n assertEquals(expression.getIndex(), 300);\r\n assertEquals(expression.getLast(), \"d\");\r\n assertEquals(expression.toString(), \"d[300]\");\r\n assertFalse(expression.isPath());\r\n \r\n expression = new PathParser(\"b[1]/c/d[300]/\", new ClassType(PathParserTest.class), new Format()); \r\n assertEquals(expression.getFirst(), \"b\");\r\n assertEquals(expression.getIndex(), 1);\r\n assertEquals(expression.getLast(), \"d\");\r\n assertEquals(expression.toString(), \"b[1]/c/d[300]\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(1); \r\n assertEquals(expression.getFirst(), \"c\");\r\n assertEquals(expression.getIndex(), 1);\r\n assertEquals(expression.getLast(), \"d\");\r\n assertEquals(expression.toString(), \"c/d[300]\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(0, 1); \r\n assertEquals(expression.getFirst(), \"c\");\r\n assertEquals(expression.getIndex(), 1);\r\n assertEquals(expression.getLast(), \"c\");\r\n assertEquals(expression.toString(), \"c\");\r\n assertFalse(expression.isPath());\r\n }\r\n \r\n public void testExpressions() throws Exception {\r\n Expression expression = new PathParser(\"./some/path/to/parse\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"some\");\r\n assertEquals(expression.getLast(), \"parse\");\r\n assertEquals(expression.toString(), \"some/path/to/parse\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(2);\r\n assertEquals(expression.getFirst(), \"to\");\r\n assertEquals(expression.getLast(), \"parse\");\r\n assertEquals(expression.toString(), \"to/parse\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = new PathParser(\"a/b/c/d/e/f/g\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"a\");\r\n assertEquals(expression.getLast(), \"g\");\r\n assertEquals(expression.toString(), \"a/b/c/d/e/f/g\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(2);\r\n assertEquals(expression.getFirst(), \"c\");\r\n assertEquals(expression.getLast(), \"g\");\r\n assertEquals(expression.toString(), \"c/d/e/f/g\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(1);\r\n assertEquals(expression.getFirst(), \"d\");\r\n assertEquals(expression.getLast(), \"g\");\r\n assertEquals(expression.toString(), \"d/e/f/g\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = new PathParser(\"1/2/3/4/5/6/7\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"1\");\r\n assertEquals(expression.getLast(), \"7\");\r\n assertEquals(expression.toString(), \"1/2/3/4/5/6/7\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(1, 1);\r\n assertEquals(expression.getFirst(), \"2\");\r\n assertEquals(expression.getLast(), \"6\");\r\n assertEquals(expression.toString(), \"2/3/4/5/6\");\r\n assertTrue(expression.isPath());\r\n\r\n expression = expression.getPath(1, 1);\r\n assertEquals(expression.getFirst(), \"3\");\r\n assertEquals(expression.getLast(), \"5\");\r\n assertEquals(expression.toString(), \"3/4/5\");\r\n assertTrue(expression.isPath());\r\n \r\n expression = expression.getPath(1, 1);\r\n assertEquals(expression.getFirst(), \"4\");\r\n assertEquals(expression.getLast(), \"4\");\r\n assertEquals(expression.toString(), \"4\");\r\n assertFalse(expression.isPath());\r\n \r\n expression = new PathParser(\".\", new ClassType(PathParserTest.class), new Format());\r\n assertFalse(expression.isPath());\r\n \r\n expression = new PathParser( \"./name\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"name\");\r\n assertEquals(expression.getLast(), \"name\");\r\n assertEquals(expression.toString(), \"name\");\r\n assertFalse(expression.isPath()); \r\n \r\n expression = new PathParser(\"./path/\", new ClassType(PathParserTest.class), new Format());\r\n assertEquals(expression.getFirst(), \"path\");\r\n assertEquals(expression.getLast(), \"path\");\r\n assertEquals(expression.toString(), \"path\");\r\n assertFalse(expression.isPath()); \r\n }\r\n \r\n \r\n public void testExceptions() throws Exception {\r\n ensureException(\"//\");\r\n ensureException(\"some[[1]/path\");\r\n ensureException(\"some1]/path\");\r\n ensureException(\"a/b//c\");\r\n ensureException(\"./a[100]//b\");\r\n ensureException(\"./a[100]/b/@@attribute\");\r\n ensureException(\"../a[100]/b/@attribute\");\r\n ensureException(\"../a[100]/@b/@attribute\");\r\n ensureException(\"a//b//c\");\r\n ensureException(\"a/@b/@c\");\r\n ensureException(\"a/@b/\");\r\n ensureException(\"a/b[1]/c[\");\r\n ensureException(\"a/b[1]/c/@\");\r\n ensureException(\"a@\");\r\n }\r\n \r\n private void ensureException(String path) {\r\n boolean exception = false;\r\n try{\r\n new PathParser( path, new ClassType(PathParserTest.class), new Format());\r\n }catch(Exception e){\r\n e.printStackTrace();\r\n exception = true;\r\n }\r\n assertTrue(\"Exception should be thrown for \"+path, exception);\r\n }\r\n\r\n}\r\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/core/PathWithExtraSectionTest.java<|end_filename|>\npackage org.simpleframework.xml.core;\r\n\r\nimport org.simpleframework.xml.Default;\r\nimport org.simpleframework.xml.Element;\r\nimport org.simpleframework.xml.Path;\r\nimport org.simpleframework.xml.ValidationTestCase;\r\n\r\npublic class PathWithExtraSectionTest extends ValidationTestCase {\r\n\r\n private static final String SOURCE =\r\n \"\\n\"+\r\n \" \\n\"+\r\n \" \\n\"+\r\n \" 67890\\n\"+\r\n \" \\n\"+\r\n \" \\n\"+\r\n \" \\n\"+\r\n \" \\n\"+\r\n \" 12345\\n\"+\r\n \" \\n\"+\r\n \" \\n\"+\r\n \" \\n\"+\r\n \" \\n\"+\r\n \" 23523\\n\"+\r\n \" \\n\"+\r\n \" \\n\"+ \r\n \"\\n\";\r\n\r\n @Default\r\n @SuppressWarnings(\"all\")\r\n private static class PathSectionIndexExample {\r\n \r\n @Path(\"contact-details[2]/phone\")\r\n private String home;\r\n \r\n @Path(\"contact-details[1]/phone\")\r\n private String mobile;\r\n \r\n public PathSectionIndexExample(\r\n @Element(name=\"home\") String home,\r\n @Element(name=\"mobile\") String mobile) {\r\n this.home = home;\r\n this.mobile = mobile;\r\n }\r\n }\r\n \r\n public void testExtraSection() throws Exception {\r\n Persister persister = new Persister();\r\n boolean exception = false;\r\n \r\n try {\r\n persister.read(PathSectionIndexExample.class, SOURCE);\r\n }catch(Exception e) {\r\n e.printStackTrace();\r\n exception = true;\r\n }\r\n assertTrue(\"There should be an exception for unmatched section\", exception); \r\n }\r\n \r\n public void testExtraSectionWithNonStrict() throws Exception {\r\n Persister persister = new Persister();\r\n PathSectionIndexExample example = persister.read(PathSectionIndexExample.class, SOURCE, false);\r\n assertEquals(example.home, \"12345\");\r\n assertEquals(example.mobile, \"67890\"); \r\n }\r\n}\r\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/core/UnionSameTypeDifferentNameTest.java<|end_filename|>\npackage org.simpleframework.xml.core;\r\n\r\nimport org.simpleframework.xml.Element;\r\nimport org.simpleframework.xml.Root;\r\nimport org.simpleframework.xml.ValidationTestCase;\r\nimport org.simpleframework.xml.ElementUnion;\r\n\r\npublic class UnionSameTypeDifferentNameTest extends ValidationTestCase {\r\n \r\n private static final String USERNAME_SOURCE =\r\n \"\"+\r\n \" john.doe\"+\r\n \"\";\r\n \r\n private static final String LOGIN_SOURCE =\r\n \"\"+\r\n \" john.doe\"+\r\n \"\";\r\n \r\n private static final String ACCOUNT_SOURCE =\r\n \"\"+\r\n \" john.doe\"+\r\n \"\"; \r\n \r\n @Root\r\n private static class OptionalNameExample {\r\n \r\n @ElementUnion({\r\n @Element(name=\"login\"),\r\n @Element(name=\"name\"),\r\n @Element(name=\"username\", type=String.class),\r\n @Element(name=\"account\")\r\n }) \r\n private String name;\r\n public String getName(){\r\n return name;\r\n }\r\n public void setName(String name){\r\n this.name = name;\r\n }\r\n }\r\n\r\n public void testOptionalName() throws Exception{\r\n Persister persister = new Persister();\r\n \r\n OptionalNameExample username = persister.read(OptionalNameExample.class, USERNAME_SOURCE);\r\n assertEquals(username.getName(), \"john.doe\");\r\n validate(persister, username);\r\n \r\n OptionalNameExample login = persister.read(OptionalNameExample.class, LOGIN_SOURCE);\r\n assertEquals(login.getName(), \"john.doe\");\r\n validate(persister, login);\r\n \r\n OptionalNameExample account = persister.read(OptionalNameExample.class, ACCOUNT_SOURCE);\r\n assertEquals(account.getName(), \"john.doe\");\r\n validate(persister, account);\r\n }\r\n}\r\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/core/CollectionConstructorTest.java<|end_filename|>\npackage org.simpleframework.xml.core;\n\nimport java.util.Map;\nimport java.util.Vector;\n\nimport junit.framework.TestCase;\n\nimport org.simpleframework.xml.Attribute;\nimport org.simpleframework.xml.Element;\nimport org.simpleframework.xml.ElementList;\nimport org.simpleframework.xml.ElementMap;\nimport org.simpleframework.xml.Root;\n\npublic class CollectionConstructorTest extends TestCase {\n \n private static final String LIST =\n \"\"+\n \" \"+\n \" \"+\n \"\";\n \n private static final String MAP =\n \"\"+\n \" \"+\n \" \"+\n \" \"+\n \" \"+\n \" \"+\n \" \"+\n \"\";\n \n \n private static final String COMPOSITE =\n \"\"+\n \" \"+\n \" \"+\n \" \"+\n \" \"+\n \"\";\n \n @Root(name=\"example\")\n private static class MapConstructor {\n \n @ElementMap(name=\"list\", entry=\"element\", key=\"key\", attribute=true, inline=true)\n private final Map map;\n \n public MapConstructor(@ElementMap(name=\"list\", entry=\"element\", key=\"key\", attribute=true, inline=true) Map map) {\n this.map = map;\n }\n \n public int size() {\n return map.size();\n }\n }\n \n @Root(name=\"example\")\n private static class CollectionConstructor {\n \n @ElementList(name=\"list\", inline=true)\n private final Vector vector;\n \n public CollectionConstructor(@ElementList(name=\"list\", inline=true) Vector vector) {\n this.vector = vector;\n }\n \n public int size() {\n return vector.size();\n }\n }\n \n @Root(name=\"entry\")\n private static class Entry {\n \n @Attribute(name=\"name\")\n private final String name;\n \n @Attribute(name=\"value\")\n private final String value;\n \n public Entry(@Attribute(name=\"name\") String name, @Attribute(name=\"value\") String value) {\n this.name = name;\n this.value = value;\n }\n \n public String getName() {\n return name;\n }\n \n public String getValue() {\n return value;\n }\n }\n \n @Root(name=\"example\")\n private static class ExtendedCollectionConstructor extends CollectionConstructor {\n \n public ExtendedCollectionConstructor(@ElementList(name=\"list\", inline=true) Vector vector) {\n super(vector);\n }\n }\n \n @Root(name=\"composite\")\n private static class CollectionConstructorComposite {\n \n @Element(name=\"example\")\n private CollectionConstructor collection;\n \n public CollectionConstructor getCollection() {\n return collection;\n }\n }\n \n public void testCollectionConstructor() throws Exception {\n Persister persister = new Persister();\n CollectionConstructor constructor = persister.read(CollectionConstructor.class, LIST);\n \n assertEquals(constructor.size(), 2);\n }\n \n public void testMapConstructor() throws Exception {\n Persister persister = new Persister();\n MapConstructor constructor = persister.read(MapConstructor.class, MAP);\n \n assertEquals(constructor.size(), 2);\n }\n\n public void testCollectionConstructorComposite() throws Exception {\n Persister persister = new Persister();\n CollectionConstructorComposite composite = persister.read(CollectionConstructorComposite.class, COMPOSITE);\n \n assertEquals(composite.getCollection().getClass(), ExtendedCollectionConstructor.class);\n assertEquals(composite.getCollection().size(), 2);\n }\n}\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/core/ConstructorInjectionDifferentTypeTest.java<|end_filename|>\npackage org.simpleframework.xml.core;\r\n\r\nimport org.simpleframework.xml.Element;\r\nimport org.simpleframework.xml.Root;\r\nimport org.simpleframework.xml.ValidationTestCase;\r\n\r\npublic class ConstructorInjectionDifferentTypeTest extends ValidationTestCase {\r\n\r\n @Root\r\n private static class Example {\r\n @Element(name=\"k\", data=true)\r\n private final String key;\r\n @Element(name=\"v\", data=true, required=false)\r\n private final String value;\r\n public Example(@Element(name=\"k\") int key, @Element(name=\"v\") String value) {\r\n this.key = String.valueOf(key);\r\n this.value = value;\r\n }\r\n public String getKey(){\r\n return key;\r\n }\r\n public String getValue(){\r\n return value;\r\n }\r\n }\r\n \r\n public void testDifferentTypes() throws Exception { \r\n Persister persister = new Persister();\r\n Example example = new Example(1, \"1\");\r\n boolean exception = false;\r\n try {\r\n persister.write(example, System.out);\r\n }catch(ConstructorException e) {\r\n e.printStackTrace();\r\n exception = true;\r\n }\r\n assertTrue(\"Parameter matching should respect types\", exception);\r\n }\r\n}\r\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/strategy/PackageParser.java<|end_filename|>\npackage org.simpleframework.xml.strategy;\n\nimport java.net.URI;\n\n\nclass PackageParser {\n \n private static final String scheme = \"http://\";\n \n public Class revert(String reference) throws Exception {\n URI uri = new URI(reference);\n String domain = uri.getHost();\n String path = uri.getPath();\n String[] list = domain.split(\"\\\\.\");\n \n if(list.length > 1) {\n domain = list[1] + \".\" + list[0];\n } else {\n domain = list[0];\n }\n String type = domain + path.replaceAll(\"\\\\/+\", \".\");\n return Class.forName(type);\n }\n \n public String parse(String className) throws Exception {\n return new Convert(className).fastParse();\n }\n \n public String parse(Class type) throws Exception {\n return new Convert(type.getName()).fastParse();\n }\n \n public static class Convert {\n private char[] array;\n private int count;\n private int mark; \n private int size; \n private int pos;\n \n public Convert(String type) {\n this.array = type.toCharArray();\n }\n \n public String fastParse() throws Exception { \n char[] work = new char[array.length + 10];\n\n scheme(work);\n domain(work);\n path(work);\n \n return new String(work, 0, pos);\n }\n \n private void scheme(char[] work) {\n \"http://\".getChars(0, 7, work, 0);\n pos += 7;\n }\n \n private void path(char[] work) {\n for(int i = size; i < array.length; i++) {\n if(array[i] == '.') {\n work[pos++] = '/';\n } else {\n work[pos++] = array[i];\n }\n }\n }\n \n private void domain(char[] work) {\n while(size < array.length) { \n if(array[size] == '.') { \n if(count++ == 1) {\n break;\n }\n mark = size + 1;\n }\n size++;\n }\n for(int i = 0; i < size - mark; i++) {\n work[pos++] = array[mark + i];\n }\n work[pos++] = '.';\n work[size + 7] = '/';\n \n for(int i = 0; i < mark - 1; i++) {\n work[pos++] = array[i];\n }\n }\n }\n}\n\n<|start_filename|>src/test/java/org/simpleframework/xml/core/TemplateTest.java<|end_filename|>\npackage org.simpleframework.xml.core;\n\nimport java.io.StringReader;\n\nimport org.simpleframework.xml.ValidationTestCase;\nimport java.io.StringWriter;\nimport java.util.List;\nimport java.util.Map;\n\nimport org.simpleframework.xml.Attribute;\nimport org.simpleframework.xml.Element;\nimport org.simpleframework.xml.ElementList;\nimport org.simpleframework.xml.Root;\nimport org.simpleframework.xml.core.Commit;\nimport org.simpleframework.xml.core.Persister;\n\npublic class TemplateTest extends ValidationTestCase {\n\n private static final String EXAMPLE =\n \"\\n\"+\n \"\\n\"+\n \" \\n\"+\n \" \\n\"+\n \" \\n\"+\n \" \\n\"+\n \" \\n\"+\n \"
\\n\\r\"+\n \" ${title} \\n\"+\n \" ${mail} \\n\"+\n \" ${name} \\n\"+\n \"
\\n\"+\n \"
\";\n\n @Root(name=\"var\")\n private static class Variable {\n\n @Attribute(name=\"name\") \n private String name; \n \n @Attribute(name=\"value\")\n private String value; \n\n @Commit\n public void commit(Map map) {\n map.put(name, value); \n }\n }\n\n @Root(name=\"test\")\n private static class Example {\n\n @Attribute(name=\"name\")\n private String name;\n\n @ElementList(name=\"config\", type=Variable.class)\n private List list;\n\n @Element(name=\"details\")\n private Details details;\n }\n \n private static class Details {\n\n @Element(name=\"title\")\n private String title;\n\n @Element(name=\"mail\")\n private String mail;\n\n @Element(name=\"name\")\n private String name;\n }\n\n \n\tprivate Persister serializer;\n\n\tpublic void setUp() {\n\t serializer = new Persister();\n\t}\n\t\n public void testTemplate() throws Exception { \n Example example = serializer.read(Example.class, EXAMPLE);\n \n assertEquals(example.name, \"test\");\n assertEquals(example.details.title, \"Mr\");\n assertEquals(example.details.mail, \"\");\n assertEquals(example.details.name, \"\");\n\n validate(example, serializer);\n }\n}\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/convert/CombinedStrategyTest.java<|end_filename|>\npackage org.simpleframework.xml.convert;\n\nimport java.io.StringWriter;\n\nimport org.simpleframework.xml.Element;\nimport org.simpleframework.xml.Root;\nimport org.simpleframework.xml.ValidationTestCase;\nimport org.simpleframework.xml.core.Persister;\nimport org.simpleframework.xml.stream.Format;\nimport org.simpleframework.xml.stream.HyphenStyle;\nimport org.simpleframework.xml.stream.InputNode;\nimport org.simpleframework.xml.stream.OutputNode;\nimport org.simpleframework.xml.stream.Style;\n\npublic class CombinedStrategyTest extends ValidationTestCase {\n\n private static class Item {\n private int value;\n public Item(int value) {\n this.value = value;\n }\n public int getValue(){\n return value;\n }\n }\n \n @Root\n @Convert(ExtendedItemConverter.class)\n private static class ExtendedItem extends Item {\n public ExtendedItem(int value) {\n super(value);\n }\n }\n \n private static class AnnotationItemConverter implements Converter {\n public Item read(InputNode node) throws Exception {\n return new Item(Integer.parseInt(node.getAttribute(\"value\").getValue()));\n }\n public void write(OutputNode node, Item value) throws Exception {\n node.setAttribute(\"value\", String.valueOf(value.getValue()));\n node.setAttribute(\"type\", getClass().getName());\n } \n }\n \n private static class RegistryItemConverter implements Converter {\n public Item read(InputNode node) throws Exception {\n return new Item(Integer.parseInt(node.getNext().getValue()));\n }\n public void write(OutputNode node, Item value) throws Exception {\n node.getChild(\"value\").setValue(String.valueOf(value.getValue()));\n node.getChild(\"type\").setValue(getClass().getName());\n }\n }\n \n private static class ExtendedItemConverter implements Converter {\n public ExtendedItem read(InputNode node) throws Exception {\n return new ExtendedItem(Integer.parseInt(node.getAttribute(\"value\").getValue()));\n }\n public void write(OutputNode node, ExtendedItem value) throws Exception {\n node.setAttribute(\"value\", String.valueOf(value.getValue()));\n node.setAttribute(\"type\", getClass().getName());\n } \n }\n \n @Root\n private static class CombinationExample {\n @Element\n private Item item; // handled by the registry\n @Element\n @Convert(AnnotationItemConverter.class) // handled by annotation\n private Item overriddenItem;\n @Element\n private Item extendedItem; // handled by class annotation\n public CombinationExample(int item, int overriddenItem, int extendedItem) {\n this.item = new Item(item);\n this.overriddenItem = new Item(overriddenItem);\n this.extendedItem = new ExtendedItem(extendedItem);\n }\n public Item getItem(){\n return item;\n }\n public Item getOverriddenItem(){\n return overriddenItem;\n }\n public Item getExtendedItem() {\n return extendedItem;\n }\n }\n \n public void testCombinedStrategy() throws Exception {\n Registry registry = new Registry();\n AnnotationStrategy annotationStrategy = new AnnotationStrategy();\n RegistryStrategy registryStrategy = new RegistryStrategy(registry, annotationStrategy);\n Persister persister = new Persister(registryStrategy);\n CombinationExample example = new CombinationExample(1, 2, 3);\n StringWriter writer = new StringWriter();\n \n registry.bind(Item.class, RegistryItemConverter.class);\n persister.write(example, writer);\n \n String text = writer.toString();\n System.out.println(text);\n \n assertElementExists(text, \"/combinationExample/item/value\");\n assertElementHasValue(text, \"/combinationExample/item/value\", \"1\");\n assertElementHasValue(text, \"/combinationExample/item/type\", RegistryItemConverter.class.getName());\n assertElementExists(text, \"/combinationExample/overriddenItem\");\n assertElementHasAttribute(text, \"/combinationExample/overriddenItem\", \"value\", \"2\");\n assertElementHasAttribute(text, \"/combinationExample/overriddenItem\", \"type\", AnnotationItemConverter.class.getName());\n assertElementExists(text, \"/combinationExample/extendedItem\");\n assertElementHasAttribute(text, \"/combinationExample/extendedItem\", \"value\", \"3\");\n assertElementHasAttribute(text, \"/combinationExample/extendedItem\", \"type\", ExtendedItemConverter.class.getName());\n }\n \n public void testCombinationStrategyWithStyle() throws Exception {\n Registry registry = new Registry();\n AnnotationStrategy annotationStrategy = new AnnotationStrategy();\n RegistryStrategy registryStrategy = new RegistryStrategy(registry, annotationStrategy);\n Style style = new HyphenStyle();\n Format format = new Format(style);\n Persister persister = new Persister(registryStrategy, format);\n CombinationExample example = new CombinationExample(1, 2, 3);\n StringWriter writer = new StringWriter();\n \n registry.bind(Item.class, RegistryItemConverter.class);\n persister.write(example, writer);\n \n String text = writer.toString();\n System.out.println(text);\n \n assertElementExists(text, \"/combination-example/item/value\");\n assertElementHasValue(text, \"/combination-example/item/value\", \"1\");\n assertElementHasValue(text, \"/combination-example/item/type\", RegistryItemConverter.class.getName());\n assertElementExists(text, \"/combination-example/overridden-item\");\n assertElementHasAttribute(text, \"/combination-example/overridden-item\", \"value\", \"2\");\n assertElementHasAttribute(text, \"/combination-example/overridden-item\", \"type\", AnnotationItemConverter.class.getName());\n assertElementExists(text, \"/combination-example/extended-item\");\n assertElementHasAttribute(text, \"/combination-example/extended-item\", \"value\", \"3\");\n assertElementHasAttribute(text, \"/combination-example/extended-item\", \"type\", ExtendedItemConverter.class.getName()); \n }\n}\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/core/NamespaceDecoratorTest.java<|end_filename|>\npackage org.simpleframework.xml.core;\n\nimport java.io.StringWriter;\nimport java.lang.annotation.Annotation;\n\nimport org.simpleframework.xml.Namespace;\nimport org.simpleframework.xml.ValidationTestCase;\nimport org.simpleframework.xml.core.NamespaceDecorator;\nimport org.simpleframework.xml.stream.NodeBuilder;\nimport org.simpleframework.xml.stream.OutputNode;\n\npublic class NamespaceDecoratorTest extends ValidationTestCase {\n \n private static class MockNamespace implements Namespace {\n \n private final String prefix;\n private final String reference;\n \n public MockNamespace(String prefix, String reference) {\n this.prefix = prefix;\n this.reference = reference;\n }\n \n public String reference() {\n return reference;\n }\n \n public String prefix() {\n return prefix;\n }\n\n public Class annotationType() {\n return Namespace.class;\n }\n }\n \n public void testQualifier() throws Exception {\n NamespaceDecorator global = new NamespaceDecorator();\n NamespaceDecorator qualifier = new NamespaceDecorator();\n NamespaceDecorator attribute = new NamespaceDecorator();\n \n global.add(new MockNamespace(\"global\", \"http://www.domain.com/global\")); \n qualifier.add(new MockNamespace(\"a\", \"http://www.domain.com/a\"));\n qualifier.add(new MockNamespace(\"b\", \"http://www.domain.com/b\"));\n qualifier.add(new MockNamespace(\"c\", \"http://www.domain.com/c\"));\n attribute.add(new MockNamespace(\"d\", \"http://www.domain.com/d\"));\n \n global.set(new MockNamespace(\"first\", \"http://www.domain.com/ignore\"));\n qualifier.set(new MockNamespace(\"a\", \"http://www.domain.com/a\"));\n attribute.set(new MockNamespace(\"b\", \"http://www.domain.com/b\"));\n\n StringWriter out = new StringWriter(); \n \n OutputNode top = NodeBuilder.write(out);\n OutputNode root = top.getChild(\"root\");\n \n root.setAttribute(\"version\", \"1.0\");\n qualifier.decorate(root, global);\n \n OutputNode child = root.getChild(\"child\");\n child.setAttribute(\"name\", \"\");\n \n OutputNode name = child.getAttributes().get(\"name\");\n attribute.decorate(name);\n \n OutputNode grandChild = child.getChild(\"grandChild\");\n grandChild.setValue(\"this is the grand child\");\n \n root.commit();\n validate(out.toString()); \n }\n}\n\n\n<|start_filename|>src/test/java/org/simpleframework/xml/transform/TimeTransformTest.java<|end_filename|>\npackage org.simpleframework.xml.transform;\n\nimport java.sql.Time;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Date;\n\nimport org.simpleframework.xml.Attribute;\nimport org.simpleframework.xml.Element;\nimport org.simpleframework.xml.ElementArray;\nimport org.simpleframework.xml.ElementList;\nimport org.simpleframework.xml.Root;\nimport org.simpleframework.xml.ValidationTestCase;\nimport org.simpleframework.xml.core.Persister;\nimport org.simpleframework.xml.transform.DateTransform;\n\npublic class TimeTransformTest extends ValidationTestCase {\n \n @Root\n public static class TimeExample {\n \n @Attribute \n private Date attribute;\n \n @Element\n private Date element;\n \n @Element\n private Time time;\n \n @ElementList\n private Collection