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