/** * 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); }
((ArraySegmentContext)_localctx).seg = new ArraySegment((((ArraySegmentContext)_localctx).Number!=null?((ArraySegmentContext)_localctx).Number.getText():null)); } else { ((ArraySegmentContext)_localctx).seg = new ArraySegment((((ArraySegmentContext)_localctx).Number!=null?((ArraySegmentContext)_localctx).Number.getText():null), (((ArraySegmentContext)_localctx).s1 == null ? ((ArraySegmentContext)_localctx).s2.seg : ((ArraySegmentContext)_localctx).s1.seg));
/** * 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); }
((ArraySegmentContext)_localctx).seg = new ArraySegment((((ArraySegmentContext)_localctx).Number!=null?((ArraySegmentContext)_localctx).Number.getText():null)); } else { ((ArraySegmentContext)_localctx).seg = new ArraySegment((((ArraySegmentContext)_localctx).Number!=null?((ArraySegmentContext)_localctx).Number.getText():null), (((ArraySegmentContext)_localctx).s1 == null ? ((ArraySegmentContext)_localctx).s2.seg : ((ArraySegmentContext)_localctx).s1.seg));
/** * Converts literal into path segment based on its type. * For unsupported types, returns null. * * @param literal literal * @return new path segment, null otherwise */ public 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; } } }
public SchemaPath getChild(int index) { NameSegment newRoot = rootSegment.cloneWithNewChild(new ArraySegment(index)); return new SchemaPath(newRoot); }
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 PathSegment clone() { PathSegment seg = index < 0 ? new ArraySegment((PathSegment) null) : new ArraySegment(index); if (getChild() != null) { seg.setChild(getChild().clone()); } return seg; }
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; } }
@Override public ArraySegment cloneWithNewChild(PathSegment newChild) { ArraySegment seg = index < 0 ? new ArraySegment((PathSegment) null) : new ArraySegment(index); if (getChild() != null) { seg.setChild(getChild().cloneWithNewChild(newChild)); } else { seg.setChild(newChild); } return seg; } }
public SchemaPath getChild(int index) { NameSegment newRoot = rootSegment.cloneWithNewChild(new ArraySegment(index)); return new SchemaPath(newRoot); }
@Override public ArraySegment cloneWithNewChild(PathSegment newChild) { ArraySegment seg = index < 0 ? new ArraySegment((PathSegment) null) : new ArraySegment(index); if (getChild() != null) { seg.setChild(getChild().cloneWithNewChild(newChild)); } else { seg.setChild(newChild); } return seg; } }
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 PathSegment clone() { PathSegment seg = index < 0 ? new ArraySegment((PathSegment) null) : new ArraySegment(index); if (getChild() != null) { seg.setChild(getChild().clone()); } return seg; }
protected PathSegment makeArraySegment(final int len, final PathSegment tail) { PathSegment node = tail; for (int i = 0; i < len; i++) { node = new PathSegment.ArraySegment(node); } return node; }