Private
fieldsHolds the actual parameters of the Mistake.
Private
pathThe relative URL path of the Mistake. Must match Fields#id.
Returns a deep copy of the #fields.aliases Array.
the #fields.aliases Array or undefined
if it is not set
a deep copy of the #fields.alt Array or undefined
if it is not set
the #fields.arten property
a deep copy of the #fields.confusion Array or undefined
if it is not set
Returns #fields.id as a GrammleID (even though it is locally stored in the form of a string).
the Mistake's ID
the #fields.name property
a deep copy of the #fields.kategorien Array
Returns the main category of this Mistake, which is the first category in the #fields.kategorien Array.
the #fields.orderID property
the #path property
a deep copy of the #fields.related Array or undefined
if it is not set
a deep copy of the #fields.source Array or undefined
if it is not set
the #fields.uid property
a deep copy of the #fields.wrongs Array or undefined
if it is not set
Generates a new fields#uid for this Mistake.
UID = unique ID of a mistake := MD5 hash of (mistake.toString() + milliseconds since 1970)
G3
and G8
only based on their respective IDs.
Further, assume we'd use the web-based edit tool to re-order several mistakes, including G3
or
G8
(or both).
Now, because G8
isn't G8
anymore – as it was re-ordered as G7
–
we'd need to figure out a way to re-link it to G3
.
The problem is: We don't know whether G3
is still G3
– perhaps it had been re-ordered itself before G8
became G7
.
The only solution that is guaranteed to always work is to create truly unique IDs for each mistake at the time of creation.
That doesn't mean it's impossible to link mistakes based on their IDs, but this would be way too complicated to implement, maintain and refactor.
Thus, we're using cryptographic hashes of the mistake objects plus the respective current date. Obviously, MD5 is outdated, but since our use case is not sensitive at all, that's perfectly ok, or rather it's not worth wasting significantly more space just for SHA512.
true
if the UID was successfully set
IllegalDiscrepancyError if the UID is already set
Sets new categories for this Mistake and deduplicates them, but keeps the previous first category and therefore does NOT update the #path, #fields.id, #fields.orderID or #fields.name accordingly.
Info: If the given array is empty, all additional categories are removed, but the first category is kept.
true
if the categories were set successfully
the new categories for this Mistake
Sets new #fields#aliases by calling Fields#setAliases and updates the #path accordingly if necessary.
true
if the aliases were valid and set successfully
IllegalArgumentError If the given aliases didn't meet the requirements of Fields#setAliases
the new aliases for this Mistake
Sets a new ID for this Mistake and updates the #path, #fields.orderID and #fields.aliases[0] accordingly.
Sets a new name for this Mistake and updates the #path, #fields.id and #fields.aliases[0] accordingly.
the new name for this Mistake
Sets a new orderID for this Mistake and updates the #path, #fields.id and #fields.aliases[0] accordingly.
true
if the orderID was set successfully, false
otherwise
if the orderID does not match the pattern <category[0]><padding zeros><UInt> with number.length == 4
the new orderID for this Mistake
Private
setUIDSets a new #fields.uid for this Mistake and updates the #fields.aliases[1] accordingly.
true
if the UID was set successfully
IllegalArgumentError if the UID is not an MD5 hash of 32 characters
the new UID for this Mistake
the Mistake as a raw Object
this Mistake as a JSON string.
Private
updateUpdates a specific item in a given string Array at a given index to a new given value.
This method exists to avoid having to check for undefined
every time.
the updated Array
the Array to update
the index of the item to update
the new value for the item at the given index
Static
fromCreates a new Mistake object from a given raw Object.
the new Mistake object
if the given parameter is not an Object or if it does not have a required property.
the raw object to create the Mistake from
Static
validateChecks whether the given Mistake is valid.
Conditions:
Generated using TypeDoc
Represents a language mistake, including its path in the Grammle URL and its Fields.