public interface Term extends PropertyValueMember
PropertyValueMember
within a PropertyValue
representing a single segment of the Declaration
value.
For example, in margin: 3px 5px
, there are two terms, 3px
and 5px
.
Modifier and Type | Method and Description |
---|---|
Term |
copy()
Performs a deep copy of the instance.
|
Declaration |
declaration()
Shortcut method to get the parent
Declaration containing this term. |
String |
textualValue()
Gets the textual content of this term.
|
isTerm
append, destroy, group, group, isDestroyed, isFirst, isLast, next, parent, prepend, previous, replaceWith, unlink
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, hasAnnotation, hasAnnotation, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, toString, writesOwnComments, writesOwnOrphanedComments
isWritable, write
propagateBroadcast, shouldBreakBroadcast, status, status
Declaration declaration()
Declaration
containing this term.Declaration
. If working with this term before it has been properly linked then this may return
null. This is not the case for normal subscription methods.String textualValue()
This method may be useful as a generic way of getting the value of unknown or potentially varying term types.
If you have the concrete type of the Term
in hand, prefer to use the more specific getter method instead of this
one.
Important: this is not a substitute or a replica of how the term will actually be written to a stylesheet. The
textual content returned may not include certain tokens and outer symbols such as hashes, quotes, parenthesis, etc... . To
get the textual content as it would be written to a stylesheet see StyleWriter#writeSingle(Writable)
instead.
However note that you should rarely have need for doing that outside of actually creating stylesheet output.
KeywordValue
s will simply return the keyword, StringValue
s will return the contents of the string not
including quotes, functions will return the content of the function not including the parenthesis, HexColorValue
will return the hex value without the leading '#' , and so on... See each specific Term
implementation for more details.
For custom Term
implementations-- You should return the most appropriate string value representing the inner
content of your term. If this is not applicable, either throw UnsupportedOperationException
or return an empty
string. Do not return null.
Term copy()
Syntax
This includes any inner syntax units, for example the selectors inside of a rule. This also carries over the comments and orphaned comments.
Keep in mind that copying is generally not preferred. Particularly, it is generally better to parse the source again than
to copy a Stylesheet
. Copying a specific syntax unit may be appropriate when duplicating the terms in a declaration
or the selector parts in a selector.
copy
in interface PropertyValueMember
copy
in interface Syntax
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.