Coverage Report - org.yaml.snakeyaml.events.ScalarEvent
 
Classes in this File Line Coverage Branch Coverage Complexity
ScalarEvent
100%
12/12
100%
2/2
1
 
 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.events;
 17  
 
 18  
 import org.yaml.snakeyaml.error.Mark;
 19  
 
 20  
 /**
 21  
  * Marks a scalar value.
 22  
  */
 23  
 public final class ScalarEvent extends NodeEvent {
 24  
     private final String tag;
 25  
     // style flag of a scalar event indicates the style of the scalar. Possible
 26  
     // values are None, '', '\'', '"', '|', '>'
 27  
     private final Character style;
 28  
     private final String value;
 29  
     // The implicit flag of a scalar event is a pair of boolean values that
 30  
     // indicate if the tag may be omitted when the scalar is emitted in a plain
 31  
     // and non-plain style correspondingly.
 32  
     private final ImplicitTuple implicit;
 33  
 
 34  
     public ScalarEvent(String anchor, String tag, ImplicitTuple implicit, String value,
 35  
             Mark startMark, Mark endMark, Character style) {
 36  1161780
         super(anchor, startMark, endMark);
 37  1161780
         this.tag = tag;
 38  1161780
         this.implicit = implicit;
 39  1161780
         this.value = value;
 40  1161780
         this.style = style;
 41  1161780
     }
 42  
 
 43  
     /**
 44  
      * Tag of this scalar.
 45  
      * 
 46  
      * @return The tag of this scalar, or <code>null</code> if no explicit tag
 47  
      *         is available.
 48  
      */
 49  
     public String getTag() {
 50  1507325
         return this.tag;
 51  
     }
 52  
 
 53  
     /**
 54  
      * Style of the scalar.
 55  
      * <dl>
 56  
      * <dt>null</dt>
 57  
      * <dd>Flow Style - Plain</dd>
 58  
      * <dt>'\''</dt>
 59  
      * <dd>Flow Style - Single-Quoted</dd>
 60  
      * <dt>'"'</dt>
 61  
      * <dd>Flow Style - Double-Quoted</dd>
 62  
      * <dt>'|'</dt>
 63  
      * <dd>Block Style - Literal</dd>
 64  
      * <dt>'>'</dt>
 65  
      * <dd>Block Style - Folded</dd>
 66  
      * </dl>
 67  
      * 
 68  
      * @see <a href="http://yaml.org/spec/1.1/#id864487">Kind/Style
 69  
      *      Combinations</a>
 70  
      * @return Style of the scalar.
 71  
      */
 72  
     public Character getStyle() {
 73  3064055
         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  1656251
         return this.value;
 86  
     }
 87  
 
 88  
     public ImplicitTuple getImplicit() {
 89  2151087
         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  1200919
         return ID.Scalar == id;
 100  
     }
 101  
 }