001/*
002 * (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.query.core;
021
022import org.nuxeo.common.xmap.annotation.XNode;
023import org.nuxeo.common.xmap.annotation.XObject;
024import org.nuxeo.ecm.platform.query.api.PredicateFieldDefinition;
025
026/**
027 * Field descriptor accepting a separate schema and field or a complete xpath.
028 *
029 * @author Anahide Tchertchian
030 * @since 5.4
031 */
032@XObject(value = "field")
033public class FieldDescriptor implements PredicateFieldDefinition {
034
035    @XNode("@name")
036    protected String name;
037
038    @XNode("@schema")
039    protected String schema;
040
041    @XNode("@xpath")
042    protected String xpath;
043
044    public FieldDescriptor() {
045    }
046
047    public FieldDescriptor(String schema, String name) {
048        this.name = name;
049        this.schema = schema;
050    }
051
052    public FieldDescriptor(String xpath) {
053        this.xpath = xpath;
054    }
055
056    @Override
057    public String getName() {
058        return name;
059    }
060
061    @Override
062    public String getSchema() {
063        return schema;
064    }
065
066    @Override
067    public String getXpath() {
068        return xpath;
069    }
070
071    /**
072     * @since 5.6
073     */
074    @Override
075    public FieldDescriptor clone() {
076        FieldDescriptor clone = new FieldDescriptor();
077        clone.name = name;
078        clone.schema = schema;
079        clone.xpath = xpath;
080        return clone;
081    }
082
083}