The Artima Developer Community
Sponsored Link

Java Community News
What is the Worst Code You've Ever Seen?

45 replies on 4 pages. Most recent reply: Jan 16, 2007 11:21 AM by Greg Engel

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 45 replies on 4 pages [ « | 1 2 3 4 ]
Greg Engel

Posts: 1
Nickname: killroyboy
Registered: Jan, 2007

Re: What is the Worst Code You've Ever Seen? Posted: Jan 16, 2007 11:21 AM
Reply to this message Reply
Advertisement
Yes this is Java. Not that it matters. In c in would be heinous. This is meant to change 1 line at the end of a
series of WSDL files.
<soap:address location="http://<<replace>>/am/amService"/>

private void makeCustomerWSDLs(){
int updatedCount = 0;
String cn = customer_name;
String curl = customer_url;
int numberofwsdlsincategory = 4;
String[] fileCopiedTo = {cn+"-AM-PROD-CSTMR.wsdl",cn+"-LM-PROD-CSTMR.wsdl",cn+"-XTVD-PROD-CSTMR.wsdl",c n+"-XMD-PROD-CSTMR.wsdl",
cn+"-AM-STAGE-CSTMR.wsdl",cn+"-LM-STAGE-CSTMR.wsdl",cn+"-XTVD-STAGE-CSTMR.wsdl" ,cn+"-XMD-STAGE-CSTMR.wsdl",
cn+"-AM-PROD-TNNL.wsdl",cn+"-LM-PROD-TNNL.wsdl",cn+"-XTVD-PROD-TNNL.wsdl",cn+"- XMD-PROD-TNNL.wsdl",
cn+"-AM-STAGE-TNNL.wsdl",cn+"-LM-STAGE-TNNL.wsdl",cn+"-XTVD-STAGE-TNNL.wsdl",cn +"-XMD-STAGE-TNNL.wsdl",
cn+"-AM-DEV.wsdl",cn+"-LM-DEV.wsdl",cn+"-XTVD-DEV.wsdl",cn+"-XMD-DEV.wsdl"};
String[] fileCopiedFrom = {"./templates/am.wsdl","./templates/lm.wsdl","./templates/xtvd.wsdl","./templat es/xmd.wsdl"};
for(int iter = 0; iter < fileCopiedTo.length; iter++){
if((iter < 8 || !prdstgonly)&&((iter%4 == 0 && makeam)||(iter%4 == 1 && makelm)||(iter%4 == 2 && makextvd)||(iter%4 == 3 && makexmd))){
try {

if (iter == 0) {


customer_url = "https://bla." + curl + ".bla.com/" + curl;
} else if (iter < 1 * numberofwsdlsincategory) {
customer_url = "http://bla." + curl + ".bla.com/" + curl;
if(iter%4 == 3){

customer_url = "http://bla.com/moviedata/=?customer="+ cn;
}
} else if (iter < 2 * numberofwsdlsincategory) {
//Customer Stage WSDLs
//http://bla.com/curl
customer_url = "http://bla." + curl + ".bla.com/" + curl;
if(iter%4 == 3){
//Movies URL - http://bla.com/bla/bla?customer=curl
customer_url = "http://bla.com/moviedata/bla?customer="+ cn;
}
} else if (iter < 3 * numberofwsdlsincategory) {

customer_url = "http://bla:8911/" + curl;
if(iter%4 == 3){
//Movies URL - http://bla.com/bla/bla?customer=curl
customer_url = "http://bla.com/bla/bla?customer="+ cn;
}
} else if (iter < 4 * numberofwsdlsincategory) {

customer_url = "http://bla:8011/" + curl;
if(iter%4 == 3){

customer_url = "http://bla.com/moviedata/bla?customer="+ cn;
}
} else if (iter < 5 * numberofwsdlsincategory) {
//Development WSDLs
//http://bla:10000/bla/curl
customer_url = "http://bla:10000/tvapp/" + curl;
if(iter%4 == 3){
//Movies URL - http://bla:10000/bla/moviesSoap?customer=curl
customer_url = "http://bla:10000/bla/bla?customer="+ cn;
}
}


updatedCount++;
File fromFile = new File(fileCopiedFrom[iter % 4]); // Number of Template WSDLs
FileReader fromReader = new FileReader(fromFile);
BufferedReader buffedRead = new BufferedReader(fromReader,
(int) fromFile.length());

File toFile = new File(fileCopiedTo[iter]);
FileWriter toWriter = new FileWriter(toFile);
BufferedWriter buffedWrite = new BufferedWriter(toWriter,
(int) fromFile.length());

int read = 0;
int[] replace = {'r', 'e', 'p', 'l', 'a', 'c', 'e'};
int[] compare = new int[(int) fromFile.length()];

int charNum = 0;
while ((read = buffedRead.read()) != -1) {
compare[charNum++] = read;
}

int y = 0;
while (y < charNum) {
if (y + 6 < charNum && compare[y + 0] == replace[0] &&
compare[y + 1] == replace[1] &&
compare[y + 2] == replace[2] &&
compare[y + 3] == replace[3] &&
compare[y + 4] == replace[4] &&
compare[y + 5] == replace[5] &&
compare[y + 6] == replace[6]) {
buffedWrite.write(customer_url, 0,
customer_url.length());
y = y + 7;
} else {
buffedWrite.write(compare[y]);
y++;
}
}

buffedWrite.flush();
buffedWrite.close();
buffedRead.close();
} catch (Exception oops) {
oops.printStackTrace();
}
}
}
}

Flat View: This topic has 45 replies on 4 pages [ « | 1  2  3  4 ]
Topic: New IBM Tutorial: Geronimo Beans and the EJB Query Language Previous Topic   Next Topic Topic: Adobe Ships FlexBuilder for the Mac

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use