1919 * and call {@link Context#setWrapFactory(WrapFactory)} Once an instance of this class or an
2020 * extension of this class is enabled for a given context (by calling setWrapFactory on that
2121 * context), Rhino will call the methods of this class whenever it needs to wrap a value resulting
22- * from a call to a Java method or an access to a Java field.
22+ * from calling a Java method or accessing a Java field.
2323 *
2424 * @see org.mozilla.javascript.Context#setWrapFactory(WrapFactory)
2525 * @since 1.5 Release 4
2626 */
2727public class WrapFactory {
28+ /**
29+ * @see #wrap(Context, Scriptable, Object, TypeInfo)
30+ */
31+ public final Object wrap (Context cx , Scriptable scope , Object obj , Class <?> staticType ) {
32+ return wrap (cx , scope , obj , TypeInfoFactory .GLOBAL .create (staticType ));
33+ }
34+
2835 /**
2936 * Wrap the object.
3037 *
@@ -42,14 +49,11 @@ public class WrapFactory {
4249 * @param cx the current Context for this thread
4350 * @param scope the scope of the executing script
4451 * @param obj the object to be wrapped. Note it can be null.
45- * @param staticType type hint. If security restrictions prevent to wrap object based on its
46- * class, staticType will be used instead.
52+ * @param staticType type hint. It will be used for improving generic support and fallback type
53+ * when security restrictions prevent wrapping object based on object class
4754 * @return the wrapped value.
55+ * @since 1.9.0
4856 */
49- public Object wrap (Context cx , Scriptable scope , Object obj , Class <?> staticType ) {
50- return wrap (cx , scope , obj , TypeInfoFactory .GLOBAL .create (staticType ));
51- }
52-
5357 public Object wrap (Context cx , Scriptable scope , Object obj , TypeInfo staticType ) {
5458 if (obj == null || obj == Undefined .instance || obj instanceof Scriptable ) {
5559 return obj ;
@@ -95,6 +99,14 @@ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) {
9599 return wrapAsJavaObject (cx , scope , obj , TypeInfo .NONE );
96100 }
97101
102+ /**
103+ * @see #wrapAsJavaObject(Context, Scriptable, Object, TypeInfo)
104+ */
105+ public final Scriptable wrapAsJavaObject (
106+ Context cx , Scriptable scope , Object javaObject , Class <?> staticType ) {
107+ return wrapAsJavaObject (cx , scope , javaObject , TypeInfoFactory .GLOBAL .create (staticType ));
108+ }
109+
98110 /**
99111 * Wrap Java object as Scriptable instance to allow full access to its methods and fields from
100112 * JavaScript.
@@ -108,15 +120,11 @@ public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) {
108120 * @param cx the current Context for this thread
109121 * @param scope the scope of the executing script
110122 * @param javaObject the object to be wrapped
111- * @param staticType type hint. If security restrictions prevent to wrap object based on its
112- * class, staticType will be used instead.
123+ * @param staticType type hint. It will be used for improving generic support and fallback type
124+ * when security restrictions prevent wrapping object based on object class
113125 * @return the wrapped value which shall not be null
126+ * @since 1.9.0
114127 */
115- public Scriptable wrapAsJavaObject (
116- Context cx , Scriptable scope , Object javaObject , Class <?> staticType ) {
117- return wrapAsJavaObject (cx , scope , javaObject , TypeInfoFactory .GLOBAL .create (staticType ));
118- }
119-
120128 public Scriptable wrapAsJavaObject (
121129 Context cx , Scriptable scope , Object javaObject , TypeInfo staticType ) {
122130 if (staticType .shouldReplace () && javaObject != null ) {
0 commit comments