SpanBuf (クラス)
public SpanBuf {inherits SpanBufChild, TextOutputStream}
パッケージ: CURL.IDE.CPA.BASE
直接継承しているサブクラス: CPASpanBuf

Span buffer

説明

An alternative to StringBuf optimized for normal text edit operations: insertions and deletions that occur mostly near each other.

In addition to fast insertion and deletion, this class also supports recursive partitioning of the buffer into child SpanBuf objects, which share the same character memory.

Operations that overwrite characters are implemented using insertion and deletion and are therefore more expensive than in a regular StringBuf. These include the following:



This data structure is also sometimes referred to as a "piece table".

オーバーライド

Subclasses should provide the following constructors and overridden methods:



Most other methods are not overridable.

Here is a minimal example:

{define-class public MySpanBuf {inherits SpanBuf}
  {constructor public {default
                          efficient-size:int = 0,
                          url:#Url = null,
                          ...:any
                      }
    {construct-super.default
        efficient-size = efficient-size,
        url = url,
        ...
    }
  }
  
  {constructor protected {clone-from
                             other:MySpanBuf,
                             state:#SpanBufState = null
                         }
    {construct-super.clone-from other, state = state}
  }
  
  {method public {clone}:MySpanBuf
    {return {MySpanBuf.clone-from self}}
  }
  
  {method protected {clone-with-state state:SpanBufState}:MySpanBuf
    {return {MySpanBuf.clone-from self, state = state}}
  }
  
  {constructor protected {construct-child parent:SpanBuf}
    {construct-super.construct-child parent}
  }
  
  {method protected {create-child
                        prev:#SpanBuf, next:#SpanBuf
                    }:MySpanBuf
    {return {MySpanBuf.construct-child self}}
  }
}

コンストラクタ
clone-from:Constructs a clone of another SpanBuf.
コンストラクタ protected {SpanBuf.clone-from
other:SpanBuf,
state:#SpanBufState = null
}
construct-child:Construct a SpanBuf as a child of another.
コンストラクタ protected {SpanBuf.construct-child parent:SpanBuf}
default:Construct a new root SpanBuf.
コンストラクタ public {SpanBuf.default
efficient-size:int = 0,
url:#Url = null,
line:int = 1,
column:int = 0,
...:any
}

プロパティ
appendable?:Specifies whether parent span can append to this span.
フィールド public SpanBuf.appendable?:bool
attributes-observed?:Indicates whether attribute changes are observed.
アクセサ public final inline SpanBuf.attributes-observed?:bool
auto-consolidate-threshold:Threshold for automatic consolidation
アクセサ public final inline SpanBuf.auto-consolidate-threshold:double
セッター public final inline SpanBuf.auto-consolidate-threshold:double
change-counter:Tracks changes to the buffer
フィールド public-get private-set SpanBuf.change-counter:uint
childless?:Indicates whether buffer has children
アクセサ public final inline SpanBuf.childless?:bool
defer-notification?:Whether to defer notification of observers.
アクセサ public SpanBuf.defer-notification?:bool
セッター public SpanBuf.defer-notification?:bool
directly-mutable?:Indicates whether buffer can be mutated by direct call.
フィールド public SpanBuf.directly-mutable?:bool
efficient-size:selfefficient-size を取得または設定します。
アクセサ public final SpanBuf.efficient-size:int
セッター public final SpanBuf.efficient-size:int
first-child:First child buffer
アクセサ public final inline SpanBuf.first-child:#SpanBuf
last-child:Last child buffer
アクセサ public final inline SpanBuf.last-child:#SpanBuf
next:Next sibling subbuffer.
アクセサ public final SpanBuf.next:#SpanBuf
non-blocking-supported?:特定のインスタンスまたはサブクラスが non-blocking? フラグをサポートし、InputStream-of.read または OutputStream-of.write のようなメソッドで使用できるかどうかを示します。
アクセサ public final SpanBuf.non-blocking-supported?:bool
observed?:Indicate whether buffer has any observers.
アクセサ public final inline SpanBuf.observed?:bool
observers:A linked list of observers of this buffer.
フィールド public-get private-set SpanBuf.observers:#SpanBufObserverLink
open?:Indiciate if stream is open.
アクセサ public final SpanBuf.open?:bool
origin-url:URL associated with buffer.
アクセサ public final SpanBuf.origin-url:#Url
orphaned?:Whether this buffer was deleted from its parent.
フィールド public SpanBuf.orphaned?:bool
prependable?:Specifies whether parent span can prepend to this span.
フィールド public SpanBuf.prependable?:bool
prev:Previous sibling subbuffer.
アクセサ public final SpanBuf.prev:#SpanBuf
root:Root SpanBuf for this buffer.
アクセサ public final inline SpanBuf.root:SpanBuf
root-digest:SHA-1-Digest of root contents.
アクセサ public final SpanBuf.root-digest:SHA-1-Digest
セッター public final SpanBuf.root-digest:SHA-1-Digest
shared-state:State shared by root buffer and its subbuffers
アクセサ protected inline SpanBuf.shared-state:any
セッター protected inline SpanBuf.shared-state:any
size:self 内の文字数。
アクセサ public final inline SpanBuf.size:int
セッター public final SpanBuf.size:int
url:URL associated with buffer.
アクセサ public inline SpanBuf.url:#Url
セッター public inline SpanBuf.url:#Url
write-buffer-data-size:バッファ内のフラッシュされていないデータ量を示します。
アクセサ public final SpanBuf.write-buffer-data-size:int
write-buffer-size:最大バッファ サイズを示します。
アクセサ public final SpanBuf.write-buffer-size:int
プロパティ 継承 SpanBufChild: parent
プロパティ 継承 TextOutputStream: character-encoding
プロパティ 継承 BufferedOutputStream-of: write-buffer-full?
プロパティ 継承 StringInterface: empty?, for-loop-count

