Top Description Fields Constructors Methods
com.vladsch.flexmark.util.sequence.builder

public Class SequenceBuilder

extends Object
implements ISequenceBuilder<SequenceBuilder, BasedSequence>
Class Inheritance
All Implemented Interfaces
com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder, java.lang.Appendable
Imports
com.vladsch.flexmark.util.misc.CharPredicate, com.vladsch.flexmark.util.sequence.BasedSequence, .Range, .SegmentedSequence, .SequenceUtils, org.jetbrains.annotations.NotNull, .Nullable, java.util.HashMap

A Builder for Segmented BasedSequences

Field Summary

Modifier and TypeField and Description
private final @NotNull BasedSequence
private final @NotNull BasedSequence
private final @NotNull HashMap<BasedSequence, Boolean>
private @Nullable BasedSequence
private final BasedSegmentBuilder

Constructor Summary

AccessConstructor and Description
private
SequenceBuilder(@NotNull BasedSequence
base sequence for which to create a builder
base
,
@Nullable SegmentOptimizer
optimizer for based segment builder, or default CharRecoveryOptimizer
optimizer
)

Construct a base sequence builder for given base sequence with default options.

private
private
SequenceBuilder(@NotNull BasedSequence
base sequence for which to create a builder
base
,
int
builder options
options
,
@Nullable SegmentOptimizer
optimizer for based segment builder, or default CharRecoveryOptimizer
optimizer
,
@NotNull HashMap<BasedSequence, Boolean> equivalentBases)

Construct a base sequence builder for given base sequence with specific options.

Method Summary

Modifier and TypeMethod and Description
public @NotNull SequenceBuilder
addByLength(int startOffset, int textLength)

public @NotNull SequenceBuilder
addByOffsets(int startOffset, int endOffset)

public @NotNull SequenceBuilder
public @NotNull SequenceBuilder
append(@Nullable CharSequence
The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
chars
,
int
The index of the first character in the subsequence
startIndex
,
int
The index of the character following the last character in the subsequence
endIndex
)

Implements java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this Appendable.

public @NotNull SequenceBuilder
append(char
The character to append
c
)

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.append.

Appends the specified character to this Appendable.

public @NotNull SequenceBuilder
public @NotNull SequenceBuilder
append(int startOffset, int endOffset)

public @NotNull SequenceBuilder
public char
public static @NotNull SequenceBuilder
public static @NotNull SequenceBuilder
public static @NotNull SequenceBuilder
emptyBuilder(@NotNull BasedSequence base, int options)

public static @NotNull SequenceBuilder
public @NotNull BasedSequence
public @NotNull SequenceBuilder
public @Nullable Range
public @NotNull BasedSegmentBuilder
public @Nullable BasedSequence
pack-priv boolean
public int
public @NotNull BasedSequence
public @NotNull BasedSequence

Returns:

builder with offsets mapped to altSequence
toSequence
(@NotNull BasedSequence
based sequence which is character identical to this builder's baseSeq
altSequence
)

Construct sequence from this builder using another based sequence which is character identical to this builder's baseSeq

public @NotNull BasedSequence

Returns:

builder with offsets mapped to altSequence
toSequence
(@NotNull BasedSequence
based sequence which is character identical to this builder's baseSeq
altSequence
,
@Nullable CharPredicate
character set of characters to trim
trimStart
,
@Nullable CharPredicate
chars which should be treated as equivalent for verification purposes (Space, Tab, EOL, usually)
ignoreCharDiff
)

Construct sequence from this builder using another based sequence which is character identical to this builder's baseSeq

public @NotNull BasedSequence

Returns:

builder with offsets mapped to altSequence
toSequenceByIndex
(@NotNull BasedSequence
based sequence which is character identical to this builder's baseSeq
altSequence
,
@Nullable CharPredicate
character set of characters to trim
trimStart
,
@Nullable CharPredicate
chars which should be treated as equivalent for verification purposes (Space, Tab, EOL, usually)
ignoreCharDiff
)

Construct sequence from this builder using another based sequence which is character identical to this builder's baseSeq by length

