| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ScalarNode |
|
| 1.3333333333333333;1.333 |
| 1 | /** | |
| 2 | * Copyright (c) 2008-2012, 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 | package org.yaml.snakeyaml.nodes; | |
| 17 | ||
| 18 | import org.yaml.snakeyaml.error.Mark; | |
| 19 | ||
| 20 | /** | |
| 21 | * Represents a scalar node. | |
| 22 | * <p> | |
| 23 | * Scalar nodes form the leaves in the node graph. | |
| 24 | * </p> | |
| 25 | */ | |
| 26 | public class ScalarNode extends Node { | |
| 27 | private Character style; | |
| 28 | private String value; | |
| 29 | ||
| 30 | public ScalarNode(Tag tag, String value, Mark startMark, Mark endMark, Character style) { | |
| 31 | 666298 | this(tag, true, value, startMark, endMark, style); |
| 32 | 666296 | } |
| 33 | ||
| 34 | public ScalarNode(Tag tag, boolean resolved, String value, Mark startMark, Mark endMark, | |
| 35 | Character style) { | |
| 36 | 1147928 | super(tag, startMark, endMark); |
| 37 | 1147928 | if (value == null) { |
| 38 | 1 | throw new NullPointerException("value in a Node is required."); |
| 39 | } | |
| 40 | 1147927 | this.value = value; |
| 41 | 1147927 | this.style = style; |
| 42 | 1147927 | this.resolved = resolved; |
| 43 | 1147927 | } |
| 44 | ||
| 45 | /** | |
| 46 | * Get scalar style of this node. | |
| 47 | * | |
| 48 | * @see org.yaml.snakeyaml.events.ScalarEvent | |
| 49 | * @see <a href="http://yaml.org/spec/1.1/#id903915">Chapter 9. Scalar | |
| 50 | * Styles</a> | |
| 51 | */ | |
| 52 | public Character getStyle() { | |
| 53 | 1259666 | return style; |
| 54 | } | |
| 55 | ||
| 56 | @Override | |
| 57 | public NodeId getNodeId() { | |
| 58 | 2883807 | return NodeId.scalar; |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * Value of this scalar. | |
| 63 | * | |
| 64 | * @return Scalar's value. | |
| 65 | */ | |
| 66 | public String getValue() { | |
| 67 | 2469149 | return value; |
| 68 | } | |
| 69 | ||
| 70 | public String toString() { | |
| 71 | 39 | return "<" + this.getClass().getName() + " (tag=" + getTag() + ", value=" + getValue() |
| 72 | + ")>"; | |
| 73 | } | |
| 74 | } |