メソッド
add-observer:Add an observer for this buffer.
public {SpanBuf.add-observer observer:SpanBufObserver}:void
clear:self をクリアします。
public final {SpanBuf.clear}:void
clear-observers:Remove all observers from this buffer.
public {SpanBuf.clear-observers}:void
clone:Returns a deep clone of this buffer.
public {SpanBuf.clone}:SpanBuf
clone-with-state:Internal method for cloning SpanBuf.
protected {SpanBuf.clone-with-state state:SpanBufState}:SpanBuf
close:Close output stream
public final {SpanBuf.close}:void
concat:StringInterfaceself に連結します。
public final {SpanBuf.concat str:StringInterface}:void
consolidate:Consolidates memory used by buffer.
public final {SpanBuf.consolidate}:void
create-child:Return a new child SpanBuf.
protected {SpanBuf.create-child prev:#SpanBuf, next:#SpanBuf}:SpanBuf
dynamic-substr:Returns substring that reflects changes in the underlying buffer.
public {SpanBuf.dynamic-substr start:int, length:int}:SafeSubString
flush:Flush output stream.
public final {SpanBuf.flush
non-blocking?:bool = false,
allow-short-write?:bool = false
}:void
get:self 内の指定された文字を返します。
public final inline {SpanBuf.get i:int}:char
get-attributes-in-range:Returns an array describing the attributes in a given range.
public {SpanBuf.get-attributes-in-range
offset:int,
length:int = 1,
out:#SpanBufAttributesArray = null
}:SpanBufAttributesArray
get-buffer-containing:Find subbuffer containing given range.
public {SpanBuf.get-buffer-containing
offset:int,
length:int = 1,
max-depth:int = max-int
}:(SpanBuf, offset-in-buf:int)
get-column:Compute the column of given location in the buffer.
public final inline {SpanBuf.get-column offset:int}:int
get-line:Reads line of text with same attributes starting at offset.
public final {SpanBuf.get-line
offset:int,
out:StringBuf = {StringBuf}
}:(uint8, StringBuf)
get-next-attribute:Find next offset at which attribute changes.
public final {SpanBuf.get-next-attribute
offset:int,
attr:uint8,
end:int = self.size,
mask:uint8 = 0xff
}:(new-offset:int, new-attr:uint8)
get-with-attributes:Gets character and associated attributes at given offset.
public final {SpanBuf.get-with-attributes i:int}:(char, uint8)
handle-transfer-to:Allows subclasses to respond to merge/split operations.
protected {SpanBuf.handle-transfer-to
other:#SpanBuf,
from-offset:int,
to-offset:int
}:void
insert:文字を self に挿入します。
public final {SpanBuf.insert c:char, i:int}:void
line-column-to-location:Converts line and column to buffer offset.
public {SpanBuf.line-column-to-location line:int, column:int}:int
location-to-line-column:Converts offset to line and column.
public {SpanBuf.location-to-line-column offset:int}:(int, int)
merge-with-next:Merges next buffer into this one.
public {SpanBuf.merge-with-next}:void
object-describe:ユーザーが印刷するのに適した方法でオブジェクトを記述します。
public {SpanBuf.object-describe}:void
object-describe-for-debugging:オブジェクトについて細部を記述します。これは主にデバッグ目的での使用が想定されています。
public {SpanBuf.object-describe-for-debugging}:void
observed-by?:Indicate whether observer is attached to this buffer.
public final {SpanBuf.observed-by? observer:SpanBufObserver}:bool
partition-at:Partition buffer into subbuffers
public {SpanBuf.partition-at offset:int}:SpanBuf
remove:指定された文字を self から削除します。
public final {SpanBuf.remove
i:int,
length:int = 1,
error-if-missing?:bool = true
}:void
remove-observer:Remove observer from this buffer.
public {SpanBuf.remove-observer observer:SpanBufObserver}:void
remove-partitions:Merges all subbuffers into one.
public final {SpanBuf.remove-partitions}:void
replace:old の各オカレンスを new に置換します。
public final {SpanBuf.replace
old:StringInterface,
new:StringInterface,
starting-index:int = 0
}:void
set:self 内の文字を置換します。
public final {SpanBuf.set i:int, c:char}:void
set-attributes:Sets attributes value for specified character range.
public final {SpanBuf.set-attributes
attributes:uint8,
mask:uint8 = 0,
start:int = 0,
end:int = self.size
}:void
set-contents:self の内容を別の文字列の内容に置換します。
public final {SpanBuf.set-contents str:StringInterface}:void
set-root-line-column:Set the starting line and column of the root buffer.
public final {SpanBuf.set-root-line-column line:int, column:int}:void
splice:StringInterfaceself に挿入します。
public final {SpanBuf.splice str:StringInterface, i:int}:void
split-at:Splits buffer at offset
public {SpanBuf.split-at offset:int}:SpanBuf
to-source-location:Produces a source location for given subrange of buffer.
public {SpanBuf.to-source-location
start:int = 0,
end:int = max-int
}:CPABaseSourceLocation
to-String:self と同一 (==) の String を作成します。
public final {SpanBuf.to-String}:String
write-one:Writes character to output stream.
public final {SpanBuf.write-one c:char}:void
write-one-string:Writes a string of characters to output stream.
public final {SpanBuf.write-one-string
str:StringInterface,
start:int = 0,
length:int = str.size - start
}:int
メソッド 継承 SpanBufChild: get-line-column, get-offset-in-parent, get-root-offset
メソッド 継承 WritableString: append, reverse, to-lower, to-upper, trim, trim-left, trim-right
メソッド 継承 OutputStream-of: async-write, write
メソッド 継承 StringInterface: compare, equal?, find, find-char-class, find-string, prefix?, replace-clone, split, substr, suffix?, tail, to-double, to-InputStream, to-int, to-int64, to-lower-clone, to-upper-clone, trim-clone, trim-left-clone, trim-right-clone
メソッド 継承 Stream-of: verify-open
メソッド 継承 Object: object-serialize



コンストラクタ詳細
clone-from (コンストラクタ)
protected {SpanBuf.clone-from
other:SpanBuf,
state:#SpanBufState = null
}

Constructs a clone of another SpanBuf.

プログラミング注意事項

This should not be invoked directly.

オーバーライド

Subclasses should implement a similar constructor that invokes this one and which will be used by the subclass's version of clone-with-state.

See SpanBuf for an example.


construct-child (コンストラクタ)
protected {SpanBuf.construct-child parent:SpanBuf}

Construct a SpanBuf as a child of another.

オーバーライド

Subclasses should implement a similar constructor which invokes this one. This is only intended for use in implementing the SpanBuf.create-child method.

See SpanBuf for an example.


default (コンストラクタ)
public {SpanBuf.default
efficient-size:int = 0,
url:#Url = null,
line:int = 1,
column:int = 0,
...:any
}

Construct a new root SpanBuf.

url: is assigned to the corresponding url attribute.
...: arguments are converted to strings and concatenated to the buffer.

説明

The line and column arguments specify the line and column number associated with the first character in the buffer. This is used by location-to-line-column and line-column-to-location. These may be changed by set-root-line-column.



プロパティ詳細
appendable? (フィールド)
public SpanBuf.appendable?:bool

Specifies whether parent span can append to this span.

説明

When true, an insertion in the parent span corresponding to the end of this span can be appended to this span. Otherwise, the parent must prepend to the following span or create a new intermediate span. Note that this only applies to insertions through the parent, not those made directly on this object.


attributes-observed? (アクセサ)
アクセサ public final inline SpanBuf.attributes-observed?:bool

Indicates whether attribute changes are observed.

説明

Indicates whether observes-attributes? is true for at least one member of observers.


auto-consolidate-threshold (アクセサ)
アクセサ public final inline SpanBuf.auto-consolidate-threshold:double
セッター public final inline SpanBuf.auto-consolidate-threshold:double

Threshold for automatic consolidation

説明

A number between 0 and 1 specifying the lower limit of the the percentage of memory that would remain after a a consolidate operation, for consolidation to be done automatically when more memory is needed.

This may not be set above 95%. Default value is 70%.


change-counter (フィールド)
public-get private-set SpanBuf.change-counter:uint

Tracks changes to the buffer

説明

This value is initially set to 0 and will increase (not necessarily by one) every time a change is made to the buffer or any subbuffer contained in it. Only changes to the character contents of the buffer will increment the change counter. Adding or removing partitions should not affect the counter.


childless? (アクセサ)
アクセサ public final inline SpanBuf.childless?:bool

Indicates whether buffer has children

説明

When true, the buffer has not been partitioned into child buffers and first-child and last-child will be null.


defer-notification? (アクセサ)
アクセサ public SpanBuf.defer-notification?:bool
セッター public SpanBuf.defer-notification?:bool

Whether to defer notification of observers.

説明

While true, observers will not be notified of changes. Setting this to false will dispatch any pending notifications.


directly-mutable? (フィールド)
public SpanBuf.directly-mutable?:bool

Indicates whether buffer can be mutated by direct call.

説明

If this is false, then directly calling a method that mutates characters (.e.g, remove or splice) will throw an error. Operations that modify how the buffer is partitioned into subsidiary buffers are not affected by this setting. The contents of the buffer may still be changed through a parent buffer that is directly mutable.

By default the root SpanBuf is directly mutable, but its children are not.


efficient-size (アクセサ)
アクセサ public final SpanBuf.efficient-size:int
セッター public final SpanBuf.efficient-size:int

selfefficient-size を取得または設定します。

説明

efficient-size は、WritableString またはサブクラスを拡張可能であり、かつ処理効率を維持できる上限サイズです。このアクセッサは実装ごとに定義されますが、一般に下位のデータ構造のサイズを反映します。割り当てサイズを超えて拡張する場合、下位のデータ構造を新しく割り当て、古いデータ構造からデータをコピーする必要があります。ただし、この処理は 非効率 であると見なされます。
requested-size: requested-size はシステムによって評価され、場合によっては変更されます。変更後の efficient-size を取得するには、ゲッターを使います。変更後の efficient-size は必ず requested-size 以上の大きさになります。

注意事項

efficient-size アクセッサの既定の実装はセッターを無視します。また、ゲッターは、すべてのサイズ変更処理が同程度に効率的であることを示す max-int を返します。


first-child (アクセサ)
アクセサ public final inline SpanBuf.first-child:#SpanBuf

First child buffer

説明

If this buffer has been partitioned into subbuffers, this will refer to the first such buffer. Otherwise, this will be null.

Also see SpanBuf.partition-at.


last-child (アクセサ)
アクセサ public final inline SpanBuf.last-child:#SpanBuf

Last child buffer

説明

If this buffer has been partitioned into subbuffers, this will refer to the last such buffer. Otherwise, this will be null.

Also see SpanBuf.partition-at.


next (アクセサ)
アクセサ public final SpanBuf.next:#SpanBuf

Next sibling subbuffer.

説明

If this buffer is a subbuffer of another buffer, this will point to the sibling buffer immediately following this one.

This will be null if this is this is the last buffer within the parent buffer or if this buffer has no parent.


non-blocking-supported? (アクセサ)
アクセサ public final SpanBuf.non-blocking-supported?:bool

特定のインスタンスまたはサブクラスが non-blocking? フラグをサポートし、InputStream-of.read または OutputStream-of.write のようなメソッドで使用できるかどうかを示します。

注意事項

また、これにより、InputStream-of または OutputStream-of 内のメソッドの既定実装は、呼び出すメソッド InputStream-of.read-one または OutputStream-of.write-one がどんな場合でもブロックしないものと仮定します。それらのメソッドが特定のサブクラスでブロックできる場合は、Stream-of.non-blocking-supported?false のままでいるか、InputStream-of.read または OutputStream-of.write の既定実装をオーバーライドしてブロック不可サポートを提供するようにする必要があります。


observed? (アクセサ)
アクセサ public final inline SpanBuf.observed?:bool

Indicate whether buffer has any observers.

説明

Indicates whether there are any SpanBufObserver objects attached to this buffer.

True if observers list is non-empty.


observers (フィールド)
public-get private-set SpanBuf.observers:#SpanBufObserverLink

A linked list of observers of this buffer.

説明

Any observers in this list will recieve notifications for major buffer operations. See SpanBufObserver for details.

Also see:



open? (アクセサ)
アクセサ public final SpanBuf.open?:bool

Indiciate if stream is open.

説明

This is always true for this class.


origin-url (アクセサ)
アクセサ public final SpanBuf.origin-url:#Url

URL associated with buffer.

説明

This returns SpanBuf.url.


orphaned? (フィールド)
public SpanBuf.orphaned?:bool

Whether this buffer was deleted from its parent.

説明

This value defaults to false. It is automatically set to true when a buffer is cleared and deleted from its parent buffer as a result of operations such as clear, merge-with-next, remove and remove-partitions.


prependable? (フィールド)
public SpanBuf.prependable?:bool

Specifies whether parent span can prepend to this span.

説明

When true, an insertion in the parent span corresponding to the beginning of this span can be prepended to this span. Otherwise, the parent must append to the following span or create a new intermediate span. Note that this only applies to insertions through the parent, not those made directly on this object.


prev (アクセサ)
アクセサ public final SpanBuf.prev:#SpanBuf

Previous sibling subbuffer.

説明

If this buffer is a subbuffer of another buffer, this will point to the sibling buffer immediately preceding this one.

This will be null if this is this is the first buffer within the parent buffer or if this buffer has no parent.


root (アクセサ)
アクセサ public final inline SpanBuf.root:SpanBuf

Root SpanBuf for this buffer.

説明

Returns the topmost SpanBuf containing this buffer.


root-digest (アクセサ)
アクセサ public final SpanBuf.root-digest:SHA-1-Digest
セッター public final SpanBuf.root-digest:SHA-1-Digest

SHA-1-Digest of root contents.

説明

Returns an SHA-1 digest of the contents of the root buffer. The value is computed on demand and is cached until the buffer changes.

Note that setting the digest explicitly does not check to make sure that the digest actually matches the content.


shared-state (アクセサ)
アクセサ protected inline SpanBuf.shared-state:any
セッター protected inline SpanBuf.shared-state:any

State shared by root buffer and its subbuffers

説明

This holds state shared by the root buffer and all of its subsidiary buffers for use by subclasses. By default this is null. State is not copied by cloning operations but is retained when buffer is deleted.


size (アクセサ)
アクセサ public final inline SpanBuf.size:int
セッター public final SpanBuf.size:int

self 内の文字数。

戻り値

文字数を示す int 値。

説明

読み取り専用文字列の場合 書き込み可能文字列の場合 size をその文字列の現在のサイズよりも小さい値に設定した場合、その文字列は切り詰められます。size を現在のサイズよりも大きい値に設定した場合、差分の文字数がその文字列の末尾に追加されます。この場合、追加される文字の値は Unicode 値の 0000 になります。

次の例は、読み取り専用文字列に対して size を使用した場合です。


{value
    || Declare and initialize a read-only string
    let s:String = "Hello World!"

    || Output a message that includes the return value of
    || a call to "size".
    || Note that you must use "value" to display the value
    || of "s.size", rather than the text "s.size".
    {text There are {value s.size} characters in the string.}
}


次の例は、書き込み可能文字列に対して size を使用した場合です。


{value
    || Declare and initialize a writable string.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Set the size of the string to 5 characters.
    || The string should now contain only the first five
    || characters, "Hello".
    set sb.size = 5

    || Output a message that includes the new string
    {text If {monospace size} is set to 5, the string
        becomes: {value sb}}
}



{value
    || Declare and initialize a writable string.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Set the size of the string to 20 characters.
    || The string should now have 8 characters
    || with the Unicode value 0000 at the end.
    set sb.size = 20

    || Output a message that includes the new string.
    {text Then, if {monospace size} is set to 20, the string
        becomes: {value sb}}
}

注意事項

これは StringInterface の抽象ゲッターです。このゲッターは StringInterface のサブクラスによって実装されます。


url (アクセサ)
アクセサ public inline SpanBuf.url:#Url
セッター public inline SpanBuf.url:#Url

URL associated with buffer.

説明

This is returned by origin-url.

Typically this will be the URL of the file from which the buffers contents were read.


write-buffer-data-size (アクセサ)
アクセサ public final SpanBuf.write-buffer-data-size:int

バッファ内のフラッシュされていないデータ量を示します。



write-buffer-size (アクセサ)
アクセサ public final SpanBuf.write-buffer-size:int

最大バッファ サイズを示します。






メソッド詳細
add-observer (メソッド)
public {SpanBuf.add-observer observer:SpanBufObserver}:void

Add an observer for this buffer.

説明

Adds a SpanBufObserver for this buffer. Observer will be added to the end of the observers list.

Does nothing if observer is already attached to this buffer.


clear (メソッド)
public final {SpanBuf.clear}:void

self をクリアします。

説明

self の内容を空の文字列に置き換えます。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Clear the StringBuf.
    {sb.clear}

    || Check if the StringBuf is empty.
    {text The assertion that the string is empty
        is... {value sb.empty?}}
}


clear-observers (メソッド)
public {SpanBuf.clear-observers}:void

Remove all observers from this buffer.



clone (メソッド)
public {SpanBuf.clone}:SpanBuf

Returns a deep clone of this buffer.



clone-with-state (メソッド)
protected {SpanBuf.clone-with-state state:SpanBufState}:SpanBuf

Internal method for cloning SpanBuf.

プログラミング注意事項

This method should not be invoked directly.

説明

This should be overridden by subclasses to return a clone of this object using the subclass's version of SpanBuf.clone-from with the provided state value.

See SpanBuf for an example.


close (メソッド)
public final {SpanBuf.close}:void

Close output stream

説明

This does nothing in this class.


concat (メソッド)
public final {SpanBuf.concat str:StringInterface}:void

StringInterfaceself に連結します。

str: StringInterface を連結する文字。このオブジェクトのデータ型は self と同じでなければなりません。

説明

strself の末尾に追加します。


{value
    || Declare and initialize two StringBufs.
    let sb1:StringBuf = {StringBuf "Hello World!"}
    let sb2:StringBuf = {StringBuf " Can you hear me?"}

    || Concatenate "sb2" onto "sb1".
    {sb1.concat sb2}

    || Display the resulting StringBuf.
    {value sb1}
}


consolidate (メソッド)
public final {SpanBuf.consolidate}:void

