Top Inners Fields Constructors Methods
io.undertow.annotationprocessor

public abstract Class AbstractParserGenerator

extends Object
Class Inheritance
Known Direct Subclasses
io.undertow.annotationprocessor.RequestParserGenerator, io.undertow.annotationprocessor.ResponseParserGenerator
Imports
org.jboss.classfilewriter.AccessFlag, .ClassFile, .ClassMethod, org.jboss.classfilewriter.code.BranchEnd, .CodeAttribute, .CodeLocation, .TableSwitchBuilder, org.jboss.classfilewriter.util.DescriptorUtils, java.lang.reflect.Modifier, java.nio.ByteBuffer, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .LinkedHashMap, .LinkedHashSet, .IdentityHashMap, .List, .Map, .Set, java.util.concurrent.atomic.AtomicInteger, .AtomicReference

Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
AbstractParserGenerator.CustomStateMachine

A class that separates out the different behaviour of the three state machines (VERB, VERSION and HEADER)

private static class

Field Summary

Modifier and TypeField and Description
public static final String
protected static final int
public static final String
private static final int
protected final String
protected static final int
private final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
protected static final int
public static final String
public static final String
private final String
public static final int
protected static final int
protected final String
private final String
public static final int
protected String
protected static final int
protected static final int
protected static final int
protected static final int

Constructor Summary

AccessConstructor and Description
public
AbstractParserGenerator(final String parseStateClass, final String resultClass, final String constructorDescriptor, String existingClassName)

Method Summary

Modifier and TypeMethod and Description
private static void
addStates(final AbstractParserGenerator.State initial, final String value, final List<AbstractParserGenerator.State> allStates)

private static void
addStates(final AbstractParserGenerator.State current, final String value, final int i, final List<AbstractParserGenerator.State> allStates)

private void
protected void
createStateMachine(final String[] originalItems, final String className, final ClassFile file, final ClassMethod sctor, final AtomicInteger fieldCounter, final String methodName, final AbstractParserGenerator.CustomStateMachine stateMachine, boolean expectNewline)

protected abstract void
createStateMachines(String[] httpVerbs, String[] httpVersions, String[] standardHeaders, String className, ClassFile file, ClassMethod sctor, AtomicInteger fieldCounter)

public byte[]
createTokenizer(final String[] httpVerbs, String[] httpVersions, String[] standardHeaders)

private void
private void
invokeState(final String className, final ClassFile file, final CodeAttribute c, final AbstractParserGenerator.State currentState, final AbstractParserGenerator.State initialState, final CodeLocation noStateStart, final CodeLocation prefixStart, final CodeLocation returnIncompleteCode, final CodeLocation returnCompleteCode, final AbstractParserGenerator.CustomStateMachine stateMachine, boolean expectNewline)

private void
private void
setupStateNo(final AbstractParserGenerator.State state, final AtomicInteger stateCounter, final AtomicInteger fieldCounter)

private static void
stateNotFound(final CodeAttribute c, final TableSwitchBuilder builder)

Throws an exception when an invalid state is hit in a tableswitch

private void
tokenDone(final CodeAttribute c, final CodeLocation returnCode, final AbstractParserGenerator.CustomStateMachine stateMachine)

private void
writeStateMachine(final String className, final ClassFile file, final CodeAttribute c, final AbstractParserGenerator.State initial, final List<AbstractParserGenerator.State> allStates, int noStates, final AbstractParserGenerator.CustomStateMachine stateMachine, boolean expectNewline)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BAD_REQUEST_EXCEPTIONback to summary
public static final String BAD_REQUEST_EXCEPTION
BYTE_BUFFER_VARback to summary
protected static final int BYTE_BUFFER_VAR
CLASS_NAME_SUFFIXback to summary
public static final String CLASS_NAME_SUFFIX
CONSTRUCTOR_HTTP_STRING_MAP_VARback to summary
private static final int CONSTRUCTOR_HTTP_STRING_MAP_VAR
constructorDescriptorback to summary
protected final String constructorDescriptor
CURRENT_STATE_VARback to summary
protected static final int CURRENT_STATE_VAR
existingClassNameback to summary
private final String existingClassName
HANDLE_AFTER_VERSIONback to summary
public static final String HANDLE_AFTER_VERSION
HANDLE_HEADERback to summary
public static final String HANDLE_HEADER
HANDLE_HEADER_VALUEback to summary
public static final String HANDLE_HEADER_VALUE
HANDLE_HTTP_VERBback to summary
public static final String HANDLE_HTTP_VERB
HANDLE_HTTP_VERSIONback to summary
public static final String HANDLE_HTTP_VERSION
HANDLE_PATHback to summary
public static final String HANDLE_PATH
HTTP_RESULTback to summary
protected static final int HTTP_RESULT
HTTP_STRING_CLASSback to summary
public static final String HTTP_STRING_CLASS
HTTP_STRING_DESCRIPTORback to summary
public static final String HTTP_STRING_DESCRIPTOR
httpExchangeDescriptorback to summary
private final String httpExchangeDescriptor
NO_STATEback to summary
public static final int NO_STATE
PARSE_STATE_VARback to summary
protected static final int PARSE_STATE_VAR
parseStateClassback to summary
protected final String parseStateClass
parseStateDescriptorback to summary
private final String parseStateDescriptor
PREFIX_MATCHback to summary
public static final int PREFIX_MATCH
resultClassback to summary
protected String resultClass
STATE_CURRENT_BYTES_VARback to summary
protected static final int STATE_CURRENT_BYTES_VAR
STATE_CURRENT_VARback to summary
protected static final int STATE_CURRENT_VAR
STATE_POS_VARback to summary
protected static final int STATE_POS_VAR
STATE_STRING_BUILDER_VARback to summary
protected static final int STATE_STRING_BUILDER_VAR

