OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [javax/] [naming/] [NameClassPair.java] - Blame information for rev 772

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 772 jeremybenn
/* NameClassPair.java --
2
   Copyright (C) 2001, 2005, 2006  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package javax.naming;
40
 
41
import java.io.Serializable;
42
 
43
/**
44
 * <code>NameClassPair</code> represents the name-classname mapping pair
45
 * of a binding in a context.
46
 * <p>
47
 * Bindings are mappings of a name to an object and this class is used to
48
 * specify the mapping of the name to the class type of the bound object.
49
 * As classname the fully qualified classname is used.
50
 * </p>
51
 *
52
 * @author Tom Tromey (tromey@redhat.com)
53
 * @since 1.3
54
 */
55
public class NameClassPair implements Serializable
56
{
57
  private static final long serialVersionUID = 5620776610160863339L;
58
 
59
  /**
60
   * Constructs an instance with the given name and classname.
61
   *
62
   * @param name the name of the binding relative to the target context
63
   * (may not be <code>null</code>)
64
   * @param className the name of the class. If <code>null</code> the bound
65
   * object is also <code>null</code>
66
   */
67
  public NameClassPair (String name, String className)
68
  {
69
    this (name, className, true);
70
  }
71
 
72
  /**
73
   * Constructs an instance with the given name and classname and a
74
   * flag indicating if the name is relative to the target context.
75
   *
76
   * @param name the name of the binding (may not be <code>null</code>)
77
   * @param className the name of the class. If <code>null</code> the bound
78
   * object is also <code>null</code>
79
   * @param isRelative flag indicating if the name is relative or not
80
   */
81
  public NameClassPair (String name, String className, boolean isRelative)
82
  {
83
    this.name = name;
84
    this.className = className;
85
    this.isRel = isRelative;
86
  }
87
 
88
  /**
89
   * Returns the classname of the binding.
90
   * @return The fully qualified classname or <code>null</code> if the
91
   * bound object is null.
92
   */
93
  public String getClassName ()
94
  {
95
    return className;
96
  }
97
 
98
  /**
99
   * Returns the name of the binding.
100
   * @return The name.
101
   */
102
  public String getName ()
103
  {
104
    return name;
105
  }
106
 
107
  /**
108
   * Checks whether the name is relative to the target context or not.
109
   * @return <code>true</code> if the name is relative,
110
   * <code>false</code> otherwise.
111
   */
112
  public boolean isRelative ()
113
  {
114
    return isRel;
115
  }
116
 
117
  /**
118
   * Sets the classname of the bound object.
119
   * @param name the classname to set (maybe <code>null</code>)
120
   */
121
  public void setClassName (String name)
122
  {
123
    this.className = name;
124
  }
125
 
126
  /**
127
   * Sets the name of the binding.
128
   * @param name the name to set
129
   */
130
  public void setName (String name)
131
  {
132
    this.name = name;
133
  }
134
 
135
  /**
136
   * Sets if the name is relative to the target context.
137
   * @param r <code>true</code> to mark as relative
138
   */
139
  public void setRelative (boolean r)
140
  {
141
    this.isRel = r;
142
  }
143
 
144
  /**
145
   * Sets the full name for this binding. Setting the full name by this
146
   * method is the only way to initialize full names of bindings if
147
   * supported by a specific naming system.
148
   *
149
   * @param fullName the full name of this binding. If not set or set to
150
   * <code>null</code> the <code>getNameInNamespace()</code> method will
151
   * throw an exception
152
   *
153
   * @see #getNameInNamespace()
154
   *
155
   * @since 1.5
156
   */
157
  public void setNameInNamespace(String fullName)
158
  {
159
    this.fullName = fullName;
160
  }
161
 
162
  /**
163
   * Returns the full name for this binding. The full name of a binding is
164
   * defined as the absolute name in its own namespace and is not valid
165
   * outside.
166
   *
167
   * @return The full name in the bindings namespace.
168
   * @throws UnsupportedOperationException if no full name is applicable in
169
   * the specific naming system.
170
   *
171
   * @see Context#getNameInNamespace()
172
   *
173
   * @since 1.5
174
   */
175
  public String getNameInNamespace()
176
  {
177
    if (this.fullName == null)
178
      throw new UnsupportedOperationException();
179
 
180
    return this.fullName;
181
  }
182
 
183
  /**
184
   * Returns the string representation.
185
   * @return The string <code>getName() + ":" + getClassName()</code>.
186
   */
187
  public String toString ()
188
  {
189
    // Specified by class documentation.
190
    return name + ":" + className;
191
  }
192
 
193
  // These field names are fixed by the serialization spec.
194
  private String name;
195
  private String className;
196
  private boolean isRel;
197
  private String fullName;
198
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.