langtools/test/jdk/javadoc/tool/VerifyLocale.java
author hannesw
Tue, 22 Mar 2016 14:23:16 +0100
changeset 36690 06b714373aa4
parent 35426 374342e56a56
child 36526 3b41f1c69604
child 36705 890c250d8da8
permissions -rw-r--r--
8151810: for-in iteration does not provide per-iteration scope Reviewed-by: attila, lagergren
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     1
/*
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     2
 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     4
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     8
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    13
 * accompanied this code).
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    14
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    18
 *
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    21
 * questions.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    22
 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    23
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    24
/*
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    25
 * @test
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    26
 * @bug 8035473
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    27
 * @summary Verify that init method works correctly.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    28
 * @modules jdk.javadoc
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    29
 */
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    30
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    31
import java.util.Collections;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    32
import java.util.Locale;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    33
import java.util.Set;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    34
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    35
import javax.lang.model.SourceVersion;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    36
import javax.tools.Diagnostic.Kind;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    37
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    38
import jdk.javadoc.doclet.Doclet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    39
import jdk.javadoc.doclet.Reporter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    40
import jdk.javadoc.doclet.DocletEnvironment;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    41
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    42
public class VerifyLocale implements Doclet {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    43
    Locale locale;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    44
    Reporter reporter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    45
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    46
    public static void main(String[] args) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    47
        String thisFile = "" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    48
            new java.io.File(System.getProperty("test.src", "."),
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    49
                             "VerifyLocale.java");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    50
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    51
        String[] argarray = {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    52
            // jumble the options in some weird order
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    53
            "-doclet", "VerifyLocale",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    54
            "-locale", "ja",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    55
            "-docletpath", System.getProperty("test.classes", "."),
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    56
            thisFile
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    57
        };
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    58
        if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0)
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    59
            throw new Error("Javadoc encountered warnings or errors.");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    60
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    61
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    62
    public boolean run(DocletEnvironment root) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    63
        reporter.print(Kind.NOTE, "just a test: Locale is: " + locale.getDisplayName());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    64
        return locale.getDisplayName(Locale.ENGLISH).contains("Japan");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    65
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    66
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    67
    @Override
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    68
    public String getName() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    69
        return "Test";
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    70
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    71
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    72
    @Override
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    73
    public Set<Option> getSupportedOptions() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    74
        return Collections.emptySet();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    75
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    76
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    77
    @Override
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    78
    public SourceVersion getSupportedSourceVersion() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    79
        return SourceVersion.latest();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    80
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    81
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    82
    public void init(Locale locale, Reporter reporter) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    83
        this.locale = locale;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    84
        this.reporter = reporter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    85
    }
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
diff changeset
    86
}