added template method analysis
This commit is contained in:
parent
17f6a66eac
commit
b0b86d61e8
3 changed files with 66 additions and 65 deletions
64
analysis.xml
64
analysis.xml
|
@ -4,7 +4,6 @@
|
|||
<instance>
|
||||
<role name="Creator" element="com.fasterxml.jackson.core.TokenStreamFactory" />
|
||||
<role name="FactoryMethod()" element="com.fasterxml.jackson.core.TokenStreamFactory::createNonBlockingByteArrayParser():com.fasterxml.jackson.core.JsonParser" />
|
||||
<role name="FactoryMethod()" element="com.fasterxml.jackson.core.TokenStreamFactory::createNonBlockingByteBufferParser():com.fasterxml.jackson.core.JsonParser" />
|
||||
</instance>
|
||||
<instance>
|
||||
<role name="Creator" element="com.fasterxml.jackson.core.TSFBuilder" />
|
||||
|
@ -72,7 +71,6 @@
|
|||
<role name="Adaptee" element="com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer" />
|
||||
<role name="adaptee" element="com.fasterxml.jackson.core.JsonFactory::_byteSymbolCanonicalizer:com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer" />
|
||||
<role name="Request()" element="com.fasterxml.jackson.core.JsonFactory::createNonBlockingByteArrayParser():com.fasterxml.jackson.core.JsonParser" />
|
||||
<role name="Request()" element="com.fasterxml.jackson.core.JsonFactory::createNonBlockingByteBufferParser():com.fasterxml.jackson.core.JsonParser" />
|
||||
</instance>
|
||||
<instance>
|
||||
<role name="Adapter" element="com.fasterxml.jackson.core.JsonFactory" />
|
||||
|
@ -292,20 +290,6 @@
|
|||
</instance>
|
||||
</pattern>
|
||||
<pattern name="Template Method">
|
||||
<instance>
|
||||
<role name="AbstractClass" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharSequence" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharSequence::parseDecFloatLiteral(java.lang.CharSequence, int, int, int, boolean, boolean):long" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharSequence::parseHexFloatLiteral(java.lang.CharSequence, int, int, int, boolean):long" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharSequence::parseInfinity(java.lang.CharSequence, int, int, boolean):long" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharSequence::parseNaN(java.lang.CharSequence, int, int):long" />
|
||||
</instance>
|
||||
<instance>
|
||||
<role name="AbstractClass" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharArray" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharArray::parseDecFloatLiteral(char[], int, int, int, boolean, boolean):long" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharArray::parseHexFloatLiteral(char[], int, int, int, boolean):long" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharArray::parseInfinity(char[], int, int, boolean):long" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.io.doubleparser.AbstractFloatingPointBitsFromCharArray::parseNaN(char[], int, int):long" />
|
||||
</instance>
|
||||
<instance>
|
||||
<role name="AbstractClass" element="com.fasterxml.jackson.core.JsonStreamContext" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonStreamContext::hasCurrentName():boolean" />
|
||||
|
@ -321,6 +305,7 @@
|
|||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::writeStartArray(int):void" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::writeStartArray(java.lang.Object):void" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::writeStartObject(java.lang.Object):void" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::writeStartObject(java.lang.Object, int):void" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::writeFieldId(long):void" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::writeArray(int[], int, int):void" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::writeArray(long[], int, int):void" />
|
||||
|
@ -356,53 +341,6 @@
|
|||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::_copyCurrentContents(com.fasterxml.jackson.core.JsonParser):void" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.JsonGenerator::_writeSimpleObject(java.lang.Object):void" />
|
||||
</instance>
|
||||
<instance>
|
||||
<role name="AbstractClass" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::nextToken():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishToken():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startDocument(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishBOM(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startFieldNameAfterComma(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startValueExpectComma(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startValueExpectColon(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_skipWS(int):int" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startSlashComment(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishHashComment(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishCppComment(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishCComment(int, boolean):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startAfterComment(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startFalseToken():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startTrueToken():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startNullToken():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishKeywordToken(java.lang.String, int, com.fasterxml.jackson.core.JsonToken):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishNonStdToken(int, int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishErrorToken():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startPositiveNumber(int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startNegativeNumber():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startPositiveNumber():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startNumberLeadingZero():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishNumberLeadingZeroes():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishNumberLeadingPosNegZeroes(boolean):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishNumberIntegralPart(char[], int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startFloat(char[], int, int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishFloatFraction():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishFloatExponent(boolean, int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_fastParseName():java.lang.String" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_parseMediumName(int, int):java.lang.String" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_parseMediumName2(int, int, int):java.lang.String" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_parseEscapedName(int, int, int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishUnquotedName(int, int, int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishAposName(int, int, int):com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_decodeSplitEscaped(int, int):int" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startString():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishRegularString():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_startAposString():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_finishAposString():com.fasterxml.jackson.core.JsonToken" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_decodeSplitMultiByte(int, int, boolean):boolean" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_decodeSplitUTF8_3(int, int, int):boolean" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_decodeSplitUTF8_4(int, int, int):boolean" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.json.async.NonBlockingUtf8JsonParserBase::_decodeFastCharEscape():int" />
|
||||
</instance>
|
||||
<instance>
|
||||
<role name="AbstractClass" element="com.fasterxml.jackson.core.type.ResolvedType" />
|
||||
<role name="TemplateMethod()" element="com.fasterxml.jackson.core.type.ResolvedType::isReferenceType():boolean" />
|
||||
|
|
BIN
report.pdf
BIN
report.pdf
Binary file not shown.
67
report.tex
67
report.tex
|
@ -2,8 +2,28 @@
|
|||
|
||||
\documentclass[12pt,a4paper]{scrartcl}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[margin=2cm]{geometry}
|
||||
\usepackage[margin=2.5cm]{geometry}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{listings}
|
||||
\usepackage{xcolor}
|
||||
\usepackage{lmodern}
|
||||
\usepackage{listings}
|
||||
\setlength{\parindent}{0cm}
|
||||
|
||||
\lstset{
|
||||
basicstyle=\small\ttfamily,
|
||||
%frame=shadowbox,
|
||||
rulesepcolor=\color{black},
|
||||
columns=fullflexible,
|
||||
commentstyle=\color{gray},
|
||||
keywordstyle=\color{blue},
|
||||
mathescape=true,
|
||||
aboveskip=1em,
|
||||
captionpos=b,
|
||||
abovecaptionskip=1em,
|
||||
belowcaptionskip=1em
|
||||
}
|
||||
|
||||
|
||||
\title{Assginment 1 -- Software Design and Modelling}
|
||||
|
||||
|
@ -174,7 +194,50 @@ TBD
|
|||
TBD
|
||||
|
||||
\subsection{Template Method Pattern}
|
||||
TBD
|
||||
Due to the extendibility of Jackson, it is of no surprise that the template
|
||||
method pattern is used extensively to create a class hierarchy that provides
|
||||
rich interfaces while maintaining behavioural flexibility. \textit{Pattern4}
|
||||
correctly detects several instances of the pattern, namely
|
||||
\textbf{JsonStreamContext}, \textbf{JsonGenerator}, \textbf{type.ResolvedType},
|
||||
\textbf{JsonParser}, \textbf{base.ParserBase}, \textbf{base.GeneratorBase},
|
||||
\textbf{base.ParserMinimalBase}. All these classes implement several concrete
|
||||
\texttt{public} methods throwgh the use of \texttt{protected abstract} methods.
|
||||
Although the concrete (i.e. the template) methods are usually not vary complex
|
||||
(as the pattern example shown in class), they still follow the principles of the
|
||||
template method pattern. We show as an example some template methods found in
|
||||
\textbf{base.ParserBase}:
|
||||
|
||||
\begin{lstlisting}[caption=Template method \texttt{void close()} and step
|
||||
methods \texttt{void \_closeInput()} and \texttt{void \_releaseBuffers()} in
|
||||
\textbf{base.ParserBase}., language=java]
|
||||
@Override public void close() throws IOException {
|
||||
if (!_closed) {
|
||||
// 19-Jan-2018, tatu: as per [core#440] need to ensure no more data
|
||||
// assumed available
|
||||
_inputPtr = Math.max(_inputPtr, _inputEnd);
|
||||
_closed = true;
|
||||
try {
|
||||
_closeInput();
|
||||
} finally {
|
||||
// as per [JACKSON-324], do in finally block
|
||||
// Also, internal buffer(s) can now be released as well
|
||||
_releaseBuffers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void _closeInput() throws IOException;
|
||||
|
||||
protected void _releaseBuffers() throws IOException {
|
||||
/* implementation omitted */
|
||||
}
|
||||
\end{lstlisting}
|
||||
|
||||
Here the pattern is slightly modified by providing a default implementation of
|
||||
\texttt{void \_releaseBuffers()}. In this case, child classes occasionally
|
||||
override the method with a body first calling \texttt{super()} and then adding
|
||||
additional buffer release code after.
|
||||
|
||||
|
||||
\subsection{Visitor Pattern}
|
||||
TBD
|
||||
|
|
Reference in a new issue