langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/FieldDocImpl.java
author jjg
Mon, 09 May 2016 16:52:15 -0700
changeset 37938 42baa89d2156
parent 25874 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/FieldDocImpl.java@83c19f00452c
child 38617 d93a7f64e231
permissions -rw-r--r--
8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API. Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2212
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
37938
42baa89d2156 8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API.
jjg
parents: 25874
diff changeset
    26
package com.sun.tools.javadoc.main;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14359
diff changeset
    28
import com.sun.source.util.TreePath;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
    29
import java.lang.reflect.Modifier;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
    30
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.javac.code.Flags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import com.sun.tools.javac.code.Symbol.ClassSymbol;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import com.sun.tools.javac.code.Symbol.VarSymbol;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14260
diff changeset
    37
import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14260
diff changeset
    38
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * Represents a field in a java class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    42
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    43
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    44
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    45
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    46
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @see MemberDocImpl
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * @author Neal Gafter (rewrite)
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * @author Scott Seligman (generics, enums, annotations)
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    protected final VarSymbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     */
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14359
diff changeset
    61
    public FieldDocImpl(DocEnv env, VarSymbol sym, TreePath treePath) {
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14359
diff changeset
    62
        super(env, sym, treePath);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * Constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    public FieldDocImpl(DocEnv env, VarSymbol sym) {
14802
969e90f68ac5 8004828: refactor init of *DocImpl classes
jjg
parents: 14359
diff changeset
    70
        this(env, sym, null);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * Returns the flags in terms of javac's flags
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    protected long getFlags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        return sym.flags();
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * Identify the containing class
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    protected ClassSymbol getContainingClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        return sym.enclClass();
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * Get type of this field.
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    public com.sun.javadoc.Type type() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        return TypeMaker.getType(env, sym.type, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * Get the value of a constant field.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * @return the value of a constant field. The value is
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * automatically wrapped in an object if it has a primitive type.
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * If the field is not constant, returns null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    public Object constantValue() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        Object result = sym.getConstValue();
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14260
diff changeset
   103
        if (result != null && sym.type.hasTag(BOOLEAN))
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            // javac represents false and true as Integers 0 and 1
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            result = Boolean.valueOf(((Integer)result).intValue() != 0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * Get the value of a constant field.
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     * @return the text of a Java language expression whose value
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * is the value of the constant. The expression uses no identifiers
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * other than primitive literals. If the field is
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * not constant, returns null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    public String constantValueExpression() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        return constantValueExpression(constantValue());
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * A static version of the above.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    static String constantValueExpression(Object cb) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        if (cb == null) return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        if (cb instanceof Character) return sourceForm(((Character)cb).charValue());
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        if (cb instanceof Byte) return sourceForm(((Byte)cb).byteValue());
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        if (cb instanceof String) return sourceForm((String)cb);
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        if (cb instanceof Double) return sourceForm(((Double)cb).doubleValue(), 'd');
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        if (cb instanceof Float) return sourceForm(((Float)cb).doubleValue(), 'f');
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        if (cb instanceof Long) return cb + "L";
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        return cb.toString(); // covers int, short
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        // where
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        private static String sourceForm(double v, char suffix) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            if (Double.isNaN(v))
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
                return "0" + suffix + "/0" + suffix;
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
            if (v == Double.POSITIVE_INFINITY)
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
                return "1" + suffix + "/0" + suffix;
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
            if (v == Double.NEGATIVE_INFINITY)
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
                return "-1" + suffix + "/0" + suffix;
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
            return v + (suffix == 'f' || suffix == 'F' ? "" + suffix : "");
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        private static String sourceForm(char c) {
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   145
            StringBuilder buf = new StringBuilder(8);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
            buf.append('\'');
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            sourceChar(c, buf);
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            buf.append('\'');
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        private static String sourceForm(byte c) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
            return "0x" + Integer.toString(c & 0xff, 16);
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        private static String sourceForm(String s) {
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   155
            StringBuilder buf = new StringBuilder(s.length() + 5);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
            buf.append('\"');
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
            for (int i=0; i<s.length(); i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
                char c = s.charAt(i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
                sourceChar(c, buf);
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
            buf.append('\"');
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
            return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        }
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   164
        private static void sourceChar(char c, StringBuilder buf) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            switch (c) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
            case '\b': buf.append("\\b"); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
            case '\t': buf.append("\\t"); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
            case '\n': buf.append("\\n"); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
            case '\f': buf.append("\\f"); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
            case '\r': buf.append("\\r"); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
            case '\"': buf.append("\\\""); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
            case '\'': buf.append("\\\'"); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
            case '\\': buf.append("\\\\"); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
                if (isPrintableAscii(c)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
                    buf.append(c); return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
                unicodeEscape(c, buf);
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
                return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        }
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   182
        private static void unicodeEscape(char c, StringBuilder buf) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
            final String chars = "0123456789abcdef";
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            buf.append("\\u");
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
            buf.append(chars.charAt(15 & (c>>12)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
            buf.append(chars.charAt(15 & (c>>8)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            buf.append(chars.charAt(15 & (c>>4)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
            buf.append(chars.charAt(15 & (c>>0)));
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        private static boolean isPrintableAscii(char c) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            return c >= ' ' && c <= '~';
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     * Return true if this field is included in the active set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    public boolean isIncluded() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        return containingClass().isIncluded() && env.shouldDocument(sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     * Is this Doc item a field (but not an enum constant?
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     */
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   204
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    public boolean isField() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        return !isEnumConstant();
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * Is this Doc item an enum constant?
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * (For legacy doclets, return false.)
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     */
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   213
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
    public boolean isEnumConstant() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        return (getFlags() & Flags.ENUM) != 0 &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
               !env.legacyDoclet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * Return true if this field is transient
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    public boolean isTransient() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        return Modifier.isTransient(getModifiers());
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * Return true if this field is volatile
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    public boolean isVolatile() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        return Modifier.isVolatile(getModifiers());
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     * Returns true if this field was synthesized by the compiler.
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    public boolean isSynthetic() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        return (getFlags() & Flags.SYNTHETIC) != 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * Return the serialField tags in this FieldDocImpl item.
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     * @return an array of <tt>SerialFieldTagImpl</tt> containing all
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 8631
diff changeset
   244
     *         <code>&#64;serialField</code> tags.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    public SerialFieldTag[] serialFieldTags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        return comment().serialFieldTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    public String name() {
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   251
        if (name == null) {
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   252
            name = sym.name.toString();
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   253
        }
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   254
        return name;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   257
    private String name;
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   258
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    public String qualifiedName() {
17276
d0957ee0fad7 8012681: Commit for JDK-8012656 breaks tl build
jfranck
parents: 17275
diff changeset
   260
        if (qualifiedName == null) {
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   261
            qualifiedName = sym.enclClass().getQualifiedName() + "." + name();
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   262
        }
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   263
        return qualifiedName;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
17275
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   266
    private String qualifiedName;
bcaa1940863a 8012656: cache frequently used name strings for DocImpl classes
jjg
parents: 14802
diff changeset
   267
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * Return the source position of the entity, or null if
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * no position is available.
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     */
8631
664f84942e74 6866185: Util.getPackageSourcePath should use lastIndexOf not indexOf and related cleanup
jjg
parents: 5520
diff changeset
   272
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    public SourcePosition position() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        if (sym.enclClass().sourcefile == null) return null;
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 10
diff changeset
   275
        return SourcePositionImpl.make(sym.enclClass().sourcefile,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
                                       (tree==null) ? 0 : tree.pos,
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
                                       lineMap);
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
}