Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "VJET/Semantic Comparison - Java and vjojs"
< VJET
(8 intermediate revisions by 2 users not shown) | |||
Line 155: | Line 155: | ||
− | |||
==== Declarations ==== | ==== Declarations ==== | ||
− | + | {| style="background-color:#F9F9F9;border:1px solid #AAAAAA;border-collapse:collapse;color:black; margin:1em 0;" | |
− | {| | + | |- |
− | + | ! style="background-color:#F2F2F2;text-align:center;border:1px solid #AAAAAA;padding:0.2em;" | To Declare | |
− | + | ! style="background-color:#F2F2F2;text-align:center;border:1px solid #AAAAAA;padding:0.2em;" | Java | |
− | + | ! style="background-color:#F2F2F2;text-align:center;border:1px solid #AAAAAA;padding:0.2em;" | VJET VJO | |
|- | |- | ||
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | Enum Constants |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | public enum Days { | |
− | + | ||
− | + | ||
− | + | ||
MON,TUE,WED,THU,FRI,SAT,SUN | MON,TUE,WED,THU,FRI,SAT,SUN | ||
− | }</ | + | } |
− | + | </source> | |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | vjo.etype('<namespace>.Days') | |
− | + | .values('MON,TUE,WED,THU,FRI,SAT,SUN') | |
− | .values('MON,TUE,WED,THU,FRI,SAT,SUN')</ | + | </source> |
|- | |- | ||
− | | Argument Types | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | Argument Types |
− | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> | |
− | + | void setName(String name){} | |
− | + | </source> | |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | //> void setName(String name) | |
− | + | setName : function(name){} | |
− | setName : function(name){}</ | + | </source> |
− | + | ||
|- | |- | ||
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | Method Scope |
− | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> | |
− | + | public void setName(String name){} | |
− | + | </source> | |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | //>public void setName(String name) | |
− | + | setName : function(name){} | |
− | setName : function(name){}</ | + | </source> |
− | + | ||
|- | |- | ||
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | Return Type |
− | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> | |
− | + | public X getIt(){} | |
− | + | </source> | |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | //> public X getIt() | |
− | + | getIt : function(){} | |
− | getIt : function(){}</ | + | </source> |
− | + | ||
|- | |- | ||
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | Overloaded Method |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | public X getIt(String x) | |
− | + | public X getIt(int x) | |
− | public X getIt(int x)</ | + | </source> |
− | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> | |
− | + | //>public X getIt(String x) | |
− | + | ||
//>public X getIt(int x) | //>public X getIt(int x) | ||
− | getIt:function(x) {}</ | + | getIt:function(x) {} |
− | + | </source> | |
+ | |||
|- | |- | ||
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | Method with Variable Arguments |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | public X getIt(String... x) | |
− | + | </source> | |
− | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> | |
− | + | //>public X getIt(String... x) | |
− | + | getIt:function(x) {} | |
− | getIt:function(x) {}</ | + | </source> |
− | + | ||
|- | |- | ||
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | Local Variable |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | int x = 10; | |
− | + | ||
String s = "hello"; | String s = "hello"; | ||
− | final boolean ok = false;</ | + | final boolean ok = false; |
− | + | </source> | |
− | | | + | | style="border:1px solid #AAAAAA;padding: 0.2em;" | <source lang="javascript"> |
− | + | var x = 10; //< int | |
− | + | ||
var s = 'hello'; //< String | var s = 'hello'; //< String | ||
− | var ok = false; //< final boolean</ | + | var ok = false; //< final boolean |
+ | </source> | ||
+ | |||
+ | |} | ||
+ | |||
+ | |||
+ | [[Category:VJET|VJOJS]] | ||
+ | [[Category:JavaScript]] |
Latest revision as of 19:26, 2 May 2013
The following tables summarize the semantic similarities between Java and VjO.
Semantic | Java | VJET VJO |
---|---|---|
Declare a Namespace | package vjo.x.y | vjo.ctype("vjo.x.y.Z") // where Z is the name of a class. |
Import a Class | import vjo.utils.X | .needs("vjo.utils.X") |
Type Definitions and Manipulation
Semantic | Java | VJET VJO |
---|---|---|
Define a Class | class X{} |
vjo.ctype("<namespace>.X") |
Define an Interface | interface Y{} |
vjo.itype("<namespace>.Y") |
Define an Enum | enum E{} |
vjo.etype("<namespace>.E") |
Define an Abstract Class | abstract class Z{} |
//> abstract vjo.ctype("<namespace>.Z") |
Define an Inner Class | class X{} |
X : vjo.ctype() |
Modify a Type | final class R{}; |
//> final vjo.ctype("vjo.R") |
Define a Constructor | D(){} |
constructs: function(){} |
Overload a Constructor | D(int arg){} D(String arg){} |
//>public void constructs(int arg) //>public void constructs(String arg) constructs:function(arg){} |
Call a Super Constructor | super() |
this.base() |
Call a Super Constructor with Arguments | super(arg) |
this.base(arg) |
Call a Super Method | super.doIt() |
this.base.doIt() |
Extend a Class | class X extends Y |
vjo.ctype("<namespace>.X") .inherits("<namespace>.Y") |
Implement an Interface | class X implements Y |
vjo.ctype("<namespace>.X") .satisfies("<namespace>.Y") |
Implement an Instance Method | void setName(String name) |
.protos({ setName: function(String name) |
Implement a Static Method | static void setName(String name) |
.props({ setName: function(String name) }) |
Implement a Static Initializer | {// static initialization here static{...} |
// static initialization here .inits(function(){...}) |
Declarations
To Declare | Java | VJET VJO |
---|---|---|
Enum Constants | public enum Days { MON,TUE,WED,THU,FRI,SAT,SUN } |
vjo.etype('<namespace>.Days') .values('MON,TUE,WED,THU,FRI,SAT,SUN') |
Argument Types | void setName(String name){} |
//> void setName(String name) setName : function(name){} |
Method Scope | public void setName(String name){} |
//>public void setName(String name) setName : function(name){} |
Return Type | public X getIt(){} |
//> public X getIt() getIt : function(){} |
Overloaded Method | public X getIt(String x) public X getIt(int x) |
//>public X getIt(String x) //>public X getIt(int x) getIt:function(x) {} |
Method with Variable Arguments | public X getIt(String... x) |
//>public X getIt(String... x) getIt:function(x) {} |
Local Variable | int x = 10; String s = "hello"; final boolean ok = false; |
var x = 10; //< int var s = 'hello'; //< String var ok = false; //< final boolean |