你如何使用java.util.regex.Pattern.Node

时间:2013-12-21 22:54:31

标签: java regex

我需要解析一系列Prolog语句,并且我一直在组合ad-hoc正则表达式来处理它们,但结果并不是非常强大。我注意到java.util.regex.Pattern.Prolog,它是java.util.regex.Pattern.Node的子类,但我似乎无法找到解释这些类的用途或如何使用它们的任何内容。 Javadocs大多是空的。是否有关于这些类的目的和用法的教程或充实文档?它们可以用来解析Prolog吗?

1 个答案:

答案 0 :(得分:0)

这些类具有包访问修饰符。例如,Oracle JDK 7中的Node被声明为

static class Node extends Object {

只能从同一个包中的类访问它们。但是,由于该程序包通常由JVM保护,因此无法向其中添加类。你会得到像

这样的例外
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.util.regex

如果需要,您可以找到并复制源代码,但您将无法自行使用这些类。


至于他们的目的,你必须再次访问源代码并查看评论。

/**
 * The following classes are the building components of the object
 * tree that represents a compiled regular expression. The object tree
 * is made of individual elements that handle constructs in the Pattern.
 * Each type of object knows how to match its equivalent construct with
 * the match() method.
 */
相关问题