Package eu.bandm.tools.lexic
Class LookaheadTokenSourceProxy<D,T,L>
java.lang.Object
eu.bandm.tools.lexic.LookaheadTokenSourceProxy<D,T,L>
- Type Parameters:
D- the type of source document identifiersT- the type of token typesL- the type of lookahead data
- All Implemented Interfaces:
LookaheadTokenSource<D,,T, L> Closeable,AutoCloseable,Supplier<Token<D,T>>
A dynamic proxy that can be reconfigured which token source to forward at
any time.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with no source to forward.LookaheadTokenSourceProxy(@Opt LookaheadTokenSource<D, T, L> source) Creates a new instance with the given source to forward. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this source and releases any resources associated with it.get()Clears the internal lookahead buffer and return its contents.voidSets the given source to forward.voidtakeOverLookahead(L lookaheadData) Fills the internal lookahead buffer with data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.bandm.tools.lexic.LookaheadTokenSource
forgetLookahead, removeTypes, removeTypes
-
Constructor Details
-
LookaheadTokenSourceProxy
public LookaheadTokenSourceProxy()Creates a new instance with no source to forward. -
LookaheadTokenSourceProxy
Creates a new instance with the given source to forward.- Parameters:
source- the source to forward
-
-
Method Details
-
setSource
Sets the given source to forward.- Parameters:
source- the source to forward, ornullif there is none
-
get
- Specified by:
getin interfaceSupplier<D>- Throws:
NullPointerException- is there is currently no source to forward
-
relinquishLookahead
Clears the internal lookahead buffer and return its contents.- Specified by:
relinquishLookaheadin interfaceLookaheadTokenSource<D,T, L> - Returns:
- the former contents of the internal lookahead buffer
- Throws:
NullPointerException- is there is currently no source to forward
-
takeOverLookahead
Fills the internal lookahead buffer with data.The buffer must be empty before this method is invoked. After return, the given data will be consumed from the buffer before the usual input is considered.
- Specified by:
takeOverLookaheadin interfaceLookaheadTokenSource<D,T, L> - Parameters:
lookaheadData- the lookahead data to fill in- Throws:
NullPointerException- is there is currently no source to forward
-
close
public void close()Closes this source and releases any resources associated with it.The default implementation does nothing.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceLookaheadTokenSource<D,T, L>
-