• Home
  • Contact Me
  • About Me
  • Resources
  • Favorites
  • Earn Money

Thursday, October 2, 2008

EGL: Extract URL details

This article helps Enterprise Generation Language (EGL) programmers to get the details about the server, port number and url type. Given below is a piece of dirty code (DONT COPY)
1) Create a Java Class like below:
package explore.your.thought.process
public class URLDetails {
public String getServer(String url) {
String replacedStr = getURLType(url);
String server = "";
String urlWithOutHTTP = url.replaceAll(replacedStr, "");
String[] strArr = urlWithOutHTTP.split("[:]");
if (strArr.length > 0)
server = strArr[0];
return server;
}
public String getServerPort(String url) {
String replacedStr = getURLType(url);
String serverPort = "";
String urlWithOutHTTP = url.replaceFirst(replacedStr, "");
String[] strArr = urlWithOutHTTP.split("[:]");
if (strArr.length > 1) {
String[] strArr1 = strArr[1].split("[/]");
if (strArr1.length > 0) {
serverPort = strArr1[0];
}
}
return serverPort;
}
public String getURLType(String url) {
String urlType = "";
if (url.indexOf("https://") != -1)
urlType = "https://";
else if (url.indexOf("http://") != -1)
urlType = "http://";
return urlType;
}
}
2) create an EGL External Type:

ExternalType URLDetails type JavaObject
{JavaName = "URLDetails", PackageName = "explore.your.thought.process"}
Function getServer(url String in) returns (String) ;
function getServerPort(url String in) returns (String);
Function getURLType(url String in) returns (String);
End
Regards
Monu

No comments: