diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-07-18 03:41:46 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-07-18 03:41:46 +0000 |
commit | 67301daff371397dafcd3668008c26fbc8f8656f (patch) | |
tree | e0bb6db520a16ce6f944bc58014ef6edd6517c66 /java/src/IceInternal/StringUtil.java | |
parent | added missing file (diff) | |
download | ice-67301daff371397dafcd3668008c26fbc8f8656f.tar.bz2 ice-67301daff371397dafcd3668008c26fbc8f8656f.tar.xz ice-67301daff371397dafcd3668008c26fbc8f8656f.zip |
align with C++ for facet path
Diffstat (limited to 'java/src/IceInternal/StringUtil.java')
-rw-r--r-- | java/src/IceInternal/StringUtil.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/java/src/IceInternal/StringUtil.java b/java/src/IceInternal/StringUtil.java new file mode 100644 index 00000000000..8a64798de37 --- /dev/null +++ b/java/src/IceInternal/StringUtil.java @@ -0,0 +1,78 @@ +// ********************************************************************** +// +// Copyright (c) 2002 +// Mutable Realms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +package IceInternal; + +public final class StringUtil +{ + // + // Return the index of the first character in str to + // appear in match, starting from 0. Returns -1 if none is + // found. + // + public static int + findFirstOf(String str, String match) + { + return findFirstOf(str, match, 0); + } + + // + // Return the index of the first character in str to + // appear in match, starting from start. Returns -1 if none is + // found. + // + public static int + findFirstOf(String str, String match, int start) + { + final int len = str.length(); + for(int i = start; i < len; i++) + { + char ch = str.charAt(i); + if(match.indexOf(ch) != -1) + { + return i; + } + } + + return -1; + } + + // + // Return the index of the first character in str which does + // not appear in match, starting from 0. Returns -1 if none is + // found. + // + public static int + findFirstNotOf(String str, String match) + { + return findFirstNotOf(str, match, 0); + } + + // + // Return the index of the first character in str which does + // not appear in match, starting from start. Returns -1 if none is + // found. + // + public static int + findFirstNotOf(String str, String match, int start) + { + final int len = str.length(); + for(int i = start; i < len; i++) + { + char ch = str.charAt(i); + if(match.indexOf(ch) == -1) + { + return i; + } + } + + return -1; + } +} |