API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.naming.spi. ResolveResult View Javadoc
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

/*
 * @(#)ResolveResult.java	1.10 03/12/19
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package javax.naming.spi;

import javax.naming.Name;
import javax.naming.Context;
import javax.naming.CompositeName;
import javax.naming.InvalidNameException;

/** 
  * This class represents the result of resolution of a name.
  * It contains the object to which name was resolved, and the portion
  * of the name that has not been resolved.
  *<p>
  * A ResolveResult instance is not synchronized against concurrent 
  * multithreaded access. Multiple threads trying to access and modify
  * a single ResolveResult instance should lock the object.
  *
  * @author Rosanna Lee
  * @author Scott Seligman
  * @version 1.10 03/12/19
  * @since 1.3
  */
public class ResolveResult implements java.io.Serializable {
    /**
     * Field containing the Object that was resolved to successfully.
     * It can be null only when constructed using a subclass.
     * Constructors should always initialize this.
     * @serial
     */
    protected Object resolvedObj;
    /**
     * Field containing the remaining name yet to be resolved.
     * It can be null only when constructed using a subclass.
     * Constructors should always initialize this.
     * @serial
     */
    protected Name remainingName;

    /**
      * Constructs an instance of ResolveResult with the
      * resolved object and remaining name both initialized to null.
      */
    protected ResolveResult() {
	resolvedObj = null;
	remainingName = null;
    }

    /**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved object and the remaining unresolved component.
      *
      * @param robj The non-null object resolved to.
      * @param rcomp The single remaining name component that has yet to be
      *			resolved. Cannot be null (but can be empty).
      */
    public ResolveResult(Object robj, String rcomp) {
	resolvedObj = robj;
	try {
	remainingName = new CompositeName(rcomp);
//	    remainingName.appendComponent(rcomp);
	} catch (InvalidNameException e) {
	    // ignore; shouldn't happen
	}
    }

    /**
      * Constructs a new instance of ResolveResult consisting of
      * the resolved Object and the remaining name.
      *
      * @param robj The non-null Object resolved to.
      * @param rname The non-null remaining name that has yet to be resolved.
      */
    public ResolveResult(Object robj, Name rname) {
	resolvedObj = robj;
	setRemainingName(rname);
    }

    /**
     * Retrieves the remaining unresolved portion of the name.
     * 
     * @return The remaining unresolved portion of the name. 
     *		Cannot be null but empty OK.
     * @see #appendRemainingName
     * @see #appendRemainingComponent
     * @see #setRemainingName
     */
    public Name getRemainingName() {
	return this.remainingName;
    }

    /**
     * Retrieves the Object to which resolution was successful.
     *
     * @return The Object to which resolution was successful. Cannot be null.
      * @see #setResolvedObj
     */
    public Object getResolvedObj() {
	return this.resolvedObj;
    }

    /**
      * Sets the remaining name field of this result to name.
      * A copy of name is made so that modifying the copy within
      * this ResolveResult does not affect <code>name</code> and
      * vice versa.
      *
      * @param name The name to set remaining name to. Cannot be null.
      * @see #getRemainingName
      * @see #appendRemainingName
      * @see #appendRemainingComponent
      */
    public void setRemainingName(Name name) {
	if (name != null)
	    this.remainingName = (Name)(name.clone());
	else {
	    // ??? should throw illegal argument exception
	    this.remainingName = null;
	}
    }

    /**
      * Adds components to the end of remaining name.
      *
      * @param name The components to add. Can be null.
      * @see #getRemainingName
      * @see #setRemainingName
      * @see #appendRemainingComponent
      */
    public void appendRemainingName(Name name) {
//	System.out.println("appendingRemainingName: " + name.toString());
//	Exception e = new Exception();
//	e.printStackTrace();
	if (name != null) {
	    if (this.remainingName != null) {
		try {
		    this.remainingName.addAll(name);
		} catch (InvalidNameException e) {
		    // ignore; shouldn't happen for composite name
		}
	    } else {
		this.remainingName = (Name)(name.clone());
	    }
	}
    }

    /**
      * Adds a single component to the end of remaining name.
      *
      * @param name The component to add. Can be null.
      * @see #getRemainingName
      * @see #appendRemainingName
      */
    public void appendRemainingComponent(String name) {
	if (name != null) {
	    CompositeName rname = new CompositeName();
	    try {
		rname.add(name);
	    } catch (InvalidNameException e) {
		// ignore; shouldn't happen for empty composite name
	    }
	    appendRemainingName(rname);
	}
    }

    /**
      * Sets the resolved Object field of this result to obj.
      *
      * @param obj The object to use for setting the resolved obj field.
      *		   Cannot be null.
      * @see #getResolvedObj
      */
    public void setResolvedObj(Object obj) {
	this.resolvedObj = obj;
	// ??? should check for null?
    }

    private static final long serialVersionUID = -4552108072002407559L;
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar