Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

RowEvalContext.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. Copyright (c) 2018 James Ahlborn
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package com.healthmarketscience.jackcess.impl;
  14. import com.healthmarketscience.jackcess.expr.EvalException;
  15. import com.healthmarketscience.jackcess.expr.Identifier;
  16. import com.healthmarketscience.jackcess.expr.Value;
  17. /**
  18. *
  19. * @author James Ahlborn
  20. */
  21. public abstract class RowEvalContext extends BaseEvalContext
  22. {
  23. private Object[] _row;
  24. public RowEvalContext(DatabaseImpl db) {
  25. super(db.getEvalContext());
  26. }
  27. protected void setRow(Object[] row) {
  28. _row = row;
  29. }
  30. protected void reset() {
  31. _row = null;
  32. }
  33. @Override
  34. public Value getIdentifierValue(Identifier identifier) {
  35. TableImpl table = getTable();
  36. // we only support getting column values in this table from the current
  37. // row
  38. if(!table.isThisTable(identifier) ||
  39. (identifier.getPropertyName() != null)) {
  40. throw new EvalException("Cannot access fields outside this table for " +
  41. identifier);
  42. }
  43. ColumnImpl col = table.getColumn(identifier.getObjectName());
  44. Object val = col.getRowValue(_row);
  45. return toValue(val, col.getType());
  46. }
  47. protected abstract TableImpl getTable();
  48. }