public final class SoyMsg extends Object
This class is heavily optimized for memory usage. In one major server using SoyTofu, Soy messages comprised the single largest category of memory usage prior to optimization. Several fields can be omitted entirely for render-only usage. ImmutableSet and ImmutableList are used because their empty implementations are singletons.
| Constructor and Description |
|---|
SoyMsg(long id,
long altId,
String localeString,
String meaning,
String desc,
boolean isHidden,
String contentType,
SourceLocation sourceLocation,
boolean isPlrselMsg,
Iterable<? extends SoyMsgPart> parts) |
SoyMsg(long id,
String localeString,
boolean isPlrselMsg,
Iterable<? extends SoyMsgPart> parts)
Constructor with just enough information for rendering only.
|
SoyMsg(long id,
String localeString,
String meaning,
String desc,
boolean isHidden,
String contentType,
SourceLocation sourceLocation,
Iterable<? extends SoyMsgPart> parts) |
| Modifier and Type | Method and Description |
|---|---|
void |
addSourceLocation(SourceLocation sourceLocation) |
boolean |
equals(Object otherObject) |
long |
getAltId()
Returns the alternate unique id for this message, or -1L if not applicable.
|
String |
getContentType()
Returns the content type of the document that this message will appear in.
|
String |
getDesc()
Returns the description for translators.
|
long |
getId()
Returns the unique id for this message (same across all translations).
|
com.ibm.icu.util.ULocale |
getLocale() |
String |
getLocaleString()
Returns the language/locale string.
|
String |
getMeaning()
Returns the meaning string if set, otherwise null (usually null).
|
com.google.common.collect.ImmutableList<SoyMsgPart> |
getParts()
Returns the parts that make up the message content.
|
com.google.common.collect.ImmutableSet<SourceLocation> |
getSourceLocations()
Returns the location(s) of the source file(s) that this message comes from.
|
int |
hashCode() |
boolean |
isHidden()
Returns whether this message should be hiddens.
|
boolean |
isPlrselMsg()
Returns whether this is a plural/select message.
|
String |
toString() |
public SoyMsg(long id,
long altId,
@Nullable
String localeString,
@Nullable
String meaning,
@Nullable
String desc,
boolean isHidden,
@Nullable
String contentType,
@Nullable
SourceLocation sourceLocation,
boolean isPlrselMsg,
Iterable<? extends SoyMsgPart> parts)
id - A unique id for this message (same across all translations).altId - An alternate unique id for this message, or -1L if not applicable.localeString - The language/locale string, or null if unknown. Should only be null for
messages newly extracted from source files. Should always be set for messages parsed from
message files/resources.meaning - The meaning string, or null if not necessary (usually null). This is a string
to create unique messages for two otherwise identical messages. This is usually done for
messages used in different contexts. (For example, the same word can be used as a noun in
one location and as a verb in another location, and the message texts would be the same
but the messages would have meanings of "noun" and "verb".). May not be applicable to all
message plugins.desc - The description for translators.isHidden - Whether this message should be hidden. May not be applicable to all message
plugins.contentType - Content type of the document that this message will appear in
(e.g. "text/html"). May not be applicable to all message plugins.sourceLocation - Location of a source file that this message comes from. More sources can
be added using addSourceLocation(). May not be applicable to all message plugins.isPlrselMsg - Whether this is a plural/select message.parts - The parts that make up the message content.public SoyMsg(long id,
@Nullable
String localeString,
@Nullable
String meaning,
@Nullable
String desc,
boolean isHidden,
@Nullable
String contentType,
@Nullable
SourceLocation sourceLocation,
Iterable<? extends SoyMsgPart> parts)
id - A unique id for this message (same across all translations).localeString - The language/locale string, or null if unknown. Should only be null for
messages newly extracted from source files. Should always be set for messages parsed from
message files/resources.meaning - The meaning string, or null if not necessary (usually null). This is a string
to create unique messages for two otherwise identical messages. This is usually done for
messages used in different contexts. (For example, the same word can be used as a noun in
one location and as a verb in another location, and the message texts would be the same
but the messages would have meanings of "noun" and "verb".). May not be applicable to all
message plugins.desc - The description for translators.isHidden - Whether this message should be hidden. May not be applicable to all message
plugins.contentType - Content type of the document that this message will appear in
(e.g. "text/html"). May not be applicable to all message plugins.sourceLocation - Location of a source file that this message comes from. More sources can
be added using addSourceLocation(). May not be applicable to all message plugins.parts - The parts that make up the message content.public SoyMsg(long id,
@Nullable
String localeString,
boolean isPlrselMsg,
Iterable<? extends SoyMsgPart> parts)
Using this constructor results in a working renderable message but uses much less memory than providing all the information for the full constructor.
id - A unique id for this message (same across all translations).localeString - The language/locale string, or null if unknown. Should only be null for
messages newly extracted from source files. Should always be set for messages parsed from
message files/resources.isPlrselMsg - Whether this is a plural/select message.parts - The parts that make up the message content.@Nullable public com.ibm.icu.util.ULocale getLocale()
public long getId()
public long getAltId()
public String getMeaning()
public String getDesc()
public boolean isHidden()
public String getContentType()
public void addSourceLocation(SourceLocation sourceLocation)
sourceLocation - Location of a source file that this message comes from.public com.google.common.collect.ImmutableSet<SourceLocation> getSourceLocations()
public boolean isPlrselMsg()
public com.google.common.collect.ImmutableList<SoyMsgPart> getParts()