478 |
478 |
|
479 |
479 |
nodePath = findNodePath(nodePath, result, key);
|
480 |
480 |
|
481 |
|
defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getBoolean(key, defaultValue);
|
|
481 |
// defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getBoolean(key, defaultValue);
|
482 |
482 |
return preferencesRootNode.node(nodePath).getBoolean(key, defaultValue);
|
483 |
483 |
}
|
484 |
484 |
|
... | ... | |
774 |
774 |
* @param key
|
775 |
775 |
* @return
|
776 |
776 |
*/
|
777 |
|
public static int getInt(String key, TXMResult result, String nodePath) {
|
|
777 |
public static int getInt(String key, TXMResult result, String nodePath, int defaultValue) {
|
778 |
778 |
nodePath = findNodePath(nodePath, result, key);
|
779 |
779 |
|
780 |
|
int defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getInt(key, 0);
|
|
780 |
// int defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getInt(key, 0);
|
781 |
781 |
return preferencesRootNode.node(nodePath).getInt(key, defaultValue);
|
782 |
782 |
|
783 |
783 |
}
|
784 |
784 |
|
785 |
785 |
/**
|
|
786 |
*
|
|
787 |
* @param key
|
|
788 |
* @param result
|
|
789 |
* @param nodePath
|
|
790 |
* @return
|
|
791 |
*/
|
|
792 |
public static int getInt(String key, TXMResult result, String nodePath) {
|
|
793 |
return getInt(key, result, nodePath, 0);
|
|
794 |
}
|
|
795 |
|
|
796 |
/**
|
786 |
797 |
*
|
787 |
798 |
* @param nodePath
|
788 |
799 |
* @param key
|
... | ... | |
803 |
814 |
}
|
804 |
815 |
|
805 |
816 |
|
|
817 |
|
|
818 |
|
806 |
819 |
/**
|
807 |
820 |
* Looks for the value of the specified <code>key</code> in the specified parameters and preference nodes.
|
808 |
821 |
* Returns the value of a key in the specified parameters if exists.
|
... | ... | |
846 |
859 |
public static long getLong(String key, TXMResult result, String nodePath, long defaultValue) {
|
847 |
860 |
nodePath = findNodePath(nodePath, result, key);
|
848 |
861 |
|
849 |
|
defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getLong(key, defaultValue);
|
|
862 |
// defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getLong(key, defaultValue);
|
850 |
863 |
return preferencesRootNode.node(nodePath).getLong(key, defaultValue);
|
851 |
864 |
|
852 |
865 |
}
|
... | ... | |
930 |
943 |
public static double getDouble(String key, String nodePath, TXMResult result, double defaultValue) {
|
931 |
944 |
nodePath = findNodePath(nodePath, result, key);
|
932 |
945 |
|
933 |
|
defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getDouble(key, defaultValue);
|
|
946 |
// defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getDouble(key, defaultValue);
|
934 |
947 |
return preferencesRootNode.node(nodePath).getDouble(key, defaultValue);
|
935 |
948 |
}
|
936 |
949 |
|
... | ... | |
1015 |
1028 |
public static float getFloat(String key, String nodePath, TXMResult result, float defaultValue) {
|
1016 |
1029 |
nodePath = findNodePath(nodePath, result, key);
|
1017 |
1030 |
|
1018 |
|
defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getFloat(key, defaultValue);
|
|
1031 |
// defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getFloat(key, defaultValue);
|
1019 |
1032 |
return preferencesRootNode.node(nodePath).getFloat(key, defaultValue);
|
1020 |
1033 |
}
|
1021 |
1034 |
|
... | ... | |
1499 |
1512 |
|
1500 |
1513 |
/**
|
1501 |
1514 |
* Internal method to find the preference node path of a result otherwise look in instance, default scopes and in alternatives nodes qualifiers.
|
1502 |
|
*
|
|
1515 |
*
|
1503 |
1516 |
* @param result
|
1504 |
1517 |
* @param key
|
1505 |
1518 |
*/
|
... | ... | |
1507 |
1520 |
|
1508 |
1521 |
boolean keyExists = (result != null && keyExists(result.getParametersNodePath(), key));
|
1509 |
1522 |
|
1510 |
|
// get the result scope preference
|
|
1523 |
// get the result scope preference (formed as "project/project_name/uuid_class")
|
1511 |
1524 |
if (keyExists) {
|
1512 |
|
nodePath = result.getParametersNodePath();
|
|
1525 |
return result.getParametersNodePath();
|
1513 |
1526 |
}
|
|
1527 |
// look in the instance scope
|
|
1528 |
else if (keyExists("instance/" + nodePath, key)) {
|
|
1529 |
return "instance/" + nodePath;
|
|
1530 |
}
|
1514 |
1531 |
// look in the global alternative preferences nodes
|
1515 |
|
else if (!keyExists("instance/" + nodePath, key)) {
|
|
1532 |
else {
|
1516 |
1533 |
for (int i = 0; i < alternativeNodesQualifiers.size(); i++) {
|
1517 |
1534 |
if (keyExists("instance/" + alternativeNodesQualifiers.get(i), key)) {
|
1518 |
|
nodePath = "instance/" + alternativeNodesQualifiers.get(i);
|
1519 |
|
break;
|
|
1535 |
return "instance/" + alternativeNodesQualifiers.get(i);
|
1520 |
1536 |
}
|
|
1537 |
else if (keyExists("default/" + alternativeNodesQualifiers.get(i), key)) {
|
|
1538 |
return "default/" + alternativeNodesQualifiers.get(i);
|
|
1539 |
}
|
1521 |
1540 |
}
|
|
1541 |
|
|
1542 |
return "default/" + nodePath;
|
1522 |
1543 |
}
|
1523 |
|
else {
|
1524 |
|
nodePath = "instance/" + nodePath;
|
1525 |
|
}
|
1526 |
1544 |
|
1527 |
|
// if (nodePath == null) {
|
1528 |
|
// try {
|
1529 |
|
// Log.warning("TXMPreferences.findNodePath(): no node qualifier has been found (key = " + key + ", TXMResult = " + result + ").");
|
1530 |
|
// }
|
1531 |
|
// catch(Exception e) {
|
1532 |
|
// e.printStackTrace();
|
1533 |
|
// }
|
1534 |
|
// }
|
1535 |
|
return nodePath;
|
1536 |
1545 |
}
|
1537 |
1546 |
|
1538 |
1547 |
|
|
1548 |
// /**
|
|
1549 |
// * Looks for the value of the specified <code>key</code> in preference nodes.
|
|
1550 |
// * Returns the value of the local result node if exists.
|
|
1551 |
// * Otherwise try to get it from the specified node qualifier if exists.
|
|
1552 |
// * Otherwise try to get it from the specified alternative node qualifiers defined in the list <code>TXMPreferences.alternativeNodesQualifiers</code>.
|
|
1553 |
// * Returns defaultValue if no value has been found for the specified key.
|
|
1554 |
// *
|
|
1555 |
// * @param nodePath
|
|
1556 |
// * @param result
|
|
1557 |
// * @param key
|
|
1558 |
// * @param defaultValue
|
|
1559 |
// * @return
|
|
1560 |
// */
|
|
1561 |
// public static long getLong(String key, TXMResult result, String nodePath, long defaultValue) {
|
|
1562 |
// if(nodePath != null) {
|
|
1563 |
// defaultValue = DefaultScope.INSTANCE.getNode(nodePath).getLong(key, defaultValue);
|
|
1564 |
// }
|
|
1565 |
//
|
|
1566 |
// nodePath = findNodePath(nodePath, result, key);
|
|
1567 |
//
|
|
1568 |
// return preferencesRootNode.node(nodePath).getLong(key, defaultValue);
|
|
1569 |
//
|
|
1570 |
// }
|
|
1571 |
//
|
|
1572 |
//
|
1539 |
1573 |
|
|
1574 |
|
|
1575 |
|
1540 |
1576 |
/**
|
1541 |
1577 |
* Stores the specified parameters pairs of key / value in a local node dedicated to the specified result. The node qualifier is generated by the <code>Object.toString()</code> method.
|
1542 |
1578 |
*
|
1543 |
1579 |
* @param result
|
1544 |
1580 |
* @param parameters
|
1545 |
1581 |
*/
|
1546 |
|
// FIXME: became useless?
|
|
1582 |
// FIXME: SJ: became useless?
|
1547 |
1583 |
// public static void putLocalParameters(TXMResult result, TXMParameters parameters) {
|
1548 |
1584 |
// Set keys = parameters.keySet();
|
1549 |
1585 |
// Iterator it = keys.iterator();
|