in src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java [212:260]
public Object jsFunction_valueOf(String hint) {
if ("undefined".equals(hint)) {
try {
switch (property.getType()) {
case PropertyType.BOOLEAN:
return property.getBoolean();
case PropertyType.DATE:
return property.getDate();
case PropertyType.DOUBLE:
return property.getDouble();
case PropertyType.LONG:
return property.getLong();
default:
return toString();
}
} catch (RepositoryException re) {
// don't care, just return the string value
return toString();
}
} else if ("object".equals(hint)) {
// return this as a Scriptable :-)
return this;
} else if ("function".equals(hint)) {
// cannot return this as a Function
return Undefined.instance;
} else if ("boolean".equals(hint)) {
// boolean value
try {
property.getBoolean();
} catch (RepositoryException re) {
return false;
}
} else if ("number".equals(hint)) {
// numeric value
try {
property.getDouble();
} catch (RepositoryException re) {
return 0.0;
}
}
// unknown hint or "string"
return toString();
}