001/*
002 * (C) Copyright 2006-2011 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.core.api;
023
024import java.io.Serializable;
025
026/**
027 * A reference to a core document.
028 * <p>
029 * The following two types of references are supported:
030 * <ul>
031 * <li> <code>ID</code> references. Refers to the core document by its UUID. See {@link IdRef}.
032 * <li> <code>PATH</code> references. Refers to the core document by its path. See {@link PathRef}.
033 * </ul>
034 *
035 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
036 */
037public interface DocumentRef extends Serializable {
038
039    // the document is specified by its UUID
040    int ID = 1;
041
042    // the document is specified by its path
043    int PATH = 2;
044
045    // the document is referenced by it's repository, principal and UUID
046    int INSTANCE = 3;
047    /**
048     * Gets the type of the reference.
049     *
050     * @return the type of the reference
051     */
052    int type();
053
054    /**
055     * Gets the reference value.
056     * <p>
057     * For an ID reference, this is the document UUID.
058     * <p>
059     * For a PATH reference, this is the document path.
060     * <p>
061     * For an INSTANCE reference this is the document itself.
062     *
063     * @return the reference value
064     */
065    Object reference();
066
067}