1 /*
2 * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
104
105 if (findDeadKeys)
106 findDeadKeys(codeKeys, resourceKeys);
107
108 if (findMissingKeys)
109 findMissingKeys(codeKeys, resourceKeys);
110
111 return (errors == 0);
112 }
113
114 /**
115 * Find keys in resource bundles which are probably no longer required.
116 * A key is required if there is a string in the code that is a resource key,
117 * or if the key is well-known according to various pragmatic rules.
118 */
119 void findDeadKeys(Set<String> codeKeys, Set<String> resourceKeys) {
120 for (String rk: resourceKeys) {
121 if (codeKeys.contains(rk))
122 continue;
123
124 error("Resource key not found in code: " + rk);
125 }
126 }
127
128 /**
129 * For all strings in the code that look like they might be
130 * a resource key, verify that a key exists.
131 */
132 void findMissingKeys(Set<String> codeKeys, Set<String> resourceKeys) {
133 for (String ck: codeKeys) {
134 if (resourceKeys.contains(ck))
135 continue;
136 error("No resource for \"" + ck + "\"");
137 }
138 }
139
140 /**
141 * Get the set of strings from (most of) the javadoc classfiles.
142 */
143 Set<String> getCodeKeys() throws IOException {
144 Set<String> results = new TreeSet<String>();
|
1 /*
2 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
104
105 if (findDeadKeys)
106 findDeadKeys(codeKeys, resourceKeys);
107
108 if (findMissingKeys)
109 findMissingKeys(codeKeys, resourceKeys);
110
111 return (errors == 0);
112 }
113
114 /**
115 * Find keys in resource bundles which are probably no longer required.
116 * A key is required if there is a string in the code that is a resource key,
117 * or if the key is well-known according to various pragmatic rules.
118 */
119 void findDeadKeys(Set<String> codeKeys, Set<String> resourceKeys) {
120 for (String rk: resourceKeys) {
121 if (codeKeys.contains(rk))
122 continue;
123
124 error("Resource key not found in code: '" + rk + "'");
125 }
126 }
127
128 /**
129 * For all strings in the code that look like they might be
130 * a resource key, verify that a key exists.
131 */
132 void findMissingKeys(Set<String> codeKeys, Set<String> resourceKeys) {
133 for (String ck: codeKeys) {
134 if (resourceKeys.contains(ck))
135 continue;
136 error("No resource for \"" + ck + "\"");
137 }
138 }
139
140 /**
141 * Get the set of strings from (most of) the javadoc classfiles.
142 */
143 Set<String> getCodeKeys() throws IOException {
144 Set<String> results = new TreeSet<String>();
|