Class SSIProcessor
java.lang.Object
org.apache.catalina.ssi.SSIProcessor
The entry point to SSI processing. This class does the actual parsing, delegating to the SSIMediator, SSICommand, and
SSIExternalResolver as necessary.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanWhether exec commands are allowed.protected static final StringThe end patternprotected static final StringThe start patternprotected final HashMap<String, SSICommand> Map of registered SSI command names to their handlers.protected final intDebug level for SSI processing.protected final SSIExternalResolverExternal resolver for file and variable access. -
Constructor Summary
ConstructorsConstructorDescriptionSSIProcessor(SSIExternalResolver ssiExternalResolver, int debug, boolean allowExec) Creates a new SSI processor with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRegisters all built-in SSI commands.voidaddCommand(String name, SSICommand command) Registers a custom SSI command handler.protected booleanCompares a substring of the buffer with the given command string.protected booleanisQuote(char c) Checks if the given character is a quote character.protected booleanisSpace(char c) Checks if the given character is a whitespace character.protected String[]parseParamNames(StringBuilder cmd, int start) Parse a StringBuilder and take out the param type token.protected String[]parseParamValues(StringBuilder cmd, int start, int count) Parse a StringBuilder and take out the param token.longprocess(Reader reader, long lastModifiedDate, PrintWriter writer) Process a file with server-side commands, reading from reader and writing the processed version to writer.
-
Field Details
-
COMMAND_START
-
COMMAND_END
-
ssiExternalResolver
External resolver for file and variable access. -
commands
Map of registered SSI command names to their handlers. -
debug
protected final int debugDebug level for SSI processing. -
allowExec
protected final boolean allowExecWhether exec commands are allowed.
-
-
Constructor Details
-
SSIProcessor
Creates a new SSI processor with the given configuration.- Parameters:
ssiExternalResolver- the external resolver for file/variable accessdebug- the debug levelallowExec- whether exec commands are allowed
-
-
Method Details
-
addBuiltinCommands
protected void addBuiltinCommands()Registers all built-in SSI commands. -
addCommand
Registers a custom SSI command handler.- Parameters:
name- the command namecommand- the command handler
-
process
Process a file with server-side commands, reading from reader and writing the processed version to writer. NOTE: We really should be doing this in a streaming way rather than converting it to an array first.- Parameters:
reader- the reader to read the file containing SSIs fromlastModifiedDate- resource last modification datewriter- the writer to write the file with the SSIs processed.- Returns:
- the most current modified date resulting from any SSI commands
- Throws:
IOException- when things go horribly awry. Should be unlikely since the SSICommand usually catches 'normal' IOExceptions.
-
parseParamNames
Parse a StringBuilder and take out the param type token. Called fromrequestHandler- Parameters:
cmd- a value of type 'StringBuilder'start- index on which parsing will start- Returns:
- an array with the parameter names
-
parseParamValues
Parse a StringBuilder and take out the param token. Called fromrequestHandler- Parameters:
cmd- a value of type 'StringBuilder'start- index on which parsing will startcount- number of values which should be parsed- Returns:
- an array with the parameter values
-
charCmp
-
isSpace
protected boolean isSpace(char c) Checks if the given character is a whitespace character.- Parameters:
c- the character to check- Returns:
- true if the character is a space, tab, newline, or carriage return
-
isQuote
protected boolean isQuote(char c) Checks if the given character is a quote character.- Parameters:
c- the character to check- Returns:
- true if the character is a single, double, or backtick quote
-