@Deprecated public SchemaPath(String simpleName, ExpressionPosition pos) { super(pos); this.rootSegment = new NameSegment(simpleName); }
/** * Returns {@link SchemaPath} equivalent of the specified {@link FieldPath}. */ public static SchemaPath fieldPath2SchemaPath(FieldPath fieldPath) { Stack<FieldSegment> fieldSegments = new Stack<FieldSegment>(); FieldSegment seg = fieldPath.getRootSegment(); while (seg != null) { fieldSegments.push(seg); seg = seg.getChild(); } PathSegment child = null; while (!fieldSegments.isEmpty()) { seg = fieldSegments.pop(); if (seg.isNamed()) { child = new PathSegment.NameSegment(((FieldSegment.NameSegment)seg).getName(), child); } else { child = new PathSegment.ArraySegment(((FieldSegment.IndexSegment)seg).getIndex(), child); } } return new SchemaPath((PathSegment.NameSegment)child); }
((NameSegmentContext)_localctx).seg = new NameSegment((((NameSegmentContext)_localctx).QuotedIdentifier!=null?((NameSegmentContext)_localctx).QuotedIdentifier.getText():null)); } else { ((NameSegmentContext)_localctx).seg = new NameSegment((((NameSegmentContext)_localctx).QuotedIdentifier!=null?((NameSegmentContext)_localctx).QuotedIdentifier.getText():null), (((NameSegmentContext)_localctx).s1 == null ? ((NameSegmentContext)_localctx).s2.seg : ((NameSegmentContext)_localctx).s1.seg)); ((NameSegmentContext)_localctx).seg = new NameSegment((((NameSegmentContext)_localctx).Identifier!=null?((NameSegmentContext)_localctx).Identifier.getText():null)); } else { ((NameSegmentContext)_localctx).seg = new NameSegment((((NameSegmentContext)_localctx).Identifier!=null?((NameSegmentContext)_localctx).Identifier.getText():null), (((NameSegmentContext)_localctx).s1 == null ? ((NameSegmentContext)_localctx).s2.seg : ((NameSegmentContext)_localctx).s1.seg));
public static SchemaPath getCompoundPath(String... strings) { NameSegment s = null; // loop through strings in reverse order for (int i = strings.length - 1; i >= 0; i--) { s = new NameSegment(strings[i], s); } return new SchemaPath(s); }
@Override public NameSegment cloneWithNewChild(PathSegment newChild) { NameSegment s = new NameSegment(this.path); if (getChild() != null) { s.setChild(getChild().cloneWithNewChild(newChild)); } else { s.setChild(newChild); } return s; } }
@Override public PathSegment visitInputRef(RexInputRef inputRef) { int index = inputRef.getIndex(); String name = fieldNames.get(index); RelDataTypeField field = fields.get(index); addDesiredField(name, field.getType(), inputRef); return new PathSegment.NameSegment(name); }
public FieldReference(CharSequence value, ExpressionPosition pos, boolean check) { super(new NameSegment(value), pos); if (check) { checkData(); } }
private static PathSegment convertLiteral(RexLiteral literal) { switch (literal.getType().getSqlTypeName()) { case CHAR: return new PathSegment.NameSegment(RexLiteral.stringValue(literal)); case INTEGER: return new PathSegment.ArraySegment(RexLiteral.intValue(literal)); default: return null; } }
private static PathSegment getPathSegment(NamePart n) { PathSegment child = n.hasChild() ? getPathSegment(n.getChild()) : null; if (n.getType() == Type.ARRAY) { return new ArraySegment(child); } else { return new NameSegment(n.getName(), child); } }
@Override public NameSegment clone() { NameSegment s = new NameSegment(this.path); if (getChild() != null) { s.setChild(getChild().clone()); } return s; }
private PathSegment newPath(String path, RexNode node) { PathSegment segment = new PathSegment.NameSegment(path); if (stackDepth == 0) { desiredFields.put(node, getFullPath(segment)); } return segment; }
@Deprecated public SchemaPath(String simpleName, ExpressionPosition pos) { super(pos); this.rootSegment = new NameSegment(simpleName); }
/** * Traverses path segment to extract named segments, omits all other segments (i.e. array). * Order of named segments appearance will be preserved. * * @param currentSegment current segment * @param resultingSegment resulting segment * @return named segment */ private NameSegment getUnIndexedNameSegment(PathSegment currentSegment, NameSegment resultingSegment) { if (!currentSegment.isLastPath()) { resultingSegment = getUnIndexedNameSegment(currentSegment.getChild(), resultingSegment); } if (currentSegment.isNamed()) { String path = currentSegment.getNameSegment().getPath(); return new NameSegment(path, resultingSegment); } return resultingSegment; }
public SchemaPath getChild(String childPath) { NameSegment newRoot = rootSegment.cloneWithNewChild(new NameSegment(childPath)); return new SchemaPath(newRoot); }
public FieldReference(CharSequence value, ExpressionPosition pos, boolean check) { super(new NameSegment(value), pos); if (check) { checkData(); } }
@Override public NameSegment clone() { NameSegment s = new NameSegment(this.path); if (getChild() != null) { s.setChild(getChild().clone()); } return s; }
public static SchemaPath getCompoundPath(String... strings) { NameSegment s = null; // loop through strings in reverse order for (int i = strings.length - 1; i >= 0; i--) { s = new NameSegment(strings[i], s); } return new SchemaPath(s); }
@Override public NameSegment cloneWithNewChild(PathSegment newChild) { NameSegment s = new NameSegment(this.path); if (getChild() != null) { s.setChild(getChild().cloneWithNewChild(newChild)); } else { s.setChild(newChild); } return s; } }
private static PathSegment getPathSegment(NamePart n) { PathSegment child = n.hasChild() ? getPathSegment(n.getChild()) : null; if (n.getType() == Type.ARRAY) { return new ArraySegment(child); } else { return new NameSegment(n.getName(), child); } }
@Test public void testIfMultiLevelCloneWorks() { final int levels = 10; final PathSegment segment = new PathSegment.NameSegment("test", makeArraySegment(levels, null)); final PathSegment clone = segment.clone(); assertEquals("result of clone & original segments must be identical", segment, clone); final PathSegment tail = new PathSegment.NameSegment("tail"); final PathSegment newSegment = new PathSegment.NameSegment("test", makeArraySegment(levels, tail)); final PathSegment newClone = segment.cloneWithNewChild(tail); assertEquals("result of cloneWithChild & original segment must be identical", newSegment, newClone); } }