public final class StringValue extends AbstractTerm
Note that the reason a setter for quotation mode doesn't exist is that it must not be set independent of the content (which
could contain incompatible), so use content(QuotationMode, String)
(and verify the content and quotation mode are
compatible) instead.
StringValueParser
Constructor and Description |
---|
StringValue(int line,
int column,
QuotationMode mode,
String content)
Constructs a new
StringValue instance. |
StringValue(QuotationMode mode,
String content)
Constructs a new
StringValue instance (used for dynamically created Syntax units). |
Modifier and Type | Method and Description |
---|---|
String |
content()
Gets the content of the string.
|
StringValue |
content(QuotationMode mode,
String content)
Sets the content of the string.
|
StringValue |
copy()
For implementations: do not copy comments or orphaned comments, instead be sure to call
AbstractSyntax.copiedFrom(Syntax) on the
new copy. |
QuotationMode |
mode()
Gets the
QuotationMode . |
static StringValue |
of(QuotationMode mode,
String content)
Creates a new
StringValue instance using the given QuotationMode and content. |
String |
textualValue()
Gets the content of the string.
|
void |
write(StyleWriter writer,
StyleAppendable appendable)
Outputs this
Writable 's string representation. |
declaration, isTerm, self
append, destroy, group, group, isDestroyed, isFirst, isLast, isWritable, 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, propagateBroadcast, shouldBreakBroadcast, status, status, toString, toString, writesOwnComments, writesOwnOrphanedComments
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
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
propagateBroadcast, shouldBreakBroadcast, status, status
public StringValue(int line, int column, QuotationMode mode, String content)
StringValue
instance.
The QuotationMode
is required so that we can preserve the original quotes used in the source. Performance-wise,
there is no reason to change it from the original, and also it keeps us from having to mess around with escaping.
* If dynamically creating a new instance then use StringValue(QuotationMode, String)
instead.
line
- The line number.column
- The column number.mode
- The QuotationMode
to use when printing out the value.content
- The content of the string.public StringValue(QuotationMode mode, String content)
StringValue
instance (used for dynamically created Syntax
units).mode
- The QuotationMode
to use when printing out the value.content
- The content of the string.public StringValue content(QuotationMode mode, String content)
mode
- The QuotationMode
to use when printing out the value.content
- The content.public String content()
public QuotationMode mode()
QuotationMode
.QuotationMode
.public String textualValue()
content()
, which is identical to this method.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 StringValue copy()
AbstractSyntax
AbstractSyntax.copiedFrom(Syntax)
on the
new copy.copy
in interface PropertyValueMember
copy
in interface Term
copy
in interface Syntax
copy
in class AbstractSyntax
public static StringValue of(QuotationMode mode, String content)
StringValue
instance using the given QuotationMode
and content.
Example:
StringValue.of("Times new Roman")
mode
- The QuotationMode
to use when printing out the value.content
- The content of the string.StringValue
instance.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.