public abstract class LineInspector extends Object
Represents an object providing replacement functionality inside a line for a group of character matching a particular pattern.
Modifier and Type | Class and Description |
---|---|
class |
LineInspector.ReplacementInfo
This object indicates the index of the rewritten statement and the associated list of nuts.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
STRING_LITERAL_REGEX
Possible value for path name.
|
Constructor and Description |
---|
LineInspector(Pattern p)
Builds a new instance.
|
Modifier and Type | Method and Description |
---|---|
abstract List<? extends ConvertibleNut> |
appendTransformation(Matcher matcher,
StringBuilder replacement,
EngineRequest request,
CompositeNut.CompositeInputStream cis,
ConvertibleNut originalNut)
Computes the replacement to be made inside the text for the given
Matcher which its find()
method as just been called. |
static void |
fallbackToVersionNumberInQueryString(StringBuilder sb,
String referencedPath,
Nut originalNut)
When the nut resolution fails (no nut found), the path is keep in the source file.
|
static NutsHeap |
getHeap(EngineRequest request,
ConvertibleNut originalNut,
CompositeNut.CompositeInputStream cis,
Matcher matcher,
int groupIndex)
|
Pattern |
getPattern()
Gets the pattern to find text to be replaced inside the lines.
|
static List<? extends ConvertibleNut> |
manageAppend(ConvertibleNut nut,
StringBuilder replacement,
EngineRequest request,
NutsHeap heap,
EngineType... skippedEngine)
Manages the given nut that corresponds to the specified referenced path and append the transformation with proper
path.
|
LineInspector.ReplacementInfo |
replacementInfo(int startIndex,
int endIndex,
Nut referencer,
List<? extends ConvertibleNut> convertibleNuts)
Builds a new
LineInspector.ReplacementInfo . |
protected abstract String |
toString(ConvertibleNut convertibleNut)
Converts the given
ConvertibleNut to a String representation that is possible to append directly
to the referencer. |
protected static final String STRING_LITERAL_REGEX
public LineInspector(Pattern p)
Builds a new instance.
p
- the pattern.public static void fallbackToVersionNumberInQueryString(StringBuilder sb, String referencedPath, Nut originalNut) throws WuicException
When the nut resolution fails (no nut found), the path is keep in the source file. However, this method allows
to append this path to a StringBuilder
with a version number retrieved from the referencer in order to
give a chance to evict client cache.
sb
- the string builder to appendreferencedPath
- the unresolved pathoriginalNut
- the referencer with the version numberWuicException
- if version number resolution failspublic static List<? extends ConvertibleNut> manageAppend(ConvertibleNut nut, StringBuilder replacement, EngineRequest request, NutsHeap heap, EngineType... skippedEngine) throws WuicException
Manages the given nut that corresponds to the specified referenced path and append the transformation with proper path.
nut
- the nut retrieved with pathreplacement
- the string builder to appendrequest
- the engine requestheap
- the heap that contains the original nutskippedEngine
- the engine to skip when processing resulting nutsWuicException
- if processing failspublic static NutsHeap getHeap(EngineRequest request, ConvertibleNut originalNut, CompositeNut.CompositeInputStream cis, Matcher matcher, int groupIndex)
request
- the requestoriginalNut
- the original nutcis
- the composite stream if anymatcher
- the matcher that inspects the streamgroupIndex
- the group index of currently matched valuepublic final Pattern getPattern()
Gets the pattern to find text to be replaced inside the lines.
public LineInspector.ReplacementInfo replacementInfo(int startIndex, int endIndex, Nut referencer, List<? extends ConvertibleNut> convertibleNuts)
Builds a new LineInspector.ReplacementInfo
.
startIndex
- the start indexendIndex
- the end indexreferencer
- the referencerconvertibleNuts
- the nutspublic abstract List<? extends ConvertibleNut> appendTransformation(Matcher matcher, StringBuilder replacement, EngineRequest request, CompositeNut.CompositeInputStream cis, ConvertibleNut originalNut) throws WuicException
Computes the replacement to be made inside the text for the given Matcher
which its find()
method as just been called.
matcher
- the matcher which provides found text thanks to its group()
method.replacement
- the text which will replace the matching textrequest
- the request that orders this transformationcis
- a composite stream which indicates what nut owns the transformed text, null
if the nut is not a compositionoriginalNut
- the original nutnull
if the inspector did not perform any changeWuicException
- if an exception occursprotected abstract String toString(ConvertibleNut convertibleNut) throws IOException
Converts the given ConvertibleNut
to a String
representation that is possible to append directly
to the referencer. This could be used as an alternative to URL statements.
convertibleNut
- the convertible nut to convertString
representation, null
if no inclusion is possibleIOException
- if the transformation failsCopyright © 2012-2015. All Rights Reserved.