Consolidates memory used by buffer.

説明

This reclaims unused memory allocated by the buffer. It does not otherwise affect the state of the buffer.


create-child (メソッド)
protected {SpanBuf.create-child prev:#SpanBuf, next:#SpanBuf}:SpanBuf

Return a new child SpanBuf.

プログラミング注意事項

This method should not be invoked directly.

オーバーライド

Subclasses should implement this method to return a new instance constructed using the subclass's version of SpanBuf.construct-child. The overridden version should not be public.

The prev and next arguments are the sibling buffers that will be before and after this buffer once it is linked in by the caller.

If this is not overridden in a subclass, then any child buffers created using partition-at and the like will be of type SpanBuf, not the subclass type.

See SpanBuf for an example.


dynamic-substr (メソッド)
public {SpanBuf.dynamic-substr start:int, length:int}:SafeSubString

Returns substring that reflects changes in the underlying buffer.

説明

Returns a SafeSubString representing the substring of this buffer starting at offset start and with given length.

Unlike StringInterface.substr, which returns an immutable String, and which therefore will not reflect changes to the buffer, this will return an object that reflects changes to the buffer after the substring is returned. This means that the size of the returned substring may become shorter if this buffer becomes shorter.


flush (メソッド)
public final {SpanBuf.flush
non-blocking?:bool = false,
allow-short-write?:bool = false
}:void

Flush output stream.

説明

This does nothing in this class.


get (メソッド)
public final inline {SpanBuf.get i:int}:char

self 内の指定された文字を返します。

index: 取得する文字の位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0(self.size - 1) の範囲です (0(self.size - 1) を含む)。

例外のスロー

index が範囲外の場合は ArrayBoundsException をスローします。


{value
    || Declare and initialize a string.
    let s:String = "Hello World!"

    || Display the string and return the
    || character at position 7.
    || Remember that the leftmost position
    || is 0 (zero).
    {text {value s}
        {br}The character at position 7 is {s.get 7}.}
}

注意事項

これは StringInterface の抽象メソッドです。このメソッドは StringInterface のサブクラスによって実装されます。


get-attributes-in-range (メソッド)
public {SpanBuf.get-attributes-in-range
offset:int,
length:int = 1,
out:#SpanBufAttributesArray = null
}:SpanBufAttributesArray

Returns an array describing the attributes in a given range.

説明

Returns an array of SpanBufAttributes describing what attributes are set in the range starting at offset and continuing for length characters.

The attributes will be appended to out, if non-null.


get-buffer-containing (メソッド)
public {SpanBuf.get-buffer-containing
offset:int,
length:int = 1,
max-depth:int = max-int
}:(SpanBuf, offset-in-buf:int)

Find subbuffer containing given range.

offset: is an offset within the range of this buffer, i.e. a value between 0 and size.
length: is the length of the range.
max-depth: is the maximum depth to recurse. By default, the lowest level subbuffer will be found. Setting this to one will ensure that only immediate children or the buffer itself may be returned. Setting this to zero will result in this buffer being returned.

戻り値

Returns the innermost buffer upto max-depth that contains all of the characters beginning at offset and ending at offset + length - 1.


get-column (メソッド)
public final inline {SpanBuf.get-column offset:int}:int

Compute the column of given location in the buffer.

説明

This is a faster alternative to SpanBuf.location-to-line-column when only the column is needed.


get-line (メソッド)
public final {SpanBuf.get-line
offset:int,
out:StringBuf = {StringBuf}
}:(uint8, StringBuf)

Reads line of text with same attributes starting at offset.

説明

Writes into out, characters from this buffer starting at offset until a newline sequence is encountered or the attributes associated with the next character differs from the last one written. The terminating newline sequence characters will be written as long as their attributes match the rest of the text.

The attributes value will default to zero if not set using set-attributes. The meaning of the attributes value is user defined.

Returns the attributes value associated with the characters and the out variable.


get-next-attribute (メソッド)
public final {SpanBuf.get-next-attribute
offset:int,
attr:uint8,
end:int = self.size,
mask:uint8 = 0xff
}:(new-offset:int, new-attr:uint8)

Find next offset at which attribute changes.

説明

Finds the next offset starting with offset below end at which the associated attribute value new-attr differs from attr after the given mask has been applied to it. That is, finds first offset at which

{bit-and mask, new-attr} != attr

is true. Returns the offset and the new (unmasked) attribute value. If no differing attribute is found within the specified range, this will return end and attr (which is not necessarily the actual attribute value associated with end).

It is assumed that {bit-and mask, attr} is equal to attr. Note that the meaning of mask is different from that used by set-attributes.

Also see SpanBuf.get-with-attributes and SpanBuf.get-line.


get-with-attributes (メソッド)
public final {SpanBuf.get-with-attributes i:int}:(char, uint8)

Gets character and associated attributes at given offset.

説明

Returns the character and its associated attributes value for the given offset i. The attributes value will default to zero if not set using set-attributes.

The meaning of the the attributes value is user defined.


handle-transfer-to (メソッド)
protected {SpanBuf.handle-transfer-to
other:#SpanBuf,
from-offset:int,
to-offset:int
}:void

Allows subclasses to respond to merge/split operations.

説明

This is invoked when merging or splitting child buffers to indicate that the contents of this buffer from from-offset to the end of the buffer is being transfered to other at to-offset. When contents are being removed this will be invoked with other set to null.

オーバーライド

Subclasses may override this method in order to transfer associated state to other.


insert (メソッド)
public final {SpanBuf.insert c:char, i:int}:void

文字を self に挿入します。

c: 挿入する文字。
index: 文字を挿入する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0self.size の範囲です (0self.size を含む)。

説明

位置 index より後ろにあるすべての文字を 1 つずつ後ろにずらし、位置 index に文字 c を挿入します。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Insert a comma (,) at position 5.
    || Remember that the leftmost position
    || is 0 (zero).
    {sb.insert ',', 5}

    || Display the resulting StringBuf.
    {value sb}
}

