⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wikicontext.java

📁 jspwiki source code,jspwiki source code
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     *  @see com.ecyrd.jspwiki.tags.InsertPageTag     *  @see com.ecyrd.jspwiki.parser.JSPWikiMarkupParser     */    public WikiPage getRealPage()    {        return m_realPage;    }    /**     *  Figure out to which page we are really going to.  Considers     *  special page names from the jspwiki.properties, and possible aliases.     *  This method forwards requests to     *  {@link com.ecyrd.jspwiki.ui.CommandResolver#getSpecialPageReference(String)}.     *  @return A complete URL to the new page to redirect to     *  @since 2.2     */    public String getRedirectURL()    {        String pagename = m_page.getName();        String redirURL = null;        redirURL = m_engine.getCommandResolver().getSpecialPageReference( pagename );        if( redirURL == null )        {            String alias = (String)m_page.getAttribute( WikiPage.ALIAS );            if( alias != null )            {                redirURL = getViewURL( alias );            }            else            {                redirURL = (String)m_page.getAttribute( WikiPage.REDIRECT );            }        }        return redirURL;    }    /**     *  Returns the handling engine.     *     *  @return The wikiengine owning this context.     */    public WikiEngine getEngine()    {        return m_engine;    }    /**     *  Returns the page that is being handled.     *     *  @return the page which was fetched.     */    public WikiPage getPage()    {        return m_page;    }    /**     *  Sets the page that is being handled.     *     *  @param page The wikipage     *  @since 2.1.37.     */    public void setPage( WikiPage page )    {        m_page = page;        updateCommand( m_command.getRequestContext() );    }    /**     *  Returns the request context.     *  @return The name of the request context (e.g. VIEW).     */    public String getRequestContext()    {        return m_command.getRequestContext();    }    /**     *  Sets the request context.  See above for the different     *  request contexts (VIEW, EDIT, etc.)     *     *  @param arg The request context (one of the predefined contexts.)     */    public void setRequestContext( String arg )    {        updateCommand( arg );    }    /**     * {@inheritDoc}     * @see com.ecyrd.jspwiki.ui.Command#getTarget()     */    public Object getTarget()    {        return m_command.getTarget();    }    /**     * {@inheritDoc}     * @see com.ecyrd.jspwiki.ui.Command#getURLPattern()     */    public String getURLPattern()    {        return m_command.getURLPattern();    }    /**     *  Gets a previously set variable.     *     *  @param key The variable name.     *  @return The variable contents.     */    public Object getVariable( String key )    {        return m_variableMap.get( key );    }    /**     *  Sets a variable.  The variable is valid while the WikiContext is valid,     *  i.e. while page processing continues.  The variable data is discarded     *  once the page processing is finished.     *     *  @param key The variable name.     *  @param data The variable value.     */    public void setVariable( String key, Object data )    {        m_variableMap.put( key, data );        updateCommand( m_command.getRequestContext() );    }    /**     *  This method will safely return any HTTP parameters that     *  might have been defined.  You should use this method instead     *  of peeking directly into the result of getHttpRequest(), since     *  this method is smart enough to do all of the right things,     *  figure out UTF-8 encoded parameters, etc.     *     *  @since 2.0.13.     *  @param paramName Parameter name to look for.     *  @return HTTP parameter, or null, if no such parameter existed.     */    public String getHttpParameter( String paramName )    {        String result = null;        if( m_request != null )        {            result = m_request.getParameter( paramName );        }        return result;    }    /**     *  If the request did originate from a HTTP request,     *  then the HTTP request can be fetched here.  However, it the request     *  did NOT originate from a HTTP request, then this method will     *  return null, and YOU SHOULD CHECK FOR IT!     *     *  @return Null, if no HTTP request was done.     *  @since 2.0.13.     */    public HttpServletRequest getHttpRequest()    {        return m_request;    }    /**     *  Sets the template to be used for this request.     *     *  @param dir The template name     *  @since 2.1.15.     */    public void setTemplate( String dir )    {        m_template = dir;    }    /**     * Returns the target of this wiki context: a page, group name or JSP. If     * the associated Command is a PageCommand, this method returns the page's     * name. Otherwise, this method delegates to the associated Command's     * {@link com.ecyrd.jspwiki.ui.Command#getName()} method. Calling classes     * can rely on the results of this method for looking up canonically-correct     * page or group names. Because it does not automatically assume that the     * wiki context is a PageCommand, calling this method is inherently safer     * than calling <code>getPage().getName()</code>.     * @return the name of the target of this wiki context     * @see com.ecyrd.jspwiki.ui.PageCommand#getName()     * @see com.ecyrd.jspwiki.ui.GroupCommand#getName()     */    public String getName()    {        if ( m_command instanceof PageCommand )        {            return m_page != null ? m_page.getName() : "<no page>";        }        return m_command.getName();    }    /**     *  Gets the template that is to be used throughout this request.     *  @since 2.1.15.     *  @return template name     */    public String getTemplate()    {        return m_template;    }    /**     *  Convenience method that gets the current user. Delegates the     *  lookup to the WikiSession associated with this WikiContect.     *  May return null, in case the current     *  user has not yet been determined; or this is an internal system.     *  If the WikiSession has not been set, <em>always</em> returns null.     *     *  @return The current user; or maybe null in case of internal calls.     */    public Principal getCurrentUser()    {        if (m_session == null)        {            // This shouldn't happen, really...            return WikiPrincipal.GUEST;        }        return m_session.getUserPrincipal();    }    /**     *  A shortcut to generate a VIEW url.     *     *  @param page The page to which to link.     *  @return An URL to the page.  This honours the current absolute/relative setting.     */    public String getViewURL( String page )    {        return getURL( VIEW, page, null );    }    /**     *  Creates an URL for the given request context.     *     *  @param context e.g. WikiContext.EDIT     *  @param page The page to which to link     *  @return An URL to the page, honours the absolute/relative setting in jspwiki.properties     */    public String getURL( String context,                          String page )    {        return getURL( context, page, null );    }    /**     *  Returns an URL from a page. It this WikiContext instance was constructed     *  with an actual HttpServletRequest, we will attempt to construct the     *  URL using HttpUtil, which preserves the HTTPS portion if it was used.     *     *  @param context The request context (e.g. WikiContext.UPLOAD)     *  @param page    The page to which to link     *  @param params  A list of parameters, separated with "&amp;"     *     *  @return An URL to the given context and page.     */    public String getURL( String context,                          String page,                          String params )    {        boolean absolute = "absolute".equals(m_engine.getVariable( this, WikiEngine.PROP_REFSTYLE ));        // FIXME: is rather slow        return m_engine.getURL( context,                                page,                                params,                                absolute );    }    /**     * Returns the Command associated with this WikiContext.     * @return the command     */    public Command getCommand()    {        return m_command;    }    /**     *  Returns a shallow clone of the WikiContext.     *     *  @since 2.1.37.     *  @return A shallow clone of the WikiContext     */    public Object clone()    {        try        {            // super.clone() must always be called to make sure that inherited objects            // get the right type            WikiContext copy = (WikiContext)super.clone();            copy.m_engine = m_engine;            copy.m_command = m_command;            copy.m_template       = m_template;            copy.m_variableMap    = m_variableMap;            copy.m_request        = m_request;            copy.m_session        = m_session;            copy.m_page           = m_page;            copy.m_realPage       = m_realPage;            return copy;        }        catch( CloneNotSupportedException e ){} // Never happens        return null;    }    /**     *  Creates a deep clone of the WikiContext.  This is useful when you want     *  to be sure that you don't accidentally mess with page attributes, etc.     *       *  @since  2.8.0     *  @return A deep clone of the WikiContext.     */    public WikiContext deepClone()    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -