public final class MediaQuery extends AbstractGroupable<MediaQueryList,MediaQuery>
In the following example:
@
media all and (min-width: 800px), projection and (color) { ... }
There are two media queries,
1) all and (min-width: 800px)
2) projection and (color)
MediaQueryParser
Constructor and Description |
---|
MediaQuery()
Constructs a new
MediaQuery instance. |
MediaQuery(int line,
int column)
Constructs a new
MediaQuery instance. |
Modifier and Type | Method and Description |
---|---|
MediaQuery |
copy()
For implementations: do not copy comments or orphaned comments, instead be sure to call
AbstractSyntax.copiedFrom(Syntax) on the
new copy. |
SyntaxCollection<MediaQuery,MediaQueryExpression> |
expressions()
Gets the collection of expressions.
|
boolean |
isWritable()
Returns whether this unit should actually be written.
|
void |
propagateBroadcast(Broadcaster broadcaster,
Status status)
Broadcasts or rebroadcasts all child units using the given
Broadcaster . |
Optional<MediaRestriction> |
restriction()
Gets the media restriction (only|not).
|
MediaQuery |
restriction(MediaRestriction restriction)
Sets the media restriction (only|not).
|
protected MediaQuery |
self()
Should return "this".
|
Optional<String> |
type()
Gets the media type, if present.
|
MediaQuery |
type(String type)
Sets the media type (e.g., "screen" or "all").
|
void |
write(StyleWriter writer,
StyleAppendable appendable)
Outputs this
Writable 's string representation. |
append, destroy, group, group, isDestroyed, isFirst, isLast, next, parent, prepend, previous, replaceWith, unlink
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, copiedFrom, equals, hasAnnotation, hasAnnotation, hashCode, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, shouldBreakBroadcast, status, status, toString, toString, writesOwnComments, writesOwnOrphanedComments
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, hasAnnotation, hasAnnotation, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, toString, writesOwnComments, writesOwnOrphanedComments
shouldBreakBroadcast, status, status
public MediaQuery()
MediaQuery
instance.
This should be used for dynamically created declarations.
public MediaQuery(int line, int column)
MediaQuery
instance.line
- The line number.column
- The column number.public MediaQuery restriction(MediaRestriction restriction)
restriction
- The restriction, or null to remove it.IllegalStateException
- When setting the restriction to null but the type is still present.public Optional<MediaRestriction> restriction()
Optional
if not present.public MediaQuery type(String type)
type
- The media type, or null to remove it.public Optional<String> type()
Optional
if not present.public SyntaxCollection<MediaQuery,MediaQueryExpression> expressions()
SyntaxCollection
object.public void propagateBroadcast(Broadcaster broadcaster, Status status)
Broadcastable
Broadcaster
.
The broadcast will only occur for a unit if its Status
matches the given Status
.
Implementers should call this on child units and SyntaxCollection
s first, then use the broadcaster to broadcast
itself. All of this should be wrapped in a check to ensure the Status
matches.
propagateBroadcast
in interface Broadcastable
propagateBroadcast
in class AbstractSyntax
broadcaster
- Use this Broadcaster
to broadcast all unbroadcasted child units.status
- Broadcast units that have this status.protected MediaQuery self()
AbstractGroupable
AbstractGroupable
class.self
in class AbstractGroupable<MediaQueryList,MediaQuery>
public boolean isWritable()
Writable
Usually this should just return true, however some units that are detachable or otherwise potentially invalid should first check their state and respond appropriately.
isWritable
in interface Writable
isWritable
in class AbstractGroupable<MediaQueryList,MediaQuery>
public void write(StyleWriter writer, StyleAppendable appendable) throws IOException
Writable
Writable
's string representation.
Important notes for implementation:
Do not use the StyleWriter
in an attempt to write direct content (Strings, chars, etc...). Use the StyleAppendable
.
The StyleWriter
should be used to make decisions based on writer settings (e.g., compressed vs. verbose output
mode), as well as for writing inner or child Writable
s. Do not call the this method method directly on inner
or child Writable
s! That would bypass any overrides that are set on the StyleWriter
. Use StyleWriter.writeInner(Writable, StyleAppendable)
instead.
writer
- Writer to use for output settings and for writing inner Writable
s.appendable
- Append direct content to this StyleAppendable
.IOException
- If an I/O error occurs.public MediaQuery copy()
AbstractSyntax
AbstractSyntax.copiedFrom(Syntax)
on the
new copy.copy
in interface Syntax
copy
in class AbstractSyntax
Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.