package bssoft.stack.sip; public class SIPROUTEHeader { public String header = null; public String headerValue = null; public String username = null; public String sipuri = null; public String uriusertag = null; public String ip = null; public int port = 0; public String tag = null; public boolean flag = false; public SIPROUTEHeader(String header) { int iS = 0; int iE = 0; if (header != null && header.length() > 0 && header.startsWith("Route: ")) { this.header = header; this.headerValue = header.substring(7).trim(); if (this.headerValue != null && this.headerValue.length() > 0) { iS = this.headerValue.indexOf("sip:"); if (iS > 0) { String str = null; iE = this.headerValue.indexOf(">", iS + 4); if (iE < 0) iE = this.headerValue.indexOf(";", iS + 4); if (iE > 0) { str = this.headerValue.substring(iS, iE); } else { str = this.headerValue.substring(iS); } if (str != null && str.length() > 0) this.sipuri = str.trim(); } if (this.sipuri != null && this.sipuri.length() > 0) { iS = this.sipuri.indexOf("@", 4); if (iS > 0) this.username = this.sipuri.substring(4, iS).trim(); } if (this.sipuri != null && this.sipuri.length() > 0) { iS = this.sipuri.indexOf("@", 4); iE = this.sipuri.indexOf(";", 4); String str = null; if (iS >= 0 && iE >= 0) { str = this.sipuri.substring(iS + 1, iE).trim(); } else if (iS >= 0) { str = this.sipuri.substring(iS + 1).trim(); } else if (iE >= 0) { str = this.sipuri.substring(4, iE).trim(); } else { str = this.sipuri.substring(4).trim(); } this.port = 5060; if (str != null && str.length() > 0) { iS = str.indexOf(":"); if (iS > 0) { this.port = Integer.parseInt(str.substring(iS + 1).trim()); this.ip = str.substring(0, iS); } else { this.ip = str; } } } iS = this.headerValue.indexOf(";tag="); if (iS > 0) { String str = null; iE = this.headerValue.indexOf(";", iS + 5); if (iE >= 0) { if (iE > iS + 5) { str = this.headerValue.substring(iS + 5, iE); } else { str = ""; } } else { str = this.headerValue.substring(iS + 5); } if (str != null && str.length() > 0) this.tag = str.trim(); } iS = this.headerValue.indexOf("sip:"); if (iS > 0) { String str = null; iE = this.headerValue.indexOf(">", iS + 4); if (iE > 0) str = this.headerValue.substring(iS, iE); if (str != null && str.length() > 0) { iS = str.indexOf(";user=", iS + 4); if (iS > 0) { this.uriusertag = str.substring(iS + 6); if (this.uriusertag != null && this.uriusertag.length() > 0 && this.uriusertag.indexOf(";") >= 0) if (this.uriusertag.indexOf(";") == 0) { this.uriusertag = null; } else { this.uriusertag = this.uriusertag.substring(0, this.uriusertag.indexOf(";")).trim(); } } } } this.flag = true; } } } public String getUsername() { return this.username; } public String getSipuri() { return this.sipuri; } public String getSipuriusertag() { return this.uriusertag; } public String getIp() { return this.ip; } public int getPort() { return this.port; } public String getTag() { return this.tag; } }