#10 some tidying for a couple of tokens

This commit is contained in:
Eliot Jones
2018-11-16 20:08:00 +00:00
parent 0f68dfeb19
commit 946ad1aec6
2 changed files with 60 additions and 1 deletions

View File

@@ -1,16 +1,61 @@
namespace UglyToad.PdfPig.Tokens
{
using Util.JetBrains.Annotations;
/// <summary>
/// The boolean object either <see cref="True"/> (<see langword="true"/>) or <see cref="False"/> (<see langword="true"/>).
/// </summary>
internal class BooleanToken : IDataToken<bool>
{
/// <summary>
/// The boolean token corresponding to <see langword="true"/>.
/// </summary>
[NotNull]
public static BooleanToken True { get; } = new BooleanToken(true);
/// <summary>
/// The boolean token corresponding to <see langword="false"/>
/// </summary>
[NotNull]
public static BooleanToken False { get; } = new BooleanToken(false);
/// <summary>
/// The value true/false of this boolean token.
/// </summary>
public bool Data { get; }
/// <summary>
/// Create a new <see cref="BooleanToken"/>.
/// </summary>
/// <param name="data">The value of the boolean.</param>
private BooleanToken(bool data)
{
Data = data;
}
public override bool Equals(object obj)
{
if (!(obj is BooleanToken other))
{
return false;
}
return other.Data == Data;
}
protected bool Equals(BooleanToken other)
{
return Data == other.Data;
}
public override int GetHashCode()
{
return Data.GetHashCode();
}
public override string ToString()
{
return Data.ToString();
}
}
}

View File

@@ -1,10 +1,24 @@
namespace UglyToad.PdfPig.Tokens
{
using Util.JetBrains.Annotations;
/// <summary>
/// A comment from a PDF document. Any occurrence of the percent sign character (%) outside a string or stream
/// introduces a comment. The comment consists of all characters between the percent sign and the end of the line.
/// </summary>
internal class CommentToken : IDataToken<string>
{
/// <summary>
/// The text of the comment (excluding the initial percent '%' sign).
/// </summary>
[CanBeNull]
public string Data { get; }
public CommentToken(string data)
/// <summary>
/// Create a new <see cref="CommentToken"/>.
/// </summary>
/// <param name="data">The text of the comment.</param>
public CommentToken([CanBeNull]string data)
{
Data = data;
}