/** * Gets the current settings of the result producer. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { String[] seOptions = new String[0]; if ((m_ResultProducer != null) && (m_ResultProducer instanceof OptionHandler)) { seOptions = ((OptionHandler) m_ResultProducer).getOptions(); } String[] options = new String[seOptions.length + 8]; int current = 0; if (!getCacheKeyName().equals("")) { options[current++] = "-F"; options[current++] = getCacheKeyName(); } if (getResultProducer() != null) { options[current++] = "-W"; options[current++] = getResultProducer().getClass().getName(); } options[current++] = "--"; System.arraycopy(seOptions, 0, options, current, seOptions.length); current += seOptions.length; while (current < options.length) { options[current++] = ""; } return options; }
/** * Gets a text descrption of the result producer. * * @return a text description of the result producer. */ @Override public String toString() { String result = "DatabaseResultProducer: "; result += getCompatibilityState(); if (m_Instances == null) { result += ": <null Instances>"; } else { result += ": " + Utils.backQuoteChars(m_Instances.relationName()); } return result; }
public void setOptions(String[] options) throws Exception { setCacheKeyName(Utils.getOption('F', options)); setResultProducer((ResultProducer) Utils.forName(ResultProducer.class, rpName, null)); if (getResultProducer() instanceof OptionHandler) { ((OptionHandler) getResultProducer()).setOptions(Utils .partitionOptions(options));
/** * Determines whether the results for a specified key must be generated. * * @param rp the ResultProducer wanting to generate the results * @param key an array of Objects (Strings or Doubles) that uniquely identify * a result for a given ResultProducer with given compatibilityState * @return true if the result should be generated * @throws Exception if it could not be determined if the result is needed. */ @Override public boolean isResultRequired(ResultProducer rp, Object[] key) throws Exception { if (m_ResultProducer != rp) { throw new Error("Unrecognized ResultProducer sending results!!"); } // System.err.println("DBRP::isResultRequired"); // Is the result needed by the listener? boolean isRequiredByListener = m_ResultListener.isResultRequired(this, key); // Is the result already in the database? boolean isRequiredByDatabase = super.isResultRequired(rp, key); if (!isRequiredByDatabase && isRequiredByListener) { // Pass the result through to the listener Object[] result = getResultFromTable(m_ResultsTableName, rp, key); System.err.println("Got result from database: " + DatabaseUtils.arrayToString(result)); m_ResultListener.acceptResult(this, key, result); return false; } return (isRequiredByListener || isRequiredByDatabase); }
public void setOptions(String[] options) throws Exception { setCacheKeyName(Utils.getOption('F', options)); setResultProducer((ResultProducer) Utils.forName(ResultProducer.class, rpName, null)); if (getResultProducer() instanceof OptionHandler) { ((OptionHandler) getResultProducer()).setOptions(Utils .partitionOptions(options));
/** * Determines whether the results for a specified key must be generated. * * @param rp the ResultProducer wanting to generate the results * @param key an array of Objects (Strings or Doubles) that uniquely identify * a result for a given ResultProducer with given compatibilityState * @return true if the result should be generated * @throws Exception if it could not be determined if the result is needed. */ @Override public boolean isResultRequired(ResultProducer rp, Object[] key) throws Exception { if (m_ResultProducer != rp) { throw new Error("Unrecognized ResultProducer sending results!!"); } // System.err.println("DBRP::isResultRequired"); // Is the result needed by the listener? boolean isRequiredByListener = m_ResultListener.isResultRequired(this, key); // Is the result already in the database? boolean isRequiredByDatabase = super.isResultRequired(rp, key); if (!isRequiredByDatabase && isRequiredByListener) { // Pass the result through to the listener Object[] result = getResultFromTable(m_ResultsTableName, rp, key); System.err.println("Got result from database: " + DatabaseUtils.arrayToString(result)); m_ResultListener.acceptResult(this, key, result); return false; } return (isRequiredByListener || isRequiredByDatabase); }
/** * Gets the current settings of the result producer. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { String[] seOptions = new String[0]; if ((m_ResultProducer != null) && (m_ResultProducer instanceof OptionHandler)) { seOptions = ((OptionHandler) m_ResultProducer).getOptions(); } String[] options = new String[seOptions.length + 8]; int current = 0; if (!getCacheKeyName().equals("")) { options[current++] = "-F"; options[current++] = getCacheKeyName(); } if (getResultProducer() != null) { options[current++] = "-W"; options[current++] = getResultProducer().getClass().getName(); } options[current++] = "--"; System.arraycopy(seOptions, 0, options, current, seOptions.length); current += seOptions.length; while (current < options.length) { options[current++] = ""; } return options; }
/** * Gets a text descrption of the result producer. * * @return a text description of the result producer. */ @Override public String toString() { String result = "DatabaseResultProducer: "; result += getCompatibilityState(); if (m_Instances == null) { result += ": <null Instances>"; } else { result += ": " + Utils.backQuoteChars(m_Instances.relationName()); } return result; }