private String getPartentPath() { int idx = includeStack.peek().getIncludeName().lastIndexOf("/") + 1; return includeStack.peek().getIncludeName().substring(0, idx); }
private String getPartentPath() { return getPartentPath(includeStack.peek().getIncludeName()); }
public String getIncludeName() { if (contextPath != null && contextPath.size() > 1) { return contextPath.peek().getIncludeName(); } return null; }
public String getIncludeName() { if (contextPath != null && contextPath.size() > 1) { return contextPath.peek().getIncludeName(); } return null; }
/** * Calculates the relative path of an include applied tag with respect * to the current context * * e.g.: * context: a/b/c/x.raml * tag: a/b/c/d/y.raml * result: d/y.raml * * @param tag include applied tag * @return the relative path part of the tag */ public String resolveRelativePath(Tag tag) { if (tag == null || !tag.startsWith(INCLUDE_APPLIED_TAG)) { throw new IllegalArgumentException("Tag must be an include applied"); } String partentPath = getPartentPath(); String includePath = new IncludeInfo(tag).getIncludeName(); if (includePath.startsWith(partentPath)) { includePath = includePath.substring(partentPath.length()); } return includePath; }
/** * @return true if two mapping nodes in the same file * have the same start mark index */ private boolean checkLoop(Node node) { if (node.getStartMark() == null) { return false; } String index = contextPath.peek().getIncludeName() + node.getStartMark().getIndex(); if (loopDetector.contains(index)) { return true; } loopDetector.push(index); return false; }
/** * @return true if two mapping nodes in the same file * have the same start mark index */ private boolean checkLoop(Node node) { if (node.getStartMark() == null) { return false; } String index = contextPath.peek().getIncludeName() + node.getStartMark().getIndex(); if (loopDetector.contains(index)) { return true; } loopDetector.push(index); return false; }