示例#1
0
        /// <summary>Reads and returns the header page (page 0) from the given pageChannel.</summary>
        /// <remarks>Reads and returns the header page (page 0) from the given pageChannel.</remarks>
        /// <exception cref="System.IO.IOException"></exception>
        protected internal static ByteBuffer ReadHeaderPage(PageChannel pageChannel)
        {
            ByteBuffer buffer = pageChannel.CreatePageBuffer();

            pageChannel.ReadPage(buffer, 0);
            return(buffer);
        }
        /// <summary>
        /// <inheritDoc></inheritDoc>
        /// <p>
        /// This implementation returns DUMMY_HANDLER for databases with no encoding
        /// and UNSUPPORTED_HANDLER for databases with any encoding.
        /// </summary>
        /// <exception cref="System.IO.IOException"></exception>
        public virtual CodecHandler CreateHandler(PageChannel channel, Encoding charset)
        {
            JetFormat format = channel.GetFormat();

            switch (format.CODEC_TYPE)
            {
            case JetFormat.CodecType.NONE:
            {
                // no encoding, all good
                return(DUMMY_HANDLER);
            }

            case JetFormat.CodecType.JET:
            {
                // check for an encode key.  if 0, not encoded
                ByteBuffer bb = channel.CreatePageBuffer();
                channel.ReadPage(bb, 0);
                int codecKey = bb.GetInt(format.OFFSET_ENCODING_KEY);
                return((codecKey == 0) ? DUMMY_HANDLER : UNSUPPORTED_HANDLER);
            }

            case JetFormat.CodecType.MSISAM:
            {
                // always encoded, we don't handle it
                return(UNSUPPORTED_HANDLER);
            }

            default:
            {
                throw new RuntimeException("Unknown codec type " + format.CODEC_TYPE);
            }
            }
        }
示例#3
0
        /// <param name="database">database that contains this usage map</param>
        /// <param name="pageNum">Page number that this usage map is contained in</param>
        /// <param name="rowNum">Number of the row on the page that contains this usage map</param>
        /// <returns>
        /// Either an InlineUsageMap or a ReferenceUsageMap, depending on
        /// which type of map is found
        /// </returns>
        /// <exception cref="System.IO.IOException"></exception>
        public static HealthMarketScience.Jackcess.UsageMap Read(Database database, int pageNum
                                                                 , int rowNum, bool assumeOutOfRangeBitsOn)
        {
            JetFormat   format      = database.GetFormat();
            PageChannel pageChannel = database.GetPageChannel();
            ByteBuffer  tableBuffer = pageChannel.CreatePageBuffer();

            pageChannel.ReadPage(tableBuffer, pageNum);
            short rowStart = Table.FindRowStart(tableBuffer, rowNum, format);
            int   rowEnd   = Table.FindRowEnd(tableBuffer, rowNum, format);

            tableBuffer.Limit(rowEnd);
            byte mapType = tableBuffer.Get(rowStart);

            HealthMarketScience.Jackcess.UsageMap rtn = new HealthMarketScience.Jackcess.UsageMap
                                                            (database, tableBuffer, pageNum, rowStart);
            rtn.InitHandler(mapType, assumeOutOfRangeBitsOn);
            return(rtn);
        }