blob: 76cb4413a58fef9e04c9d7f8aee55d00d9bbec9e [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2009, 2018 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.yaml.core.ast;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.statet.ltk.ast.core.AstNode;
import org.eclipse.statet.ltk.ast.core.AstVisitor;
import org.eclipse.statet.yaml.core.ast.YamlAst.NodeType;
public abstract class Scalar extends YamlAstNode {
static class DQuoted extends Scalar {
DQuoted(final YamlAstNode parent, final int startOffset, final int endOffset, final String value) {
super(parent, startOffset, endOffset, value);
}
@Override
public char getOperator() {
return '\"';
}
}
static class SQuoated extends Scalar {
SQuoated(final YamlAstNode parent, final int startOffset, final int endOffset, final String value) {
super(parent, startOffset, endOffset, value);
}
@Override
public char getOperator() {
return '\'';
}
}
static class Plain extends Scalar {
Plain(final YamlAstNode parent, final int startOffset, final int endOffset, final String value) {
super(parent, startOffset, endOffset, value);
}
@Override
public char getOperator() {
return 0;
}
}
String value;
Scalar(final YamlAstNode parent, final int startOffset, final int endOffset,
final String value) {
super(parent, startOffset, endOffset);
this.value= value;
}
@Override
public NodeType getNodeType() {
return NodeType.SCALAR;
}
@Override
public String getText() {
return this.value;
}
@Override
public boolean hasChildren() {
return false;
}
@Override
public int getChildCount() {
return 0;
}
@Override
public YamlAstNode getChild(final int index) {
throw new IndexOutOfBoundsException();
}
@Override
public int getChildIndex(final AstNode element) {
return -1;
}
@Override
public void acceptInChildren(final AstVisitor visitor) throws InvocationTargetException {
}
@Override
public void acceptInYaml(final YamlAstVisitor visitor) throws InvocationTargetException {
visitor.visit(this);
}
@Override
public void acceptInYamlChildren(final YamlAstVisitor visitor) throws InvocationTargetException {
}
}