src/java.naming/share/classes/javax/naming/NameClassPair.java
author herrick
Tue, 24 Sep 2019 13:41:16 -0400
branchJDK-8200758-branch
changeset 58301 e0efb29609bd
parent 47216 71c04702a3d5
permissions -rw-r--r--
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code Submitted-by: asemenyuk Reviewed-by: herrick, almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.naming;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * This class represents the object name and class name pair of a binding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * found in a context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * A context consists of name-to-object bindings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The NameClassPair class represents the name and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * class of the bound object. It consists
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * of a name and a string representing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * package-qualified class name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Use subclassing for naming systems that generate contents of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * a name/class pair dynamically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * A NameClassPair instance is not synchronized against concurrent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * access by multiple threads. Threads that need to access a NameClassPair
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * concurrently should synchronize amongst themselves and provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * the necessary locking.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @see Context#list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  * The serialized form of a NameClassPair object consists of the name (a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  * String), class name (a String), and isRelative flag (a boolean).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public class NameClassPair implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Contains the name of this NameClassPair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * It is initialized by the constructor and can be updated using
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    63
     * {@code setName()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @see #getName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @see #setName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *Contains the class name contained in this NameClassPair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * It is initialized by the constructor and can be updated using
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    73
     * {@code setClassName()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @see #getClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @see #setClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private String className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Contains the full name of this NameClassPair within its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * own namespace.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    83
     * It is initialized using {@code setNameInNamespace()}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @see #getNameInNamespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @see #setNameInNamespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private String fullName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    92
     * Records whether the name of this {@code NameClassPair}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * is relative to the target context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * It is initialized by the constructor and can be updated using
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    95
     * {@code setRelative()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @see #isRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @see #setRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @see #getName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @see #setName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private boolean isRel = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Constructs an instance of a NameClassPair given its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * name and class name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @param   name    The non-null name of the object. It is relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *                  to the <em>target context</em> (which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * named by the first parameter of the <code>list()</code> method)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param   className       The possibly null class name of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *          bound to name. It is null if the object bound is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @see #getClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @see #setClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @see #getName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see #setName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public NameClassPair(String name, String className) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        this.className = className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Constructs an instance of a NameClassPair given its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * name, class name, and whether it is relative to the listing context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param   name    The non-null name of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param   className       The possibly null class name of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *  bound to name.  It is null if the object bound is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param isRelative true if <code>name</code> is a name relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *          to the target context (which is named by the first parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *          of the <code>list()</code> method); false if <code>name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *          is a URL string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @see #getClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @see #setClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @see #getName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @see #setName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @see #isRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @see #setRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public NameClassPair(String name, String className, boolean isRelative) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        this.className = className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        this.isRel = isRelative;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Retrieves the class name of the object bound to the name of this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * If a reference or some other indirect information is bound,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * retrieves the class name of the eventual object that
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   151
     * will be returned by {@code Binding.getObject()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @return  The possibly null class name of object bound.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *          It is null if the object bound is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @see Binding#getObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @see Binding#getClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @see #setClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public String getClassName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Retrieves the name of this binding.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   165
     * If {@code isRelative()} is true, this name is relative to the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * target context (which is named by the first parameter of the
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   167
     * {@code list()}).
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   168
     * If {@code isRelative()} is false, this name is a URL string.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @return  The non-null name of this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @see #isRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @see #setName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * Sets the name of this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @param   name the non-null string to use as the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @see #getName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @see #setRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public void setName(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * Sets the class name of this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @param   name the possibly null string to use as the class name.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   193
     * If null, {@code Binding.getClassName()} will return
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * the actual class name of the object in the binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * The class name will be null if the object bound is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @see #getClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @see Binding#getClassName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public void setClassName(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        this.className = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * Determines whether the name of this binding is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * relative to the target context (which is named by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * the first parameter of the <code>list()</code> method).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @return true if the name of this binding is relative to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *          target context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *          false if the name of this binding is a URL string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @see #setRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @see #getName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public boolean isRelative() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return isRel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Sets whether the name of this binding is relative to the target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * context (which is named by the first parameter of the <code>list()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * method).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @param r If true, the name of binding is relative to the target context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *          if false, the name of binding is a URL string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @see #isRelative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @see #setName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public void setRelative(boolean r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        isRel = r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * Retrieves the full name of this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * The full name is the absolute name of this binding within
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * its own namespace. See {@link Context#getNameInNamespace()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * In naming systems for which the notion of full name does not
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   239
     * apply to this binding an {@code UnsupportedOperationException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * This exception is also thrown when a service provider written before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * the introduction of the method is in use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * The string returned by this method is not a JNDI composite name and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * should not be passed directly to context methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @return The full name of this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @throws UnsupportedOperationException if the notion of full name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *         does not apply to this binding in the naming system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @see #setNameInNamespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @see #getName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public String getNameInNamespace() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        if (fullName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        return fullName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Sets the full name of this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * This method must be called to set the full name whenever a
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   264
     * {@code NameClassPair} is created and a full name is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * applicable to this binding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * Setting the full name to null, or not setting it at all, will
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   268
     * cause {@code getNameInNamespace()} to throw an exception.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @param fullName The full name to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @see #getNameInNamespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @see #setName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public void setNameInNamespace(String fullName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        this.fullName = fullName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Generates the string representation of this name/class pair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * The string representation consists of the name and class name separated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * by a colon (':').
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * The contents of this string is useful
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * for debugging and is not meant to be interpreted programmatically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @return The string representation of this name/class pair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        return (isRelative() ? "" : "(not relative)") + getName() + ": " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                getClassName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * Use serialVersionUID from JNDI 1.1.1 for interoperability
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    private static final long serialVersionUID = 5620776610160863339L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
}