1 package SnowMailClient.Language; 2 3 import java.util.*; 4 import java.util.zip.*; 5 import java.io.*; 6 import javax.swing.table.*; 7 8 import snow.utils.storage.*; 9 10 public final class Common 11 { 12 13 private Common() 14 { 15 } 16 17 20 public static int getNumberOfSpacesAtBegining(String s) 21 { 22 for(int i=0; i<s.length(); i++) 23 { 24 if(s.charAt(i)!=' ') return i; 25 } 26 return s.length(); 27 } 28 29 31 public static int getNumberOfSpacesAtEnd(String s) 32 { 33 for(int i=0; i<s.length(); i++) 34 { 35 if(s.charAt(s.length()-i-1)!=' ') return i; 36 } 37 return s.length(); 38 } 39 40 44 public static int getNumberOfParametersInSentence(String sentence) throws Exception 45 { 46 if(sentence.indexOf("%2")!=-1) 47 { 48 if(sentence.indexOf("%1")==-1) 49 { 50 throw new Exception ("Sentence has only argument %2, %1 is missing ?"); 51 } 52 return 2; 53 } 54 if(sentence.indexOf("%1")!=-1) 55 { 56 if(sentence.indexOf("%2")==-1) 57 { 58 throw new Exception ("Sentence has only argument %1, %2 is missing ?"); 59 } 60 return 2; 61 } 62 63 if(sentence.indexOf("%")!=-1) 64 { 65 return 1; 66 } 67 68 return 0; 69 } 70 71 73 public static String convertPathToJavaClassPathSyntax(String _path) 74 { 75 String path = _path; 76 if(path.endsWith(".java")) path = path.substring(0, path.length()-5); 78 79 int pos = -1; 81 while((pos=path.indexOf("\\"))!=-1) 82 { 83 path = path.substring(0,pos)+"."+path.substring(pos+1); 84 } 85 86 return path; 87 } 88 89 90 91 92 93 } | Popular Tags |