@Override public Object construct(Node node) { throw new ConstructorException(null, null, "could not determine a constructor for the tag " + node.getTag(), node.getStartMark()); } }
public AnchorNode(Node realNode) { super(realNode.getTag(), realNode.getStartMark(), realNode.getEndMark()); this.realNode = realNode; }
public Object construct(Node node) { try { return getConstructor(node).construct(node); } catch (ConstructorException e) { throw e; } catch (Exception e) { throw new ConstructorException(null, null, "Can't construct a java object for " + node.getTag() + "; exception=" + e.getMessage(), node.getStartMark(), e); } }
public void construct2ndStep(Node node, Object object) { try { getConstructor(node).construct2ndStep(node, object); } catch (Exception e) { throw new ConstructorException( null, null, "Can't construct a second step for a java object for " + node.getTag() + "; exception=" + e.getMessage(), node.getStartMark(), e); } } }
protected Object constructObjectNoCheck(Node 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 = (constructedObjects.containsKey(node)) ? constructedObjects.get(node) : constructor.construct(node); finalizeConstruction(node, data); constructedObjects.put(node, data); recursiveObjects.remove(node); if (node.isTwoStepsConstruction()) { constructor.construct2ndStep(node, data); } return data; }
throw new ConstructorException("while constructing pairs", node.getStartMark(), "expected a sequence, but found " + node.getNodeId(), node.getStartMark()); for (Node subnode : snode.getValue()) { if (!(subnode instanceof MappingNode)) { throw new ConstructorException("while constructingpairs", node.getStartMark(), "expected a mapping of length 1, but found " + subnode.getNodeId(), subnode.getStartMark()); throw new ConstructorException("while constructing pairs", node.getStartMark(), "expected a single mapping item, but found " + mnode.getValue().size() + " items",
if (!(node instanceof SequenceNode)) { throw new ConstructorException("while constructing an ordered map", node.getStartMark(), "expected a sequence, but found " + node.getNodeId(), node.getStartMark()); if (!(subnode instanceof MappingNode)) { throw new ConstructorException("while constructing an ordered map", node.getStartMark(), "expected a mapping of length 1, but found " + subnode.getNodeId(), subnode.getStartMark()); node.getStartMark(), "expected a single mapping item, but found " + mnode.getValue().size() + " items", mnode.getStartMark());
throw new ConstructorException("while constructing a mapping", node.getStartMark(), "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e); if (!isAllowDuplicateKeys()) { throw new DuplicateKeyException(node.getStartMark(), key, tuple.getKeyNode().getStartMark());
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); } } }
private Origin getOrigin(Node node) { Mark mark = node.getStartMark(); Location location = new Location(mark.getLine(), mark.getColumn()); return new TextResourceOrigin(OriginTrackedYamlLoader.this.resource, location); }
"expected a mapping for merging, but found " + subnode.getNodeId(), subnode.getStartMark()); "expected a mapping or list of mappings for merging, but found " + valueNode.getNodeId(), valueNode.getStartMark());
throw new ConstructorException("while constructing a mapping", node.getStartMark(), "found unacceptable key " + key, tuple.getKeyNode().getStartMark(), e);
/** * Reads a document from a source that contains only one document. * <p> * If the stream contains more than one document an exception is thrown. * </p> * * @return The root node of the document or <code>null</code> if no document * is available. */ public Node getSingleNode() { // Drop the STREAM-START event. parser.getEvent(); // Compose a document if the stream is not empty. Node document = null; if (!parser.checkEvent(Event.ID.StreamEnd)) { document = getNode(); } // Ensure that the stream contains no more documents. if (!parser.checkEvent(Event.ID.StreamEnd)) { Event event = parser.getEvent(); throw new ComposerException("expected a single document in the stream", document.getStartMark(), "but found another document", event.getStartMark()); } // Drop the STREAM-END event. parser.getEvent(); return document; }
throw new ConstructorException( "Cannot create property=" + key + " for JavaBean=" + object, node.getStartMark(), e.getMessage(), valueNode.getStartMark(), e);
private int indexStart(Node node, boolean defaultIsYamlEnd) { if (node==null) return defaultIsYamlEnd ? yaml.length() : 0; return index(node.getStartMark()); } private int indexEnd(Node node, boolean defaultIsYamlEnd) {
private int getStartColumnOfThis() { if (includeKey && focusTuple!=null) return focusTuple.getKeyNode().getStartMark().getColumn(); return focus.getStartMark().getColumn(); } public int getEndOfThis() {
public static ValidationResult createWarnResult(String message, Node node) { return new ValidationResult(Level.WARN, message, node.getStartMark().getLine(), node.getStartMark().getColumn(), node.getEndMark().getColumn()); }
public Object construct(Node node) { switch (node.getTag().getValue()) { case "!include": // TODO use implicit resolver (Resolver.addImplicitResolver) to convert "<include: path.dig" to new Tag("!include")? return "!include:" + java.util.UUID.randomUUID().toString(); } throw new TagException( "could not determine a constructor for the tag " + node.getTag(), node.getStartMark()); }
public static ValidationResult createWarnResult(String message, Node node) { return new ValidationResult(Level.WARN, message, node.getStartMark().getLine(), node.getStartMark().getColumn(), node.getEndMark().getColumn()); }
public static ReconcileProblem problem(ProblemType problemType, String msg, Node node) { int start = node.getStartMark().getIndex(); int end = node.getEndMark().getIndex(); return new ReconcileProblemImpl(problemType, msg, start, end-start); }