I tried to separate the my output value using java regex api.I am getting the output value into single variable.I need to separate the
output. I can able to separate value using regex but i didn't able to get the name of the value.
This is my java code
public void propertyChange(PropertyChangeEvent propertyChangeEvent)
{
String channel=propertyChangeEvent.toString();
System.out.println("Channel:"+channel);
String regex="name='([^']*+)'";
String regex1="callerId='([^']*+)'";
String regex2="state='([^']*+)'";
String regex3="name='([^']*+)'";
Pattern p1=Pattern.compile(regex);
Pattern p2=Pattern.compile(regex1);
Pattern p3=Pattern.compile(regex2);
Pattern p4=Pattern.compile(regex3);
Matcher m1=p1.matcher(channel);
Matcher m2=p2.matcher(channel);
Matcher m3=p3.matcher(channel);
Matcher m4=p4.matcher(channel);
while (m1.find() && m2.find()&& m3.find()&& m4.find())
{
s1=m1.group();
s2=m2.group();
s3=m3.group();
s4=m4.group();
String cause1=s1;
String cause2=s2;
String cause3=s3;
String cause4=s4;
name1=cause1.substring(cause1.indexOf("=")+1);
callername=name1.substring(5,9);
callerid1=cause2.substring(cause2.indexOf("=")+1);
state1=cause3.substring(cause3.indexOf("=")+1);
System.out.println("CallerName:"+callername);
System.out.println("CallerState:"+state1);
calleename=cause4.substring(cause4.lastIndexOf("=")+1);
System.out.println("CalleeName:"+calleename);
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "user", "user");
st = conn.createStatement();
// st.executeUpdate("INSERT INTO `livedetails` (`caller_name`,`callerid`,`caller_state`,`start_time`,`end_time`) VALUES ('"+ callername +"',''"+ callerid1 +"'',''"+ state1 +"'',sysdate(),sysdate())");
st.executeUpdate("Update livedetails set callerid=''"+ callerid1 +"'',caller_state=''"+ state1 +"'',start_time=sysdate(),end_time=sysdate() where caller_name='"+ callername +"'");
rs1=st.executeQuery("SELECT caller_name,callerid,caller_state FROM livedetails WHERE caller_state != ''");
if(rs1.next())
{
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
This is my output
Channel:java.beans.PropertyChangeEvent[source=AsteriskChannel[id='1242386487.122',name='SIP/5104-095ce300',callerId='"device" <5104>',state='HUNGUP',account='null',dateOfCreation=Fri May 15 16:51:27 GMT+05:30 2009,dialedChannel=AsteriskChannel[id='1242386549.124',name='SIP/5104-095f7ab8'],dialingChannel=null,linkedChannel=null]]
CallerName:'SIP/5104-095ce300'
CallerState:'HUNGUP'
CalleeName:'SIP/5104-095ce300'
Now i need to get the value of dialedchannel name='SIP/5104-095f7ab8'.How can i get the output.Please assist me to do solve this
problem.
Regards,
Suganya R

New Topic/Question
Reply




MultiQuote



|