Package org.opencms.site
Class CmsSiteMatcher
- java.lang.Object
-
- org.opencms.site.CmsSiteMatcher
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public final class CmsSiteMatcher extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
A matcher object to compare request data against the configured sites.- Since:
- 6.0.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsSiteMatcher.RedirectMode
Represents the different redirect modes for a site alias.
-
Field Summary
Fields Modifier and Type Field Description static CmsSiteMatcher
DEFAULT_MATCHER
Default matcher that always matches all other Site matchers.
-
Constructor Summary
Constructors Constructor Description CmsSiteMatcher(java.lang.String serverString)
Construct a new site matcher from a String which should be in default URL notation.CmsSiteMatcher(java.lang.String serverString, long timeOffset)
Construct a new site matcher from a String which should be in default URL notation.CmsSiteMatcher(java.lang.String serverProtocol, java.lang.String serverName, int serverPort)
Constructs a new site matcher object.CmsSiteMatcher(java.lang.String serverProtocol, java.lang.String serverName, int serverPort, long timeOffset)
Constructs a new site matcher object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Returns a clone of this Objects instance.boolean
equals(java.lang.Object obj)
CmsSiteMatcher
forDifferentScheme(java.lang.String scheme)
Generates a site matcher equivalent to this one but with a different scheme.CmsSiteMatcher.RedirectMode
getRedirectMode()
Gets the redirect mode.java.lang.String
getServerName()
Returns the hostname (e.g.int
getServerPort()
Returns the port (e.g.java.lang.String
getServerProtocol()
Returns the protocol (e.g.long
getTimeOffset()
Returns the time Offset.java.lang.String
getUrl()
Returns the url of this site matcher.int
hashCode()
boolean
isRedirect()
Is alias to be redirected?void
setRedirectMode(CmsSiteMatcher.RedirectMode redirect)
Set redirect.protected void
setServerName(java.lang.String serverName)
Sets the hostname (e.g.protected void
setServerPort(int serverPort)
Sets the port (e.g.protected void
setServerProtocol(java.lang.String serverProtocol)
Sets the protocol (e.g.protected void
setTimeOffset(long timeOffset)
Sets the time Offset in seconds.java.lang.String
toString()
-
-
-
Field Detail
-
DEFAULT_MATCHER
public static final CmsSiteMatcher DEFAULT_MATCHER
Default matcher that always matches all other Site matchers.
-
-
Constructor Detail
-
CmsSiteMatcher
public CmsSiteMatcher(java.lang.String serverString)
Construct a new site matcher from a String which should be in default URL notation.If no port is provided, the default port 80 or 443 will be used for http or https respectively. If no protocol is provided, the default protocol "http" will be used.
- Parameters:
serverString
- the String, e.g. http://localhost:8080
-
CmsSiteMatcher
public CmsSiteMatcher(java.lang.String serverString, long timeOffset)
Construct a new site matcher from a String which should be in default URL notation.If no port is provided, the default port 80 or 443 will be used for http or https respectively. If no protocol is provided, the default protocol "http" will be used.
- Parameters:
serverString
- the String, e.g. http://localhost:8080timeOffset
- the time offset
-
CmsSiteMatcher
public CmsSiteMatcher(java.lang.String serverProtocol, java.lang.String serverName, int serverPort)
Constructs a new site matcher object.- Parameters:
serverProtocol
- to protocol required to access this siteserverName
- the server URL prefix to which this site is mappedserverPort
- the port required to access this site
-
CmsSiteMatcher
public CmsSiteMatcher(java.lang.String serverProtocol, java.lang.String serverName, int serverPort, long timeOffset)
Constructs a new site matcher object.- Parameters:
serverProtocol
- to protocol required to access this siteserverName
- the server URL prefix to which this site is mappedserverPort
- the port required to access this sitetimeOffset
- the time offset
-
-
Method Detail
-
clone
public java.lang.Object clone()
Returns a clone of this Objects instance.- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone of this instance
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
forDifferentScheme
public CmsSiteMatcher forDifferentScheme(java.lang.String scheme)
Generates a site matcher equivalent to this one but with a different scheme.- Parameters:
scheme
- the new scheme- Returns:
- the new site matcher
-
getRedirectMode
public CmsSiteMatcher.RedirectMode getRedirectMode()
Gets the redirect mode.- Returns:
- the redirect mode
-
getServerName
public java.lang.String getServerName()
Returns the hostname (e.g. localhost) which is required to access this site.- Returns:
- the hostname (e.g. localhost) which is required to access this site
-
getServerPort
public int getServerPort()
Returns the port (e.g. 80) which is required to access this site.- Returns:
- the port (e.g. 80) which is required to access this site
-
getServerProtocol
public java.lang.String getServerProtocol()
Returns the protocol (e.g. "http", "https") which is required to access this site.- Returns:
- the protocol (e.g. "http", "https") which is required to access this site
-
getTimeOffset
public long getTimeOffset()
Returns the time Offset.- Returns:
- the time Offset
-
getUrl
public java.lang.String getUrl()
Returns the url of this site matcher.- Returns:
- the url, i.e. {protocol}://{servername}[:{port}], port appened only if != 80
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
isRedirect
public boolean isRedirect()
Is alias to be redirected?- Returns:
- boolean
-
setRedirectMode
public void setRedirectMode(CmsSiteMatcher.RedirectMode redirect)
Set redirect.- Parameters:
redirect
- boolean
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
setServerName
protected void setServerName(java.lang.String serverName)
Sets the hostname (e.g. localhost) which is required to access this site.Setting the hostname to "*" is a wildcard that matches all hostnames
- Parameters:
serverName
- the hostname (e.g. localhost) which is required to access this site
-
setServerPort
protected void setServerPort(int serverPort)
Sets the port (e.g. 80) which is required to access this site.Setting the port to 0 (zero) is a wildcard that matches all ports
- Parameters:
serverPort
- the port (e.g. 80) which is required to access this site
-
setServerProtocol
protected void setServerProtocol(java.lang.String serverProtocol)
Sets the protocol (e.g. "http", "https") which is required to access this site.Setting the protocol to "*" is a wildcard that matches all protocols.
- Parameters:
serverProtocol
- the protocol (e.g. "http", "https") which is required to access this site
-
setTimeOffset
protected void setTimeOffset(long timeOffset)
Sets the time Offset in seconds.- Parameters:
timeOffset
- the time Offset to set
-
-