1 /*
2 * ModeShape (http://www.modeshape.org)
3 * See the COPYRIGHT.txt file distributed with this work for information
4 * regarding copyright ownership. Some portions may be licensed
5 * to Red Hat, Inc. under one or more contributor license agreements.
6 * See the AUTHORS.txt file in the distribution for a full listing of
7 * individual contributors.
8 *
9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10 * is licensed to you under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
13 *
14 * ModeShape is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this software; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23 */
24 package org.modeshape.jcr.query.qom;
25
26 import org.modeshape.graph.query.model.Column;
27 import org.modeshape.graph.query.model.SelectorName;
28
29 /**
30 * An implementation of JCR's {@link javax.jcr.query.qom.Column} and specialization of the Graph API's {@link Column}.
31 */
32 public class JcrColumn extends Column implements javax.jcr.query.qom.Column {
33
34 private static final long serialVersionUID = 1L;
35
36 /**
37 * Include a column for each of the single-valued, accessible properties on the node identified by the selector.
38 *
39 * @param selectorName the selector name
40 */
41 public JcrColumn( SelectorName selectorName ) {
42 super(selectorName);
43 }
44
45 /**
46 * A column with the given name representing the named property on the node identified by the selector.
47 *
48 * @param selectorName the selector name
49 * @param propertyName the name of the property
50 * @param columnName the name of the column
51 */
52 public JcrColumn( SelectorName selectorName,
53 String propertyName,
54 String columnName ) {
55 super(selectorName, propertyName, columnName);
56 }
57
58 /**
59 * {@inheritDoc}
60 *
61 * @see javax.jcr.query.qom.Column#getSelectorName()
62 */
63 @Override
64 public String getSelectorName() {
65 return selectorName().name();
66 }
67
68 /**
69 * {@inheritDoc}
70 *
71 * @see javax.jcr.query.qom.Column#getPropertyName()
72 */
73 @Override
74 public String getPropertyName() {
75 return propertyName();
76 }
77
78 /**
79 * {@inheritDoc}
80 *
81 * @see javax.jcr.query.qom.Column#getColumnName()
82 */
83 @Override
84 public String getColumnName() {
85 return columnName();
86 }
87
88 /**
89 * Create a copy of this Column except that uses the supplied selector name instead.
90 *
91 * @param newSelectorName the new selector name
92 * @return a new Column with the supplied selector name and the property and column names from this object; never null
93 * @throws IllegalArgumentException if the supplied selector name is null
94 */
95 @Override
96 public Column with( SelectorName newSelectorName ) {
97 return new JcrColumn(newSelectorName, getPropertyName(), getColumnName());
98 }
99 }