Skip to content

Commit f3c34f9

Browse files
author
jossonsmith
committed
Add System.set/getProperty support
1 parent 5a2ab8f commit f3c34f9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

sources/net.sf.j2s.java.core/src/java/lang/ClassExt.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,21 @@ System = {
646646
setProperties : function (props) {
647647
System.props = props;
648648
},
649+
getProperty : function (key, def) {
650+
if (System.props != null) {
651+
return System.props.getProperty (key, def);
652+
}
653+
if (def != null) {
654+
return def;
655+
}
656+
return key;
657+
},
658+
setProperty : function (key, val) {
659+
if (System.props == null) {
660+
return ;
661+
}
662+
System.props.setProperty (key, val);
663+
},
649664
arraycopy : function (src, srcPos, dest, destPos, length) {
650665
for (var i = 0; i < length; i++) {
651666
dest[destPos + i] = src[srcPos + i];

sources/net.sf.j2s.java.core/src/java/lang/Console.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,24 @@ window.assert = function () {
464464
System.getProperties = function () {
465465
return System.props;
466466
};
467+
System.getProperty = function (key, def) {
468+
if (System.props != null) {
469+
return System.props.getProperty (key, def);
470+
}
471+
if (def != null) {
472+
return def;
473+
}
474+
return key;
475+
};
467476
System.setProperties = function (props) {
468477
System.props = props;
469478
};
479+
System.setProperty = function (key, val) {
480+
if (System.props == null) {
481+
return ;
482+
}
483+
System.props.setProperty (key, val);
484+
};
470485

471486
/* public */
472487
System.out = {

0 commit comments

Comments
 (0)