1 /* gnu.classpath.tools.doclets.DocletOptionPackageWildcard
2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 package gnu
.classpath
.tools
.doclets
;
23 import java
.util
.LinkedHashSet
;
25 import java
.util
.SortedSet
;
26 import java
.util
.StringTokenizer
;
27 import java
.util
.TreeSet
;
29 import com
.sun
.javadoc
.PackageDoc
;
32 * Processes a doclet option whose value consists of a
33 * colon-separated list of package wildcards, or - optionally -
34 * equals the string "all", denoting that all packages should match.
36 public class DocletOptionPackageWildcard
39 private PackageMatcher packageMatcher
;
40 private boolean allowAll
;
41 private boolean specified
;
43 DocletOptionPackageWildcard(String optionName
, boolean allowAll
)
46 this.allowAll
= allowAll
;
49 public int getLength()
54 public boolean isSpecified()
59 public boolean set(String
[] optionArr
)
61 this.specified
= true;
63 if (allowAll
&& "all".equals(optionArr
[2])) {
64 packageMatcher
= null;
67 packageMatcher
= new PackageMatcher();
69 StringTokenizer tokenizer
= new StringTokenizer(optionArr
[2], ":");
70 while (tokenizer
.hasMoreTokens()) {
71 String packageWildcard
= tokenizer
.nextToken();
72 packageMatcher
.addWildcard(packageWildcard
);
77 catch (InvalidPackageWildcardException e
) {
78 // FIXME: output problem description here, better throw
79 // DocletConfigurationException
84 public SortedSet
filter(PackageDoc
[] packages
)
86 if (null != packageMatcher
) {
87 return packageMatcher
.filter(packages
);
90 SortedSet result
= new TreeSet();
91 for (int i
=0; i
<packages
.length
; ++i
) {
92 result
.add(packages
[i
]);
98 public boolean match(PackageDoc packageDoc
)
100 if (null != packageMatcher
) {
101 return packageMatcher
.match(packageDoc
);