| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ScalarEvent |
|
| 1.0;1 |
| 1 | /** | |
| 2 | * Copyright (c) 2008-2011, http://www.snakeyaml.org | |
| 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 | package org.yaml.snakeyaml.events; | |
| 18 | ||
| 19 | import org.yaml.snakeyaml.error.Mark; | |
| 20 | ||
| 21 | /** | |
| 22 | * Marks a scalar value. | |
| 23 | */ | |
| 24 | public final class ScalarEvent extends NodeEvent { | |
| 25 | private final String tag; | |
| 26 | // style flag of a scalar event indicates the style of the scalar. Possible | |
| 27 | // values are None, '', '\'', '"', '|', '>' | |
| 28 | private final Character style; | |
| 29 | private final String value; | |
| 30 | // The implicit flag of a scalar event is a pair of boolean values that | |
| 31 | // indicate if the tag may be omitted when the scalar is emitted in a plain | |
| 32 | // and non-plain style correspondingly. | |
| 33 | private final ImplicitTuple implicit; | |
| 34 | ||
| 35 | public ScalarEvent(String anchor, String tag, ImplicitTuple implicit, String value, | |
| 36 | Mark startMark, Mark endMark, Character style) { | |
| 37 | 967032 | super(anchor, startMark, endMark); |
| 38 | 967032 | this.tag = tag; |
| 39 | 967032 | this.implicit = implicit; |
| 40 | 967032 | this.value = value; |
| 41 | 967032 | this.style = style; |
| 42 | 967032 | } |
| 43 | ||
| 44 | /** | |
| 45 | * Tag of this scalar. | |
| 46 | * | |
| 47 | * @return The tag of this scalar, or <code>null</code> if no explicit tag | |
| 48 | * is available. | |
| 49 | */ | |
| 50 | public String getTag() { | |
| 51 | 1246997 | return this.tag; |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Style of the scalar. | |
| 56 | * <dl> | |
| 57 | * <dt>''</dt> | |
| 58 | * <dd>Flow Style - Plain</dd> | |
| 59 | * <dt>'\''</dt> | |
| 60 | * <dd>Flow Style - Single-Quoted</dd> | |
| 61 | * <dt>'"'</dt> | |
| 62 | * <dd>Flow Style - Double-Quoted</dd> | |
| 63 | * <dt>'|'</dt> | |
| 64 | * <dd>Block Style - Literal</dd> | |
| 65 | * <dt>'>'</dt> | |
| 66 | * <dd>Block Style - Folded</dd> | |
| 67 | * </dl> | |
| 68 | * | |
| 69 | * @see http://yaml.org/spec/1.1/#id864487 | |
| 70 | * @return Style of the scalar. | |
| 71 | */ | |
| 72 | public Character getStyle() { | |
| 73 | 2782923 | return this.style; |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * String representation of the value. | |
| 78 | * <p> | |
| 79 | * Without quotes and escaping. | |
| 80 | * </p> | |
| 81 | * | |
| 82 | * @return Value as Unicode string. | |
| 83 | */ | |
| 84 | public String getValue() { | |
| 85 | 1332373 | return this.value; |
| 86 | } | |
| 87 | ||
| 88 | public ImplicitTuple getImplicit() { | |
| 89 | 1960081 | return this.implicit; |
| 90 | } | |
| 91 | ||
| 92 | @Override | |
| 93 | protected String getArguments() { | |
| 94 | 11 | return super.getArguments() + ", tag=" + tag + ", " + implicit + ", value=" + value; |
| 95 | } | |
| 96 | ||
| 97 | @Override | |
| 98 | public boolean is(Event.ID id) { | |
| 99 | 942675 | return ID.Scalar == id; |
| 100 | } | |
| 101 | } |