Class AbstractPage

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) char[] pageData
      Date of page contents.
      private java.util.Map properties
      Map of all properties.
      private javax.servlet.http.HttpServletRequest request
      RequestURI of original Page.
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractPage()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addProperty​(java.lang.String name, java.lang.String value)
      Add a property to the properties list.
      boolean getBooleanProperty​(java.lang.String name)
      Get a property embedded into the Page as a boolean.
      int getContentLength()
      Length of the Page, in the format before it was parsed.
      int getIntProperty​(java.lang.String name)
      Get a property embedded into the Page as an int.
      long getLongProperty​(java.lang.String name)
      Get a property embedded into the Page as a long.
      java.util.Map getProperties()
      Get a Map representing all the properties in the Page.
      java.lang.String getProperty​(java.lang.String name)
      Get a property embedded into the Page as a String.
      java.lang.String[] getPropertyKeys()
      Get all available property keys for the Page.
      javax.servlet.http.HttpServletRequest getRequest()
      Return the request of the original page.
      java.lang.String getTitle()
      Return title of from "title" property.
      boolean isPropertySet​(java.lang.String name)
      Determine whether a property embedded into the Page has been set.
      protected static java.lang.String noNull​(java.lang.String in)
      Return String as is, or "" if null.
      void setRequest​(javax.servlet.http.HttpServletRequest request)
      Create snapshot of Request.
      abstract void writeBody​(java.io.Writer out)
      Write data of html <body> tag.
      void writePage​(java.io.Writer out)
      Write the entire contents of the Page, in the format before it was parsed, to the Writer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • properties

        private java.util.Map properties
        Map of all properties. Key is String. Value is java.util.List of multiple String values.
      • pageData

        char[] pageData
        Date of page contents.
      • request

        private javax.servlet.http.HttpServletRequest request
        RequestURI of original Page.
    • Constructor Detail

      • AbstractPage

        public AbstractPage()
    • Method Detail

      • writePage

        public void writePage​(java.io.Writer out)
                       throws java.io.IOException
        Description copied from interface: Page
        Write the entire contents of the Page, in the format before it was parsed, to the Writer.
        Specified by:
        writePage in interface Page
        Parameters:
        out - Writer to write to.
        Throws:
        java.io.IOException - Rethrown if cannot write to writer.
      • writeBody

        public abstract void writeBody​(java.io.Writer out)
                                throws java.io.IOException
        Write data of html <body> tag.

        Must be implemented. Data written should not actually contain the body tags, but all the data in between.

        Specified by:
        writeBody in interface Page
        Throws:
        java.io.IOException
      • getTitle

        public java.lang.String getTitle()
        Return title of from "title" property. Never returns null.
        Specified by:
        getTitle in interface Page
      • getContentLength

        public int getContentLength()
        Description copied from interface: Page
        Length of the Page, in the format before it was parsed.
        Specified by:
        getContentLength in interface Page
        Returns:
        Length of page data (in number of bytes).
      • getProperty

        public java.lang.String getProperty​(java.lang.String name)
        Description copied from interface: Page
        Get a property embedded into the Page as a String.
        Specified by:
        getProperty in interface Page
        Parameters:
        name - Name of property
        Returns:
        Property value
      • getIntProperty

        public int getIntProperty​(java.lang.String name)
        Description copied from interface: Page
        Get a property embedded into the Page as an int. Returns 0 if property not specified or not valid number.
        Specified by:
        getIntProperty in interface Page
        Parameters:
        name - Name of property
        Returns:
        Property value
      • getLongProperty

        public long getLongProperty​(java.lang.String name)
        Description copied from interface: Page
        Get a property embedded into the Page as a long. Returns 0L if property not specified or not valid number.
        Specified by:
        getLongProperty in interface Page
        Parameters:
        name - Name of property
        Returns:
        Property value
      • getBooleanProperty

        public boolean getBooleanProperty​(java.lang.String name)
        Description copied from interface: Page
        Get a property embedded into the Page as a boolean. Returns true if value starts with '1', 't' or 'y' (case-insensitive) - otherwise returns false.
        Specified by:
        getBooleanProperty in interface Page
        Parameters:
        name - Name of property
        Returns:
        Property value
      • isPropertySet

        public boolean isPropertySet​(java.lang.String name)
        Description copied from interface: Page
        Determine whether a property embedded into the Page has been set.
        Specified by:
        isPropertySet in interface Page
        Parameters:
        name - Name of property
        Returns:
        Whether it has been set
      • getPropertyKeys

        public java.lang.String[] getPropertyKeys()
        Description copied from interface: Page
        Get all available property keys for the Page.
        Specified by:
        getPropertyKeys in interface Page
        Returns:
        Property keys
      • getProperties

        public java.util.Map getProperties()
        Description copied from interface: Page
        Get a Map representing all the properties in the Page.
        Specified by:
        getProperties in interface Page
        Returns:
        Properties map
      • getRequest

        public javax.servlet.http.HttpServletRequest getRequest()
        Description copied from interface: Page
        Return the request of the original page.
        Specified by:
        getRequest in interface Page
        See Also:
        Page.getRequest()
      • setRequest

        public void setRequest​(javax.servlet.http.HttpServletRequest request)
        Create snapshot of Request.
        Specified by:
        setRequest in interface Page
        See Also:
        Page.getRequest()
      • addProperty

        public void addProperty​(java.lang.String name,
                                java.lang.String value)
        Add a property to the properties list.
        Specified by:
        addProperty in interface Page
        Parameters:
        name - Name of property
        value - Value of property
      • noNull

        protected static java.lang.String noNull​(java.lang.String in)
        Return String as is, or "" if null. (Prevents NullPointerExceptions)