You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComplexColumnImpl.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. Copyright (c) 2014 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 java.io.IOException;
  15. import com.healthmarketscience.jackcess.PropertyMap;
  16. import com.healthmarketscience.jackcess.complex.ComplexColumnInfo;
  17. import com.healthmarketscience.jackcess.complex.ComplexDataType;
  18. import com.healthmarketscience.jackcess.complex.ComplexValue;
  19. import com.healthmarketscience.jackcess.impl.complex.ComplexColumnInfoImpl;
  20. import com.healthmarketscience.jackcess.impl.complex.MultiValueColumnInfoImpl;
  21. import com.healthmarketscience.jackcess.impl.complex.MultiValueColumnPropertyMap;
  22. /**
  23. * ColumnImpl subclass which is used for complex data types.
  24. *
  25. * @author James Ahlborn
  26. * @usage _advanced_class_
  27. */
  28. class ComplexColumnImpl extends ColumnImpl
  29. {
  30. /** additional information specific to complex columns */
  31. private final ComplexColumnInfo<? extends ComplexValue> _complexInfo;
  32. /** properties for multi-value column */
  33. private PropertyMap _mvProps;
  34. ComplexColumnImpl(InitArgs args) throws IOException
  35. {
  36. super(args);
  37. _complexInfo = ComplexColumnSupport.create(this, args.buffer, args.offset);
  38. }
  39. @Override
  40. void postTableLoadInit() throws IOException {
  41. if(_complexInfo != null) {
  42. ((ComplexColumnInfoImpl<? extends ComplexValue>)_complexInfo)
  43. .postTableLoadInit();
  44. }
  45. super.postTableLoadInit();
  46. }
  47. @Override
  48. public PropertyMap getProperties() throws IOException {
  49. if(_complexInfo.getType() == ComplexDataType.MULTI_VALUE) {
  50. if(_mvProps == null) {
  51. PropertyMap primaryProps = super.getProperties();
  52. PropertyMap complexProps = ((MultiValueColumnInfoImpl)_complexInfo)
  53. .getValueColumn().getProperties();
  54. _mvProps = new MultiValueColumnPropertyMap(primaryProps, complexProps);
  55. }
  56. return _mvProps;
  57. }
  58. return super.getProperties();
  59. }
  60. @Override
  61. public ComplexColumnInfo<? extends ComplexValue> getComplexInfo() {
  62. return _complexInfo;
  63. }
  64. }