In addition to those required by the JDO 1.0.1 spec, TJDO supports some query methods from JDO 2.0, and also supports a few others not mentioned in either spec.
int Collection.size() boolean Map.containsKey(Object key) boolean Map.containsValue(Object value) boolean Map.isEmpty() int Map.size() int String.indexOf(String substr) String String.substring(int begin) String String.substring(int begin, int end) String String.toLowerCase() String String.toUpperCase()
Except for the limitation on indexOf() described below, all behave as described in the 2.0 spec.
Set Map.keySet() Collection Map.values() char String.charAt(int index) int String.length() boolean String.startsWith(String substr, int toffset) String String.trim()
These are all non-standard TriActive extensions to JDOQL. They are highly likely to work in TJDO no matter what database is in-use (DB portable) but are far less likely to be available in another vendor's JDO implementation (not very JDO portable). Except for the limitation on length() described below, all behave like their Java counterparts.
Object Map.get(Object key) int String.indexOf(String substr, int fromIndex) boolean String.matches(String regex) Number Math.abs(Number) Number Math.sqrt(Number) Object JDOHelper.getObjectId(Object pc)
These methods are coming soon as we flesh out full support for JDO 2.0.
String.indexOf() is used to perform the equivalent of
LIKE '%xyz%'
in SQL.
For example, the filter:
str.indexOf("xyz") >= 0
will effectively generate WHERE STR LIKE '%xyz%'
in the
resulting SQL, and:
str.indexOf("xyz") < 0
will generate WHERE STR NOT LIKE '%xyz%'
.
indexOf() is very limited in that it can only be used in this way; that is, to test for the existence or non-existence of an embedded substring. In other words, it can only be used in a subexpression in which the return value is compared to the constant(s) 0 or -1 to test for found vs. not found. It cannot be used to otherwise obtain or filter on the index position of a substring; an occurrence of indexOf() must always occur in such a subexpression or an exception will be thrown.
When using Oracle, String.length() will not return reliable results for strings of lengths zero or one. To circumvent the fact Oracle equates empty strings with NULL, TJDO represents empty strings in the database by a single surrogate character '\001'. Therefore when the SQL LENGTH() function is executed "empty" strings will appear to have a length of one.
When I get time I'd like to add some methods from java.util.Date to pick apart date fields:
int Date.getDate() int Date.getHours() int Date.getMinutes() int Date.getMonth() int Date.getSeconds() int Date.getYear()
Let me know if you're particularly interested in adding these or any other new methods.