#10 make all token classes public and expose via a public structure member on pdf document

This commit is contained in:
Eliot Jones
2018-11-24 19:02:06 +00:00
parent 8c0e8d5f26
commit 2fa781b8e9
49 changed files with 824 additions and 187 deletions

View File

@@ -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}";
}
}
}