1 /** 2 * Copyright (c) 2008, SnakeYAML 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 * in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the License 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 * or implied. See the License for the specific language governing permissions and limitations under 12 * the License. 13 */ 14 package org.yaml.snakeyaml.tokens; 15 16 import org.yaml.snakeyaml.DumperOptions; 17 import org.yaml.snakeyaml.error.Mark; 18 19 public final class ScalarToken extends Token { 20 21 private final String value; 22 private final boolean plain; 23 private final DumperOptions.ScalarStyle style; 24 ScalarToken(String value, Mark startMark, Mark endMark, boolean plain)25 public ScalarToken(String value, Mark startMark, Mark endMark, boolean plain) { 26 this(value, plain, startMark, endMark, DumperOptions.ScalarStyle.PLAIN); 27 } 28 ScalarToken(String value, boolean plain, Mark startMark, Mark endMark, DumperOptions.ScalarStyle style)29 public ScalarToken(String value, boolean plain, Mark startMark, Mark endMark, 30 DumperOptions.ScalarStyle style) { 31 super(startMark, endMark); 32 this.value = value; 33 this.plain = plain; 34 if (style == null) { 35 throw new NullPointerException("Style must be provided."); 36 } 37 this.style = style; 38 } 39 getPlain()40 public boolean getPlain() { 41 return this.plain; 42 } 43 getValue()44 public String getValue() { 45 return this.value; 46 } 47 getStyle()48 public DumperOptions.ScalarStyle getStyle() { 49 return this.style; 50 } 51 52 @Override getTokenId()53 public Token.ID getTokenId() { 54 return ID.Scalar; 55 } 56 } 57