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 * <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 016 * 017 * $Id: AbstractDocumentViewCodec.java 29556 2008-01-23 00:59:39Z jcarsique $ 018 */ 019 020package org.nuxeo.ecm.platform.url.service; 021 022import org.nuxeo.ecm.platform.url.api.DocumentView; 023import org.nuxeo.ecm.platform.url.codec.api.DocumentViewCodec; 024 025/** 026 * Abstract implementation for codecs. 027 * <p> 028 * Implements methods that are not likely to be customized except for optimization. 029 * 030 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 031 */ 032public abstract class AbstractDocumentViewCodec implements DocumentViewCodec { 033 034 protected String prefix; 035 036 public String getPrefix() { 037 return prefix; 038 } 039 040 public void setPrefix(String prefix) { 041 this.prefix = prefix; 042 } 043 044 public boolean handleDocumentView(DocumentView docView) { 045 String url = getUrlFromDocumentView(docView); 046 return url != null; 047 } 048 049 public boolean handleUrl(String url) { 050 DocumentView docView = getDocumentViewFromUrl(url); 051 return docView != null; 052 } 053 054}