code: public String readQuery(CmsUUID projectId, String queryKey) {
  
          String key;
          if ((projectId != null) && !projectId.isNullUUID()) {
              // id 0 is special, please see below
              StringBuffer buffer = new StringBuffer(128);
              buffer.append(queryKey);
              if (projectId.equals(CmsProject.ONLINE_PROJECT_ID)) {
                  buffer.append("_ONLINE");
              } else {
                  buffer.append("_OFFLINE");
              }
              key = buffer.toString();
          } else {
              key = queryKey;
          }
  
          // look up the query in the cache
          String query = m_cachedQueries.get(key);
  
          if (query == null) {
              // the query has not been cached yet
              // get the SQL statement from the properties hash
              query = readQuery(queryKey);
  
              if (query == null) {
                  throw new CmsRuntimeException(Messages.get().container(Messages.ERR_QUERY_NOT_FOUND_1, queryKey));
              }
  
              // replace control chars.
              query = CmsStringUtil.substitute(query, "\t", " ");
              query = CmsStringUtil.substitute(query, "\n", " ");
  
              if ((projectId != null) && !projectId.isNullUUID()) {
                  // a project ID = 0 is an internal indicator that a project-independent
                  // query was requested - further regex operations are not required then
                  query = CmsSqlManager.replaceProjectPattern(projectId, query);
              }
  
              // to minimize costs, all statements with replaced expressions are cached in a map
              m_cachedQueries.put(key, query);
          }
  
          return query;
      }
docs: Searches for the SQL query with the specified key and project-ID.<p>
  
  For projectIds &ne; 0, the pattern {@link #QUERY_PROJECT_SEARCH_PATTERN} in table names of queries is
  replaced with "_ONLINE_" or "_OFFLINE_" to choose the right database
  tables for SQL queries that are project dependent!
  
  @param projectId the ID of the specified CmsProject
  @param queryKey the key of the SQL query
  @return the the SQL query in this property list with the specified key