001/*
002 * (C) Copyright 2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.platform.query.core;
023
024import org.nuxeo.common.xmap.annotation.XNode;
025import org.nuxeo.common.xmap.annotation.XObject;
026import org.nuxeo.ecm.platform.query.api.PredicateFieldDefinition;
027
028/**
029 * Field descriptor accepting a separate schema and field or a complete xpath.
030 *
031 * @author Anahide Tchertchian
032 * @since 5.4
033 */
034@XObject(value = "field")
035public class FieldDescriptor implements PredicateFieldDefinition {
036
037    @XNode("@name")
038    protected String name;
039
040    @XNode("@schema")
041    protected String schema;
042
043    @XNode("@xpath")
044    protected String xpath;
045
046    public FieldDescriptor() {
047    }
048
049    public FieldDescriptor(String schema, String name) {
050        this.name = name;
051        this.schema = schema;
052    }
053
054    public FieldDescriptor(String xpath) {
055        this.xpath = xpath;
056    }
057
058    @Override
059    public String getName() {
060        return name;
061    }
062
063    @Override
064    public String getSchema() {
065        return schema;
066    }
067
068    @Override
069    public String getXpath() {
070        return xpath;
071    }
072
073    /**
074     * @since 5.6
075     */
076    @Override
077    public FieldDescriptor clone() {
078        FieldDescriptor clone = new FieldDescriptor();
079        clone.name = name;
080        clone.schema = schema;
081        clone.xpath = xpath;
082        return clone;
083    }
084
085}