001/*
002 * (C) Copyright 2006-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: DocumentViewCodec.java 29556 2008-01-23 00:59:39Z jcarsique $
020 */
021
022package org.nuxeo.ecm.platform.url.codec.api;
023
024import org.nuxeo.ecm.platform.url.api.DocumentView;
025import org.nuxeo.ecm.platform.url.api.DocumentViewCodecManager;
026
027public interface DocumentViewCodec {
028
029    String getPrefix();
030
031    void setPrefix(String prefix);
032
033    /**
034     * Returns true if this codec should apply when iterating over codecs to find a matching one.
035     *
036     * @see DocumentViewCodecManager#getUrlFromDocumentView(DocumentView, boolean, String)
037     */
038    boolean handleDocumentView(DocumentView docView);
039
040    /**
041     * Returns true if this codec should apply when iterating over codecs to find a matching one.
042     *
043     * @see DocumentViewCodecManager#getDocumentViewFromUrl(String, boolean, String)
044     */
045    boolean handleUrl(String url);
046
047    /**
048     * Extracts the document view from given url.
049     * <p>
050     * The url is partial: it does not hold the context path information (server:port/nuxeo).
051     *
052     * @param url the partial url to redirect to.
053     * @return a document view instance.
054     */
055    DocumentView getDocumentViewFromUrl(String url);
056
057    /**
058     * Builds an url from the given document view.
059     * <p>
060     * The url should be partial: it should not hold the context path information (server:port/nuxeo).
061     *
062     * @param docView
063     * @return
064     */
065    String getUrlFromDocumentView(DocumentView docView);
066
067}