1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package Torello.HTML;

import java.util.HashMap;

/**
 * An enumeration of the standard Search Engine index-directives.
 * 
 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=ROBOTS>
 *
 * @see Features.Meta#insertRobots(Vector, boolean, boolean)
 * @see Features.Meta#getAllRobots(Vector)
 * @see Features.Meta#robotsMetaTag
 */
public enum Robots
{
    /**
     * Tells a search engine to index a page. Note that you don’t need to add this meta tag; it’s
     * the default.
     */
    Index("Index"),

    /** Tells a search engine not to index a page.*/
    NoIndex("NoIndex"),

    /**
     * Even if the page isn’t indexed, the crawler should follow all the links on a page and pass
     * equity to the linked pages.
     */
    Follow("Follow"),

    /** Tells a crawler not to follow any links on a page or pass along any link equity. */
    NoFollow("NoFollow"),

    /** Tells a crawler not to index any images on a page. */
    NoImageIndex("NoImageIndex"),

    /**
     * Equivalent to using both the {@code 'noindex'} and {@code 'nofollow'} tags
     * simultaneously.
     */
    None("None"),

    /** Search engines should not show a cached link to this page on a SERP. */
    NoArchive("NoArchive"),

    /** Same as {@code 'noarchive'}, but only used by Internet Explorer and Firefox. */
    NoCache("NoCache"),

    /**
     * Tells a search engine not to show a snippet of this page (i.e. meta {@code 'description'})
     * of this page on a SERP.
     */
    NoSnippet("NoSnippet"),

    /** Prevents all search-engine stuff. */
    All("All"),

    /**
     * [OBSOLETE]: Prevents search engines from using a page’s DMOZ description as the SERP snippet
     * for this page. However, DMOZ was retired in early 2017, making this tag obsolete.
     */
    NoYDir("NoYDir"),

    /**
     * [OBSOLETE]: Prevents search engines from using a page’s DMOZ description as the SERP snippet
     * for this page. However, DMOZ was retired in early 2017, making this tag obsolete.
     */
    NoODP("NoODP");

    public final String name;

    // The constructor
    private Robots(String name) { this.name = name; }

    // a robots lookup table.... Populate the lookup table on loading time
    private static final HashMap<String, Robots> lookup = new HashMap<>();

    // static initializer for the above hashmap
    static { for (Robots r : Robots.values()) lookup.put(r.name.toLowerCase(), r); }

    /**
     * This will retrieve the robot that maps to this parameter-{@code String}.  The {@code String}
     * should be a valid HMTL Meta-Tag {@code 'robots'} attribute-<B STYLE="color:red;">value</B>.
     * The valid values are the ones listed by this enumeration.  If an attempt is made to retrieve
     * a copy of an invalid {@code 'robots'} attribute-<B STYLE="color:red;">value</B>, then a 
     * {@code MalformedHTMLException} will be thrown.
     *
     * @param robotParam This parameter should be a {@code String} retrieved from a vectorized-html
     * page that is was found inside the {@code content='...'}
     * attribute-<B STYLE="color:red;">value</B> of a {@code 'robots'} meta-tag.
     *
     * @return An instance of this enumerated type.  The instance will map to the
     * passed-{@code String} parameter.
     *
     * @throws MalformedHTMLException If the passed parameter was not a valid robotParam.
     *
     * @see Features.Meta#insertRobots(Vector, boolean, boolean)
     * @see Features.Meta#getAllRobots(Vector)
     */
    public static Robots getRobot(String robotParam) throws MalformedHTMLException
    {
        Robots r = lookup.get(robotParam.toLowerCase());

        if (r != null) return r;

        else

            throw new MalformedHTMLException(
                "The robot parameter you are asking about does not exist: [" + robotParam + "]. " +
                "Please review the list of valid parameters to meta-tag robots."
            );
    }

    /**
     * This will retrieve the robot that maps to this parameter string.  The string should be a
     * valid HMTL Meta-Tag robots attribute value.  The valid values are the ones listed by this
     * enumeration.
     *
     * <BR /><BR /><B>NOTE:</B> This method will not throw an "Invalid HTML Exception" if an
     * invalid robots-parameter is passed.  Instead {@code 'null'} will simply be returned.
     *
     * @param robotParam This parameter should be a string retrieved from a vectorized-html page
     * that was in the {@code content='...'} attribute-field of a robots meta-tag.
     * 
     * @return An instance of this enumerated type.  The instance will be retrieved using
     * {@code 'robotParam'}.
     *
     *  @see Features.Meta#insertRobots(Vector, boolean, boolean)
     * @see Features.Meta#getAllRobots(Vector)
     */
    public static Robots getRobotNOMHE(String robotParam)
    { return lookup.get(robotParam.toLowerCase()); }
}