Hey people. I need someone to tell me what they think of this.
I've been trying to write this small java program to search for mobile phone numbers in a document.
The document is a .csv file, but thats not too relevant.
The numbers are Irish mobile numbers in the format 08[3,5,6,7,8]1234567. so ten digits, eg 0868278402. Thats not my number btw.
Anyway so in a document which contains at least 5000 numbers (i estimate), the result of the scan is only about 3500. Its important that I get all the numbers, or as many as possible.
So I need help.
Here is the code:
class checker extends Thread
{
String ID = null;
private boolean goGo = true;
public lineBox linebox;
public isolatedUseTools IUTools;
char[] number;
char[] numberDone;
String[] Pt;
String woow;
boolean newNumber;
boolean hasNum;
public checker(lineBox linebox, isolatedUseTools IUTools)
{
this.IUTools = IUTools;
this.linebox = linebox;
number = new char [10];
numberDone = new char [10];
}
public void setID(String ID)
{
this.ID = ID;
}
public static boolean isNumber(char [] number)
{
for(int i = 0; i < 10; i++)
{
if(number[i] != '0'&& number[i] != '1'&& number[i] != '2'&& number[i] != '3'){
if(number[i] != '4'&& number[i] != '5'&& number[i] != '6'){
if(number[i] != '7'&& number[i] != '8'&& number[i] != '9'){
return false;
}
}
}
if(number[i] == '"'|| number[i] == ','|| number[i] == '/'|| number[i] == '-'||
number[i] == '\\' || number[i] == ':'){
return false;
}
}
return true;
}
public int processLine(String woow)
{
hasNum = false;
newNumber = false;
char [] blankNum = new char [10];
number = blankNum;
if(woow != null)
{
for(int i=1; i<woow.length()-13; i++)
{
if(woow.charAt(i)=='0' && woow.charAt(i+1)=='8' && i+10<woow.length())
{
if(woow.charAt(i+2)=='3'||woow.charAt(i+2)=='5'||
woow.charAt(i+2)=='6'||woow.charAt(i+2)=='7'||woow.charAt(i+2)=='8')
{
int a = 0;
int b = 0;
while(a<10){
if(woow.charAt(i+b) == ' ' || woow.charAt(i+b) == '-'){
a--;
}
else {
number[a] = woow.charAt(i+b);
}
a++;
b++;
}
if(isNumber(number) == true)
{
newNumber = true;
}
}
}
else if(woow.charAt(i) == '3' && woow.charAt(i+1) == '5' && woow.charAt(i+2) == '3' && i+13 < woow.length())
{
number[0] = '0';
int a = 1;
int b = i + 3;
while(a<10)
{
if(woow.charAt(b) == ' ' || woow.charAt(b) == '-'){
a--;
}
else {
number[a] = woow.charAt(b);
}
a++;
b++;
}
if(isNumber(number) == true)
{
newNumber = true;
}
}
else if(woow.charAt(i) == '8' && i+13 < woow.length())
{
if(woow.charAt(i+1)=='6'||woow.charAt(i+1)=='7'||
woow.charAt(i+1)=='5'||woow.charAt(i+1)=='3'||woow.charAt(i+1)=='8')
{
number[0] = '0';
int a = 1;
int b = 0;
while(a<10)
{
if(woow.charAt(i+b) == ' ' || woow.charAt(i+b) == '-'){
a--;
}
else{
number[a] = woow.charAt(i+b);
}
a++;
b++;
}
if(isNumber(number)){
newNumber = true;
}
}
}
if(newNumber && isNumber(number) && number != numberDone)
{
IUTools.outNumber(number);
numberDone = number;
newNumber = false;
hasNum = true;
i = i+9;
System.out.println(number);
}
}
}
return 0;
}
public void run()
{
String line="";
while(goGo)
{
hasNum = false;
IUTools.hasNum = false;
newNumber = false;
line = linebox.takeLine();
if(line.compareTo("yoke~~~~~~yoke") == 0){
goGo = false;
}
else{
if(line.length()>13)
{
int waitForThisMethod = processLine(line);
hasNum = IUTools.hasNum;
newNumber = IUTools.newNum;
if(line!=null && !hasNum){
IUTools.outAddress(line);
}
}
}
IUTools.newNum = false;
}
}
}
Numbers can sometimes have spaces in them that need to be omitted. And sometimes the first 0 is missing, and they appear as 868242602. and sometimes they might be in the form +353868242602.