Package acdp.misc
Class Layout.Seq
java.lang.Object
acdp.misc.Layout.Seq
- Enclosing class:
Layout
Defines the sequence value type of a layout.
A sequence is one of the three value types of an entry in a layout or of
an element in a sequence.
- Author:
- Beat Hörmann
-
Method Summary
Modifier and TypeMethodDescriptionfinal Layout.Seq
Appends the specified layout to the end of this sequence.final Layout.Seq
add
(Layout.Seq seq) Appends the specified sequence to the end of this sequence.final Layout.Seq
Appends the specified string value to the end of this sequence.final Layout
Creates a new layout, appends it to the end of this sequence and returns the new layout.final Layout.Seq
addSeq()
Creates a new sequence, appends it to the end of this sequence and returns the new sequence.asList()
Returns this sequence as anunmodifiable
list.final Layout
getLayout
(int index) Returns the layout at the specified position in this sequence.final Layout.Seq
getSeq
(int index) Returns the sequence at the specified position in this sequence.final String
getString
(int index) Returns the string value at the specified position in this sequence.final Layout.Seq
Inserts the specified layout at the specified position in this sequence.final Layout.Seq
insert
(int index, Layout.Seq seq) Inserts the specified sequence at the specified position in this sequence.final Layout.Seq
Inserts the specified string value at the specified position in this sequence.final Layout
insertLayout
(int index) Creates a new layout, inserts it at the specified position in this sequence and returns the new layout.final Layout.Seq
insertSeq
(int index) Creates a new sequence, inserts it at the specified position in this sequence and returns the new sequence.final Layout.Seq
remove
(int index) Removes the element at the specified position in this sequence.final Layout.Seq
Replaces the layout at the specified position in this sequence with the specified layout.final Layout.Seq
replace
(int index, Layout.Seq seq) Replaces the sequence at the specified position in this sequence with the specified sequence.final Layout.Seq
Replaces the string value at the specified position in this sequence with the specified string value.final int
size()
Returns the number of elements in this sequence.
-
Method Details
-
size
public final int size()Returns the number of elements in this sequence.- Returns:
- The number of elements in this sequence.
-
asList
Returns this sequence as anunmodifiable
list. The elements of the returned list are the elements of this sequence in the correct order. They are of typeString
,Seq
orLayout
.- Returns:
- The sequence as an unmodifiable list.
-
getString
Returns the string value at the specified position in this sequence.- Parameters:
index
- The index of the element to return.- Returns:
- The string value at the specified position in this sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
≥size()
).ClassCastException
- If the stored element is not a string.
-
getSeq
Returns the sequence at the specified position in this sequence.- Parameters:
index
- The index of the element to return.- Returns:
- The sequence at the specified position in this sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
≥size()
).ClassCastException
- If the stored element is not a sequence.
-
getLayout
Returns the layout at the specified position in this sequence.- Parameters:
index
- The index of the element to return.- Returns:
- The layout at the specified position in this sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
≥size()
).ClassCastException
- If the stored element is not a layout.
-
insert
public final Layout.Seq insert(int index, String value) throws IndexOutOfBoundsException, NullPointerException Inserts the specified string value at the specified position in this sequence.- Parameters:
index
- The index at which the specified string value is to be inserted.value
- The string value to be inserted.- Returns:
- This sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
>size()
).NullPointerException
- If the specified string value isnull
.
-
insertSeq
Creates a new sequence, inserts it at the specified position in this sequence and returns the new sequence.- Parameters:
index
- The index at which the created sequence is to be inserted.- Returns:
- seq The newly created empty sequence, never
null
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
>size()
).
-
insert
public final Layout.Seq insert(int index, Layout.Seq seq) throws IndexOutOfBoundsException, NullPointerException Inserts the specified sequence at the specified position in this sequence.- Parameters:
index
- The index at which the specified sequence is to be inserted.seq
- The sequence to be inserted.- Returns:
- This sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
>size()
).NullPointerException
- If the specified sequence isnull
.
-
insertLayout
Creates a new layout, inserts it at the specified position in this sequence and returns the new layout.- Parameters:
index
- The index at which the created layout is to be inserted.- Returns:
- The newly created empty layout, never
null
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
>size()
).
-
insert
public final Layout.Seq insert(int index, Layout layout) throws IndexOutOfBoundsException, NullPointerException Inserts the specified layout at the specified position in this sequence.- Parameters:
index
- The index at which the specified layout is to be inserted.layout
- The layout to be inserted.- Returns:
- This sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
>size()
).NullPointerException
- If the specified layout isnull
.
-
add
Appends the specified string value to the end of this sequence.- Parameters:
value
- The string value to be appended to this sequence, not allowed to benull
.- Returns:
- This sequence.
- Throws:
NullPointerException
- If the specified string value isnull
.
-
addSeq
Creates a new sequence, appends it to the end of this sequence and returns the new sequence.- Returns:
- The newly created empty sequence, never
null
.
-
add
Appends the specified sequence to the end of this sequence.- Parameters:
seq
- The sequence to be appended to this sequence, not allowed to benull
.- Returns:
- This sequence.
- Throws:
NullPointerException
- If the specified sequence isnull
.
-
addLayout
Creates a new layout, appends it to the end of this sequence and returns the new layout.- Returns:
- The newly created empty layout, never
null
- Throws:
NullPointerException
-
add
Appends the specified layout to the end of this sequence.- Parameters:
layout
- The layout to be appended to this sequence, not allowed to benull
.- Returns:
- This sequence.
- Throws:
NullPointerException
- If the specified layout isnull
.
-
replace
public final Layout.Seq replace(int index, String value) throws IndexOutOfBoundsException, NullPointerException, ClassCastException Replaces the string value at the specified position in this sequence with the specified string value.- Parameters:
index
- The index of the string value to replace.value
- The value to be inserted.- Returns:
- This sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
>size()
).NullPointerException
- If the specified value isnull
.ClassCastException
- If the stored value at the specified position is not a string.
-
replace
public final Layout.Seq replace(int index, Layout.Seq seq) throws IndexOutOfBoundsException, NullPointerException, ClassCastException Replaces the sequence at the specified position in this sequence with the specified sequence.- Parameters:
index
- The index of the sequence to replace.seq
- The sequence to be inserted.- Returns:
- This sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
≥size()
).NullPointerException
- If the specified sequence isnull
.ClassCastException
- If the stored value at the specified position is not a sequence.
-
replace
public final Layout.Seq replace(int index, Layout layout) throws IndexOutOfBoundsException, NullPointerException, ClassCastException Replaces the layout at the specified position in this sequence with the specified layout.- Parameters:
index
- The index of the layout to replace.layout
- The layout to be inserted.- Returns:
- This sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
≥size()
).NullPointerException
- If the specified layout isnull
.ClassCastException
- If the stored value at the specified position is not a layout.
-
remove
Removes the element at the specified position in this sequence.- Parameters:
index
- The index of the element to be removed.- Returns:
- This sequence.
- Throws:
IndexOutOfBoundsException
- If the index is out of range (index
< 0 ||index
≥size()
).
-