summaryrefslogtreecommitdiff
path: root/android_icu4j/src/main/java/android/icu/message2/PlainStringFormattedValue.java
blob: 370c30d4cc657c4e0c3d1fbbaa7313c7a5fa2b3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* GENERATED SOURCE. DO NOT MODIFY. */
// © 2022 and later: Unicode, Inc. and others.
// License & terms of use: https://www.unicode.org/copyright.html

package android.icu.message2;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.text.AttributedCharacterIterator;

import android.icu.text.ConstrainedFieldPosition;
import android.icu.text.FormattedValue;

/**
 * Very-very rough implementation of FormattedValue, packaging a string.
 * Expect it to change.
 *
 * @deprecated This API is for unit testing only.
 * @hide Only a subset of ICU is exposed in Android
 * @hide draft / provisional / internal are hidden on Android
 */
@Deprecated
public class PlainStringFormattedValue implements FormattedValue {
    private final String value;

    /**
     * Constructor, taking the string to store.
     *
     * @param value the string value to store
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    public PlainStringFormattedValue(String value) {
        if (value == null) {
            throw new IllegalAccessError("Should not try to wrap a null in a formatted value");
        }
        this.value = value;
    }

    /**
     * {@inheritDoc}
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    @Override
    public int length() {
        return value == null ? 0 : value.length();
    }

    /**
     * {@inheritDoc}
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    @Override
    public char charAt(int index) {
        return value.charAt(index);
    }

    /**
     * {@inheritDoc}
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    @Override
    public CharSequence subSequence(int start, int end) {
        return value.subSequence(start, end);
    }

    /**
     * {@inheritDoc}
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    @Override
    public <A extends Appendable> A appendTo(A appendable) {
        try {
            appendable.append(value);
        } catch (IOException e) {
            throw new UncheckedIOException("problem appending", e);
        }
        return appendable;
    }

    /**
     * Not yet implemented.
     *
     * {@inheritDoc}
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    @Override
    public boolean nextPosition(ConstrainedFieldPosition cfpos) {
        throw new RuntimeException("nextPosition not yet implemented");
    }

    /**
     * Not yet implemented.
     *
     * {@inheritDoc}
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    @Override
    public AttributedCharacterIterator toCharacterIterator() {
        throw new RuntimeException("toCharacterIterator not yet implemented");
    }

    /**
     * {@inheritDoc}
     *
     * @deprecated This API is for unit testing only.
     * @hide draft / provisional / internal are hidden on Android
     */
    @Deprecated
    @Override
    public String toString() {
        return value;
    }
}