von hol.sten » So, 05.02.2012 18:04
Kakao hat geschrieben:Nur Frage ich mich, was die imports zum anfang eines makroscripts machen..
Nur Frage ich mich, warum du nicht die Doku liest, auf die ich bereits verwiesen haben? Da wird doch wunderbar erklärt was die Imports machen:
Rhino project page > Scripting Java hat geschrieben:If your scripts access a lot of different Java classes it can get awkward to use the full package name of the class every time. Rhino provides a top-level function importPackage that serves the same purpose as Java's import declaration. For example, we could import all of the classes in the java.io package and access class java.io.File using just the name File: ...
Rhino project page > Scripting Java hat geschrieben:Above we saw the use of the importPackage function to import all the classes from a particular Java package. There is also importClass, which imports a single class: ...
Quellen:
http://www.mozilla.org/rhino/ScriptingJava.html und
http://www.mozilla.org/rhino/scriptjava.html
Die Imports dienen nur der Vereinfachung des Schreibens von Klassennamen. Mit importPackage(...) kann man ein ganzes Package importieren. Mit importClass(...) eine einzelne Klasse eines Packages. Anschließend kann man die Klassen imJavaScript-Code ohne Packagenamen angeben.
[quote="Kakao"]Nur Frage ich mich, was die imports zum anfang eines makroscripts machen..[/quote]
Nur Frage ich mich, warum du nicht die Doku liest, auf die ich bereits verwiesen haben? Da wird doch wunderbar erklärt was die Imports machen:
[quote="Rhino project page > Scripting Java"]If your scripts access a lot of different Java classes it can get awkward to use the full package name of the class every time. Rhino provides a top-level function importPackage that serves the same purpose as Java's import declaration. For example, we could import all of the classes in the java.io package and access class java.io.File using just the name File: ...[/quote]
[quote="Rhino project page > Scripting Java"]Above we saw the use of the importPackage function to import all the classes from a particular Java package. There is also importClass, which imports a single class: ...[/quote]
Quellen: [url]http://www.mozilla.org/rhino/ScriptingJava.html[/url] und [url]http://www.mozilla.org/rhino/scriptjava.html[/url]
Die Imports dienen nur der Vereinfachung des Schreibens von Klassennamen. Mit importPackage(...) kann man ein ganzes Package importieren. Mit importClass(...) eine einzelne Klasse eines Packages. Anschließend kann man die Klassen imJavaScript-Code ohne Packagenamen angeben.