注意事項

これは WritableString の抽象メソッドです。このメソッドは WritableString のサブクラスによって実装されます。


line-column-to-location (メソッド)
public {SpanBuf.line-column-to-location line:int, column:int}:int

Converts line and column to buffer offset.

説明

Returns offset in this buffer corresponding to given line and column. The line and column are computed with respect to the root buffer.

This will return a value outside of the range of this buffer (i.e. either less than zero or greater than the size of the buffer) if line and column refer to a location outside the buffer.


location-to-line-column (メソッド)
public {SpanBuf.location-to-line-column offset:int}:(int, int)

Converts offset to line and column.

説明

The line and column are computed with respect to the root buffer.

Columns are indexed from 0, while lines are indexed from 1; .e.g, the first position in the file is line 1, column 0.


merge-with-next (メソッド)
public {SpanBuf.merge-with-next}:void

Merges next buffer into this one.

説明

Merges the next sibling buffer, if any, into this buffer. This buffer's appendable? attribute will be set to that of the next buffer.

If next is null, this will do nothing.


object-describe (メソッド)
public {SpanBuf.object-describe}:void

ユーザーが印刷するのに適した方法でオブジェクトを記述します。

out: 文字が送られるストリーム。
locale: self の表示方法をコントロールする Locale

説明

