Class FormThemeReference
- java.lang.Object
-
- de.xima.fc.form.common.models.FormThemeReference
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
FormThemeReference.ClientFormTheme
,FormThemeReference.FormThemePlugin
,FormThemeReference.System
public abstract class FormThemeReference extends Object implements Serializable
A reference to a form theme that is used to style a form. A form theme may come from different sources, such as built-in form themes, user-defined form themes, or plugin form themes.A form theme consists of JavaScript and CSS files, as well as other resources such as fonts and images. Users can select a form theme in the form designer, and each form can have a different form theme. The form theme affects both the main web form and related pages such as HTML templates.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FormThemeReference.ClientFormTheme
A form theme reference to a client form theme.static class
FormThemeReference.DefaultMatcher<R,E extends Throwable>
A special type ofFormThemeReference.Matcher
for a form theme that returns a given default value for each type of theme.static class
FormThemeReference.FormThemePlugin
A form theme reference to a form theme provided by a plugin, i.e.static class
FormThemeReference.FormThemeReferenceDeserializer
FastJson deserializer forFormThemeReference
.static interface
FormThemeReference.Matcher<R,E extends Throwable>
A matcher on aFormThemeReference
.static class
FormThemeReference.System
A form theme reference to a system form theme, i.e.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
canonicalPartsLength()
Gets the length of the parts representing this reference, i.e.abstract int
canonicalPayloadPartsLength()
Gets the length of the parts representing the payload of this reference, i.e.static FormThemeReference
clientFormTheme(UUID templateUuid)
Creates a reference to a client form theme with the given UUID.Object
clone()
abstract FormThemeReference
copy()
Creates a copy of this form theme reference.abstract boolean
equals(Object other)
protected abstract void
fillCanonicalPayloadParts(String[] parts, int offset)
static FormThemeReference
formThemePlugin(String pluginKey, String pluginName, String themeId)
Gets a reference to a form theme provided by a form theme plugin (de.xima.fc.plugin.form.IPluginFormTheme
).abstract int
hashCode()
abstract EFormThemeReferenceKind
kind()
Gets the enum constant that represents the kind of this form theme reference.static <R,E extends Throwable>
RmatchFormThemeReference(FormThemeReference reference, FormThemeReference.Matcher<R,E> matcher)
Matches the given form theme reference with the appropriate method of the given matcher.static FormThemeReference
ofAttributeMap(String prefix, Map<String,String> map)
Reads a form theme reference to the given attribute map that is stored at the given prefix.static FormThemeReference
ofCanonicalParts(String[] parts, int offset)
Creates a form theme reference from its canonical parts representation.static FormThemeReference
ofCanonicalPartsOrNull(String[] parts, int offset)
Creates a form theme reference from its canonical parts representation.static FormThemeReference
ofCanonicalPayloadParts(EFormThemeReferenceKind kind, String[] parts, int offset)
Creates a form theme reference from its canonical parts representation.static FormThemeReference
ofCanonicalPayloadPartsOrNull(EFormThemeReferenceKind kind, String[] parts, int offset)
Creates a form theme reference from its canonical parts representation.static FormThemeReference
ofCanonicalPayloadString(EFormThemeReferenceKind kind, String canonicalRepresentation)
Creates a form theme reference from its canonical string representation.static FormThemeReference
ofCanonicalPayloadStringOrNull(EFormThemeReferenceKind kind, String canonicalRepresentation)
Creates a form theme reference from its canonical string representation.static FormThemeReference
ofCanonicalString(String canonicalRepresentation)
Creates a form theme reference from its canonical string representation.static FormThemeReference
ofCanonicalStringOrNull(String canonicalRepresentation)
Creates a form theme reference from its canonical string representation.static FormThemeReference
system(ESystemFormThemeType type)
Gets a reference to the system form theme of the given type.static FormThemeReference
systemClassic()
Gets a reference to the classic system form theme.static FormThemeReference
systemModern()
Gets a reference to the modern system form theme.static void
toAttributeMap(FormThemeReference theme, String prefix, Map<String,String> map)
Writes the given form theme reference to the given attribute map.String[]
toCanonicalParts()
Converts this form theme reference to its canonical string parts representation.String[]
toCanonicalPayloadParts()
Converts this form theme reference to its canonical string parts representation.abstract String
toCanonicalPayloadString()
Converts this form theme reference to its canonical string representation.String
toCanonicalString()
Converts this form theme reference to its canonical string representation.abstract String
toSimpleName()
Gets a simple name describing this reference.
-
-
-
Method Detail
-
canonicalPartsLength
public final int canonicalPartsLength()
Gets the length of the parts representing this reference, i.e. the length of the array returned bytoCanonicalParts()
.- Returns:
- The length of the parts representing this reference.
-
canonicalPayloadPartsLength
public abstract int canonicalPayloadPartsLength()
Gets the length of the parts representing the payload of this reference, i.e. the length of the array returned bytoCanonicalPayloadParts()
. The payload is the data of this reference, without thekind()
.- Returns:
- The length of the parts representing this reference.
-
copy
public abstract FormThemeReference copy()
Creates a copy of this form theme reference.- Returns:
- A copy of this form theme reference.
-
kind
public abstract EFormThemeReferenceKind kind()
Gets the enum constant that represents the kind of this form theme reference.- Returns:
- The kind of the form theme reference.
-
toCanonicalParts
public final String[] toCanonicalParts()
Converts this form theme reference to its canonical string parts representation.In other words creates an array strings that is compatible with
equals(Object)
. Two references that are equal will have the same string parts representation.- Returns:
- The canonical string parts representation of the form theme reference.
- See Also:
toCanonicalString()
-
toCanonicalPayloadParts
public final String[] toCanonicalPayloadParts()
Converts this form theme reference to its canonical string parts representation. Only includes the data of this particularkind()
of reference, does not include data regarding which kind of reference this is.- Returns:
- The canonical string parts representation of the form theme reference.
- See Also:
toCanonicalParts()
-
toCanonicalPayloadString
public abstract String toCanonicalPayloadString()
Converts this form theme reference to its canonical string representation. Only includes the data of this particularkind()
of reference, does not include data regarding which kind of reference this is.- Returns:
- The canonical string representation of the form theme reference.
- See Also:
toCanonicalParts()
-
toCanonicalString
public final String toCanonicalString()
Converts this form theme reference to its canonical string representation.In other words creates a string representation that is compatible with
equals(Object)
. Two references that are equal will have the same string representation.- Returns:
- The canonical string representation of the form theme reference.
- See Also:
toCanonicalParts()
-
toSimpleName
public abstract String toSimpleName()
Gets a simple name describing this reference. Should not be used for any purposes other than to pretty-print the reference.- Returns:
- A simple name describing this reference.
-
fillCanonicalPayloadParts
protected abstract void fillCanonicalPayloadParts(String[] parts, int offset)
-
clientFormTheme
public static FormThemeReference clientFormTheme(UUID templateUuid)
Creates a reference to a client form theme with the given UUID. The given UUID must reference the UUID of an existingde.xima.fc.entities.ClientFormTheme
.- Parameters:
templateUuid
- The UUID of the client form theme.- Returns:
- A reference to the client form theme.
-
formThemePlugin
public static FormThemeReference formThemePlugin(String pluginKey, String pluginName, String themeId)
Gets a reference to a form theme provided by a form theme plugin (de.xima.fc.plugin.form.IPluginFormTheme
). A form theme from a form theme plugin is uniquely identified by the plugin key and name of the plugin, as well as the theme ID. Each form theme plugin may provide multiple form themes, each with a unique ID.- Parameters:
pluginKey
- The key of the plugin, i.e. the value of thePlugin-Key
attribute in the plugin's manifest.pluginName
- The name of the plugin, i.e. the value returned byde.xima.fc.plugin.interfaces.IFCPlugin#getName()
.themeId
- The ID of one of the themes provided by the plugin.- Returns:
- A reference to the form theme provided by the form theme plugin.
-
matchFormThemeReference
public static <R,E extends Throwable> R matchFormThemeReference(FormThemeReference reference, FormThemeReference.Matcher<R,E> matcher) throws E extends Throwable
Matches the given form theme reference with the appropriate method of the given matcher.- Type Parameters:
R
- The return type of the matcher functions.E
- The type of exception that the matcher functions may throw.- Parameters:
reference
- The form theme reference to match.matcher
- The matcher to use.- Returns:
- The result of the matching function.
- Throws:
E
- The exception that may be thrown by the matching function.E extends Throwable
-
ofAttributeMap
public static FormThemeReference ofAttributeMap(String prefix, Map<String,String> map)
Reads a form theme reference to the given attribute map that is stored at the given prefix. This is the counterpart totoAttributeMap
.A form theme reference consists of several pieces of data, depending on the kind of the reference. For each piece of data, the attribute map should contain an entry with a key that is the given prefix plus a suffix that identifies the piece of data. The suffix is internal to this method and should not be relied upon. Use
toAttributeMap
to write a form theme reference to an attribute map.This method ignores superfluous attributes that do not apply to the
kind()
of the given form theme reference.When the given form theme reference is null, this method returns null.
When an attribute contains an invalid value, this method returns null.
- Parameters:
prefix
- The prefix to use for the keys in the map. null is treated as an empty string.map
- The map to write the attributes to. If null, this method returns null.- Returns:
- The form theme reference, or null when the given map is null, empty, or does not contain the required attributes.
-
ofCanonicalParts
public static FormThemeReference ofCanonicalParts(String[] parts, int offset)
Creates a form theme reference from its canonical parts representation. The given parts must conform to the format as returned bytoCanonicalParts()
.Note that the number of parts depends on the type of form theme. Use
canonicalPartsLength()
to get the number of parts required for a specific form theme reference.- Parameters:
parts
- The parts of the form theme reference to parse.offset
- The offset in the parts array where the form theme reference starts.- Returns:
- The form theme reference, or null if the given parts are null or empty.
- Throws:
IllegalArgumentException
- If the given parts do not represent a valid form theme reference.
-
ofCanonicalPartsOrNull
public static FormThemeReference ofCanonicalPartsOrNull(String[] parts, int offset)
Creates a form theme reference from its canonical parts representation. The given parts must conform to the format as returned bytoCanonicalParts()
.Note that the number of parts depends on the type of form theme. Use
canonicalPartsLength()
to get the number of parts required for a specific form theme reference.- Parameters:
parts
- The parts of the form theme reference to parse.offset
- The offset in the parts array where the form theme reference starts.- Returns:
- The form theme reference, or null if the given parts are null, empty, or do not represent a valid form theme reference.
-
ofCanonicalPayloadParts
public static FormThemeReference ofCanonicalPayloadParts(EFormThemeReferenceKind kind, String[] parts, int offset)
Creates a form theme reference from its canonical parts representation. The given parts must conform to the format as returned bytoCanonicalPayloadParts()
.Note that the number of parts depends on the type of form theme. Use
canonicalPayloadPartsLength()
to get the number of parts required for a specific form theme reference.- Parameters:
kind
- The type of form theme reference.parts
- The parts of the form theme reference to parse.offset
- The offset in the parts array where the form theme reference starts.- Returns:
- The form theme reference, or null if the given parts are null or empty.
- Throws:
IllegalArgumentException
- If the given parts do not represent a valid form theme reference.
-
ofCanonicalPayloadPartsOrNull
public static FormThemeReference ofCanonicalPayloadPartsOrNull(EFormThemeReferenceKind kind, String[] parts, int offset)
Creates a form theme reference from its canonical parts representation. The given parts must conform to the format as returned bytoCanonicalPayloadParts()
.Note that the number of parts depends on the type of form theme. Use
canonicalPayloadPartsLength()
to get the number of parts required for a specific form theme reference.- Parameters:
kind
- The type of form theme reference.parts
- The parts of the form theme reference to parse.offset
- The offset in the parts array where the form theme reference starts.- Returns:
- The form theme reference, or null if the given parts are null or empty; or if the given parts do not represent a valid form theme reference.
-
ofCanonicalPayloadString
public static FormThemeReference ofCanonicalPayloadString(EFormThemeReferenceKind kind, String canonicalRepresentation)
Creates a form theme reference from its canonical string representation. The given string must conform to the format as returned bytoCanonicalPayloadString()
.- Parameters:
kind
- The type of form theme reference.canonicalRepresentation
- The canonical string representation of the form theme reference.- Returns:
- The form theme reference, or null when the given kind is null and the string is null, empty, or blank.
- Throws:
IllegalArgumentException
- If the given string is not a valid canonical representation.
-
ofCanonicalPayloadStringOrNull
public static FormThemeReference ofCanonicalPayloadStringOrNull(EFormThemeReferenceKind kind, String canonicalRepresentation)
Creates a form theme reference from its canonical string representation. The given string must conform to the format as returned bytoCanonicalPayloadString()
.- Parameters:
kind
- The type of form theme reference.canonicalRepresentation
- The canonical string representation of the form theme reference.- Returns:
- The form theme reference, or null when the given string is null, empty, or blank; or if the given string is not a valid canonical representation.
-
ofCanonicalString
public static FormThemeReference ofCanonicalString(String canonicalRepresentation)
Creates a form theme reference from its canonical string representation. The given string must conform to the format as returned bytoCanonicalString()
.- Parameters:
canonicalRepresentation
- The canonical string representation of the form theme reference.- Returns:
- The form theme reference, or null when the given string is null, empty, or blank.
- Throws:
IllegalArgumentException
- If the given string is not a valid canonical representation.
-
ofCanonicalStringOrNull
public static FormThemeReference ofCanonicalStringOrNull(String canonicalRepresentation)
Creates a form theme reference from its canonical string representation. The given string must conform to the format as returned bytoCanonicalString()
.- Parameters:
canonicalRepresentation
- The canonical string representation of the form theme reference.- Returns:
- The form theme reference, or null when the given string is null, empty, or blank; or it does not represent a valid form theme reference.
-
system
public static FormThemeReference system(ESystemFormThemeType type)
Gets a reference to the system form theme of the given type.- Parameters:
type
- The type of the system form theme.- Returns:
- A reference to the system form theme of the given type.
-
systemClassic
public static FormThemeReference systemClassic()
Gets a reference to the classic system form theme.- Returns:
- A reference to the classic system form theme.
-
systemModern
public static FormThemeReference systemModern()
Gets a reference to the modern system form theme.- Returns:
- A reference to the modern system form theme.
-
toAttributeMap
public static void toAttributeMap(FormThemeReference theme, String prefix, Map<String,String> map)
Writes the given form theme reference to the given attribute map. A form theme reference consists of several pieces of data, depending on the kind of the reference. For each piece of data, this method writes an entry to the map with a key that is the given prefix plus a suffix that identifies the piece of data. The suffix is internal to this method and should not be relied upon. UseofAttributeMap
to extract the form theme reference from an attribute map.This method removes superfluous attributes that do not apply to the
kind()
of the given form theme reference.When the given form theme reference is null, all attributes are removed from the map.
- Parameters:
theme
- The form theme reference to write to the map.prefix
- The prefix to use for the keys in the map. Null is treated as an empty string.map
- The map to write the attributes to.
-
-