1 | /**
|
2 | * Copyright (C) 2016-2019 Michael Kourlas
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | /**
|
17 | * The options used to create new character data.
|
18 | */
|
19 | export interface IXmlCharDataOptions {
|
20 | /**
|
21 | * The character data.
|
22 | */
|
23 | charData: string;
|
24 | /**
|
25 | * Whether to replace any invalid characters in the character data with the
|
26 | * Unicode replacement character. By default, this is disabled.
|
27 | */
|
28 | replaceInvalidCharsInCharData?: boolean;
|
29 | }
|
30 | /**
|
31 | * Represents character data.
|
32 | *
|
33 | * Restricted characters, such as the ampersand (`&`), the opening angle
|
34 | * bracket (`<`), and the closing angle bracket (`>`) when it appears in the
|
35 | * string `]]>`, are all automatically escaped.
|
36 | */
|
37 | export default class XmlCharData<Parent> {
|
38 | private readonly _replaceInvalidCharsInCharData;
|
39 | private readonly _parent;
|
40 | private readonly _validation;
|
41 | private _charData;
|
42 | constructor(parent: Parent, validation: boolean, options: IXmlCharDataOptions);
|
43 | /**
|
44 | * Gets the text of this character data.
|
45 | */
|
46 | get charData(): string;
|
47 | /**
|
48 | * Sets the text of this character data.
|
49 | */
|
50 | set charData(charData: string);
|
51 | /**
|
52 | * Returns an XML string representation of this character data.
|
53 | */
|
54 | toString(): string;
|
55 | /**
|
56 | * Returns the parent of this character data.
|
57 | */
|
58 | up(): Parent;
|
59 | }
|