This project has retired. For details please refer to its Attic page.
ColumnReference xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.server.support.query;
20  
21  import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
22  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
23  
24  public class ColumnReference extends CmisSelector {
25  
26      private final String qualifier;      // type qualifier coming from query statement
27      private final String propQueryName;  // property query name coming from query statement
28  
29      // The following fields are set when the types are resolved:
30      private String propertyId;
31      private TypeDefinition typeDef;
32  
33      public ColumnReference(String qualifier, String propQueryName) {
34          this.qualifier = qualifier;
35          this.propQueryName = propQueryName;
36      }
37  
38      public ColumnReference(String propQueryName) {
39          this.qualifier = null;
40          this.propQueryName = propQueryName;
41      }
42  
43      public String getQualifier() {
44          return qualifier;
45      }
46  
47      /** @deprecated use {@link #getQualifier} instead. */
48      @Deprecated
49      public String getTypeQueryName() {
50          return getQualifier();
51      }
52  
53      public String getPropertyQueryName() {
54          return propQueryName;
55      }
56  
57      @Override
58      public String getName() {
59          return propQueryName;
60      }
61  
62      public void setTypeDefinition(String propertyId, TypeDefinition typeDef) {
63          this.typeDef = typeDef;
64          this.propertyId = propertyId;
65      }
66  
67      public TypeDefinition getTypeDefinition() {
68          return typeDef;
69      }
70  
71      public PropertyDefinition<?> getPropertyDefinition() {
72          return typeDef.getPropertyDefinitions().get(getPropertyId());
73      }
74  
75      public String getPropertyId() {
76          return propertyId;
77      }
78  
79      @Override
80      public String toString() {
81          return "ColumnReference("
82                  + (qualifier == null ? "" : qualifier + ".")
83                  + propQueryName + (aliasName == null ? "" : " AS " + aliasName)
84                  + ")";
85      }
86  }