Gridarta Editor
net.sf.gridarta.utils.StringUtils Class Reference
+ Collaboration diagram for net.sf.gridarta.utils.StringUtils:

Static Public Member Functions

static CharSequence diffTextString (@NotNull final CharSequence base, @NotNull final String str, final boolean ignoreValues)
 
static CharSequence ensureTrailingNewline (@NotNull final String str)
 
static String getAttribute (@NotNull final CharSequence attributes, @NotNull final String attributeName)
 
static String removeTrailingWhitespace (@NotNull final CharSequence str)
 
static String removeTrailingWhitespaceFromLines (@NotNull final CharSequence str)
 
static String sortLines (@NotNull final CharSequence string)
 

Static Public Attributes

static final Pattern PATTERN_BACKSLASH = Pattern.compile("\\\\")
 
static final Pattern PATTERN_COLON = Pattern.compile(":")
 
static final Pattern PATTERN_COMMA = Pattern.compile(",")
 
static final Pattern PATTERN_END_OF_LINE = Pattern.compile("\\s*\n")
 
static final Pattern PATTERN_EQUAL = Pattern.compile("=")
 
static final Pattern PATTERN_NEWLINE = Pattern.compile("\n")
 
static final Pattern PATTERN_SLASH = Pattern.compile("/")
 
static final Pattern PATTERN_SPACE = Pattern.compile(" ")
 
static final Pattern PATTERN_SPACES = Pattern.compile(" +")
 
static final Pattern PATTERN_WHITESPACE = Pattern.compile("[\\x00-\\x09\\x0b\\x20]+")
 
static final Pattern PATTERN_WHITESPACE_NEWLINE = Pattern.compile("[\\x00-\\x0b\\x0d\\x20]+")
 

Private Member Functions

 StringUtils ()
 

Static Private Attributes

static final Pattern PATTERN_MULTI_LINE_TRAILING_WHITESPACE = Pattern.compile("(?m)[\\x00-\\x09\\x0b\\x20]+$")
 
static final Pattern PATTERN_TRAILING_WHITESPACE = Pattern.compile("[\\x00-\\x09\\x0b\\x20]+$")
 

Detailed Description

Utility class for string manipulation.

Author
Andreas Kirschbaum

Definition at line 31 of file StringUtils.java.

Constructor & Destructor Documentation

◆ StringUtils()

net.sf.gridarta.utils.StringUtils.StringUtils ( )
private

Private constructor to prevent instantiation.

Definition at line 114 of file StringUtils.java.

Member Function Documentation

◆ diffTextString()

static CharSequence net.sf.gridarta.utils.StringUtils.diffTextString ( @NotNull final CharSequence  base,
@NotNull final String  str,
final boolean  ignoreValues 
)
static

Helper function for 'diffArchText()': Looks for occurrence of the attribute 'str' in 'base' and if found, returns the full line where 'str' occurs in base. Only occurrences of 'str' at the beginning of a new line are counted as valid. If not found, null is returned.

Parameters
basefull text to search
strstring (attribute) to look for
ignoreValuesif true, lines are matched against 'str' only till the first space (" ")
Returns
the text that differs

Definition at line 162 of file StringUtils.java.

References net.sf.gridarta.utils.StringUtils.PATTERN_END_OF_LINE.

Referenced by net.sf.gridarta.model.io.AttributeListUtils.diffArchTextKeys(), net.sf.gridarta.model.io.AttributeListUtils.diffArchTextValues(), and net.sf.gridarta.utils.StringUtilsTest.testDiffTextString().

+ Here is the caller graph for this function:

◆ ensureTrailingNewline()

static CharSequence net.sf.gridarta.utils.StringUtils.ensureTrailingNewline ( @NotNull final String  str)
static

Returns a given string which ends with a trailing newline character; empty strings remain empty. If the input strings ends in a newline character or if it is empty, it is returned; else a newline character is appended first.