このメソッドは、一般に、"%s" フォーマット キーを使用して間接的に起動されます。

{format out = out, "%s", obj}
上記の表現は単純に以下を呼び出します。
{obj.object-describe out}


たとえば、uUrl である場合を考えます。
{u.object-describe os}
上記の表現により、u の名前が os に書き込まれます。

このメソッドの既定の実装では、以下を呼び出す効果があります。
{format out = out, locale = locale, "%v", obj }
("%v" フォーマット キーの詳細については、format を参照してください)。


object-describe-for-debugging (メソッド)
public {SpanBuf.object-describe-for-debugging}:void

オブジェクトについて細部を記述します。これは主にデバッグ目的での使用が想定されています。

out: 文字が送られるストリーム。
locale: self の表示方法をコントロールする Locale

説明

このメソッドは、一般に、"%y" フォーマット キーを使用して間接的に起動されます。"%y" フォーマット キーは、このメソッドによって生成された結果を、次のような何らかの型またはアドレス情報でラップします。
{do
    let buf:StringBuf = {StringBuf}
    {self.object-describe-for-debugging buf, {get-syntax-locale}}
    {format out = out, "[<type> @<addr> %s]", buf}
}
このメソッドの既定の実装では
{format out = out, "%w", self} を呼び出します。
(「%w」フォーマット キーの詳細については、format を参照してください)。
これが FormatFailedException を取得する場合、通常ユーザー定義のクラスのように、このメソッドは object-describe メソッドの呼び出しに戻ります。


