Top Description Inners Fields Constructors Methods
org.springframework.web.servlet.resource

public abstract Class AbstractVersionStrategy

extends Object
implements VersionStrategy
Class Inheritance
All Implemented Interfaces
org.springframework.web.servlet.resource.VersionStrategy, org.springframework.web.servlet.resource.VersionPathStrategy
Known Direct Subclasses
org.springframework.web.servlet.resource.ContentVersionStrategy, org.springframework.web.servlet.resource.FixedVersionStrategy
Imports
java.util.regex.Matcher, .Pattern, org.apache.commons.logging.Log, .LogFactory, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils

Abstract base class for VersionStrategy implementations.

Supports versions as:

Note

This base class does not provide support for generating the version string.

Authors
Brian Clozel, Rossen Stoyanchev
Since
4.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
AbstractVersionStrategy.FileNameVersionPathStrategy

File name-based VersionPathStrategy, e.g. "path/foo-{version}.css".

protected static class
AbstractVersionStrategy.PrefixVersionPathStrategy

A prefix-based VersionPathStrategy, e.g. "{version}/path/foo.js".

Field Summary

Modifier and TypeField and Description
protected final Log
private final VersionPathStrategy

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public String
addVersion(String
the requestPath
requestPath
,
String
the version
version
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Add a version to the given request path.

public String
extractVersion(String
the request path to check
requestPath
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Extract the resource version from the request path.

public VersionPathStrategy
public String
removeVersion(String
the request path of the resource being resolved
requestPath
,
String
the version obtained from extractVersion(String)
version
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Remove the version from the request path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
protected final Log logger
pathStrategyback to summary
private final VersionPathStrategy pathStrategy

Constructor Detail

AbstractVersionStrategyback to summary
protected AbstractVersionStrategy(VersionPathStrategy pathStrategy)

Method Detail

addVersionback to summary
public String addVersion(String requestPath, String version)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Add a version to the given request path.

Parameters
requestPath:String

the requestPath

version:String

the version

Returns:String

the requestPath updated with a version string

Annotations
@Override
extractVersionback to summary
public String extractVersion(String requestPath)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Extract the resource version from the request path.

Parameters
requestPath:String

the request path to check

Returns:String

the version string or null if none was found

Annotations
@Override
@Nullable
getVersionPathStrategyback to summary
public VersionPathStrategy getVersionPathStrategy()
removeVersionback to summary
public String removeVersion(String requestPath, String version)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Remove the version from the request path. It is assumed that the given version was extracted via extractVersion(String).

Parameters
requestPath:String

the request path of the resource being resolved

version:String

the version obtained from extractVersion(String)

Returns:String

the request path with the version removed

Annotations
@Override
org.springframework.web.servlet.resource back to summary

protected Class AbstractVersionStrategy.FileNameVersionPathStrategy

extends Object
implements VersionPathStrategy
Class Inheritance
  • java.lang.Object
  • org.springframework.web.servlet.resource.AbstractVersionStrategy.FileNameVersionPathStrategy
All Implemented Interfaces
org.springframework.web.servlet.resource.VersionPathStrategy

File name-based VersionPathStrategy, e.g. "path/foo-{version}.css".

Field Summary

Modifier and TypeField and Description
private static final Pattern

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public String
addVersion(String
the requestPath
requestPath
,
String
the version
version
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Add a version to the given request path.

public String
extractVersion(String
the request path to check
requestPath
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Extract the resource version from the request path.

public String
removeVersion(String
the request path of the resource being resolved
requestPath
,
String
the version obtained from extractVersion(String)
version
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Remove the version from the request path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

patternback to summary
private static final Pattern pattern

Constructor Detail

FileNameVersionPathStrategyback to summary
protected FileNameVersionPathStrategy()

Method Detail

addVersionback to summary
public String addVersion(String requestPath, String version)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Add a version to the given request path.

Parameters
requestPath:String

the requestPath

version:String

the version

Returns:String

the requestPath updated with a version string

Annotations
@Override
extractVersionback to summary
public String extractVersion(String requestPath)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Extract the resource version from the request path.

Parameters
requestPath:String

the request path to check

Returns:String

the version string or null if none was found

Annotations
@Override
@Nullable
removeVersionback to summary
public String removeVersion(String requestPath, String version)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Remove the version from the request path. It is assumed that the given version was extracted via extractVersion(String).

Parameters
requestPath:String

the request path of the resource being resolved

version:String

the version obtained from extractVersion(String)

Returns:String

the request path with the version removed

Annotations
@Override
org.springframework.web.servlet.resource back to summary

protected Class AbstractVersionStrategy.PrefixVersionPathStrategy

extends Object
implements VersionPathStrategy
Class Inheritance
  • java.lang.Object
  • org.springframework.web.servlet.resource.AbstractVersionStrategy.PrefixVersionPathStrategy
All Implemented Interfaces
org.springframework.web.servlet.resource.VersionPathStrategy

A prefix-based VersionPathStrategy, e.g. "{version}/path/foo.js".

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
addVersion(String
the requestPath
path
,
String
the version
version
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Add a version to the given request path.

public String
extractVersion(String
the request path to check
requestPath
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Extract the resource version from the request path.

public String
removeVersion(String
the request path of the resource being resolved
requestPath
,
String
the version obtained from extractVersion(String)
version
)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Remove the version from the request path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

prefixback to summary
private final String prefix

Constructor Detail

PrefixVersionPathStrategyback to summary
public PrefixVersionPathStrategy(String version)

Method Detail

addVersionback to summary
public String addVersion(String path, String version)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.addVersion.

Add a version to the given request path.

Parameters
path:String

the requestPath

version:String

the version

Returns:String

the requestPath updated with a version string

Annotations
@Override
extractVersionback to summary
public String extractVersion(String requestPath)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.extractVersion.

Extract the resource version from the request path.

Parameters
requestPath:String

the request path to check

Returns:String

the version string or null if none was found

Annotations
@Override
@Nullable
removeVersionback to summary
public String removeVersion(String requestPath, String version)

Implements org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Doc from org.springframework.web.servlet.resource.VersionPathStrategy.removeVersion.

Remove the version from the request path. It is assumed that the given version was extracted via extractVersion(String).

Parameters
requestPath:String

the request path of the resource being resolved

version:String

the version obtained from extractVersion(String)

Returns:String

the request path with the version removed

Annotations
@Override