Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LongValue.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 LongValue extends BaseNumericValue
  21. {
  22. private final Integer _val;
  23. public LongValue(Integer val)
  24. {
  25. _val = val;
  26. }
  27. public Type getType() {
  28. return Type.LONG;
  29. }
  30. public Object get() {
  31. return _val;
  32. }
  33. @Override
  34. protected Number getNumber() {
  35. return _val;
  36. }
  37. @Override
  38. public boolean getAsBoolean(LocaleContext ctx) {
  39. return (_val.longValue() != 0L);
  40. }
  41. @Override
  42. public Integer getAsLongInt(LocaleContext ctx) {
  43. return _val;
  44. }
  45. @Override
  46. public BigDecimal getAsBigDecimal(LocaleContext ctx) {
  47. return BigDecimal.valueOf(_val);
  48. }
  49. @Override
  50. public String getAsString(LocaleContext ctx) {
  51. return _val.toString();
  52. }
  53. }