Package cat.inspiracio.orange
Class Template
- java.lang.Object
-
- cat.inspiracio.orange.Template
-
public abstract class Template extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.servlet.ServletContextapplicationprotected javax.servlet.ServletConfigconfigprotected Throwableexceptionprotected javax.servlet.jsp.JspWriteroutprotected Templatepageprotected javax.servlet.jsp.PageContextpageContextprotected javax.servlet.http.HttpServletRequestrequestprotected javax.servlet.http.HttpServletResponseresponseprotected javax.servlet.http.HttpSessionsession
-
Constructor Summary
Constructors Constructor Description Template(javax.servlet.jsp.PageContext pc)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidattribute(String key, boolean b)Boolean attribute: write the key if the value is true.protected voidattribute(String key, Object v)Attribute: If the value is empty, writes just the key, otherwise key and value, quoted.protected Stringescape(int i)Escapes an int for html: just convert it to String.protected Stringescape(Object o)escape for html: ≤ & Called from generated write().protected voidforward(String u)Forward.protected Stringquote(Object o)Quotes a value so that it can be an attribute's value.protected voidredirect(String location)Sends a temporary redirect response to the client using the specified redirect location URL.abstract voidrender()This is the method that template must implement.protected Stringunquote(Object o)Escapes " by " .Templatewrite(int i)Writes an int to out.Templatewrite(Object o)Writes an object to out.Templatewrite(String s)Writes a String to out.Templatewriteln()Write a string to output.Templatewriteln(String s)Write a string to output.
-
-
-
Field Detail
-
request
protected javax.servlet.http.HttpServletRequest request
-
response
protected javax.servlet.http.HttpServletResponse response
-
pageContext
protected javax.servlet.jsp.PageContext pageContext
-
session
protected javax.servlet.http.HttpSession session
-
application
protected javax.servlet.ServletContext application
-
out
protected javax.servlet.jsp.JspWriter out
-
config
protected javax.servlet.ServletConfig config
-
page
protected Template page
-
exception
protected Throwable exception
-
-
Method Detail
-
render
public abstract void render() throws ExceptionThis is the method that template must implement.- Throws:
Exception- Java-islands threw an exception.
-
redirect
protected void redirect(String location) throws IOException
Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to. After redirect, template execution continues. There will be no more output to the response, but maybe there are other effects. In order to avoid it, you can follow it by if(true) return; Uses status code 302.- Parameters:
location- the redirect location URL, can be relative- Throws:
IOException- If an input or output exception occursIllegalStateException- If the response was committed or if a partial URL is given and cannot be converted into a valid URL
-
forward
protected void forward(String u) throws javax.servlet.ServletException, IOException
Forward. After forward, template execution continues. There will be no more output to the response, but maybe there are other effects. In order to avoid it, you can follow it by if(true) return;- Parameters:
u- the forward location URL, can be relative- Throws:
javax.servlet.ServletException- if the target resource throws this exceptionIOException- if the target resource throws this exceptionIllegalStateException- If the response was committed or if a partial URL is given and cannot be converted into a valid URL
-
quote
protected final String quote(Object o)
Quotes a value so that it can be an attribute's value. Escapes " by " and encloses in ". For null returns quote(""). Called from generated write().- Parameters:
o- object- Returns:
- quoted
-
unquote
protected final String unquote(Object o)
Escapes " by " . For null returns "". Called from generated write().- Parameters:
o- Object- Returns:
- ...
-
escape
protected final String escape(Object o)
escape for html: ≤ & Called from generated write().- Parameters:
o- Object- Returns:
- escaped
-
escape
protected final String escape(int i)
Escapes an int for html: just convert it to String. Called from generated write().- Parameters:
i- int- Returns:
- escaped
-
attribute
protected final void attribute(String key, boolean b) throws IOException
Boolean attribute: write the key if the value is true. Called from generated write().- Parameters:
key- keyb- value- Throws:
IOException- couldn't write
-
attribute
protected final void attribute(String key, Object v) throws IOException
Attribute: If the value is empty, writes just the key, otherwise key and value, quoted.- Parameters:
key- keyv- value- Throws:
IOException- bad IO
-
write
public final Template write(int i) throws IOException
Writes an int to out. Called from generated write().- Parameters:
i- ...- Returns:
- same template
- Throws:
IOException- ...
-
write
public final Template write(Object o) throws IOException
Writes an object to out. Does nothing if the object is empty (null or its toString() is null or "").- Parameters:
o- ...- Returns:
- same template
- Throws:
IOException- ...
-
write
public final Template write(String s) throws IOException
Writes a String to out. Does nothing if the String is null or "".- Parameters:
s- ...- Returns:
- same template
- Throws:
IOException- ...
-
writeln
public final Template writeln() throws IOException
Write a string to output.- Returns:
- same template
- Throws:
IOException- ...
-
writeln
public final Template writeln(String s) throws IOException
Write a string to output.- Parameters:
s- ...- Returns:
- same template
- Throws:
IOException- ...
-
-