- All Implemented Interfaces:
Serializable
,Comparable<Style>
- an optional media condition
- an optional crossorigin attribute
- a disabled attribute
Optimizers should be careful to only group styles that have equivalent constraints.
TODO: Support a "group" (or "position" / "category"?): prelude, main, and coda. "prelude" is before all others (except possibly other prelude). "main" (the default) is the middle. "coda" is after all others (except possibly other coda). It would be an error if the topological sort results in prelude that is not first or coda that is not last. Use "prelude" for "html5.css".
TODO: Support inline styles without URI.
- Author:
- AO Industries, Inc.
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator
<Style> Styles start with a default ordering that should minimize the number of explicit ordering declarations: TODO: Review that this is the best default ordering. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Style.Builder
builder()
int
All concrete implementations of Resource must be comparable to themselves.boolean
Two resources may be compared to see if they are exactly equal, including all relevant attributes.Gets the optional crossorigin policy.Gets the direction for the style.getMedia()
Gets the optional media condition.int
hashCode()
The hash key must be consistent withResource.equals(java.lang.Object)
.boolean
Style may be disabled by default, then enabled via JavaScript.toString()
-
Field Details
-
COMPARATOR
Styles start with a default ordering that should minimize the number of explicit ordering declarations: TODO: Review that this is the best default ordering.- Order by media condition, nulls first
- Order by direction, nulls first
- Order by URI
Note: The crossorigin policy is not used in ordering.
Note: The disabled flag is not used in ordering.
All string comparisons are performed via
SmartComparator.ROOT
.As an example of this ordering, consider the following order would be the default, which we expect will often match the way CSS styles override base definitions:
global.css
(no media)global-print.css
(media="print")
-
-
Constructor Details
-
Style
public Style(String href, String media, Style.Direction direction, String crossorigin, boolean disabled) Creates a new style.- Parameters:
href
- SeeResource.getUri()
media
- SeegetMedia()
direction
- SeegetDirection()
crossorigin
- SeegetCrossorigin()
disabled
- SeeisDisabled()
-
Style
Creates a new style.- Parameters:
href
- SeeResource.getUri()
-
-
Method Details
-
builder
-
toString
-
equals
Description copied from class:Resource
Two resources may be compared to see if they are exactly equal, including all relevant attributes. -
hashCode
public int hashCode()Description copied from class:Resource
The hash key must be consistent withResource.equals(java.lang.Object)
. -
compareTo
All concrete implementations of Resource must be comparable to themselves.This default implementation compares by URI only via
SmartComparator.ROOT
. -
getMedia
Gets the optional media condition. -
getDirection
Gets the direction for the style. This is matched against the current response language/locale, when know, to selectively include the style. -
getCrossorigin
Gets the optional crossorigin policy. -
isDisabled
public boolean isDisabled()Style may be disabled by default, then enabled via JavaScript.
-