Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TULIP
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NUI
TULIP
Commits
4b7a188e
Commit
4b7a188e
authored
May 16, 2018
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added toTitleCase method to StringUtils class
parent
f35589d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
TULIP/src/lu/list/itis/dkd/tui/utility/StringUtils.java
TULIP/src/lu/list/itis/dkd/tui/utility/StringUtils.java
+28
-0
TULIP/test/lu/list/itis/dkd/tui/utility/StringUtilsTest.java
TULIP/test/lu/list/itis/dkd/tui/utility/StringUtilsTest.java
+6
-0
No files found.
TULIP/src/lu/list/itis/dkd/tui/utility/StringUtils.java
View file @
4b7a188e
...
...
@@ -37,6 +37,8 @@ public class StringUtils {
private
static
final
Pattern
ESCAPED_PATTERN
=
Pattern
.
compile
(
"\\\\([{}])"
,
Pattern
.
CASE_INSENSITIVE
);
//$NON-NLS-1$
private
static
final
Pattern
TITLE_CASE_PATTERN
=
Pattern
.
compile
(
"\\b([a-z]).*?"
,
Pattern
.
CASE_INSENSITIVE
);
//$NON-NLS-1$
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
StringUtils
.
class
.
getSimpleName
());
// ---------------------------------------------------------------------------
...
...
@@ -108,4 +110,30 @@ public class StringUtils {
return
builder
.
toString
();
}
// ---------------------------------------------------------------------------
/**
* @param original
* @return
*/
// ---------------------------------------------------------------------------
public
static
String
toTitleCase
(
String
original
)
{
StringBuilder
builder
=
new
StringBuilder
();
Matcher
titleMatcher
=
TITLE_CASE_PATTERN
.
matcher
(
original
);
int
position
=
0
;
while
(
titleMatcher
.
find
())
{
builder
.
append
(
original
.
substring
(
position
,
titleMatcher
.
start
()));
builder
.
append
(
titleMatcher
.
group
(
1
).
toUpperCase
());
position
=
titleMatcher
.
end
();
}
builder
.
append
(
original
.
substring
(
position
));
return
builder
.
toString
();
}
// ---------------------------------------------------------------------------
}
TULIP/test/lu/list/itis/dkd/tui/utility/StringUtilsTest.java
View file @
4b7a188e
...
...
@@ -68,7 +68,13 @@ public class StringUtilsTest {
completed
=
StringUtils
.
build
(
"Careful with that axe eugene!"
,
param2
);
assertEquals
(
"Careful with that axe eugene!"
,
completed
);
}
@Test
public
void
testTitleCase
()
{
String
original
=
"what the @ has this 2 do with me"
;
//$NON-NLS-1$
String
titleCase
=
StringUtils
.
toTitleCase
(
original
);
assertEquals
(
"What The @ Has This 2 Do With Me"
,
titleCase
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment