mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-22 20:13:58 +08:00
#10 make all token classes public and expose via a public structure member on pdf document
This commit is contained in:
@@ -1,24 +1,44 @@
|
||||
namespace UglyToad.PdfPig.Tokens
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Filters;
|
||||
using Util.JetBrains.Annotations;
|
||||
|
||||
internal class StreamToken : IDataToken<byte[]>
|
||||
/// <summary>
|
||||
/// A stream consists of a dictionary followed by zero or more bytes bracketed between the keywords stream and endstream.
|
||||
/// The bytes may be compressed by application of zero or more filters which are run in the order specified in the <see cref="StreamDictionary"/>.
|
||||
/// </summary>
|
||||
public class StreamToken : IDataToken<IReadOnlyList<byte>>
|
||||
{
|
||||
private readonly object lockObject = new object();
|
||||
|
||||
private byte[] decodedBytes;
|
||||
private IReadOnlyList<byte> decodedBytes;
|
||||
|
||||
/// <summary>
|
||||
/// The dictionary specifying the length of the stream, any applied compression filters and additional information.
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public DictionaryToken StreamDictionary { get; }
|
||||
|
||||
public byte[] Data { get; }
|
||||
/// <summary>
|
||||
/// The compressed byte data of the stream.
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public IReadOnlyList<byte> Data { get; }
|
||||
|
||||
public StreamToken(DictionaryToken streamDictionary, byte[] data)
|
||||
/// <summary>
|
||||
/// Create a new <see cref="StreamToken"/>.
|
||||
/// </summary>
|
||||
/// <param name="streamDictionary">The stream dictionary.</param>
|
||||
/// <param name="data">The stream data.</param>
|
||||
public StreamToken([NotNull] DictionaryToken streamDictionary, [NotNull] IReadOnlyList<byte> data)
|
||||
{
|
||||
StreamDictionary = streamDictionary;
|
||||
Data = data;
|
||||
StreamDictionary = streamDictionary ?? throw new ArgumentNullException(nameof(streamDictionary));
|
||||
Data = data ?? throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
public byte[] Decode(IFilterProvider filterProvider)
|
||||
internal IReadOnlyList<byte> Decode(IFilterProvider filterProvider)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
@@ -40,5 +60,11 @@
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Length: {Data.Count}, Dictionary: {StreamDictionary}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user