public final class FontDescriptor extends AbstractGroupable<FontFaceBlock,FontDescriptor> implements Named
FontFaceBlock
font-descriptors (src, font-weight, font-style, etc...).FontFaceBlock
,
FontFacePlugin
Constructor and Description |
---|
FontDescriptor(Declaration source)
Creates a new
FontDescriptor instance using the given Declaration s PropertyName and PropertyValue , as well as comments. |
FontDescriptor(PropertyName propertyName,
PropertyValue propertyValue)
Creates a new
FontDescriptor instance with the given property name and value. |
Modifier and Type | Method and Description |
---|---|
FontDescriptor |
copy()
For implementations: do not copy comments or orphaned comments, instead be sure to call
AbstractSyntax.copiedFrom(Syntax) on the
new copy. |
boolean |
isProperty(Property property)
Gets whether this
FontDescriptor has the given Property name. |
boolean |
isProperty(String property)
Gets whether this
FontDescriptor has the given property name. |
boolean |
isWritable()
Returns whether this unit should actually be written.
|
String |
name()
Gets the name of this object.
|
void |
propagateBroadcast(Broadcaster broadcaster,
Status status)
Broadcasts or rebroadcasts all child units using the given
Broadcaster . |
PropertyName |
propertyName()
Gets the property name.
|
PropertyValue |
propertyValue()
Gets the property value.
|
FontDescriptor |
propertyValue(PropertyValue propertyValue)
Sets a new property value.
|
FontDescriptor |
propertyValue(Term singleTerm)
Sets a new property value.
|
protected FontDescriptor |
self()
Should return "this".
|
void |
write(StyleWriter writer,
StyleAppendable appendable)
Outputs this
Writable 's string representation. |
boolean |
writesOwnComments()
Specifies whether this object will handle writing its own comments, instead of the automatic behavior of the
StyleWriter . |
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, 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, writesOwnOrphanedComments
shouldBreakBroadcast, status, status
public FontDescriptor(PropertyName propertyName, PropertyValue propertyValue)
FontDescriptor
instance with the given property name and value.propertyName
- The name of this font-descriptor.propertyValue
- The value of this font-descriptor.public FontDescriptor(Declaration source)
FontDescriptor
instance using the given Declaration
s PropertyName
and PropertyValue
, as well as comments.
Note that this will result in refinement of the Declaration
if not already done so.
source
- The source Declaration
public PropertyName propertyName()
public boolean isProperty(String property)
FontDescriptor
has the given property name. Prefer to use isProperty(Property)
instead.
Example:
if (descriptor.isProperty("font-family") {...}
property
- Name of the property.FontDescriptor
has the given property name.public boolean isProperty(Property property)
FontDescriptor
has the given Property
name.
Example:
if (descriptor.isProperty(Property.FONT_FAMILY)) {...}
property
- The Property
.FontDescriptor
has the given property name.public FontDescriptor propertyValue(Term singleTerm)
singleTerm
- The single Term
.public FontDescriptor propertyValue(PropertyValue propertyValue)
propertyValue
- The new property value.public PropertyValue propertyValue()
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 FontDescriptor self()
AbstractGroupable
AbstractGroupable
class.self
in class AbstractGroupable<FontFaceBlock,FontDescriptor>
public boolean writesOwnComments()
Syntax
StyleWriter
.
If returning true, be sure to check StyleWriter#shouldWriteAllComments()
to determine if comments should actually
be written out or not. The StyleWriter#appendComments(Iterable, StyleAppendable)
utility method contains this logic
and is the preferable way to handle it.
writesOwnComments
in interface Syntax
writesOwnComments
in class AbstractSyntax
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<FontFaceBlock,FontDescriptor>
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.
write
in interface Writable
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 FontDescriptor 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.