@Override public int hashCode() { return getMapping().hashCode(); }
@Override public int compareTo(MappingNode target) { return this.getMapping().compareTo(target.getMapping()); }
public MappingNode getChild(String mapping) { MappingNode sibling = this.leftMostChild; while (sibling != null) { if (sibling.getMapping().getDefinition().equals(mapping)) { return sibling; } else { sibling = sibling.sibling; } } return null; }
private int countRegexChildren(MappingNode curNode) { int ammountOfRegexChildren = 0; MappingNode child = curNode.leftMostChild; while (child != null) { if (child.getMapping().getParameterName() != null) { ammountOfRegexChildren++; } child = child.sibling; } return ammountOfRegexChildren; }
public void linkAsChild(final MappingNode child) { if (this.leftMostChild == null) { this.leftMostChild = child; } else { MappingNode prev = null; MappingNode position = this.leftMostChild; while (true) { if (position == null) { prev.sibling = child; break; } int c = child.getMapping().compareTo(position.getMapping()); if (c < 0) { child.sibling = position; if (prev == null) { this.leftMostChild = child; } else { prev.sibling = child; } break; } else { prev = position; position = position.sibling; } } } }
/** * 检查整个树的状况,尽可能报告可能存在的问题 * * @param tree * @param parent * @param prefix */ private void check(MappingNode tree, MappingNode parent, String prefix) { MappingNode child = parent.getLeftMostChild(); MappingNode sibling = null; while (child != null) { if (sibling != null) { if (child.compareTo(sibling) == 0) { logger.error("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'; here is the mapping tree, " + "you can find the conflict in it:\n" + PrinteHelper.list(tree)); throw new IllegalArgumentException("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'"); } } check(tree, child, prefix + child.getMapping().getDefinition()); sibling = child; child = child.getSibling(); } } }
last = curNode.getMapping().match(remaining); if (last != null && /*只对常量匹配的作判断*/last.getParameterName() == null) {
@Override public int hashCode() { return getMapping().hashCode(); }
@Override public int compareTo(MappingNode target) { return this.getMapping().compareTo(target.getMapping()); }
private int countRegexChildren(MappingNode curNode) { int ammountOfRegexChildren = 0; MappingNode child = curNode.leftMostChild; while (child != null) { if (child.getMapping().getParameterName() != null) { ammountOfRegexChildren++; } child = child.sibling; } return ammountOfRegexChildren; }
public MappingNode getChild(String mapping) { MappingNode sibling = this.leftMostChild; while (sibling != null) { if (sibling.getMapping().getDefinition().equals(mapping)) { return sibling; } else { sibling = sibling.sibling; } } return null; }
public void linkAsChild(final MappingNode child) { if (this.leftMostChild == null) { this.leftMostChild = child; } else { MappingNode prev = null; MappingNode position = this.leftMostChild; while (true) { if (position == null) { prev.sibling = child; break; } int c = child.getMapping().compareTo(position.getMapping()); if (c < 0) { child.sibling = position; if (prev == null) { this.leftMostChild = child; } else { prev.sibling = child; } break; } else { prev = position; position = position.sibling; } } } }
/** * 检查整个树的状况,尽可能报告可能存在的问题 * * @param tree * @param parent * @param prefix */ private void check(MappingNode tree, MappingNode parent, String prefix) { MappingNode child = parent.getLeftMostChild(); MappingNode sibling = null; while (child != null) { if (sibling != null) { if (child.compareTo(sibling) == 0) { logger.error("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'; here is the mapping tree, " + "you can find the conflict in it:\n" + PrinteHelper.list(tree)); throw new IllegalArgumentException("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'"); } } check(tree, child, prefix + child.getMapping().getDefinition()); sibling = child; child = child.getSibling(); } } }
last = curNode.getMapping().match(remaining); if (last != null && /*只对常量匹配的作判断*/last.getParameterName() == null) {