001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (C) Alkacon Software (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.db;
029
030import org.opencms.gwt.shared.alias.CmsAliasMode;
031import org.opencms.util.CmsUUID;
032
033/**
034 * This class represents an alias which does not just map a fixed path to a fixed resource, but instead uses
035 * a regular expression substitution to determine the target path.<p>
036 */
037public class CmsRewriteAlias {
038
039    /** The id of the alias. */
040    private CmsUUID m_id;
041
042    /** The alias mode. */
043    private CmsAliasMode m_mode;
044
045    /** The regular expression string used for matching. */
046    private String m_patternString;
047
048    /** The replacement string used when the regular expression matches. */
049    private String m_replacementString;
050
051    /** The site root inside which this alias should be valid. */
052    private String m_siteRoot;
053
054    /**
055     * Creates a new instance.<p>
056     *
057     * @param id the id of the alias
058     * @param siteRoot the site root inside which the alias is valid
059     * @param patternString the regular expression used for matching the URI
060     * @param replacementString the replacement string used when the URI is matched
061     * @param mode the alias mode
062     */
063    public CmsRewriteAlias(
064        CmsUUID id,
065        String siteRoot,
066        String patternString,
067        String replacementString,
068        CmsAliasMode mode) {
069
070        m_id = id;
071        m_patternString = patternString;
072        m_replacementString = replacementString;
073        m_siteRoot = siteRoot;
074        m_mode = mode;
075    }
076
077    /**
078     * Gets the id of the alias.<p>
079     *
080     * @return the id of the alias
081     */
082    public CmsUUID getId() {
083
084        return m_id;
085    }
086
087    /**
088     * Gets the alias mode.<p>
089     *
090     * @return the alias mode
091     */
092    public CmsAliasMode getMode() {
093
094        return m_mode;
095    }
096
097    /**
098     * Gets the regular expression string.<p>
099     *
100     * @return the regular expression string
101     */
102    public String getPatternString() {
103
104        return m_patternString;
105    }
106
107    /**
108     * Gets the string used to replace the string matching the regex.<p>
109     *
110     * @return the replacement string
111     */
112    public String getReplacementString() {
113
114        return m_replacementString;
115    }
116
117    /**
118     * Gets the root of the site in which this alias is valid.<p>
119     *
120     * @return the site root
121     */
122    public String getSiteRoot() {
123
124        return m_siteRoot;
125    }
126
127}