ANTLR (or alternative): decoupling parsing from evaluation

I have a relatively simple DSL that I would like to handle more robustly than a bunch of manually-coded java.util.regex.Pattern statements + parsing logic. The most-quoted tool seems to be ANTLR. I'm not familiar with it and am willing to give it a try. However I get a little leery when I look at the examples (eg the ANTLR expression evaluator example, or Martin Fowler's HelloAntlr, o

ANTLR(或其他):解析与评估解耦

我有一个相对简单的DSL,我希望比一些手动编写的java.util.regex.Pattern语句+解析逻辑更强大。 最引用的工具似乎是ANTLR。 我不熟悉它,并且愿意试一试。 然而,当我看到这些例子时(例如ANTLR表达式求值器例子,或者Martin Fowler的HelloAntlr,或者这个在stackoverflow上的其他Q),我会有点茫然。 原因在于语法文件看起来像是散布着语言定义的大杂烩,其中散布着实际语言中必不可少的实现语言(例如Java)片段。 我真

Download manager in Java

I need to several some huge files (several gigs) from Java via FTP/HTTP. Is there a ready library (java / command line tool) to facilitate the download? Some obvious requirements are: Multi-connection download - should be able to open several connections to the server to accelerate the download (like FlashGet/GetRight/...) Resume a download Edit - I'd really prefer not to write such a

下载Java中的管理器

我需要通过FTP / HTTP从Java几个大文件(几个演出)。 有没有一个现成的库(java /命令行工具)来方便下载? 一些明显的要求是: 多连接下载 - 应该能够打开到服务器的多个连接以加速下载(如FlashGet / GetRight / ...) 恢复下载 编辑 - 我真的不想写这样的图书馆,而是窃取(或支付)现有的经过测试的生产级图书馆。 rsynch不相关,因为我需要从HTTP和FTP站点下载文件,它不适用于内部文件传输。 HTTP协议确实支持

Java Drag and Drop on Mac OS X

