r9512 - apps/gobi/trunk/code/Link
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: hannes
Date: 2009-02-17 20:11:40 +0100 (Tue, 17 Feb 2009)
New Revision: 9512
Modified:
apps/gobi/trunk/code/Link/Link.js
Log:
Protect agains null reference in removeLink(), add curly braces and spaces in if/else statements.
Details at http://dev.helma.org/trac/helma/changeset/9512
Modified: apps/gobi/trunk/code/Link/Link.js
===================================================================
--- apps/gobi/trunk/code/Link/Link.js 2009-02-17 19:04:55 UTC (rev 9511)
+++ apps/gobi/trunk/code/Link/Link.js 2009-02-17 19:11:40 UTC (rev 9512)
@@ -44,10 +44,12 @@
*/
function removeLink() {
this.remove();
- if (this.target.links_in.get(this.type))
+ if (this.target && this.target.links_in.get(this.type)) {
this.target.links_in.get(this.type).removeChild(this);
- if (this.source.links_out.get(this.type))
+ }
+ if (this.source && this.source.links_out.get(this.type)) {
this.source.links_out.get(this.type).removeChild(this);
+ }
}
@@ -56,12 +58,13 @@
* "known" page is specified by the direction argument.
*/
function getPage(direction) {
- if (direction == "in")
+ if (direction == Link.IN) {
return this.source;
- else if (direction == "out")
+ } else if (direction == Link.OUT) {
return this.target;
- else
- throw "Invalid link direction: "+direction;
+ } else {
+ throw "Invalid link direction: " + direction;
+ }
}
/**
@@ -69,14 +72,15 @@
* "known" page is specified by the direction argument.
*/
function getId(direction) {
- if (direction == "in")
+ if (direction == Link.IN) {
return this.sourceId;
- else if (direction == "out")
+ } else if (direction == Link.OUT) {
return this.targetId;
- else
- throw "Invalid link direction: "+direction;
+ } else {
+ throw "Invalid link direction: " + direction;
+ }
}
function toString() {
- return "Link["+this.type+":"+this.source.name+"->"+this.target.name+"]";
+ return "Link[" + this.type + ":" + this.source.name + "->" + this.target.name + "]";
}