Modifier and Type | Method and Description |
---|---|
static SafeStyle |
fromConstant(String style)
Creates a SafeStyle from the given compile-time constant string
style . |
static SafeStyle |
fromProto(SafeStyleProto proto)
Deserializes a SafeStyleProto into a SafeStyle instance.
|
static SafeStyleProto |
toProto(SafeStyle style)
Serializes a SafeStyle into its opaque protocol message representation.
|
public static SafeStyle fromConstant(@CompileTimeConstant String style)
style
.
style
should be in the format name: value; [name: value; ...]
and must
not have any < or > characters in it. This is so that SafeStyle's contract is preserved,
allowing the SafeStyle to correctly be interpreted as a sequence of CSS declarations and
without affecting the syntactic structure of any surrounding CSS and HTML.
This method performs basic sanity checks on the format of style
but does not
constrain the format of name
and value
, except for disallowing tag characters.
IllegalArgumentException
- if some of the constraints of the format specified above
are not metpublic static SafeStyle fromProto(SafeStyleProto proto)
Protocol-message forms are intended to be opaque. The fields of the protocol message should
be considered encapsulated and are not intended for direct inspection or manipulation. Protocol
message forms of this type should be produced by toProto(SafeStyle)
or its equivalent
in other implementation languages.
Important: It is unsafe to invoke this method on a protocol message that has been received from an entity outside the application's trust domain. Data coming from the browser is outside the application's trust domain.
public static SafeStyleProto toProto(SafeStyle style)
Protocol message forms of this type are intended to be opaque. The fields of the returned
protocol message should be considered encapsulated and are not intended for direct inspection
or manipulation. Protocol messages can be converted back into a SafeStyle using
fromProto(SafeStyleProto)
.