observed-by? (メソッド)
public final {SpanBuf.observed-by? observer:SpanBufObserver}:bool

Indicate whether observer is attached to this buffer.

説明

Return true if observer is currently attached to this buffer.


partition-at (メソッド)
public {SpanBuf.partition-at offset:int}:SpanBuf

Partition buffer into subbuffers

説明

Partitions the buffer at the specified offset, which must be less than size, and returns the child SpanBuf beginning at that offset.

The child's parent will be set to this object and its its prev and next accessors will refer to adjacent sibling SpanBufs, if they exist.

This will do nothing if there is already a child SpanBuf at the offset. If offset is zero and the buffer currently has no child SpanBufs, then this will create a single child including the entire contents of the buffer.


remove (メソッド)
public final {SpanBuf.remove
i:int,
length:int = 1,
error-if-missing?:bool = true
}:void

指定された文字を self から削除します。

index: 文字の削除を開始する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0self.size の範囲です (0self.size を含む)。
length: 削除する文字数。length の既定値は 1 です。length はキーワード引数です。length を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:length = 6)。
error-if-missing?:
存在しない文字を削除しようとしたときにこのメソッドがエラーを生成するかどうかを示す、ブール値のフラグ。位置 0 と self.size の間の文字を削除できます。
error-if-missing?true に設定した場合、存在しない文字を削除しようとするとエラーがスローされます。エラーが発生するとプログラムの実行が停止し、エラー メッセージが表示されます。既定では、error-if-missing?true です。error-if-missing?false に設定した場合、エラーは生成されません。また、有効な範囲内にある文字は削除されますが、有効な範囲内にない文字は削除されず、削除後の文字列が返されます。
error-if-missing? はキーワード引数です。error-if-missing? を指定するには、メソッド呼び出しのキーワードに対して適切な値を設定します (例:error-if-missing? = false)。

説明

self から length 個の文字を削除します。削除開始位置は index です。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Remove 6 characters, starting at
    || position 5.
    || Remember that the leftmost position
    || is 0 (zero).
    {sb.remove 5, length = 6}

    || Display the resulting StringBuf.
    {value sb}
}

注意事項

これは WritableString の抽象メソッドです。このメソッドは WritableString のサブクラスによって実装されます。


remove-observer (メソッド)
public {SpanBuf.remove-observer observer:SpanBufObserver}:void

Remove observer from this buffer.

説明

Remove observer from the list of observers for this buffer.

Does nothing if observer is not currently attached to the buffer.


remove-partitions (メソッド)
public final {SpanBuf.remove-partitions}:void

Merges all subbuffers into one.

説明

Removes all subbuffers, returning content to the this buffer. After invoking this, childless? will be true for the buffer.

