本文整理匯總了Java中org.yaml.snakeyaml.nodes.Node.isTwoStepsConstruction方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.isTwoStepsConstruction方法的具體用法?Java Node.isTwoStepsConstruction怎麽用?Java Node.isTwoStepsConstruction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.yaml.snakeyaml.nodes.Node
的用法示例。
在下文中一共展示了Node.isTwoStepsConstruction方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: constructObject
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
/**
* Construct object from the specified Node. Return existing instance if the
* node is already constructed.
*
* @param node
* Node to be constructed
* @return Java instance
*/
protected Object constructObject(Node node) {
if (constructedObjects.containsKey(node)) {
return constructedObjects.get(node);
}
if (recursiveObjects.contains(node)) {
throw new ConstructorException(null, null, "found unconstructable recursive node",
node.getStartMark());
}
recursiveObjects.add(node);
Construct constructor = getConstructor(node);
Object data = constructor.construct(node);
constructedObjects.put(node, data);
recursiveObjects.remove(node);
if (node.isTwoStepsConstruction()) {
constructor.construct2ndStep(node, data);
}
return data;
}
示例2: constructSet2ndStep
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
protected void constructSet2ndStep(MappingNode node, Set<Object> set) {
List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
for (NodeTuple tuple : nodeValue) {
Node keyNode = tuple.getKeyNode();
Object key = constructObject(keyNode);
if (key != null) {
try {
key.hashCode();// check circular dependencies
} catch (Exception e) {
throw new ConstructorException("while constructing a Set", node.getStartMark(),
"found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
}
}
if (keyNode.isTwoStepsConstruction()) {
/*
* if keyObject is created it 2 steps we should postpone putting
* it into the set because it may have different hash after
* initialization compared to clean just created one. And set of
* course does not observe value hashCode changes.
*/
sets2fill.add(0, new RecursiveTuple<Set<Object>, Object>(set, key));
} else {
set.add(key);
}
}
}
示例3: constructObject
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
/**
* Construct object from the specified Node. Return existing instance if the
* node is already constructed.
*
* @param node
* Node to be constructed
* @return Java instance
*/
protected Object constructObject(Node node) {
if (constructedObjects.containsKey(node)) {
return constructedObjects.get(node);
}
if (recursiveObjects.contains(node)) {
throw new ConstructorException(null, null, "found unconstructable recursive node",
node.getStartMark());
}
recursiveObjects.add(node);
Construct constructor = getConstructor(node);
Object data = constructor.construct(node);
constructedObjects.put(node, data);
recursiveObjects.remove(node);
if (node.isTwoStepsConstruction()) {
constructor.construct2ndStep(node, data);
}
return data;
}
示例4: constructSet2ndStep
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
protected void constructSet2ndStep(MappingNode node, Set<Object> set) {
List<NodeTuple> nodeValue = node.getValue();
for (NodeTuple tuple : nodeValue) {
Node keyNode = tuple.getKeyNode();
Object key = constructObject(keyNode);
if (key != null) {
try {
key.hashCode();// check circular dependencies
} catch (Exception e) {
throw new ConstructorException("while constructing a Set", node.getStartMark(),
"found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
}
}
if (keyNode.isTwoStepsConstruction()) {
/*
* if keyObject is created it 2 steps we should postpone putting
* it into the set because it may have different hash after
* initialization compared to clean just created one. And set of
* course does not observe value hashCode changes.
*/
sets2fill.add(0, new RecursiveTuple<Set<Object>, Object>(set, key));
} else {
set.add(key);
}
}
}
示例5: constructMapping2ndStep
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
List<NodeTuple> nodeValue = (List<NodeTuple>) node.getValue();
for (NodeTuple tuple : nodeValue) {
Node keyNode = tuple.getKeyNode();
Node valueNode = tuple.getValueNode();
Object key = constructObject(keyNode);
if (key != null) {
try {
key.hashCode();// check circular dependencies
} catch (Exception e) {
throw new ConstructorException("while constructing a mapping",
node.getStartMark(), "found unacceptable key " + key, tuple
.getKeyNode().getStartMark(), e);
}
}
Object value = constructObject(valueNode);
if (keyNode.isTwoStepsConstruction()) {
/*
* if keyObject is created it 2 steps we should postpone putting
* it in map because it may have different hash after
* initialization compared to clean just created one. And map of
* course does not observe key hashCode changes.
*/
maps2fill.add(0,
new RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>(
mapping, new RecursiveTuple<Object, Object>(key, value)));
} else {
mapping.put(key, value);
}
}
}
示例6: construct2ndStep
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
/**
* Fail with a reminder to provide the seconds step for a recursive
* structure
*
* @see Construct#construct2ndStep(Node,
* Object)
*/
public void construct2ndStep(Node node, Object data) {
if (node.isTwoStepsConstruction()) {
throw new IllegalStateException("Not Implemented in " + getClass().getName());
} else {
throw new YAMLException("Unexpected recursive structure for Node: " + node);
}
}
示例7: construct
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
public Object construct(Node node) {
if (node.isTwoStepsConstruction()) {
return createDefaultSet();
} else {
return constructSet((MappingNode) node);
}
}
示例8: construct2ndStep
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void construct2ndStep(Node node, Object object) {
if (node.isTwoStepsConstruction()) {
constructSet2ndStep((MappingNode) node, (Set<Object>) object);
} else {
throw new YAMLException("Unexpected recursive set structure. Node: " + node);
}
}
示例9: construct
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
public Object construct(Node node) {
if (node.isTwoStepsConstruction()) {
return createDefaultMap();
} else {
return constructMapping((MappingNode) node);
}
}
示例10: constructMapping2ndStep
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
List<NodeTuple> nodeValue = node.getValue();
for (NodeTuple tuple : nodeValue) {
Node keyNode = tuple.getKeyNode();
Node valueNode = tuple.getValueNode();
Object key = constructObject(keyNode);
if (key != null) {
try {
key.hashCode();// check circular dependencies
} catch (Exception e) {
throw new ConstructorException("while constructing a mapping",
node.getStartMark(), "found unacceptable key " + key,
tuple.getKeyNode().getStartMark(), e);
}
}
Object value = constructObject(valueNode);
if (keyNode.isTwoStepsConstruction()) {
/*
* if keyObject is created it 2 steps we should postpone putting
* it in map because it may have different hash after
* initialization compared to clean just created one. And map of
* course does not observe key hashCode changes.
*/
maps2fill.add(0,
new RecursiveTuple<Map<Object, Object>, RecursiveTuple<Object, Object>>(
mapping, new RecursiveTuple<Object, Object>(key, value)));
} else {
mapping.put(key, value);
}
}
}
示例11: construct2ndStep
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
/**
* Fail with a reminder to provide the seconds step for a recursive
* structure
*
* @see org.yaml.snakeyaml.constructor.Construct#construct2ndStep(org.yaml.snakeyaml.nodes.Node,
* java.lang.Object)
*/
public void construct2ndStep(Node node, Object data) {
if (node.isTwoStepsConstruction()) {
throw new IllegalStateException("Not Implemented in " + getClass().getName());
} else {
throw new YAMLException("Unexpected recursive structure for Node: " + node);
}
}
示例12: construct
import org.yaml.snakeyaml.nodes.Node; //導入方法依賴的package包/類
/**
* Construct JavaBean. If type safe collections are used please look at
* <code>TypeDescription</code>.
*
* @param node
* node where the keys are property names (they can only be
* <code>String</code>s) and values are objects to be created
* @return constructed JavaBean
*/
public Object construct(Node node) {
MappingNode mnode = (MappingNode) node;
if (Properties.class.isAssignableFrom(node.getType())) {
Properties properties = new Properties();
if (!node.isTwoStepsConstruction()) {
constructMapping2ndStep(mnode, properties);
} else {
throw new YAMLException("Properties must not be recursive.");
}
return properties;
} else if (SortedMap.class.isAssignableFrom(node.getType())) {
SortedMap<Object, Object> map = new TreeMap<Object, Object>();
if (!node.isTwoStepsConstruction()) {
constructMapping2ndStep(mnode, map);
}
return map;
} else if (Map.class.isAssignableFrom(node.getType())) {
if (node.isTwoStepsConstruction()) {
return createDefaultMap();
} else {
return constructMapping(mnode);
}
} else if (SortedSet.class.isAssignableFrom(node.getType())) {
SortedSet<Object> set = new TreeSet<Object>();
// XXX why this is not used ?
// if (!node.isTwoStepsConstruction()) {
constructSet2ndStep(mnode, set);
// }
return set;
} else if (Collection.class.isAssignableFrom(node.getType())) {
if (node.isTwoStepsConstruction()) {
return createDefaultSet();
} else {
return constructSet(mnode);
}
} else {
if (node.isTwoStepsConstruction()) {
return createEmptyJavaBean(mnode);
} else {
return constructJavaBean2ndStep(mnode, createEmptyJavaBean(mnode));
}
}
}