Home
AccessorsAccessors
JoSQL relies on a particular concept to do it's work, an "accessor". An accessor is basically a way of accessing information held with an object (this is performed by using Java Reflection). The accessor provides a textual way of representing the public methods names or fields that are accessed, separated by ".". The basic rule however is that each part of the accessor must reference a no-argument public method or a public field (static methods and fields can be referenced). Accessors generally follow the Java-bean naming convention, i.e. that access methods start with "get" or "is" and are followed by a value with the first letter capitalised. However, since in real programming this convention is rarely followed exactly accessors also allow for method names that DON'T start with "get" or "is".

For example, class java.io.File:
  • To access the getName method, use: name or getName
  • To access the lastModified method, use: lastModified
  • To access the length of the path for the File use: path.length
The level to which you are "drill" is up to you, however of course the methods/fields MUST be present in the class of the returned object, for example the path accessor returns an instance of java.lang.String, therefore only methods that are available in the java.lang.String class are exposed. So to return the length of a "trimmed" version of the path (this is only done for demonstration purposes!), use: path.trim.length.

Accessors basically convert the object to a pure data structure, similar to C data structures.