This does not affect the underlying string contents.


replace (メソッド)
public final {SpanBuf.replace
old:StringInterface,
new:StringInterface,
starting-index:int = 0
}:void

old の各オカレンスを new に置換します。

old: new で置換する部分文字列。
new: old の各オカレンスを置換する部分文字列。

説明

左から右に部分文字列 old を検索します。各オカレンスごとに、old を削除し、new をつなぎ合わせて、新規に挿入された文字のから検索を再開します。


{value
    || Declare and initialize a string
    let sb:StringBuf = {StringBuf "Silly willy"}

    || Replace each occurrence of "ill" with "ick".
    {sb.replace "ill", "ick"}

    || Display the resulting StringBuf.
    sb
}


set (メソッド)
public final {SpanBuf.set i:int, c:char}:void

self 内の文字を置換します。

index: 置換する文字の位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0(self.size - 1) の範囲です (0(self.size - 1) を含む)。
c: 新しい文字。

説明

位置 index にある文字を c に置換します。


{value
    || Declare and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Replace character 11 (!) with a period (.).
    || Remember that the leftmost position
    || is 0 (zero).
    {sb.set 11, '.'}

    || Display the resulting StringBuf.
    {value sb}
}

注意事項

これは WritableString の抽象メソッドです。このメソッドは WritableString のサブクラスによって実装されます。


set-attributes (メソッド)
public final {SpanBuf.set-attributes
attributes:uint8,
mask:uint8 = 0,
start:int = 0,
end:int = self.size
}:void

Sets attributes value for specified character range.

説明

Sets the attributes value associated with the characters starting at offset start and ending just before offset end. The attributes value is set by replacing the previous attributes value using the following logic:

{bit-or attributes, {bit-and old-attributes, mask} }

Setting the mask to zero will cause the attributes in the specified range to be overwritten with the new value. You can use the mask to allocate bit fields within the attributes value.

The attributes values set by this method are available through get-with-attributes and get-line.

The meaning of the attributes value is user defined, but it is expected to be used to associate semantic tags to ranges of text which may be used in rendering. For instance, a bit could be used to indicate the presence of an error in a range of text, and a text renderer using the buffer can use the presence of the error bit to peform some kind of error highlighting for that range.

Both start and end will be normalized to fit within the current range of the buffer.


set-contents (メソッド)
public final {SpanBuf.set-contents str:StringInterface}:void

self の内容を別の文字列の内容に置換します。

str: self を置換する文字列を含む StringInterface


{value
    || Declare and initialize a StringBuf
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Replace the contents
    {sb.set-contents {StringBuf "Here comes Curl!"}}

    || Display the StringBuf
    {value sb}
}


set-root-line-column (メソッド)
public final {SpanBuf.set-root-line-column line:int, column:int}:void

Set the starting line and column of the root buffer.

説明

All line and column computations are computed relative to these numbers. Typically these values are set in the default constructor and are usually set to their default values of 1 and 0.


splice (メソッド)
public final {SpanBuf.splice str:StringInterface, i:int}:void

StringInterfaceself に挿入します。

str: 挿入する StringInterface。このオブジェクトのデータ型は self と同じでなければなりません。
index: StringInterface を挿入する位置。最左端の文字の位置は 0 です。最右端の文字の位置は (self.size - 1) です。有効値は 0self.size の範囲です (0self.size を含む)。

説明

self 内の位置 index より後ろにある文字を str の文字数分後ろにずらし、位置 indexstr を挿入します。


{value
    || Declare and initialize two StringBufs.
    let sb1:StringBuf = {StringBuf "Hello World!"}
    let sb2:StringBuf = {StringBuf ", can you hear me,"}

    || Insert "sb2" into "sb1" at position 5.
    || Remember that the leftmost position
    || is 0 (zero).
    {sb1.splice sb2, 5}

    || Display the resulting StringBuf.
    {value sb1}
}


split-at (メソッド)
public {SpanBuf.split-at offset:int}:SpanBuf

Splits buffer at offset

説明

Splits this buffer into two adjacent buffers and returns the latter buffer.

If the buffer has no parent, then this is the same as partition-at.


to-source-location (メソッド)
public {SpanBuf.to-source-location
start:int = 0,
end:int = max-int
}:CPABaseSourceLocation

Produces a source location for given subrange of buffer.

説明

By default produces location corresponding to the entire buffer.


to-String (メソッド)
public final {SpanBuf.to-String}:String

self と同一 (==) の String を作成します。

戻り値

self 内の文字を含む String


{value
    || Define and initialize a StringBuf.
    let sb:StringBuf = {StringBuf "Hello World!"}

    || Convert the StringBuf to a String.
    let s:String = {sb.to-String}

    || Display the contents of the String.
    {value s}
}


write-one (メソッド)
public final {SpanBuf.write-one c:char}:void

Writes character to output stream.

説明

This is the same as append.


write-one-string (メソッド)
public final {SpanBuf.write-one-string
str:StringInterface,
start:int = 0,
length:int = str.size - start
}:int

Writes a string of characters to output stream.

説明

Appends characters from str to end of this buffer, beginning with start and with length specified by length.