我想获取一个方法的注释,以下面的方法为例:
/**
* Returns the regex to extract all inputs from a file.
* @param string The class name to search for.
* @return string The regex.
*/
public function method($param)
{
//...
}
Run Code Online (Sandbox Code Playgroud)
结果应该是
Returns the regex to extract all inputs from a file.
@param string The class name to search for.
@return string The regex.
Run Code Online (Sandbox Code Playgroud)
我发现的方法是使用像 file_get_content 这样的函数来获取文件内容 -> 过滤我想要的方法 -> 使用正则表达式获取评论
好像有点复杂,有什么方便的存档方法吗?
有没有办法遍历一个对象来获取父对象数据?对于"父对象",我不是指父类,而是字面上的对象.这里有一个例子,在javascripty世界:-):
$parent->test = "hello world!";
$parent->child = new B();
Run Code Online (Sandbox Code Playgroud)
如果我可以访问子对象中父节点的所有数据,那就太好了:
class B{
//I know this doesn't exists, but it's what I wanted do do
function B(){
$this->parent = $this->parent();
echo $this->parent->test; //it would ouput "hello world"
}
}
Run Code Online (Sandbox Code Playgroud)
现在我的解决方案是将父对象传递给子对象(作为参考)或使父对象成为全局对象.你有更好的解决方案吗?
谢谢!
这是我正在进行的计划的最后一部分.我想输出一个表格列表的歌曲cout.然后我想将一个特殊格式的歌曲信息列表输出到fout(稍后将用作输入文件).
打印到cout效果很好.问题是在打印到fout时会增加大量的额外字符.
有任何想法吗?
这是代码:
void Playlist::printFile(ofstream &fout, LinkedList<Playlist> &allPlaylists, LinkedList<Songs*> &library)
{
fout.open("music.txt");
if(fout.fail())
{
cout << "Output file failed. Information was not saved." << endl << endl;
}
else
{
if(library.size() > 0)
fout << "LIBRARY" << endl;
for(int i = 0; i < library.size(); i++) // For Loop - "Incremrenting i"-Loop to go through library and print song information.
{
fout << library.at(i)->getSongName() << endl; // Prints song name.
fout << library.at(i)->getArtistName() << endl; // Prints artist name. …Run Code Online (Sandbox Code Playgroud) 我正在考虑编写一个新的基于网络的游戏,并想知道是否有人对我应该选择哪个平台有任何建议.
游戏将基于2D精灵,但需要保持一个不错的fps速率(一次最多可能有20件事情).它都将通过鼠标控制.
我每天都使用.NET,所以Silverlight对我来说似乎是一个自然的选择,但我想确保尽可能多的人可以玩它...
所以我只是希望得到一些反馈,让我对一个简单的基于2D网页的游戏使用最好的东西.
编辑:
你能提供更多信息吗?这个单人/多人?什么样的流派?是否会涉及很多经典的UI(很多形式有很多按钮/复选框,数据网格等)?会有很多动画和特效吗?
我尝试在两种情况下运行应用程序:安装了SQL Server压缩版(3.5),没有安装.未安装SQL Server Compact版时,我收到以下错误:
Exception :Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
Inner Exception :
========================
Stack Trace :
========================
at System.Data.SqlServerCe.NativeMethods.CloseStore(IntPtr pSeStore)
at System.Data.SqlServerCe.SqlCeConnection.ReleaseNativeInterfaces()
at System.Data.SqlServerCe.SqlCeConnection.Dispose(Boolean disposing)
at System.Data.SqlServerCe.SqlCeConnection.Finalize()
Source :
========================
System.Data.SqlServerCe
----------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我正在使用此方法处理未处理的异常.
我从一个控制台应用程序收到此错误,我从Windows窗体开始.在这两个应用程序中,我都插入了Unhandled Exception编码,它正在执行并返回到文本文件,并且正在生成Microsoft"报告错误"对话框; 我如何防止这种情况发生?如何解决导致此问题的原因?
我第一次使用JSON ...并希望用我的JSON数据填充我的数据网格,这是我的JSON数据:
{
"head": {
"vars": [ "s" , "fname" , "lname" ]
} ,
"results": {
"bindings": [
{
"s": { "type": "uri" , "value": "http://tn.gov.in/Person/41" } ,
"fname": { "type": "literal" , "value": " } ,
"lname": { "type": "literal" ,n" }
} ,
{
"s": { "type": "uri" , "value": "http://tn.gov.in/Person/37" } ,
"fname": { "type": "literal" , "value": "sh" } ,
"lname": { "type": "literal" , "value": "Vvan" }
} ,
{
"s": { "type": "uri" …Run Code Online (Sandbox Code Playgroud) 我想以编程方式使用初始数据设置我的数据库.我想填充我的数据库用于开发运行,而不是用于测试运行(这很容易).该产品构建于Spring和JPA/Hibernate之上.
然后:
我想要的是通过必需的部分设置我的环境,以便调用我的DAO并将新对象插入数据库.我不想在原始SQL,XML,转储数据库或其他任何东西中创建初始数据集.我想以编程方式创建对象并将其持久保存在数据库中,就像在普通应用程序逻辑中一样.
实现此目的的一种方法是正常启动我的应用程序并运行一个执行初始化的特殊servlet.但这真的是要走的路吗?我很乐意将初始数据设置作为Maven任务执行,如果我采用servlet方法,我不知道该怎么做.
有一些类似的问题.我快速浏览了建议的DBUnit和Unitils.但他们似乎非常专注于设置测试环境,这不是我想要的.DBUnit执行初始数据填充,但仅使用xml/csv fixtures,这不是我在此之后所做的.然后,Maven有SQL插件,但我不想处理原始SQL.Maven也有Hibernate插件,但它似乎只对Hibernate配置和表模式创建有帮助(而不是用数据填充db).
这该怎么做?
部分解决方案2010-03-19
建议的替代方案是:
我使用Spring的ApplicationListener实现了这个:
类:
public class ApplicationContextListener implements ApplicationListener {
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
...check if database is already populated, if not, populate it...
}
}
}
Run Code Online (Sandbox Code Playgroud)
applicationContext.xml中:
<bean id="applicationContextListener" class="my.namespaces.ApplicationContextListener" />
Run Code Online (Sandbox Code Playgroud)
出于某种原因,我无法启动ContextStartedEvent,因此我选择了在启动时启动的ContextRefreshedEvent(尚未碰到其他情况).
如何刷新数据库?目前,我只是删除了HSQLDB工件,并在Hibernate启动时生成了新的模式.因为DB也是空的.
我来自C,php和bash背景,它很容易学习,因为它们都具有相同的C结构,我可以将其与我已经知道的相关联.
然后2年前我学习了Python并且学到了很多东西,Python比Ruby更容易学习.然后从去年开始,我试图学习Ruby,然后是Rails,我承认,直到现在我仍然无法得到它,具有讽刺意味的是,那些被认为是易于学习的,但对于像我这样经验丰富的程序员,我只是无法将它与我之前学到的东西联系起来,我有两本关于Ruby和Rails的书,当我读到它时,没有什么东西被我的思绪所吸引,我接近放弃......
在ruby中,我很难掌握块的概念,为什么@variables可以被其他函数访问,$ variable和:variable有什么作用呢?在Rails中,为什么有像this_is_another_function_that_do_this这样的函数,所以因此ruby,它只是一个命名约定,或者它是使用此变量_can_do_this_function自动生成的.我仍然感到困惑的是,所有这些神奇的概念和事物都来自哪里?现在,1年的尝试和吸收,但仍然没有进展......
编辑: 总结:
has_one X好吧,请耐心等待我的困惑,至少我对自己诚实,自从我第一次尝试学习红宝石以来已经超过一年了,而且我不会变得更年轻..
所以
I learned this in Bash/C/PHP
solve_problem($problem)
{
if [ -e $problem == "trivial" ];
then
write_solution();
else
breakdown_problem_into_N_subproblems(\;
define_relationship_between_subproblems;
for i in $( command $each_subproblem );
do
solve_problem $i
done
fi
}
write_solution(problem) {
some_solution=$(command <parameters> "input" | command);
command | command $some_solution > output_solved_problem_to_file
}
breakdown_problem_into_N_subproblems($problems) {
for i in $problems;
do
command $i | command > i_can_output_a_file_right_away
done
}
define_relationship_between_subproblems($problems) {
if …Run Code Online (Sandbox Code Playgroud) 我在我的机器上安装了Vim和MinGW,所以我尝试创建Hello World然后在Vim中编译,一切正常.但是,当我键入:make它显示错误'make' not recognized as an internal or external command.
我已经添加了变量路径C:\MinGW\bin.我想知道如何配置Vim或我的机器以允许make命令.
有没有人有在实际生产负载下使用Oracle UCP的经验?它是否能很好地处理数据库重新连接?有任何多线程问题吗?有没有人将它与C3P0或Apache DBCP进行比较?