Constructor Detail

AbstractParserGeneratorback to summary
public AbstractParserGenerator(final String parseStateClass, final String resultClass, final String constructorDescriptor, String existingClassName)

Method Detail

addStatesback to summary
private static void addStates(final AbstractParserGenerator.State initial, final String value, final List<AbstractParserGenerator.State> allStates)
addStatesback to summary
private static void addStates(final AbstractParserGenerator.State current, final String value, final int i, final List<AbstractParserGenerator.State> allStates)
createStateFieldback to summary
private void createStateField(final AbstractParserGenerator.State state, final ClassFile file, final CodeAttribute sc)
createStateMachineback to summary
protected void createStateMachine(final String[] originalItems, final String className, final ClassFile file, final ClassMethod sctor, final AtomicInteger fieldCounter, final String methodName, final AbstractParserGenerator.CustomStateMachine stateMachine, boolean expectNewline)
createStateMachinesback to summary
protected abstract void createStateMachines(String[] httpVerbs, String[] httpVersions, String[] standardHeaders, String className, ClassFile file, ClassMethod sctor, AtomicInteger fieldCounter)
createTokenizerback to summary
public byte[] createTokenizer(final String[] httpVerbs, String[] httpVersions, String[] standardHeaders)
handleReturnIfNoMoreBytesback to summary
private void handleReturnIfNoMoreBytes(final CodeAttribute c, final CodeLocation returnCode)
invokeStateback to summary
private void invokeState(final String className, final ClassFile file, final CodeAttribute c, final AbstractParserGenerator.State currentState, final AbstractParserGenerator.State initialState, final CodeLocation noStateStart, final CodeLocation prefixStart, final CodeLocation returnIncompleteCode, final CodeLocation returnCompleteCode, final AbstractParserGenerator.CustomStateMachine stateMachine, boolean expectNewline)
setupLocalVariablesback to summary
private void setupLocalVariables(final CodeAttribute c)
setupStateNoback to summary
private void setupStateNo(final AbstractParserGenerator.State state, final AtomicInteger stateCounter, final AtomicInteger fieldCounter)
stateNotFoundback to summary
private static void stateNotFound(final CodeAttribute c, final TableSwitchBuilder builder)

Throws an exception when an invalid state is hit in a tableswitch

tokenDoneback to summary
private void tokenDone(final CodeAttribute c, final CodeLocation returnCode, final AbstractParserGenerator.CustomStateMachine stateMachine)
writeStateMachineback to summary
private void writeStateMachine(final String className, final ClassFile file, final CodeAttribute c, final AbstractParserGenerator.State initial, final List<AbstractParserGenerator.State> allStates, int noStates, final AbstractParserGenerator.CustomStateMachine stateMachine, boolean expectNewline)
io.undertow.annotationprocessor back to summary

public Interface AbstractParserGenerator.CustomStateMachine

Known Direct Implementers
io.undertow.annotationprocessor.RequestParserGenerator.HeaderStateMachine, io.undertow.annotationprocessor.RequestParserGenerator.VersionStateMachine, io.undertow.annotationprocessor.RequestParserGenerator.VerbStateMachine, io.undertow.annotationprocessor.ResponseParserGenerator.HeaderStateMachine, io.undertow.annotationprocessor.ResponseParserGenerator.VersionStateMachine

A class that separates out the different behaviour of the three state machines (VERB, VERSION and HEADER)

Method Summary

Modifier and TypeMethod and Description
public void
public void
public boolean
public boolean
public void

Method Detail

handleOtherTokenback to summary
public void handleOtherToken(CodeAttribute c)
handleStateMachineMatchedTokenback to summary
public void handleStateMachineMatchedToken(CodeAttribute c)
initialNewlineMeansRequestDoneback to summary
public boolean initialNewlineMeansRequestDone()
isHeaderback to summary
public boolean isHeader()
updateParseStateback to summary
public void updateParseState(CodeAttribute c)
io.undertow.annotationprocessor back to summary

private Class AbstractParserGenerator.State

extends Object
implements Comparable<AbstractParserGenerator.State>
Class Inheritance
  • java.lang.Object
  • io.undertow.annotationprocessor.AbstractParserGenerator.State
All Implemented Interfaces
java.lang.Comparable

Field Summary

Modifier and TypeField and Description
private final Set<BranchEnd>
pack-priv String
pack-priv String
private CodeLocation
pack-priv final Map<Byte, AbstractParserGenerator.State>
pack-priv final String
pack-priv Integer
pack-priv String
pack-priv final byte

Constructor Summary

AccessConstructor and Description
private
State(final byte value, final String soFar)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(final AbstractParserGenerator.State
the object to be compared.
o
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv void
ifne(final CodeAttribute ca)

pack-priv void
pack-priv void
mark(final CodeAttribute ca)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

branchEndsback to summary
private final Set<BranchEnd> branchEnds
fieldNameback to summary
pack-priv String fieldName
httpStringFieldNameback to summary
pack-priv String httpStringFieldName
locationback to summary
private CodeLocation location
nextback to summary
pack-priv final Map<Byte, AbstractParserGenerator.State> next
soFarback to summary
pack-priv final String soFar
statenoback to summary
pack-priv Integer stateno
terminalStateback to summary
pack-priv String terminalState
valueback to summary
pack-priv final byte value

Constructor Detail

Stateback to summary
private State(final byte value, final String soFar)

Method Detail

compareToback to summary
public int compareTo(final AbstractParserGenerator.State o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
o:AbstractParserGenerator.State

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
ifneback to summary
pack-priv void ifne(final CodeAttribute ca)
jumpToback to summary
pack-priv void jumpTo(final CodeAttribute ca)
markback to summary
pack-priv void mark(final CodeAttribute ca)