Class AttributeNames
An attribute name may carry a relation qualifier separated by a .,
for example Users.id. The qualifier is everything up to and including
the last .; the column name is everything after it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisPathInto(String name, String column) Whethernameis a path intocolumn— dotted, withcolumnas its head:skills.yearsis a path intoskills, whileskillsandOrders.skillsare not.static StringReturns the head of an attribute name — everything before the first., or the whole name when it has none:location.cityandlocation.geo.latboth yieldlocation.static StringqualifierOf(String name) Returns the relation qualifier of an attribute name, ornullif it carries none:rooms.nameyieldsrooms, and a barenameyieldsnull.static StringstripQualifier(String name) Strips any relation qualifier from an attribute name, returning the bare column name:Users.idyieldsid, and a bareidis returned unchanged.
-
Method Details
-
stripQualifier
Strips any relation qualifier from an attribute name, returning the bare column name:Users.idyieldsid, and a bareidis returned unchanged. The qualifier is everything up to and including the last..- Parameters:
name- a possibly-qualified attribute name; must not be null- Returns:
- the unqualified column name
-
qualifierOf
Returns the relation qualifier of an attribute name, ornullif it carries none:rooms.nameyieldsrooms, and a barenameyieldsnull. The qualifier is everything up to (but not including) the last..- Parameters:
name- a possibly-qualified attribute name; must not be null- Returns:
- the relation qualifier, or
nullif the name is unqualified
-
pathHead
Returns the head of an attribute name — everything before the first., or the whole name when it has none:location.cityandlocation.geo.latboth yieldlocation.This is the column a name denotes under the struct-path reading, and it is the other half of a genuine ambiguity. A dotted name may be a relation-qualified reference (
Orders.amount— the columnamountcoming fromOrders, whose column part is the tail, seestripQualifier(java.lang.String)) or a path into a nested column (location.city— the fieldcityof the columnlocation, whose column part is the head). The two readings are told apart against a schema, bySchema.resolvePath, and never by the spelling alone.Reach for this wherever a decision is about which column a reference touches — a rewrite that moves an operator past the column, say. Using the qualifier reading alone there is the mistake it exists to prevent: the head of
skills.yearsisskills, and a rule that only inspected the tailyearswould conclude the reference has nothing to do with askillscolumn.- Parameters:
name- a possibly-qualified or dotted attribute name; must not be null- Returns:
- the name's head — the column it names as a path
-
isPathInto
Whethernameis a path intocolumn— dotted, withcolumnas its head:skills.yearsis a path intoskills, whileskillsandOrders.skillsare not.- Parameters:
name- a possibly-qualified or dotted attribute name; must not be nullcolumn- the column to test against; must not be null- Returns:
- whether the name reads a field beneath that column
-