aboutsummaryrefslogtreecommitdiff
path: root/files/es/archive/web/liveconnect/javaobject/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/es/archive/web/liveconnect/javaobject/index.html')
-rw-r--r--files/es/archive/web/liveconnect/javaobject/index.html61
1 files changed, 61 insertions, 0 deletions
diff --git a/files/es/archive/web/liveconnect/javaobject/index.html b/files/es/archive/web/liveconnect/javaobject/index.html
new file mode 100644
index 0000000000..7248cef567
--- /dev/null
+++ b/files/es/archive/web/liveconnect/javaobject/index.html
@@ -0,0 +1,61 @@
+---
+title: JavaObject
+slug: Archive/Web/LiveConnect/JavaObject
+translation_of: Archive/Web/LiveConnect_Reference/JavaObject
+---
+<p>
+</p>
+<h3 id="Summary" name="Summary"> Summary </h3>
+<p><b>Core Object</b>
+</p><p>The type of a wrapped Java object accessed from within JavaScript code.
+</p>
+<h3 id="Created_by" name="Created_by"> Created by </h3>
+<p>Any Java method which returns an object type. In addition, you can explicitly construct a <code>JavaObject</code> using the object's Java constructor with the <code>Packages</code> keyword:
+</p>
+<pre class="eval">new Packages.<i>JavaClass</i>(<i>parameterList</i>)
+</pre>
+<p><i>JavaClass</i> is the fully-specified name of the object's Java class.
+</p>
+<h3 id="Parameters" name="Parameters"> Parameters </h3>
+<dl><dt> <code>parameterList</code> </dt><dd> An optional list of parameters, specified by the constructor of the Java class.
+</dd></dl>
+<h3 id="Description" name="Description"> Description </h3>
+<p>The <code>JavaObject</code> object is an instance of a Java class that is created in or passed to JavaScript. <code>JavaObject</code> is a wrapper for the instance; all references to the class instance are made through the <code>JavaObject</code>.
+</p><p>Any Java data brought into JavaScript is converted to JavaScript data types. When the <code>JavaObject</code> is passed back to Java, it is unwrapped and can be used by Java code. See the <a href="es/Core_JavaScript_1.5_Guide">Core JavaScript 1.5 Guide</a> for more information about data type conversions.
+</p>
+<h3 id="Properties" name="Properties"> Properties </h3>
+<p>Inherits public data members from the Java class of which it is an instance as properties. It also inherits public data members from any superclass as properties.
+</p>
+<h3 id="Methods" name="Methods"> Methods </h3>
+<p>Inherits public methods from the Java class of which it is an instance. The <code>JavaObject</code> also inherits methods from <code>java.lang.Object</code> and any other superclass.
+</p>
+<h3 id="Examples" name="Examples"> Examples </h3>
+<h4 id="Example:_Instantiating_a_Java_Object_in_JavaScript" name="Example:_Instantiating_a_Java_Object_in_JavaScript"> Example: Instantiating a Java Object in JavaScript </h4>
+<p>The following code creates the <code>JavaObject</code> <code>theString</code>, which is an instance of the class <code>java.lang.String</code>:
+</p>
+<pre class="eval">var theString = new Packages.java.lang.String("Hello, world");
+</pre>
+<p>Because the <code>String</code> class is in the <code>java</code> package, you can also use the java synonym and omit the <code>Packages</code> keyword when you instantiate the class:
+</p>
+<pre class="eval">var theString = new java.lang.String("Hello, world");
+</pre>
+<h4 id="Example:_Accessing_methods_of_a_Java_object" name="Example:_Accessing_methods_of_a_Java_object"> Example: Accessing methods of a Java object </h4>
+<p>Because the <code>JavaObject</code> <code>theString</code> is an instance of <code>java.lang.String</code>, it inherits all the public methods of <code>java.lang.String</code>. The following example uses the <code>startsWith</code> method to check whether <code>theString</code> begins with "Hello".
+</p>
+<pre class="eval">var theString = new java.lang.String("Hello, world");
+theString.startsWith("Hello"); // returns true
+</pre>
+<h4 id="Example:_Accessing_inherited_methods" name="Example:_Accessing_inherited_methods"> Example: Accessing inherited methods </h4>
+<p>Because <code>getClass</code> is a method of <code>Object</code>, and <code>java.lang.String</code> extends <code>Object</code>, the <code>String</code> class inherits the <code>getClass</code> method. Consequently, <code>getClass</code> is also a method of the <code>JavaObject</code> which instantiates <code>String</code> in JavaScript.
+</p>
+<pre class="eval">var theString = new java.lang.String("Hello, world");
+theString.getClass(); // returns java.lang.String
+</pre>
+<h3 id="See_also" name="See_also"> See also </h3>
+<p><a href="es/Core_JavaScript_1.5_Reference/Global_Objects/JavaArray">JavaArray</a>,
+<a href="es/Core_JavaScript_1.5_Reference/Global_Objects/JavaClass">JavaClass</a>,
+<a href="es/Core_JavaScript_1.5_Reference/Global_Objects/JavaPackage">JavaPackage</a>,
+<a href="es/Core_JavaScript_1.5_Reference/Global_Objects/Packages">Packages</a>
+</p>
+<div class="noinclude">
+</div>