1 /****************************************************************************
2 * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the LGPL License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/lgpl.html
7 ****************************************************************************/
8
9 package it.imolinfo.jbi4corba.utils;
10
11 import java.util.StringTokenizer;
12
13
14 public class HelperStringUtils {
15
16 /**
17 * Method that extract string from 2 delimiter start and end passed as String
18 *
19 * @param target
20 * @param start delimiter
21 * @param ends delimiters
22 * @return the result String
23 * */
24 public static String ExtractString(final String target,final String start,final String endWith ) {
25 // TODO Auto-generated method stub
26
27 String result= null;
28 String currentToken=null;
29 StringTokenizer tokenizer=new StringTokenizer(target,start);
30 while(tokenizer.hasMoreTokens()){
31 if((currentToken=tokenizer.nextToken()).contains(endWith)){
32 result=currentToken;
33 }
34 }
35 int index=result.indexOf(endWith);
36 return result.substring(0, index);
37
38 }
39
40 /**
41 * Method that compare the two String a return if there are equals and ignore the String order
42 *
43 * @param str1 String source
44 * @param str2 String to compare
45 * @return boolean true if the String are equals false if the String not are equals
46 * */
47 public static boolean compareStringNoOrder(String str1,String str2){
48
49 StringTokenizer tk=new StringTokenizer(str2);
50 boolean sameSize=false;
51 if(str1.length()==str2.length())
52 sameSize=true;
53 boolean equals=true;
54 while(tk.hasMoreTokens()){
55 if(!str1.contains(tk.nextToken())){
56 equals=false;
57 break;
58 }
59
60 }
61 return equals;
62
63 }
64
65
66
67 }