我有一个布局,在基于Webkit的浏览器中渲染完美,但在Internet Explorer和firefox中垂直对齐关闭.最简单的代码示例是:
<html>
<head>
<style>
body {
padding: 20px;
background-color: #c0c0c0 ;
}
#wrapper {
border: 4px solid #9cf ;
}
#wrapper > div {
display: inline-block ;
height: 30px ;
line-height: 30px ;
}
#content1 {
width: 100px ;
background-color: yellow ;
}
#content2 {
width: 325px ;
overflow: hidden ;
white-space: nowrap ;
background-color: blue ;
}
#content3 {
width: 400px ;
background-color: red ;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="content1">Content 1</div>
<div id="content2">A rather long …Run Code Online (Sandbox Code Playgroud)我正在为基于Apache MINA的协议项目创建一个测试平台.在MINA中,当您收到数据包时,该messageReceived()方法将获取一个Object.理想情况下,我想使用JUnit方法assertClass(),但它不存在.我正在努力找出最接近的东西.我试图找到类似的东西instanceof.
目前我有:
public void assertClass(String msg, Class expected, Object given) {
if(!expected.isInstance(given)) Assert.fail(msg);
}
Run Code Online (Sandbox Code Playgroud)
称之为:
assertClass("Packet type is correct", SomePacket.class, receivedPacket);
Run Code Online (Sandbox Code Playgroud)
这可以毫无问题地工作,但是在试验和玩这个游戏时,我的兴趣达到了instanceof运营商的高峰.
if (receivedPacket instanceof SomePacket) { .. }
Run Code Online (Sandbox Code Playgroud)
instanceof如何SomePacket用于引用手头的对象?它不是一个对象的实例,它不是一个类,它是什么?!一旦确定了什么类型SomePacket,那么有可能扩展我assertClass()不必包括SomePacket.class参数,而是支持SomePacket?