/** * Convenience method that creates a selector name object using the supplied string. * * @param name the name of the selector; may not be null * @return the selector name; never null */ protected SelectorName selector( String name ) { return new SelectorName(name.trim()); }
/** * Convenience method that creates a selector name object using the supplied string. * * @param name the name of the selector; may not be null * @return the selector name; never null */ protected SelectorName selector( String name ) { return new SelectorName(name.trim()); }
/** * Make sure the column on the named table has extra columns that can be used without validation error. * * @param tableName the name of the table * @return this builder, for convenience in method chaining; never null * @throws IllegalArgumentException if the table name is null or empty, or the table does not exist */ public Builder markExtraColumns( String tableName ) { CheckArg.isNotEmpty(tableName, "tableName"); tablesOrViewsWithExtraColumns.add(new SelectorName(tableName)); return this; }
protected MutableTable( String name, List<Column> columns, boolean extraColumns ) { this.name = new SelectorName(name); this.columns.addAll(columns); for (Column column : columns) { Column existing = this.columnsByName.put(column.getName(), column); assert existing == null; } }
protected MutableTable( String name, List<Column> columns, boolean extraColumns ) { this.name = new SelectorName(name); this.columns.addAll(columns); for (Column column : columns) { Column existing = this.columnsByName.put(column.getName(), column); assert existing == null; } }
@Override public String toString() { return "(" + Visitors.readable(new PropertyValue(new SelectorName(selectorName), propertyName)) + ")"; } }
/** * Make sure the column on the named table has extra columns that can be used without validation error. * * @param tableName the name of the table * @return this builder, for convenience in method chaining; never null * @throws IllegalArgumentException if the table name is null or empty, or the table does not exist */ public Builder markExtraColumns( String tableName ) { CheckArg.isNotEmpty(tableName, "tableName"); tablesOrViewsWithExtraColumns.add(new SelectorName(tableName)); return this; }
@Override public String toString() { return "(" + Visitors.readable(new PropertyValue(new SelectorName(selectorName), propertyName)) + ")"; } }
protected SelectorName parseSelectorName( TokenStream tokens, TypeSystem typeSystem ) { return new SelectorName(parseName(tokens, typeSystem)); }
protected SelectorName selector( String name ) { return new SelectorName(name); } }
protected Column column( String table, String columnName ) { if (multipleSelectors) { return new Column(new SelectorName(table), columnName, table + "." + columnName); } return new Column(new SelectorName(table), columnName, columnName); }
protected Column column( String table, String columnName, String alias ) { return new Column(new SelectorName(table), columnName, alias); }
protected Column column( String table, String columnName, String alias ) { return new Column(new SelectorName(table), columnName, alias); } }
/** * Returns this selector in qualified form (see #3.2.5 of the JCR spec) * * @param nameFactory a {@link org.modeshape.jcr.value.NameFactory} instance; may not be null * @return a {@link org.modeshape.jcr.query.model.SelectorName} instance for which the name is always in qualified form; never null */ public SelectorName qualifiedForm(NameFactory nameFactory) { if (expandedForm) { return new SelectorName(nameFactory.create(this.name).getString(nameFactory.getNamespaceRegistry())); } return this; }
/** * Returns this selector in qualified form (see #3.2.5 of the JCR spec) * * @param nameFactory a {@link org.modeshape.jcr.value.NameFactory} instance; may not be null * @return a {@link org.modeshape.jcr.query.model.SelectorName} instance for which the name is always in qualified form; never null */ public SelectorName qualifiedForm(NameFactory nameFactory) { if (expandedForm) { return new SelectorName(nameFactory.create(this.name).getString(nameFactory.getNamespaceRegistry())); } return this; }
protected DynamicOperand score( String... tableNames ) { DynamicOperand operand = null; for (String tableName : tableNames) { DynamicOperand right = new FullTextSearchScore(new SelectorName(tableName)); if (operand == null) operand = right; else operand = new ArithmeticOperand(operand, ArithmeticOperator.ADD, right); } assert operand != null; return operand; }
protected void assertSelectors( PlanNode node, String... selectors ) { Set<SelectorName> selectorSet = new HashSet<SelectorName>(); for (String selectorName : selectors) { selectorSet.add(new SelectorName(selectorName)); } assertThat("Selectors don't match", node.getSelectors(), is(selectorSet)); }
protected void assertSortOrderBy( PlanNode sortNode, String... selectors ) { List<SelectorName> expected = new ArrayList<SelectorName>(selectors.length); for (String selectorName : selectors) { expected.add(new SelectorName(selectorName)); } List<SelectorName> actualSortedBy = sortNode.getPropertyAsList(Property.SORT_ORDER_BY, SelectorName.class); assertThat("Sort node order-by doesn't match selector name list", actualSortedBy, is(expected)); } }
@Test public void shouldSupportPropertyExistanceConstraint() { PropertyExistence pe = new PropertyExistence(new SelectorName("test"), def2.getName()); validate(pe, "key1", "key2", "key3", "key4", "key5", "key6"); }
@Test public void shouldNotAddNullSelectorNames() { Collection<SelectorName> names = Collections.singletonList(null); node.addSelectors(names); assertThat(node.getSelectors().isEmpty(), is(true)); node.addSelector(null); assertThat(node.getSelectors().isEmpty(), is(true)); SelectorName name = new SelectorName("something"); node.addSelector(name, null); assertThat(node.getSelectors().size(), is(1)); assertThat(node.getSelectors().contains(name), is(true)); }