本文整理汇总了Java中org.yaml.snakeyaml.nodes.ScalarNode.getStyle方法的典型用法代码示例。如果您正苦于以下问题:Java ScalarNode.getStyle方法的具体用法?Java ScalarNode.getStyle怎么用?Java ScalarNode.getStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.yaml.snakeyaml.nodes.ScalarNode
的用法示例。
在下文中一共展示了ScalarNode.getStyle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onScalar
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
@Override
public void onScalar(ScalarNode node, TupleType tupleType) {
if (schemaTuple != null && node instanceof IncludeResolver.IncludeScalarNode) {
final String includeName = ((IncludeResolver.IncludeScalarNode) node).getIncludeName();
if (includeName.endsWith(".json")) {
try {
@SuppressWarnings("unchecked")
final Map<String, Object> json = mapper.readValue(node.getValue(), Map.class);
if (json.containsKey("$schema") && !json.containsKey("id")) {
json.put("id", protocol + ":/" + includeName);
super.onScalar(new ScalarNode(node.getTag(), node.isResolved(), mapper.writeValueAsString(json), node.getStartMark(), node.getEndMark(), node.getStyle()), tupleType);
return;
}
} catch (IOException e) {
log.warn("Line {}: Could not parse json file '{}' as schema. Relative $refs inside might not work: {}",
node.getStartMark().getLine() + 1, includeName, e.getMessage());
}
}
}
super.onScalar(node, tupleType);
}
示例2: representData
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
public Node representData(Object data) {
ScalarNode node = (ScalarNode) super.representData(data);
if (node.getStyle() == null) {
// if Plain scalar style
if (node.getValue().length() < 25) {
return node;
} else {
// Folded scalar style
return new ScalarNode(node.getTag(), node.getValue(), node.getStartMark(),
node.getEndMark(), '>');
}
} else {
return node;
}
}
示例3: getValue
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
public static String getValue(ScalarNode node) {
int style = (int)node.getStyle();
String value = node.getValue();
if (value.equals("null") && style == 0) {
return null;
} else {
return value;
}
}
示例4: printScalar
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
public static String printScalar(ScalarNode node) {
int style = (int)node.getStyle();
String value = node.getValue();
if (style != 0) {
return node.getStyle() + value + node.getStyle();
} else {
return value;
}
}
示例5: serializeNode
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
private void serializeNode(Node node, Node parent) throws IOException {
if (node.getNodeId() == NodeId.anchor) {
node = ((AnchorNode) node).getRealNode();
}
String tAlias = this.anchors.get(node);
if (this.serializedNodes.contains(node)) {
this.emitter.emit(new AliasEvent(tAlias, null, null));
} else {
this.serializedNodes.add(node);
switch (node.getNodeId()) {
case scalar:
ScalarNode scalarNode = (ScalarNode) node;
Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
.getTag().equals(defaultTag));
ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
scalarNode.getValue(), null, null, scalarNode.getStyle());
this.emitter.emit(event);
break;
case sequence:
SequenceNode seqNode = (SequenceNode) node;
boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence,
null, true));
this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
implicitS, null, null, seqNode.getFlowStyle()));
List<Node> list = seqNode.getValue();
for (Node item : list) {
serializeNode(item, node);
}
this.emitter.emit(new SequenceEndEvent(null, null));
break;
default:// instance of MappingNode
Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
boolean implicitM = node.getTag().equals(implicitTag);
this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
MappingNode mnode = (MappingNode) node;
List<NodeTuple> map = mnode.getValue();
for (NodeTuple row : map) {
Node key = row.getKeyNode();
Node value = row.getValueNode();
serializeNode(key, mnode);
serializeNode(value, mnode);
}
this.emitter.emit(new MappingEndEvent(null, null));
}
}
}
示例6: serializeNode
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
private void serializeNode(Node node, @Nullable Node parent, LinkedList<String> commentPath, boolean mappingScalar) throws IOException
{
if (node.getNodeId() == NodeId.anchor)
{
node = ((AnchorNode) node).getRealNode();
}
String tAlias = this.anchors.get(node);
if (this.serializedNodes.contains(node))
{
this.emitter.emit(new AliasEvent(tAlias, null, null));
}
else
{
this.serializedNodes.add(node);
switch (node.getNodeId())
{
case scalar:
ScalarNode scalarNode = (ScalarNode) node;
Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
String[] pathNodes = commentPath.toArray(new String[commentPath.size()]);
String comment;
if (this.checkCommentsSet(pathNodes))
{
comment = this.comments.getComment(pathNodes);
}
else
{
comment = null;
}
ImplicitTuple tuple = new ImplicitTupleExtension(node.getTag().equals(detectedTag), node.getTag().equals(defaultTag), comment);
ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple, scalarNode.getValue(), null, null, scalarNode.getStyle());
this.emitter.emit(event);
break;
case sequence:
SequenceNode seqNode = (SequenceNode) node;
boolean implicitS = node.getTag().equals(this.resolver.resolve(NodeId.sequence, null, true));
this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(), implicitS, null, null, seqNode.getFlowStyle()));
List<Node> list = seqNode.getValue();
for (Node item : list)
{
this.serializeNode(item, node, commentPath, false);
}
this.emitter.emit(new SequenceEndEvent(null, null));
break;
default:// instance of MappingNode
Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
boolean implicitM = node.getTag().equals(implicitTag);
this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(), implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
MappingNode mnode = (MappingNode) node;
List<NodeTuple> map = mnode.getValue();
for (NodeTuple row : map)
{
Node key = row.getKeyNode();
Node value = row.getValueNode();
if (key instanceof ScalarNode)
{
commentPath.add(((ScalarNode) key).getValue());
}
this.serializeNode(key, mnode, commentPath, true);
this.serializeNode(value, mnode, commentPath, false);
if (key instanceof ScalarNode)
{
commentPath.removeLast();
}
}
this.emitter.emit(new MappingEndEvent(null, null));
}
}
}
示例7: serializeNode
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
private void serializeNode(Node node, Node parent) throws IOException {
if (node.getNodeId() == NodeId.anchor) {
node = ((AnchorNode) node).getRealNode();
}
String tAlias = this.anchors.get(node);
if (this.serializedNodes.contains(node)) {
this.emitter.emit(new AliasEvent(tAlias, null, null));
} else {
this.serializedNodes.add(node);
switch (node.getNodeId()) {
case scalar:
ScalarNode scalarNode = (ScalarNode) node;
Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node
.getTag().equals(defaultTag));
ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple,
scalarNode.getValue(), null, null, scalarNode.getStyle());
this.emitter.emit(event);
break;
case sequence:
SequenceNode seqNode = (SequenceNode) node;
boolean implicitS = (node.getTag().equals(this.resolver.resolve(NodeId.sequence,
null, true)));
this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(),
implicitS, null, null, seqNode.getFlowStyle()));
@SuppressWarnings("unused")
int indexCounter = 0;
List<Node> list = seqNode.getValue();
for (Node item : list) {
serializeNode(item, node);
indexCounter++;
}
this.emitter.emit(new SequenceEndEvent(null, null));
break;
default:// instance of MappingNode
Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
boolean implicitM = (node.getTag().equals(implicitTag));
this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(),
implicitM, null, null, ((CollectionNode) node).getFlowStyle()));
MappingNode mnode = (MappingNode) node;
List<NodeTuple> map = mnode.getValue();
for (NodeTuple row : map) {
Node key = row.getKeyNode();
Node value = row.getValueNode();
serializeNode(key, mnode);
serializeNode(value, mnode);
}
this.emitter.emit(new MappingEndEvent(null, null));
}
}
}
示例8: serializeNode
import org.yaml.snakeyaml.nodes.ScalarNode; //导入方法依赖的package包/类
private void serializeNode(Node node, final Node parent) throws IOException {
if (node.getNodeId() == NodeId.anchor) {
node = ((AnchorNode) node).getRealNode();
}
String tAlias = this.anchors.get(node);
if (this.serializedNodes.contains(node)) {
this.emitter.emit(new AliasEvent(tAlias, null, null));
} else {
this.serializedNodes.add(node);
switch (node.getNodeId()) {
case scalar:
ScalarNode scalarNode = (ScalarNode) node;
Tag detectedTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), true);
Tag defaultTag = this.resolver.resolve(NodeId.scalar, scalarNode.getValue(), false);
ImplicitTuple tuple = new ImplicitTuple(node.getTag().equals(detectedTag), node.getTag().equals(defaultTag));
ScalarEvent event = new ScalarEvent(tAlias, node.getTag().getValue(), tuple, scalarNode.getValue(), null, null,
scalarNode.getStyle());
this.emitter.emit(event);
break;
case sequence:
SequenceNode seqNode = (SequenceNode) node;
boolean implicitS = (node.getTag().equals(this.resolver.resolve(NodeId.sequence, null, true)));
this.emitter.emit(new SequenceStartEvent(tAlias, node.getTag().getValue(), implicitS, null, null, seqNode.getFlowStyle()));
int indexCounter = 0;
List<Node> list = seqNode.getValue();
for (Node item : list) {
serializeNode(item, node);
indexCounter++;
}
this.emitter.emit(new SequenceEndEvent(null, null));
break;
default:// instance of MappingNode
Tag implicitTag = this.resolver.resolve(NodeId.mapping, null, true);
boolean implicitM = (node.getTag().equals(implicitTag));
this.emitter.emit(new MappingStartEvent(tAlias, node.getTag().getValue(), implicitM, null, null, ((CollectionNode) node)
.getFlowStyle()));
MappingNode mnode = (MappingNode) node;
List<NodeTuple> map = mnode.getValue();
for (NodeTuple row : map) {
Node key = row.getKeyNode();
Node value = row.getValueNode();
serializeNode(key, mnode);
serializeNode(value, mnode);
}
this.emitter.emit(new MappingEndEvent(null, null));
}
}
}