小编ser*_*laz的帖子

Java:从静态方法获取继承类的类

我在Java中有以下问题:我有一个基类和一个派生类,我在基类中有一个方法.当我通过Derived调用Base的foo方法时,我希望得到Derived的类.如果可以这样做,foo方法可以是通用的.

class Base
{
    static void foo()
    {
        // I want to get Derived class here
        // Derived.class
    }
}

class Derived extends Base
{
}

Derived.foo();
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!

大卫

java inheritance

11
推荐指数
1
解决办法
5696
查看次数

heroku + git子模块需要身份验证

我们使用gitolite来管理我们的存储库,我们的一个heroku项目有git子模块.有没有办法获得Heroku的身份验证公钥?

谢谢,大卫

git heroku gitolite

6
推荐指数
1
解决办法
3358
查看次数

红宝石instance_variable_get返回nil

我的instance_variable_get方法有问题,因为它总是返回一个对象实例为nil的对象。这是我的代码:

logger.info "ASDF: " + @d_tree.inspect
logger.info "ASDF: " + @d_tree.instance_variable_get(:@content);
Run Code Online (Sandbox Code Playgroud)

输出为:

ASDF: #<DTree id: 11, parent_id: nil, content: "bababababa", subsidiary_info: "", deep_info: "blabla", title: "hello", direction: 1, created_at: "2010-10-26 19:27:32", updated_at: "2010-11-01 23:14:31", color: 2, cell_color: 2, howtoinfo: "howtoinfooo", textinfo: "textInfooo", locationinfo: "locationInfoooo", productinfo: "productinfoooo">
TypeError (can't convert nil into String):
    /app/controllers/d_trees_controller.rb:38:in `+'
Run Code Online (Sandbox Code Playgroud)

根据检查,该对象似乎很好,但是instance_variable_get返回一个nil对象

谢谢你的帮助!

ruby ruby-on-rails

5
推荐指数
1
解决办法
3915
查看次数

Capybara选择器匹配但不是所有过滤器,这是什么意思?

在运行水豚选择器之前,我使用save_and_open_page命令保存了以下html(我还检查了page.body,它是相同的):https://gist.github.com/davidkovaccs/8991af5bed1805277f52

我收到以下错误消息:'期望找到xpath"// div [@ class ='box']"9次,找到6个匹配:"box_2001 attrkulcs1:attrvalue 1 attrkulcs2:attrvalue 2 attrkulcs3:attrvalue 3","box_2002 attrkulcs1:attrvalue 1 attrkulcs2:attrvalue 2 attrkulcs3:attrvalue 3 attrkulcs4:attrvalue 4","box_2003","box_1001","box_1002 attrkulcs1:attrvalue 1 attrkulcs2:attrvalue 2 attrkulcs3:attrvalue 3","box_1003 attrkulcs1:attrvalue 1".还找到了"","","",它与选择器匹配但不是所有过滤器.(水豚:: ExpectationNotMet)"

请注意,对于每次测试运行,找到的6个匹配项不是6.它是一个4到9之间的数字.我真的不明白'匹配选择器但不是所有过滤器'的说法.据我所知,我没有使用任何过滤器.

我尝试了以下选择器,但所有这些选择器都给出了相同的错误消息:

have_xpath("//div[@class='box']", :count => 9)
have_selector(:css, '.box', :count => 9)
have_css('.box', :count => 9)
Run Code Online (Sandbox Code Playgroud)

我已经尝试过与capybara 2.2.1和2.3.0.我正在使用Selenium webdriver 2.42.0

从浏览器控制台运行$ x("// div [@ class ='box']").长度完美无缺.

selenium ruby-on-rails css-selectors cucumber capybara

5
推荐指数
1
解决办法
3519
查看次数

在默认的MonoTouch应用程序中,xib未在Xcode中打开

我刚刚使用MonoDevelop创建了一个MonoTouch解决方案,在我尝试在XCode中打开xib进行编辑之后,我得到以下异常(并且xib没有打开):

System.NotSupportedException: Custom attribute type 0x43 is not supported.
at ICSharpCode.NRefactory.TypeSystem.CecilLoader+BlobReader.ReadCustomAttributeFieldOrPropType () [0x00000] in <filename unknown>:0 
at ICSharpCode.NRefactory.TypeSystem.CecilLoader+BlobReader.ReadNamedArg (IType attributeType) [0x00000] in <filename unknown>:0 
at ICSharpCode.NRefactory.TypeSystem.CecilLoader+CecilResolvedAttribute.DecodeBlob (System.Collections.Generic.List`1 positionalArguments, System.Collections.Generic.List`1 namedArguments) [0x00000] in <filename unknown>:0 
at ICSharpCode.NRefactory.TypeSystem.CecilLoader+CecilResolvedAttribute.DecodeBlob () [0x00000] in <filename unknown>:0 
at ICSharpCode.NRefactory.TypeSystem.CecilLoader+CecilResolvedAttribute.get_PositionalArguments () [0x00000] in <filename unknown>:0 
at MonoDevelop.MacDev.ObjCIntegration.NSObjectInfoService.ConvertType (MonoDevelop.Ide.TypeSystem.ProjectContentWrapper dom, ITypeDefinition type) [0x00000] in <filename unknown>:0 
at MonoDevelop.MacDev.ObjCIntegration.NSObjectInfoService+<GetRegisteredObjects>c__Iterator2.MoveNext () [0x00000] in <filename unknown>:0 
at MonoDevelop.MacDev.ObjCIntegration.NSObjectProjectInfo.Update () [0x00000] in <filename unknown>:0 
at MonoDevelop.MacDev.ObjCIntegration.NSObjectProjectInfo.Update (Boolean force) [0x00000] in <filename unknown>:0 …
Run Code Online (Sandbox Code Playgroud)

xcode xib xamarin.ios ios xamarin

4
推荐指数
1
解决办法
745
查看次数