View Javadoc
1   /*
2   Copyright (c) 2014 James Ahlborn
3   
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7   
8       http://www.apache.org/licenses/LICENSE-2.0
9   
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16  
17  package com.healthmarketscience.jackcess.impl;
18  
19  
20  /**
21   * ColumnImpl subclass which is used for Memo data types.
22   *
23   * @author James Ahlborn
24   * @usage _advanced_class_
25   */
26  class MemoColumnImpl extends LongValueColumnImpl
27  {
28    /** whether or not they are compressed */
29    private final boolean _compressedUnicode;
30    /** the collating sort order for a text field */
31    private final SortOrder _sortOrder;
32    /** the code page for a text field (for certain db versions) */
33    private final short _codePage;
34    /** complex column which tracks the version history for this "append only"
35        column */
36    private ColumnImpl _versionHistoryCol;
37    /** whether or not this is a hyperlink column (only possible for columns
38        of type MEMO) */
39    private final boolean _hyperlink;
40  
41    MemoColumnImpl(InitArgs args)
42    {
43      super(args);
44  
45        // co-located w/ precision/scale
46        _sortOrder = readSortOrder(
47            args.buffer, args.offset + getFormat().OFFSET_COLUMN_SORT_ORDER,
48            getFormat());
49        _codePage = readCodePage(args.buffer, args.offset, getFormat());
50  
51        _compressedUnicode =
52          ((args.extFlags & COMPRESSED_UNICODE_EXT_FLAG_MASK) != 0);
53  
54        // only memo fields can be hyperlinks
55        _hyperlink = ((args.flags & HYPERLINK_FLAG_MASK) != 0);
56    }
57  
58    @Override
59    public boolean isCompressedUnicode() {
60      return _compressedUnicode;
61    }
62  
63    @Override
64    public short getTextCodePage() {
65      return _codePage;
66    }
67  
68    @Override
69    public SortOrder getTextSortOrder() {
70      return _sortOrder;
71    }
72  
73    @Override
74    public ColumnImpl getVersionHistoryColumn() {
75      return _versionHistoryCol;
76    }
77  
78    @Override
79    public void setVersionHistoryColumn(ColumnImpl versionHistoryCol) {
80      _versionHistoryCol = versionHistoryCol;
81    }
82  
83    @Override
84    public boolean isHyperlink() {
85      return _hyperlink;
86    }
87  }