本文整理汇总了Java中org.yaml.snakeyaml.nodes.NodeId.scalar方法的典型用法代码示例。如果您正苦于以下问题:Java NodeId.scalar方法的具体用法?Java NodeId.scalar怎么用?Java NodeId.scalar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.yaml.snakeyaml.nodes.NodeId
的用法示例。
在下文中一共展示了NodeId.scalar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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);
}
示例3: 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);
}
示例4: construct
import org.yaml.snakeyaml.nodes.NodeId; //导入方法依赖的package包/类
@Override
public Object construct(Node node) {
if (node.getNodeId() == NodeId.scalar) {
ScalarNode n = (ScalarNode) node;
String value = n.getValue();
int i = 3;
if (value.length() != 0) {
i = Integer.parseInt(value);
}
return new BeanHolder(new Bean1(i));
} else {
return new BeanHolder();
}
}
示例5: isReference
import org.yaml.snakeyaml.nodes.NodeId; //导入方法依赖的package包/类
/**
* Returns true if the argument can be identified as a JSON reference node.
*
* @param tuple
* @return true if a reference node
*/
public static boolean isReference(NodeTuple tuple) {
if (tuple.getKeyNode().getNodeId() == NodeId.scalar) {
String value = ((ScalarNode) tuple.getKeyNode()).getValue();
return JsonReference.PROPERTY.equals(value) && tuple.getValueNode().getNodeId() == NodeId.scalar;
}
return false;
}
示例6: 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
*/
@Nullable
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, @Nullable Object propertyValue, @Nullable Tag customTag)
{
ScalarNode nodeKey = (ScalarNode) this.representData(property.getName());
// the first occurrence of the node must keep the tag
boolean hasAlias = this.representedObjects.containsKey(propertyValue);
Node nodeValue = this.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);
}
}
}
}
this.checkGlobalTag(property, nodeValue, propertyValue);
}
}
}
return new NodeTuple(nodeKey, nodeValue);
}