Jungle Utils
The JungleUtils
class provides a collection of utility functions used by Jungle Sequencers runtime scripts.
Overview
The JungleUtils
class provides the following functionalities:
- Contains a property with the package version.
- Method for generating a unique identifier.
- Method for find a unique name from a list of names.
- Methods for shortening strings.
- Method for processing and regenerating unique identifiers on
JungleTree
s - Method for generating structured author info for the current user.
Properties
JUNGLE_VERSION
public const string JUNGLE_VERSION;
The installed package version of Jungle Sequencer.
Methods
GenerateUid
public static string GenerateUid(int length = 16)
Generates a unique identifier of the specified length.
Parameters
int length
: The length of the unique identifier.- The default length is 16.
- The minimum length is 2.
- The maximum length is 64.
Returns
A unique identifier.
FindUnqiueName
public static string FindUniqueName(string baseName, string[] otherNames)
Ensures baseName
is unique within otherNames
by appending the lowest unused numeric suffix.
Parameters
string baseName
: The desired name.string[] otherNames
: Existing names to avoid.
Returns
A unique name.
Exceptions
ArgumentNullException
: Thrown whenbaseName
is null or empty.
ShortenStringEnd
public static string ShortenStringEnd(string value, int maximumLength)
Shortens a string to a maximum length, appending "..." if it exceeds that length.
Parameters
string value
: The string to shorten.int maximumLength
: The maximum allowed length of the result.
Returns
The original string if it's within the limit; otherwise, a truncated version ending with "...".
ShortenStringMiddle
public static string ShortenStringMiddle(string value, int maximumLength)
Shortens a string by removing characters from the middle and inserting "..." if it exceeds the maximum length.
Parameters
string value
: The string to shorten.int maximumLength
: The maximum allowed length of the result.
Returns
The original string if it's within the limit; otherwise, a shortened version with "..." in the middle.
ProcessTrees
public static void ProcessTrees(List<JungleTree> trees)
Shortens a string by removing characters from the middle and inserting "..." if it exceeds the maximum length.
Parameters
List<JungleTree> trees
: The list ofJungleTree
s to process and clean up.
Exceptions
ArgumentNullException
: Thrown if the given list of trees is null.
RegenerateUids
public static void RegenerateUids(JungleTree tree, bool reprocess = true)
Regenerates all unique identifiers on the given JungleTree
.
This includes: The tree, all nodes, and all sticky notes.
Parameters
JungleTree tree
: TheJungleTree
to regenerate unique identifiers for.bool reprocess = true
: If the given tree should be reprocessed after regeneration.
Exceptions
ArgumentNullException
: Thrown if the given tree is null.Exception
: Thrown if the given trees manifest is in an invalid state.
ProcessTrees
public static void ProcessTrees(List<JungleTree> trees)
Shortens a string by removing characters from the middle and inserting "..." if it exceeds the maximum length.
Parameters
List<JungleTree> trees
: The list ofJungleTree
s to process and clean up.
Exceptions
ArgumentNullException
: Thrown if the given list of trees is null.