I am making a Java program, and one way to load files is to drag the file onto the application window (swing). I have code that works in Windows and Linux. It works in OS X, but the 1st file I drag throws an exception, and then the rest work fine. Here is the code I use to enable DnD. /* * Allow a file to be opened by dragging it onto the window */ public void drop(DropTargetDropEvent dtde

Java在Mac OS X上拖放

我正在制作一个Java程序,加载文件的一种方法是将文件拖到应用程序窗口(摆动)上。 我的代码适用于Windows和Linux。 它在OS X中工作,但我拖动的第一个文件抛出异常,然后其余的工作正常。 这是我用来启用DnD的代码。 /* * Allow a file to be opened by dragging it onto the window */ public void drop(DropTargetDropEvent dtde){ try { // Get the object to be transferred Transferable tr =

How to find potential numeric overflows in Java code, using Eclipse?

Is there a way to find potential numeric overflows in Java code, using the Eclipse IDE? For example... long aLong = X * Y * Z; ... where X, Y, and Z are ints and the result may overflow Integer.MAX_VALUE. (Note that, perhaps counter-intuitively, if the result in this example overflows Integer.MAX_VALUE, aLong will be assigned the erroneous overflowed value). I've looked in Eclipse's

如何使用Eclipse在Java代码中查找潜在的数字溢出?

有没有办法使用Eclipse IDE在Java代码中查找潜在的数字溢出? 例如... long aLong = X * Y * Z; ...其中X,Y和Z是整数,结果可能会溢出Integer.MAX_VALUE。 (请注意,如果本例中的结果溢出Integer.MAX_VALUE,aLong将被分配错误的溢出值)。 我查看了Eclipse的警告设置,PMD规则和FindBugs规则,我找不到任何设置来帮助解决这个问题。 一位同事指出,IntelliJ会警告这个......我不想承认我不能在Eclipse上做同样的事情。

Inferring generic types of nested static generic functions

Is the Java compiler able to infer the type of a generic static function from its context as the argument to another generic static function? For example, I have a simple Pair class: public class Pair<F, S> { private final F mFirst; private final S mSecond; public Pair(F first, S second) { mFirst = checkNotNull(first); mSecond = checkNotNull(second); }

推断泛型类型的嵌套静态泛型函数

Java编译器能否从其上下文中推断泛型静态函数的类型作为另一个泛型静态函数的参数? 例如,我有一个简单的Pair类: public class Pair<F, S> { private final F mFirst; private final S mSecond; public Pair(F first, S second) { mFirst = checkNotNull(first); mSecond = checkNotNull(second); } public static <F, S, F1 extends F, S1 extends S> Pair<F, S&g

Log4J able to recover from disk full?

We have several java application server running here, with several apps. They all log with Log4J into the same file system, which we created only for that reason. From time to time it happens that the file system runs out of space and the app gets log4j:ERROR Failed to flush writer, java.io.IOException Unfortunately Log4J does not recover from this

Log4J能够从磁盘恢复完整?

我们有几个Java应用服务器在这里运行,有几个应用程序。 他们都将Log4J记录到同一个文件系统中,我们只是为此创建了这个文件系统。 有时会发生文件系统空间不足,应用程序无法运行 log4j:ERROR Failed to flush writer, java.io.IOException 不幸的是,Log4J不能从这个错误中恢复,所以即使在文件系统中释放了空间之后,也没有更多的日志从该应用程序写入。 除了重新启动应用

Java temp files and automated deletion

It is safe to use java's createTempFile method to create a temp file and then rename it and keep it as a permanent file? Or does java or the system in some way keep track of its temporary files and delete them at some point? btw..this is related to Mac OS X specifically. Unless you call the deleteOnExit() method on the file object, it will remain after the application terminates. It is

Java临时文件和自动删除

使用java的createTempFile方法创建临时文件并重命名它并将其保存为永久文件是安全的? 或者java或系统以某种方式跟踪其临时文件并在某些时候删除它们? 顺便说一句..这与Mac OS X具体有关。 除非您调用文件对象上的deleteOnExit()方法,否则在应用程序终止后它将保持不变。 然而,最好在你的目录中创建文件,而不是在可能被操作系统擦除的默认目录(通常为/ tmp)中。 在OSX清理临时文件夹时看看这篇文章: http://

openid consumer for gwt

Anyone have or know of a java implementation of an openid relying party(consumer) for gwt/gae? openid4java and joid bring in too much baggage for my needs. App Engine recently started supporting openID. See the docs for details. This just happened in release 1.3.4 of the sdk. Since version 1.3.4 Google App Engine is supporting authentication via OpenID (in addition to OAuth) out of box.

对于gwt的openid消费者

任何人都知道java的gwt / gae的openid依赖方(消费者)的实现? openid4java和joid为我的需求带来了太多的包袱。 App Engine最近开始支持openID。 有关详细信息,请参阅文档。 这只发生在sdk的1.3.4版本中。 从版本1.3.4开始,Google App Engine支持通过OpenID(除了OAuth)进行身份验证。 看看应用程序注册页面。 OpenID被认为是“联合登录”,目前仍被标记为[实验] ...但它正在工作......并且API看起来太简单了,以至

Collections.emptyList() returns a List<Object>?

I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the following class, which has an optional list parameter: import java.util.Collections; import java.util.List; public class Person { private String name; private List<String> nicknames; public Person(String name) { this(name,Collections.emptyList()); } public Person(Str

Collections.emptyList()返回一个List <Object>?

我在浏览Java规则推断泛型类型参数时遇到了一些麻烦。 考虑下面的类,它有一个可选的列表参数: import java.util.Collections; import java.util.List; public class Person { private String name; private List<String> nicknames; public Person(String name) { this(name,Collections.emptyList()); } public Person(String name,List<String> nicknames) { this.name = name; this.

Convert iCal to HTML or plaintext in Java

I'm looking for a Java API to convert ICS (aka iCal) attachments to nicely formatted HTML or plaintext for display purposes. Ideally, it would be able to handle: Converting dates to a specified timezone. Expanding recurrence patterns into human readable sentences. Multiple VCALENDAR records in a single file. I'm looking at iCal4j, which has a nice DOM parser, but no way to serial

在Java中将iCal转换为HTML或纯文本

我正在寻找一个Java API来将ICS(又名iCal)附件转换为格式良好的HTML或明文用于显示目的。 理想情况下,它将能够处理: 将日期转换为指定的时区。 将复发模式扩展为人类可读的句子。 多个VCALENDAR记录在一个文件中。 我在看iCal4j,它有一个很好的DOM解析器,但没有办法序列化到除iCal之外的任何东西。 对不起,如果你四处搜索,什么都没有发现,那么你肯定有一套独特的要求,有时间去创新。 拿出你有的东西,想