Class ProfilePropertyValueUtil
java.lang.Object
io.meeds.social.core.profileproperty.util.ProfilePropertyValueUtil
Rules on profile attribute names shared by the listing cascade of the
attribute settings, the forms' allow-list and the attribute form, and on
how a stored attribute value reads back.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternThe WHATWG valid e-mail address production, which the browser applies to the profile's e-mail fields, whose input is of type email.static final intThe size of SOC_USER_PERMISSION.GROUP_ID, which holds the group a group-synchronized value grantsstatic final intThe size of SOC_IDENTITY_PROPERTIES.NAME, where a value is storedstatic final intThe size of SOC_IDENTITY_PROPERTIES.VALUE, which holds an attribute's stored form, in UTF-16 unitsstatic final intThe longest cleaned name a group-synchronized attribute can have to be listed: its prefix, a slash and a one-character value then take the whole group id bound.static final StringThe parent of the groups a group-synchronized attribute's values grant, as GroupSynchronizationSocialProfileListener builds their ids: this prefix, the attribute's cleaned name, a slash and the value's cleaned text.Names no form lists, compared ignoring case: the default fields, always present in the forms, and the profile keys the forms never write.static final PatternThe e-mail rule of $utils.isValidEmail (vue-apps/common/js/Utils.js), which the profile's e-mail fields apply; only an ASCII value passesINPUT_EMAIL_PATTERNtoo, so Java's ASCII \s is enough here -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetCleanedLength(String text) static intgetSynchronizedGroupIdLength(String propertyName, String value) static booleanisListableName(String propertyName, boolean groupSynchronized) static booleanisUnlistableName(String propertyName) static booleanisValidEmail(String value) static booleanmatchesInputEmail(String value) static booleanmatchesUtilsEmail(String value) static booleanreadsBackAsList(String value) Every list the identity storage writes is a JSON array of JSON objects, so only such a text is read back as a list; any other text, a bracketed one included, is read back as the text it is.static intstoredLength(Object value)
-
Field Details
-
UNLISTABLE_NAMES
-
MAX_LISTABLE_NAME_LENGTH
public static final int MAX_LISTABLE_NAME_LENGTHThe size of SOC_IDENTITY_PROPERTIES.NAME, where a value is stored- See Also:
-
MAX_GROUP_ID_LENGTH
public static final int MAX_GROUP_ID_LENGTHThe size of SOC_USER_PERMISSION.GROUP_ID, which holds the group a group-synchronized value grants- See Also:
-
SYNCHRONIZED_GROUP_ID_PREFIX
The parent of the groups a group-synchronized attribute's values grant, as GroupSynchronizationSocialProfileListener builds their ids: this prefix, the attribute's cleaned name, a slash and the value's cleaned text.- See Also:
-
MAX_SYNCHRONIZED_NAME_LENGTH
public static final int MAX_SYNCHRONIZED_NAME_LENGTHThe longest cleaned name a group-synchronized attribute can have to be listed: its prefix, a slash and a one-character value then take the whole group id bound. -
MAX_STORED_VALUE_LENGTH
public static final int MAX_STORED_VALUE_LENGTHThe size of SOC_IDENTITY_PROPERTIES.VALUE, which holds an attribute's stored form, in UTF-16 units- See Also:
-
UTILS_EMAIL_PATTERN
The e-mail rule of $utils.isValidEmail (vue-apps/common/js/Utils.js), which the profile's e-mail fields apply; only an ASCII value passesINPUT_EMAIL_PATTERNtoo, so Java's ASCII \s is enough here -
INPUT_EMAIL_PATTERN
The WHATWG valid e-mail address production, which the browser applies to the profile's e-mail fields, whose input is of type email. The labels' repetition is possessive: a greedy one recurses once per label, and a value of a few thousand labels, checked before its size, overflows the stack; since a label holds no dot, giving one back never helps the match
-
-
Method Details
-
isUnlistableName
- Parameters:
propertyName- an attribute's technical name- Returns:
- true when the name is one of
UNLISTABLE_NAMES, ignoring case
-
isListableName
- Parameters:
propertyName- an attribute's technical namegroupSynchronized- whether the attribute's values grant group memberships- Returns:
- true when an attribute of that name can be listed
in a form: neither unlistable nor longer than
MAX_LISTABLE_NAME_LENGTHUTF-16 units, and, when group-synchronized, a cleaned name of 1 toMAX_SYNCHRONIZED_NAME_LENGTHcharacters
-
getCleanedLength
- Parameters:
text- a name or a value- Returns:
- the length of the text as it appears in a synchronized group's id, 0 when nothing of it remains
-
getSynchronizedGroupIdLength
- Parameters:
propertyName- a group-synchronized attribute's technical namevalue- one of its values- Returns:
- the length of the id of the group the value makes, as
GroupSynchronizationSocialProfileListener builds it:
SYNCHRONIZED_GROUP_ID_PREFIX, the cleaned name, a slash and the cleaned value
-
isValidEmail
- Parameters:
value- a single value- Returns:
- true when the value passes both e-mail rules the profile's e-mail fields apply
-
matchesUtilsEmail
- Parameters:
value- a single value- Returns:
- true when the whole value matches
UTILS_EMAIL_PATTERN
-
matchesInputEmail
- Parameters:
value- a single value- Returns:
- true when the whole value matches
INPUT_EMAIL_PATTERN
-
storedLength
- Parameters:
value- an attribute's value in the storage shape: a text, or a list of maps for a multi-valued attribute- Returns:
- the length, in UTF-16 units, of the text the identity storage writes for it: the text itself, or the JSON array org.json serialises the list's maps to, escapes included
-
readsBackAsList
Every list the identity storage writes is a JSON array of JSON objects, so only such a text is read back as a list; any other text, a bracketed one included, is read back as the text it is. The text is parsed under JSON's own grammar, a repeated name refused: org.json, which converts it, accepts unquoted or single-quoted names, extra commas and semicolons, and ignores what follows the array, so a text it accepts can come back changed, while it refuses a repeated name, so a text it refuses would come back empty.- Parameters:
value- a profile attribute's stored text- Returns:
- true when the whole text, from its first to its last character, is a JSON array whose entries are all JSON objects, the empty array included
-