public class VersionUtilImpl extends AbstractLoggableComponent implements VersionUtil
VersionUtil interface.| Modifier and Type | Class and Description |
|---|---|
protected static class |
VersionUtilImpl.FormatPatternStatus
This inner class holds the status used to determine if a
formatPattern is strict. |
| Modifier and Type | Field and Description |
|---|---|
private VersionIdentifierFormatter |
defaultFormatter |
private static CharFilter |
INFIX_FILTER
A
CharFilter that accepts all but ASCII letters. |
private static VersionUtil |
instance |
private Iso8601Util |
iso8601Util |
private static CharFilter |
LETTER_FILTER
A
CharFilter that accepts all but separators and digits. |
private Map<String,DevelopmentPhase> |
phaseMap |
private Set<String> |
phasePrefixSet |
private static CharFilter |
SEPARATOR_FILTER
A
CharFilter that accepts common separators. |
private StringUtil |
stringUtil |
| Constructor and Description |
|---|
VersionUtilImpl()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Map<String,DevelopmentPhase> |
createDefaultPhaseMap()
This method creates the
phase map used as default. |
VersionIdentifierFormatter |
createFormatter(String formatPattern)
Variant of
VersionUtil.createFormatter(String, boolean) with strict mode. |
VersionIdentifierFormatter |
createFormatter(String formatPattern,
boolean strict)
This method creates a
VersionIdentifierFormatter for the given formatPattern. |
VersionIdentifier |
createVersionIdentifier(String versionString)
This method parses the given
versionString and builds an according VersionIdentifier
instance. |
VersionIdentifier |
createVersionIdentifier(String versionString,
boolean normalizeFormat)
This method parses the given
versionString and builds an according VersionIdentifier
instance. |
protected void |
doInitialize()
This method performs the actual
initialization. |
protected void |
doInitialized()
This method is invoked at the end of the actual
initialization. |
VersionIdentifierFormatter |
getDefaultFormatter() |
static VersionUtil |
getInstance()
This method gets the singleton instance of this
VersionUtilImpl. |
protected Iso8601Util |
getIso8601Util() |
protected Map<String,DevelopmentPhase> |
getPhaseMap() |
protected Set<String> |
getPhasePrefixSet() |
protected StringUtil |
getStringUtil() |
protected Formatter<VersionIdentifier> |
parseSubFormatter(CharSequenceScanner scanner,
String formatPattern,
StringBuilder infixBuffer,
VersionUtilImpl.FormatPatternStatus status) |
protected void |
putPhase(Map<String,DevelopmentPhase> map,
String key,
DevelopmentPhase phase)
This method puts the given
phase in the given map using normalized variants of the given
key. |
void |
setDefaultFormatter(VersionIdentifierFormatter defaultFormatter) |
void |
setIso8601Util(Iso8601Util iso8601Util) |
void |
setPhaseMap(Map<String,DevelopmentPhase> phaseMappingTable) |
void |
setPhasePrefixSet(Set<String> phasePrefixSet) |
void |
setStringUtil(StringUtil stringUtil) |
createLogger, getLoggergetInitializationState, initializeprivate static final CharFilter INFIX_FILTER
CharFilter that accepts all but ASCII letters.private static final CharFilter SEPARATOR_FILTER
CharFilter that accepts common separators.private static final CharFilter LETTER_FILTER
CharFilter that accepts all but separators and digits.private static VersionUtil instance
private StringUtil stringUtil
private Iso8601Util iso8601Util
private Map<String,DevelopmentPhase> phaseMap
private VersionIdentifierFormatter defaultFormatter
public static VersionUtil getInstance()
VersionUtilImpl. getInstance() methods and construct new instances via
the container-framework of your choice. To wire up the
dependent components everything is properly annotated using annotations (JSR-250 and JSR-330). If your
container does NOT support this, you should consider using a better one.protected StringUtil getStringUtil()
@Inject public void setStringUtil(StringUtil stringUtil)
stringUtil - is the stringUtil to setprotected Iso8601Util getIso8601Util()
@Inject public void setIso8601Util(Iso8601Util iso8601Util)
iso8601Util - is the iso8601Util to setprotected Map<String,DevelopmentPhase> getPhaseMap()
public void setPhasePrefixSet(Set<String> phasePrefixSet)
phasePrefixSet - is the phasePrefixSet to setpublic void setPhaseMap(Map<String,DevelopmentPhase> phaseMappingTable)
phaseMappingTable - is the phaseMappingTable to setpublic VersionIdentifierFormatter getDefaultFormatter()
getDefaultFormatter in interface VersionUtilpublic void setDefaultFormatter(VersionIdentifierFormatter defaultFormatter)
defaultFormatter - is the defaultFormatter to setprotected void doInitialize()
AbstractComponentinitialization. It is called when AbstractComponent.initialize() is
invoked for the first time. super.AbstractComponent.doInitialize().doInitialize in class AbstractLoggableComponentprotected void doInitialized()
AbstractComponentinitialization. It is called when
AbstractComponent.initialize() is invoked for the first time after AbstractComponent.doInitialize() is completed and
initialization-state has changed to initialized. super.AbstractComponent.doInitialized().doInitialized in class AbstractComponentprotected void putPhase(Map<String,DevelopmentPhase> map, String key, DevelopmentPhase phase)
phase in the given map using normalized variants of the given
key.map - is the getPhaseMap().key - is the key.phase - is the DevelopmentPhase to put.protected Map<String,DevelopmentPhase> createDefaultPhaseMap()
phase map used as default.Map.public VersionIdentifier createVersionIdentifier(String versionString) throws NlsParseException
VersionUtilversionString and builds an according VersionIdentifier
instance. It delegates to VersionUtil.createFormatter(String, boolean) using false for
normalizeFormat.createVersionIdentifier in interface VersionUtilversionString - is the string representation of a
VersionIdentifier.VersionIdentifier.NlsParseException - if the given versionString is invalid and could not be parsed.public VersionIdentifier createVersionIdentifier(String versionString, boolean normalizeFormat) throws NlsParseException
VersionUtilversionString and builds an according VersionIdentifier
instance.createVersionIdentifier in interface VersionUtilversionString - is the string representation of a
VersionIdentifier.normalizeFormat - - if true the returned VersionIdentifier will return a normalized
string representation that may differ from the given
versionString. Otherwise the original versionString will be used.VersionIdentifier.NlsParseException - if the given versionString is invalid and could not be parsed.public VersionIdentifierFormatter createFormatter(String formatPattern)
VersionUtilVersionUtil.createFormatter(String, boolean) with strict mode.createFormatter in interface VersionUtilformatPattern - is the format string.VersionIdentifierFormatter.VersionUtil.createFormatter(String, boolean)protected Formatter<VersionIdentifier> parseSubFormatter(CharSequenceScanner scanner, String formatPattern, StringBuilder infixBuffer, VersionUtilImpl.FormatPatternStatus status)
scanner - is the CharSequenceScanner.formatPattern - is the format pattern.infixBuffer - is a StringBuilder containing the current infix.status - is the VersionUtilImpl.FormatPatternStatus.Formatter or null to continue parsing the infix.createFormatter(String, boolean)public VersionIdentifierFormatter createFormatter(String formatPattern, boolean strict)
VersionUtilVersionIdentifierFormatter for the given formatPattern. Similar to
SimpleDateFormat the format pattern is parsed and there are particular
letter symbols that have a specific meaning.
| letter | meaning | comment |
|---|---|---|
| V | version segments |
Needs to be of the form V«separator»[{«min»,«max»,«padding»}] where «separator»
is a character used to separate the version segments
(typically the dot sign '.'). Further, «min» and «max» are the minimum and maximum number
of segments to format and «padding» is the
minimum number of digits to pad each
segment. |
| P | phase |
The official phase name - typically you want to use "A" instead.
May be followed by {«max»} to limit (truncate) to a maximum number of characters. |
| A | alias |
The phase alias. May be followed by {«max»} to limit (truncate) to a maximum number of
characters. |
| N | phase number |
The phase number. May be followed by
{«padding»} to pad to a
minimum number of digits. |
| S | snapshot indicator |
The snapshot indicator. May be followed by
{«indicator»} to override the default snapshot indicator
with {«indicator»}. |
| L | label |
The label. May be followed by {«max»} to limit (truncate) to a maximum number of
characters. |
| R | revision |
The revision. May be followed by {«padding»} to
pad to a minimum number of digits. |
| T | timestamp |
The timestamp by default in basic ISO-8601 format. May
be followed by {«format»} to use the given format instead as
SimpleDateFormat pattern (e.g. "T{yyyy-MM-dd}"). |
String "rev" as infix for a format pattern). segment count |
major |
minor |
milli |
micro |
phase |
alias |
phase number |
snapshot |
label |
revision |
timestamp |
formatPattern | format |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4 | 1 | 2 | 3 | 4 | null | null | null | false | null | null | null | "V.-AN-S-L-(rev)R-T" | "1.2.3.4-GA" |
| 4 | 1 | 2 | 3 | 4 | "update" |
"SR" | 2 | false | null | 654321 | null | "V.-AN-S-L-(rev)R-T" | "1.2.3.4-SR2-rev654321" |
| 4 | 1 | 2 | 3 | 4 | "update" |
"SR" | 2 | true | kassiopeia | 654321 | 31.12.1999 23:59:59 UTC | "V.-AN-S-L-(rev)R-T" | "1.2.3.4-SR2-SNAPSHOT-kassiopeia-rev654321-19991231T23:59:59Z" |
| 4 | 1 | 2 | 3 | 4 | "update" |
"SR" | 2 | true | null | 654321 | 31.12.1999 23:59:59 UTC | "V.{0,3,2}P{2}N{2}-S{snap}_$-L-(rev)R-T" | "01.02.03up02-snap_-rev654321-19991231T23:59:59Z" |
createFormatter in interface VersionUtilformatPattern - is the format string.strict - - if true then the given formatPattern has to include at least the
version segments, the
phase (in any form including alias),
phase number, and snapshot.VersionIdentifierFormatter.Copyright © 2001–2016 mmm-Team. All rights reserved.