Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

BigDecimalValue.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright (c) 2016 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.expr;
  14. import java.math.BigDecimal;
  15. import com.healthmarketscience.jackcess.expr.LocaleContext;
  16. /**
  17. *
  18. * @author James Ahlborn
  19. */
  20. public class BigDecimalValue extends BaseNumericValue
  21. {
  22. private final BigDecimal _val;
  23. public BigDecimalValue(BigDecimal val)
  24. {
  25. _val = val;
  26. }
  27. @Override
  28. public Type getType() {
  29. return Type.BIG_DEC;
  30. }
  31. @Override
  32. public Object get() {
  33. return _val;
  34. }
  35. @Override
  36. protected Number getNumber() {
  37. return _val;
  38. }
  39. @Override
  40. public boolean getAsBoolean(LocaleContext ctx) {
  41. return (_val.compareTo(BigDecimal.ZERO) != 0L);
  42. }
  43. @Override
  44. public String getAsString(LocaleContext ctx) {
  45. return NumberFormatter.format(_val);
  46. }
  47. @Override
  48. public BigDecimal getAsBigDecimal(LocaleContext ctx) {
  49. return _val;
  50. }
  51. }