是否有一种优雅的方式断言数字是平等的,而忽略了他们的类?我想在JUnit测试框架中使用它,例如
Assert.assertEquals(1,1L)
Run Code Online (Sandbox Code Playgroud)
失败的java.lang.AssertionError:expected:java.lang.Integer <1>但是:java.lang.Long <1>
我希望有一个很好的方法,只比较值,并使用int,long,float,byte,double,BigDecimal,BigInteger,你命名它...
明显
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.1.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
取决于jasperreports-functions,但我无法在任何存储库中找到它.我在Tibco Jasper Studio中看到jar文件,我发现http://community.jaspersoft.com/project/jasperreports-library/releases链接下载库,但是我们在企业环境中使用maven,所以我很感激maven存储库到自动下载工件.
更新
我的问题是我可以在Tibco Jasper studio中编译和运行模板,但我无法使用java api编译模板
JasperCompileManager.compileReportToFile(src, dest);
Run Code Online (Sandbox Code Playgroud)
表达式如下所示,我在打印时使用函数:
NOT(EQUALS($F{title}, null))
Run Code Online (Sandbox Code Playgroud)
在java中编译时遇到错误:
Caused by: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method EQUALS(String, null) is undefined for the type sickInjuriesClosePerson_1447428912021_94804
value = NOT(EQUALS(((java.lang.String)field_title.getValue()), null)); //$JR_EXPR_ID=9$
<---->
2. The method EQUALS(String, null) is undefined for the type sickInjuriesClosePerson_1447428912021_94804
value = NOT(EQUALS(((java.lang.String)field_firstName.getValue()), null)); //$JR_EXPR_ID=11$
<---->
Run Code Online (Sandbox Code Playgroud)
在这一点上,我确定这是因为我在类路径上缺少jasperreports-functions-6.1.1.jar.该文件存在于jaspersoft @ studio中
我想格式化(圆)浮点(双)数字,让我们说2位有效数字,例如:
1 => 1
11 => 11
111 => 110
119 => 120
0.11 => 0.11
0.00011 => 0.00011
0.000111 => 0.00011
Run Code Online (Sandbox Code Playgroud)
所以任意精度保持不变
我希望它已经内置了一些不错的功能,但到目前为止找不到任何功能
我被指向如何向下舍入到最近的有效数字,这是关闭但不适用于N位有效数字,我不知道它对0.000XXX数字有什么作用
运行最新的Vaadin 7.1.1应用程序时遇到问题.这主要是因为我找不到该版本的文档.Maven原型创建扩展Root的旧式应用程序.Root已经不见了,所以我试图扩展UI,就像在Book of Vaadin中那样.
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>
com.vaadin.server.VaadinServlet
</servlet-class>
<init-param>
<param-name>UI</param-name>
<param-value>cz.simplecoin.simplegui.MainScreen</param-value>
</init-param>
</servlet>
Run Code Online (Sandbox Code Playgroud)
和MainScreen简单地说:
public class MainScreen extends UI {
Run Code Online (Sandbox Code Playgroud)
项目正确编译(使用maven).当我调试时,我看到MainScreen正确调用的init方法,但我看到只有空白屏幕(bootstrap JavavScript在那里)与警报:
无法加载widgetset:./ VAADIN/widgetsets/com.vaadin.DefaultWidgetSet/com.vaadin.DefaultWidgetSet.nocache.js?1393503103223
我想从Default widgetset开始.我几乎可以肯定,它在maven构建/依赖中存在某种问题.我不知道要使用哪些库:我尝试了两种变体(已评论)
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>${vaadin.version}</version>
</dependency>
<!--
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-theme-compiler</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin.addon</groupId>
<artifactId>vaadin-charts</artifactId>
<version>1.0.0</version>
</dependency>
-->
Run Code Online (Sandbox Code Playgroud)
我可能会尝试使用自己的widgetset,看看是否能解决问题.
我有配置的com.googlecode.cqengine.IndexedCollection对象NavigableIndex。我通常需要从索引或索引的迭代器中获取第一个或最后一个项目。
我想这应该是微不足道的。我知道我可以使用 queryOptions 对象创建 Query 对象,使用它从 IndexedCollection 检索迭代器并获取第一个对象,但我不确定它是否是最佳性能。肯定不优雅。
我有包含单元格格式日期或时间 (DD.MM.YYYY HH:MM:SS) 和值的列,例如
03.12.2013 14:01:49
04.12.2013 10:19:27
04.12.2013 12:44:56
04.12.2013 14:20:12
04.12.2013 18:30:21
我需要将这些值转换为 unix 纪元(自 1970 年以来的秒数)。不知何故,感觉这些值不被识别为日期,而是作为字符串。我尝试了不同的格式,没有时间的日期运气不好。
java ×3
maven ×2
calc ×1
cqengine ×1
date ×1
javascript ×1
junit ×1
libreoffice ×1
php ×1
servlets ×1