本文整理汇总了Java中org.yaml.snakeyaml.nodes.NodeId类的典型用法代码示例。如果您正苦于以下问题:Java NodeId类的具体用法?Java NodeId怎么用?Java NodeId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeId类属于org.yaml.snakeyaml.nodes包,在下文中一共展示了NodeId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SafeConstructor
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
public SafeConstructor() {
this.yamlConstructors.put(Tag.NULL, new ConstructYamlNull());
this.yamlConstructors.put(Tag.BOOL, new ConstructYamlBool());
this.yamlConstructors.put(Tag.INT, new ConstructYamlInt());
this.yamlConstructors.put(Tag.FLOAT, new ConstructYamlFloat());
this.yamlConstructors.put(Tag.BINARY, new ConstructYamlBinary());
this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructYamlTimestamp());
this.yamlConstructors.put(Tag.OMAP, new ConstructYamlOmap());
this.yamlConstructors.put(Tag.PAIRS, new ConstructYamlPairs());
this.yamlConstructors.put(Tag.SET, new ConstructYamlSet());
this.yamlConstructors.put(Tag.STR, new ConstructYamlStr());
this.yamlConstructors.put(Tag.SEQ, new ConstructYamlSeq());
this.yamlConstructors.put(Tag.MAP, new ConstructYamlMap());
this.yamlConstructors.put(null, undefinedConstructor);
this.yamlClassConstructors.put(NodeId.scalar, undefinedConstructor);
this.yamlClassConstructors.put(NodeId.sequence, undefinedConstructor);
this.yamlClassConstructors.put(NodeId.mapping, undefinedConstructor);
}
示例2: composeScalarNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
protected Node composeScalarNode(String anchor) {
ScalarEvent ev = (ScalarEvent) parser.getEvent();
String tag = ev.getTag();
boolean resolved = false;
Tag nodeTag;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.scalar, ev.getValue(), ev.getImplicit()
.canOmitTagInPlainScalar());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
Node node = new ScalarNode(nodeTag, resolved, ev.getValue(), ev.getStartMark(),
ev.getEndMark(), ev.getStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
return node;
}
示例3: composeSequenceNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
protected Node composeSequenceNode(String anchor) {
SequenceStartEvent startEvent = (SequenceStartEvent) parser.getEvent();
String tag = startEvent.getTag();
Tag nodeTag;
boolean resolved = false;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.sequence, null, startEvent.getImplicit());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
final ArrayList<Node> children = new ArrayList<Node>();
SequenceNode node = new SequenceNode(nodeTag, resolved, children,
startEvent.getStartMark(), null, startEvent.getFlowStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
while (!parser.checkEvent(Event.ID.SequenceEnd)) {
children.add(composeNode(node));
}
Event endEvent = parser.getEvent();
node.setEndMark(endEvent.getEndMark());
return node;
}
示例4: composeMappingNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
protected Node composeMappingNode(String anchor) {
MappingStartEvent startEvent = (MappingStartEvent) parser.getEvent();
String tag = startEvent.getTag();
Tag nodeTag;
boolean resolved = false;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.mapping, null, startEvent.getImplicit());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
final List<NodeTuple> children = new ArrayList<NodeTuple>();
MappingNode node = new MappingNode(nodeTag, resolved, children, startEvent.getStartMark(),
null, startEvent.getFlowStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
while (!parser.checkEvent(Event.ID.MappingEnd)) {
composeMappingChildren(children, node);
}
Event endEvent = parser.getEvent();
node.setEndMark(endEvent.getEndMark());
return node;
}
示例5: composeScalarNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
protected Node composeScalarNode(String anchor) {
ScalarEvent ev = (ScalarEvent) parser.getEvent();
String tag = ev.getTag();
boolean resolved = false;
Tag nodeTag;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.scalar, ev.getValue(),
ev.getImplicit().canOmitTagInPlainScalar());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
Node node = new ScalarNode(nodeTag, resolved, ev.getValue(), ev.getStartMark(),
ev.getEndMark(), ev.getStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
return node;
}
示例6: composeSequenceNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
protected Node composeSequenceNode(String anchor) {
SequenceStartEvent startEvent = (SequenceStartEvent) parser.getEvent();
String tag = startEvent.getTag();
Tag nodeTag;
boolean resolved = false;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.sequence, null, startEvent.getImplicit());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
final ArrayList<Node> children = new ArrayList<Node>();
SequenceNode node = new SequenceNode(nodeTag, resolved, children, startEvent.getStartMark(),
null, startEvent.getFlowStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
while (!parser.checkEvent(Event.ID.SequenceEnd)) {
children.add(composeNode(node));
}
Event endEvent = parser.getEvent();
node.setEndMark(endEvent.getEndMark());
return node;
}
示例7: newYaml
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
private static Yaml newYaml() {
return new Yaml(new Constructor(),
new Representer(),
new DumperOptions(),
new Resolver() {
@Override
public Tag resolve(NodeId kind, String value, boolean implicit) {
if (value != null) {
if (value.equalsIgnoreCase("on") ||
value.equalsIgnoreCase("off") ||
value.equalsIgnoreCase("yes") ||
value.equalsIgnoreCase("no")) {
return Tag.STR;
}
}
return super.resolve(kind, value, implicit);
}
});
}
示例8: lookAhead
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
@Override
protected void lookAhead(Lexer baseLexer) {
super.lookAhead(baseLexer);
if (getTokenType() == YamlTokenTypes.YAML_Scalar) {
Tag tag = resolver.resolve(NodeId.scalar, getTokenText().trim(), true);
if (tag.equals(Tag.BOOL)) replaceCachedType(0, YamlTokenTypes.YAML_Tag_BOOL);
else if (tag.equals(Tag.INT)) replaceCachedType(0, YamlTokenTypes.YAML_Tag_INT);
else if (tag.equals(Tag.FLOAT)) replaceCachedType(0, YamlTokenTypes.YAML_Tag_FLOAT);
else if (tag.equals(Tag.NULL)) replaceCachedType(0, YamlTokenTypes.YAML_Tag_NULL);
else if (tag.equals(Tag.TIMESTAMP)) replaceCachedType(0, YamlTokenTypes.YAML_Tag_TIMESTAMP);
if (baseLexer.getTokenType() == YamlTokenTypes.YAML_Value) {
replaceCachedType(0, YamlTokenTypes.YAML_Key);
}
}
}
示例9: composeScalarNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
private Node composeScalarNode(String anchor) {
ScalarEvent ev = (ScalarEvent) parser.getEvent();
String tag = ev.getTag();
boolean resolved = false;
Tag nodeTag;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.scalar, ev.getValue(), ev.getImplicit()
.canOmitTagInPlainScalar());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
Node node = new ScalarNode(nodeTag, resolved, ev.getValue(), ev.getStartMark(),
ev.getEndMark(), ev.getStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
return node;
}
示例10: composeSequenceNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
private Node composeSequenceNode(String anchor) {
SequenceStartEvent startEvent = (SequenceStartEvent) parser.getEvent();
String tag = startEvent.getTag();
Tag nodeTag;
boolean resolved = false;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.sequence, null, startEvent.getImplicit());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
final ArrayList<Node> children = new ArrayList<Node>();
SequenceNode node = new SequenceNode(nodeTag, resolved, children,
startEvent.getStartMark(), null, startEvent.getFlowStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
while (!parser.checkEvent(Event.ID.SequenceEnd)) {
children.add(composeNode(node));
}
Event endEvent = parser.getEvent();
node.setEndMark(endEvent.getEndMark());
return node;
}
示例11: representJavaBeanProperty
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
@Override // Skip null values for configuration generating
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object value, Tag customTag) {
if (value != null) {
NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, value, customTag);
Node valueNode = tuple.getValueNode();
// Avoid using tags for enums
if (customTag == null && valueNode.getNodeId() == NodeId.scalar && value instanceof Enum<?>) {
valueNode.setTag(Tag.STR);
}
return tuple;
} else {
return null;
}
}
示例12: composeScalarNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
private Node composeScalarNode(final String anchor) {
ScalarEvent ev = (ScalarEvent) parser.getEvent();
String tag = ev.getTag();
boolean resolved = false;
Tag nodeTag;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.scalar, ev.getValue(), ev.getImplicit().canOmitTagInPlainScalar());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
Node node = new ScalarNode(nodeTag, resolved, ev.getValue(), ev.getStartMark(), ev.getEndMark(), ev.getStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
return node;
}
示例13: composeSequenceNode
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
private Node composeSequenceNode(final String anchor) {
SequenceStartEvent startEvent = (SequenceStartEvent) parser.getEvent();
String tag = startEvent.getTag();
Tag nodeTag;
boolean resolved = false;
if (tag == null || tag.equals("!")) {
nodeTag = resolver.resolve(NodeId.sequence, null, startEvent.getImplicit());
resolved = true;
} else {
nodeTag = new Tag(tag);
}
final ArrayList<Node> children = new ArrayList<Node>();
SequenceNode node = new SequenceNode(nodeTag, resolved, children, startEvent.getStartMark(), null, startEvent.getFlowStyle());
if (anchor != null) {
anchors.put(anchor, node);
}
int index = 0;
while (!parser.checkEvent(Event.ID.SequenceEnd)) {
children.add(composeNode(node));
index++;
}
Event endEvent = parser.getEvent();
node.setEndMark(endEvent.getEndMark());
return node;
}
示例14: SafeConstructor
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
public SafeConstructor() {
this.yamlConstructors.put(Tag.NULL, new ConstructYamlNull());
this.yamlConstructors.put(Tag.BOOL, new ConstructYamlBool());
this.yamlConstructors.put(Tag.INT, new ConstructYamlInt());
this.yamlConstructors.put(Tag.FLOAT, new ConstructYamlFloat());
this.yamlConstructors.put(Tag.BINARY, new ConstructYamlBinary());
this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructYamlTimestamp());
this.yamlConstructors.put(Tag.OMAP, new ConstructYamlOmap());
this.yamlConstructors.put(Tag.PAIRS, new ConstructYamlPairs());
this.yamlConstructors.put(Tag.SET, new ConstructYamlSet());
this.yamlConstructors.put(Tag.STR, new ConstructYamlStr());
this.yamlConstructors.put(Tag.SEQ, new ConstructYamlSeq());
this.yamlConstructors.put(Tag.MAP, new ConstructYamlMap());
this.yamlConstructors.put(null, undefinedConstructor);
this.yamlClassConstructors.put(NodeId.scalar, undefinedConstructor);
this.yamlClassConstructors.put(NodeId.sequence, undefinedConstructor);
this.yamlClassConstructors.put(NodeId.mapping, undefinedConstructor);
}
示例15: representJavaBeanProperty
import org.yaml.snakeyaml.nodes.NodeId; //导入依赖的package包/类
/**
* Represent one JavaBean property.
*
* @param javaBean
* - the instance to be represented
* @param property
* - the property of the instance
* @param propertyValue
* - value to be represented
* @param customTag
* - user defined Tag
* @return NodeTuple to be used in a MappingNode. Return null to skip the
* property
*/
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
Object propertyValue, Tag customTag) {
ScalarNode nodeKey = (ScalarNode) representData(property.getName());
// the first occurrence of the node must keep the tag
boolean hasAlias = this.representedObjects.containsKey(propertyValue);
Node nodeValue = representData(propertyValue);
if (propertyValue != null && !hasAlias) {
NodeId nodeId = nodeValue.getNodeId();
if (customTag == null) {
if (nodeId == NodeId.scalar) {
if (propertyValue instanceof Enum<?>) {
nodeValue.setTag(Tag.STR);
}
} else {
if (nodeId == NodeId.mapping) {
if (property.getType() == propertyValue.getClass()) {
if (!(propertyValue instanceof Map<?, ?>)) {
if (!nodeValue.getTag().equals(Tag.SET)) {
nodeValue.setTag(Tag.MAP);
}
}
}
}
checkGlobalTag(property, nodeValue, propertyValue);
}
}
}
return new NodeTuple(nodeKey, nodeValue);
}