My favorites | Sign in
Project Home Downloads Wiki Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
Copyright 2011 Christian Dadswell
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package uk.co.chrisdadswell.bbcbc;

import java.util.regex.Pattern;

public class Func_Strings {

// ARRAY TO STRING
public static String arrayToString(String[] a, String separator) {
StringBuffer result = new StringBuffer();
if (a.length > 0) {
result.append(a[0]);
for (int i=1; i<a.length; i++) {
result.append(separator);
result.append(a[i]);
}
}
return result.toString();
}

// FIND WORD IN STRING
public static boolean FindWordInString(String StringToSearch, String WordToFind) {

int intIndex = StringToSearch.toLowerCase().indexOf(WordToFind.toLowerCase());
if(intIndex == - 1){
return false;
}else{
return true;
}
}

//STRING REPLACE
public static String StringToReplace(String string, String stringToReplace) {
String str = string;
String strreplace = string;
String resultantString = str.replaceAll(stringToReplace, strreplace);
return resultantString;
}

public static boolean compareStr(String str1, String str2){
if(str1.equals(str2)) {
return true;
}else{
return false;
}

}

public static String[] arraySplit(String a, String splitter) {
String[] x = Pattern.compile(splitter).split(a);
for (int i=0; i<x.length; i++) {
System.out.println(" \"" + x[i] + "\"");
}
return x;
}

public static String[] stringToArray( String s, String sep ) {
// convert a String s to an Array, the elements
// are delimited by sep
// NOTE : for old JDK only (<1.4).
// for JDK 1.4 +, use String.split() instead
StringBuffer buf = new StringBuffer(s);
int arraysize = 1;
for ( int i = 0; i < buf.length(); i++ ) {
if ( sep.indexOf(buf.charAt(i) ) != -1 )
arraysize++;
}
String [] elements = new String [arraysize];
int y,z = 0;
if ( buf.toString().indexOf(sep) != -1 ) {
while ( buf.length() > 0 ) {
if ( buf.toString().indexOf(sep) != -1 ) {
y = buf.toString().indexOf(sep);
if ( y != buf.toString().lastIndexOf(sep) ) {
elements[z] = buf.toString().substring(0, y );
z++;
buf.delete(0, y + 1);
}
else if ( buf.toString().lastIndexOf(sep) == y ) {
elements[z] = buf.toString().substring
(0, buf.toString().indexOf(sep));
z++;
buf.delete(0, buf.toString().indexOf(sep) + 1);
elements[z] = buf.toString();z++;
buf.delete(0, buf.length() );
}
}
}
}
else {
elements[0] = buf.toString();
}
buf = null;
return elements;
}


}

Change log

r319 by chrisdadswell on Jan 9, 2011   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

r175 by chrisdadswell on Jun 14, 2010   Diff
Version 3.0 - Search completed.
Need to tidy up about page
Need to ensure people know how the app
works from podcast view...
r170 by chrisdadswell on Jun 9, 2010   Diff
Version 2.6 - Release to MarketPlace -
ByGenre complete.
r166 by chrisdadswell on Jun 5, 2010   Diff
Version 2.6 - Work on ByGenre begins.
Need to work on how the handler
returns podcasts by a selected genre.
All revisions of this file

File info

Size: 3200 bytes, 112 lines
Powered by Google Project Hosting