public @NotNull String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public @NotNull String
public @NotNull String
public @NotNull String
toStringWithRanges(boolean toVisibleWhiteSpace)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

altBaseback to summary
private final @NotNull BasedSequence altBase
Annotations
@NotNull
baseSeqback to summary
private final @NotNull BasedSequence baseSeq
Annotations
@NotNull
equivalentBasesback to summary
private final @NotNull HashMap<BasedSequence, Boolean> equivalentBases
Annotations
@NotNull
resultSeqback to summary
private @Nullable BasedSequence resultSeq
Annotations
@Nullable
segmentsback to summary
private final BasedSegmentBuilder segments

Constructor Detail

SequenceBuilderback to summary
private SequenceBuilder(@NotNull BasedSequence base, @Nullable SegmentOptimizer optimizer)

Construct a base sequence builder for given base sequence with default options.

Note

the builder is always constructed for the base sequence of the base. ie. for the based sequence returned by BasedSequence#getBaseSequence(), so any subsequence from a base can be used as argument for the constructor

Parameters
base:@NotNull BasedSequence

base sequence for which to create a builder

optimizer:@Nullable SegmentOptimizer

optimizer for based segment builder, or default CharRecoveryOptimizer

SequenceBuilderback to summary
private SequenceBuilder(@NotNull BasedSequence base, @Nullable SegmentOptimizer optimizer, @NotNull HashMap<BasedSequence, Boolean> equivalentBases)
SequenceBuilderback to summary
private SequenceBuilder(@NotNull BasedSequence base, int options, @Nullable SegmentOptimizer optimizer, @NotNull HashMap<BasedSequence, Boolean> equivalentBases)

Construct a base sequence builder for given base sequence with specific options.

Note

the builder is always constructed for the base sequence of the base. ie. for the based sequence returned by BasedSequence#getBaseSequence(), so any subsequence from a base can be used as argument for the constructor

Parameters
base:@NotNull BasedSequence

base sequence for which to create a builder

options:int

builder options

optimizer:@Nullable SegmentOptimizer

optimizer for based segment builder, or default CharRecoveryOptimizer

Method Detail

addByLengthback to summary
public @NotNull SequenceBuilder addByLength(int startOffset, int textLength)
Annotations
@NotNull
addByOffsetsback to summary
public @NotNull SequenceBuilder addByOffsets(int startOffset, int endOffset)
Annotations
@NotNull
addRangeback to summary
public @NotNull SequenceBuilder addRange(@NotNull Range range)
Annotations
@NotNull
appendback to summary
public @NotNull SequenceBuilder append(@Nullable CharSequence chars, int startIndex, int endIndex)

Implements java.lang.Appendable.append.

Doc from java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this Appendable.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

    out.append(csq.subSequence(start, end)) 

The contents of this Appendable are unspecified if the CharSequence is modified during the method call or an exception is thrown when accessing the CharSequence.

Parameters
chars:@Nullable CharSequence

The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".

startIndex:int

The index of the first character in the subsequence

endIndex:int

The index of the character following the last character in the subsequence

Returns:@NotNull SequenceBuilder

A reference to this Appendable

Annotations
@NotNull
@Override
appendback to summary
public @NotNull SequenceBuilder append(char c)

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.append.

Doc from java.lang.Appendable.append.

Appends the specified character to this Appendable.

Parameters
c:char

The character to append

Returns:@NotNull SequenceBuilder

A reference to this Appendable

Annotations
@NotNull
appendback to summary
public @NotNull SequenceBuilder append(char c, int count)

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.append.

Annotations
@NotNull
appendback to summary
public @NotNull SequenceBuilder append(int startOffset, int endOffset)
Annotations
@NotNull
appendback to summary
public @NotNull SequenceBuilder append(@NotNull Range chars)
Annotations
@NotNull
charAtback to summary
public char charAt(int index)

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.charAt.

Annotations
@Override
emptyBuilderback to summary
public static @NotNull SequenceBuilder emptyBuilder(@NotNull BasedSequence base)
Annotations
@NotNull
emptyBuilderback to summary
public static @NotNull SequenceBuilder emptyBuilder(@NotNull BasedSequence base, @NotNull SegmentOptimizer optimizer)
Annotations
@NotNull
emptyBuilderback to summary
public static @NotNull SequenceBuilder emptyBuilder(@NotNull BasedSequence base, int options)
Annotations
@NotNull
emptyBuilderback to summary
public static @NotNull SequenceBuilder emptyBuilder(@NotNull BasedSequence base, int options, @NotNull SegmentOptimizer optimizer)
Annotations
@NotNull
getBaseSequenceback to summary
public @NotNull BasedSequence getBaseSequence()
Annotations
@NotNull
getBuilderback to summary
public @NotNull SequenceBuilder getBuilder()

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.getBuilder.

Annotations
@NotNull
@Override
getLastRangeOrNullback to summary
public @Nullable Range getLastRangeOrNull()
Annotations
@Nullable
getSegmentBuilderback to summary
public @NotNull BasedSegmentBuilder getSegmentBuilder()
Annotations
@NotNull
getSingleBasedSequenceback to summary
public @Nullable BasedSequence getSingleBasedSequence()

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.getSingleBasedSequence.

Doc from com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.getSingleBasedSequence.

Note

returns non-null value if the underlying IBasedSegmentBuilder#getBaseSubSequenceRange() returns non-null value

Returns:@Nullable BasedSequence

sub-sequence of base representing the single segment or null if sequence not representable by a single subsequence

Annotations
@Nullable
@Override
isCommonBaseSequenceback to summary
pack-priv boolean isCommonBaseSequence(@NotNull BasedSequence chars)
lengthback to summary
public int length()

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.length.

Annotations
@Override
toSequenceback to summary
public @NotNull BasedSequence toSequence()

Implements com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder.toSequence.

Annotations
@NotNull
@Override
toSequenceback to summary
public @NotNull BasedSequence toSequence(@NotNull BasedSequence altSequence)

Construct sequence from this builder using another based sequence which is character identical to this builder's baseSeq

Parameters
altSequence:@NotNull BasedSequence

based sequence which is character identical to this builder's baseSeq

Returns:@NotNull BasedSequence

builder with offsets mapped to altSequence

Annotations
@NotNull
toSequenceback to summary
public @NotNull BasedSequence toSequence(@NotNull BasedSequence altSequence, @Nullable CharPredicate trimStart, @Nullable CharPredicate ignoreCharDiff)

Construct sequence from this builder using another based sequence which is character identical to this builder's baseSeq

Parameters
altSequence:@NotNull BasedSequence

based sequence which is character identical to this builder's baseSeq

trimStart:@Nullable CharPredicate

character set of characters to trim

ignoreCharDiff:@Nullable CharPredicate

chars which should be treated as equivalent for verification purposes (Space, Tab, EOL, usually)

Returns:@NotNull BasedSequence

builder with offsets mapped to altSequence

Annotations
@NotNull
toSequenceByIndexback to summary
public @NotNull BasedSequence toSequenceByIndex(@NotNull BasedSequence altSequence, @Nullable CharPredicate trimStart, @Nullable CharPredicate ignoreCharDiff)

Construct sequence from this builder using another based sequence which is character identical to this builder's baseSeq by length

Parameters
altSequence:@NotNull BasedSequence

based sequence which is character identical to this builder's baseSeq

trimStart:@Nullable CharPredicate

character set of characters to trim

ignoreCharDiff:@Nullable CharPredicate

chars which should be treated as equivalent for verification purposes (Space, Tab, EOL, usually)

Returns:@NotNull BasedSequence

builder with offsets mapped to altSequence

Annotations
@NotNull
toStringback to summary
public @NotNull String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:@NotNull String

a string representation of the object

Annotations
@NotNull
toStringNoAddedSpacesback to summary
public @NotNull String toStringNoAddedSpaces()
Annotations
@NotNull
toStringWithRangesback to summary
public @NotNull String toStringWithRanges()
Annotations
@NotNull
toStringWithRangesback to summary
public @NotNull String toStringWithRanges(boolean toVisibleWhiteSpace)
Annotations
@NotNull