Parameters
strthe input string
Returns
the string with a trailing newline character

Definition at line 146 of file StringUtils.java.

Referenced by net.sf.gridarta.model.baseobject.AbstractBaseObject< G, A, R, G >.setMsgText(), and net.sf.gridarta.utils.StringUtilsTest.testEnsureTrailingNewline().

+ Here is the caller graph for this function:

◆ getAttribute()

static String net.sf.gridarta.utils.StringUtils.getAttribute ( @NotNull final CharSequence  attributes,
@NotNull final String  attributeName 
)
static

Returns an attribute line from a set of attribute definitions. If the set contains more than one instance of

attributeName

, only the first instance is returned.

Parameters
attributesthe attribute set to search
attributeNamethe attribute name to search for
Returns
the set of attribute value or
null
if the attribute was not found

Definition at line 181 of file StringUtils.java.

References net.sf.gridarta.utils.StringUtils.PATTERN_END_OF_LINE.

Referenced by net.sf.gridarta.utils.StringUtilsTest.testGetAttribute().

+ Here is the caller graph for this function:

◆ removeTrailingWhitespace()

◆ removeTrailingWhitespaceFromLines()

◆ sortLines()

static String net.sf.gridarta.utils.StringUtils.sortLines ( @NotNull final CharSequence  string)
static

Sorts newline separated lines in a string.

Parameters
stringthe string to sort
Returns
the sorted string

Definition at line 197 of file StringUtils.java.

References net.sf.gridarta.utils.StringUtils.PATTERN_NEWLINE.

Referenced by net.sf.gridarta.model.baseobject.GameObjectText.setObjectText().

+ Here is the caller graph for this function:

Member Data Documentation

◆ PATTERN_BACKSLASH

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_BACKSLASH = Pattern.compile("\\\\")
static

The pattern that matches a single backslash ("\").

Definition at line 85 of file StringUtils.java.

Referenced by net.sf.gridarta.utils.PathManagerUtils.path().

◆ PATTERN_COLON

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_COLON = Pattern.compile(":")
static

◆ PATTERN_COMMA

◆ PATTERN_END_OF_LINE

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_END_OF_LINE = Pattern.compile("\\s*\n")
static

◆ PATTERN_EQUAL

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_EQUAL = Pattern.compile("=")
static

◆ PATTERN_MULTI_LINE_TRAILING_WHITESPACE

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_MULTI_LINE_TRAILING_WHITESPACE = Pattern.compile("(?m)[\\x00-\\x09\\x0b\\x20]+$")
staticprivate

Pattern to match trailing whitespace in a multi line string.

Definition at line 55 of file StringUtils.java.

Referenced by net.sf.gridarta.utils.StringUtils.removeTrailingWhitespaceFromLines().

◆ PATTERN_NEWLINE

◆ PATTERN_SLASH

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_SLASH = Pattern.compile("/")
static

◆ PATTERN_SPACE

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_SPACE = Pattern.compile(" ")
static

◆ PATTERN_SPACES

◆ PATTERN_TRAILING_WHITESPACE

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_TRAILING_WHITESPACE = Pattern.compile("[\\x00-\\x09\\x0b\\x20]+$")
staticprivate

Pattern to match trailing whitespace.

Definition at line 49 of file StringUtils.java.

Referenced by net.sf.gridarta.utils.StringUtils.removeTrailingWhitespace().

◆ PATTERN_WHITESPACE

◆ PATTERN_WHITESPACE_NEWLINE

final Pattern net.sf.gridarta.utils.StringUtils.PATTERN_WHITESPACE_NEWLINE = Pattern.compile("[\\x00-\\x0b\\x0d\\x20]+")
static

Pattern to match whitespace including NL and CR.

Definition at line 43 of file StringUtils.java.

Referenced by net.sf.gridarta.model.archetypetype.ArchetypeTypeSetParser.parseAttributeOrder().


The documentation for this class was generated from the following file: