Context-aware classes represent a powerful interface for writing Java modules that are more closely coupled with the BaseX core library.
If an instantiated class inherits the abstract [https://github.com/BaseXdb/basex/blob/master/src/main/java/org/basex/query/QueryModule.java QueryModule] class of BaseX, it will be enriched with two internal, context-dependent variables:
* {{Mono|context}} is an instance of the [https://github.com/BaseXdb/basex/blob/master/src/main/java/org/basex/query/QueryContext.java QueryContext] class. It provides access to all static and dynamic properties of the current query.
* {{Mono|input}} is an instance of [https://github.com/BaseXdb/basex/blob/master/src/main/java/org/basex/util/InputInfo.java InputInfo]. It contains line/column and the original query and is mainly used for providing to generate better error messages.Context-aware classes represent a powerful interface for writing Java modules that are more closely coupled with the BaseX core libraryline and column information.
The following XQuery code invokes two context-aware Java methods: