Package org.zoolu.tools

Examples of org.zoolu.tools.Parser


   public int getExpires()
   {  int secs=-1;
      String exp_param=getParameter("expires");
      if (exp_param!=null)
      {  if (exp_param.indexOf("GMT")>=0)
         {  Date date=(new SipParser((new Parser(exp_param)).getStringUnquoted())).getDate();
            secs=(int)((date.getTime()-System.currentTimeMillis())/1000);
            if (secs<0) secs=0;
         }
         else secs=(new SipParser(exp_param)).getInt();
      }
View Full Code Here


   public Date getExpiresDate()
   {  Date date=null;
      String exp_param=getParameter("expires");
      if (exp_param!=null)
      {  if (exp_param.indexOf("GMT")>=0)
         {  date=(new SipParser((new Parser(exp_param)).getStringUnquoted())).getDate();
         }
         else
         long secs=(new SipParser(exp_param)).getInt();
            if (secs>=0) date=new Date(System.currentTimeMillis()+secs*1000);
         }
View Full Code Here

   value=String.valueOf(n);
   }

   /** Gets Max-Forwards number */
   public int getNumber()
   {  return (new Parser(value)).getInt();
   }
View Full Code Here

   super(hd);
   }
  
   /** Gets the subscription state. */
   public String getState()
   {  return new Parser(value).getWord(delim);
   }
View Full Code Here

   // *********************** Protected methods **********************

   /** Parses a single line (loaded from the config file) */
   protected void parseLine(String line)
   {  String attribute;
      Parser par;
      int index=line.indexOf("=");
      if (index>0) {  attribute=line.substring(0,index).trim(); par=new Parser(line,index+1)}
      else attribute=line; par=new Parser("")}
             
      if (attribute.equals("from_url"))       { from_url=par.getRemainingString().trim(); return; }
      if (attribute.equals("contact_url"))    { contact_url=par.getRemainingString().trim(); return; }
      if (attribute.equals("username"))       { username=par.getString(); return; }
      if (attribute.equals("realm"))          { realm=par.getRemainingString().trim(); return; }
      if (attribute.equals("passwd"))         { passwd=par.getRemainingString().trim(); return; }
      if (attribute.equals("ua_jar"))         { ua_jar=par.getStringUnquoted(); return; }     
      if (attribute.equals("contacts_file"))  { contacts_file=par.getStringUnquoted(); return; }     

      if (attribute.equals("do_register"))    { do_register=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("do_unregister"))  { do_unregister=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("do_unregister_all")) { do_unregister_all=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("expires"))        { expires=par.getInt(); return; }
      if (attribute.equals("keepalive_time")) { keepalive_time=par.getInt(); return; }

      if (attribute.equals("call_to"))     { call_to=par.getRemainingString().trim(); return; }
      if (attribute.equals("accept_time"))    { accept_time=par.getInt(); return; }
      if (attribute.equals("hangup_time"))    { hangup_time=par.getInt(); return; }
      if (attribute.equals("transfer_time"))  { transfer_time=par.getInt(); return; }
      if (attribute.equals("re_invite_time")) { re_invite_time=par.getInt(); return; }
      if (attribute.equals("redirect_to"))    { redirect_to=par.getRemainingString().trim(); return; }
      if (attribute.equals("transfer_to"))    { transfer_to=par.getRemainingString().trim(); return; }
      if (attribute.equals("no_offer"))       { no_offer=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("no_prompt"))      { no_prompt=(par.getString().toLowerCase().startsWith("y")); return; }

      if (attribute.equals("audio"))          { audio=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("video"))          { video=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("recv_only"))      { recv_only=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("send_only"))      { send_only=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("send_tone"))      { send_tone=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("send_file"))      { send_file=par.getRemainingString().trim(); return; }
      if (attribute.equals("recv_file"))      { recv_file=par.getRemainingString().trim(); return; }

      if (attribute.equals("audio_port"))     { audio_port=par.getInt(); return; }
      if (attribute.equals("audio_avp"))      { audio_avp=par.getInt(); return; }
      if (attribute.equals("audio_codec"))    { audio_codec=par.getString(); return; }
      if (attribute.equals("audio_sample_rate"))     { audio_sample_rate=par.getInt(); return; }
      if (attribute.equals("audio_sample_size"))     { audio_sample_size=par.getInt(); return; }
      if (attribute.equals("audio_frame_size"))      { audio_frame_size=par.getInt(); return; }
      if (attribute.equals("video_port"))     { video_port=par.getInt(); return; }
      if (attribute.equals("video_avp"))      { video_avp=par.getInt(); return; }

      if (attribute.equals("use_jmf"))        { use_jmf=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("use_rat"))        { use_rat=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("bin_rat"))        { bin_rat=par.getStringUnquoted(); return; }
      if (attribute.equals("use_vic"))        { use_vic=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("bin_vic"))        { bin_vic=par.getStringUnquoted(); return; }     

      // for backward compatibily
      if (attribute.equals("contact_user"))   { username=par.getString(); return; }
      if (attribute.equals("auto_accept"))    { accept_time=((par.getString().toLowerCase().startsWith("y")))? 0 : -1; return; }
   }
View Full Code Here


   /** Parses a single line (loaded from the config file) */
   public void parseLine(String line)
   {  String attribute;
      Parser par;
      int index=line.indexOf("=");
      if (index>0) {  attribute=line.substring(0,index).trim(); par=new Parser(line,index+1)}
      else attribute=line; par=new Parser("")}
      char[] delim={' ',','};

      if (attribute.equals("via_addr")) {  via_addr=par.getString(); return}
      if (attribute.equals("host_port")) {  host_port=par.getInt(); return; }
      if (attribute.equals("host_ifaddr")) {  host_ifaddr=par.getString(); return}
      if (attribute.equals("transport_protocols")) {  transport_protocols=par.getWordArray(delim); return}
      if (attribute.equals("nmax_connections")) {  nmax_connections=par.getInt(); return}
      if (attribute.equals("outbound_proxy"))
      {  String soaddr=par.getString();
         if (soaddr==null || soaddr.length()==0 || soaddr.equalsIgnoreCase(Configure.NONE) || soaddr.equalsIgnoreCase("NO-OUTBOUND")) outbound_proxy=null;
         else outbound_proxy=new SocketAddress(soaddr);
         return;
      }
      if (attribute.equals("log_all_packets")) { log_all_packets=(par.getString().toLowerCase().startsWith("y")); return; }

      // old parameters
      if (attribute.equals("host_addr")) System.err.println("WARNING: parameter 'host_addr' is no more supported; use 'via_addr' instead.");
      if (attribute.equals("all_interfaces")) System.err.println("WARNING: parameter 'all_interfaces' is no more supported; use 'host_iaddr' for setting a specific interface or let it undefined.");
      if (attribute.equals("use_outbound")) System.err.println("WARNING: parameter 'use_outbound' is no more supported; use 'outbound_proxy' for setting an outbound proxy or let it undefined.");
      if (attribute.equals("outbound_addr"))
      {  System.err.println("WARNING: parameter 'outbound_addr' has been deprecated; use 'outbound_proxy=<host_addr>[:<host_port>]' instead.");
         outbound_addr=par.getString();
         return;
      }
      if (attribute.equals("outbound_port"))
      {  System.err.println("WARNING: parameter 'outbound_port' has been deprecated; use 'outbound_proxy=<host_addr>[:<host_port>]' instead.");
         outbound_port=par.getInt();
         return;
      }

      if (attribute.equals("sendResponseUsingOutboundProxy")) { sendResponseUsingOutboundProxy=(par.getString().toLowerCase().startsWith("y")); return; }
          if (attribute.equals("useViaReceived")) { useViaReceived=(par.getString().toLowerCase().startsWith("y")); return; }
          if (attribute.equals("useViaRport")) { useViaRport=(par.getString().toLowerCase().startsWith("y")); return; }

          if (attribute.equals("SipInboundAllChannelsBusyAction"))
          {
            String sipInboundAllChannelsBusyAction=(par.getRemainingString());
            if (sipInboundAllChannelsBusyAction.startsWith("transferto:"))  // redirect the call elsewhere
             sipBusyUrl=sipInboundAllChannelsBusyAction.replaceAll("transferto:","");
            else
              sipBusyUrl=null;
            return;
View Full Code Here

       
        return remoteAudioPort;
    }
 
  public static String getRemoteMediaAddress(SessionDescriptor remoteSdp) {
    return (new Parser(remoteSdp.getConnection().toString())).skipString().skipString().getString();
  }
View Full Code Here


   /** Parses a single text line (read from the config file) */
   protected void parseLine(String line)
   {  String attribute;
      Parser par;
      int index=line.indexOf("=");
      if (index>0) {  attribute=line.substring(0,index).trim(); par=new Parser(line,index+1)}
      else attribute=line; par=new Parser("")}
      char[] delim={' ',','};

      // general configurations
      if (attribute.equals("default_port"))   { default_port=par.getInt(); return; }
      if (attribute.equals("default_transport_protocols")) { default_transport_protocols=par.getWordArray(delim); return; }
      if (attribute.equals("default_nmax_connections")) { default_nmax_connections=par.getInt(); return; }
      if (attribute.equals("use_rport")) { use_rport=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("force_rport")) { force_rport=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("max_forwards"))   { max_forwards=par.getInt(); return; }
      if (attribute.equals("retransmission_timeout")) { retransmission_timeout=par.getInt(); return; }
      if (attribute.equals("max_retransmission_timeout")) { max_retransmission_timeout=par.getInt(); return; }
      if (attribute.equals("transaction_timeout")) { transaction_timeout=par.getInt(); return; }
      if (attribute.equals("clearing_timeout"))    { clearing_timeout=par.getInt(); return; }
      if (attribute.equals("single_timer"))   { single_timer=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("early_dialog"))   { early_dialog=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("default_expires")){ default_expires=par.getInt(); return; }
      if (attribute.equals("ua_info"))        { ua_info=par.getRemainingString().trim(); return; }
      if (attribute.equals("server_info"))    { server_info=par.getRemainingString().trim(); return; }

      // debug and logs
      if (attribute.equals("debug_level"))    { debug_level=par.getInt(); return; }
      if (attribute.equals("log_path"))       { log_path=par.getString(); return; }
      if (attribute.equals("max_logsize"))    { max_logsize=par.getInt(); return; }
      if (attribute.equals("log_rotations"))  { log_rotations=par.getInt(); return; }
      if (attribute.equals("log_rotation_time"))   { log_rotation_time=par.getRemainingString(); return; }

      // old parameters
      if (attribute.equals("host_addr")) printLog("WARNING: parameter 'host_addr' is no more supported; use 'via_addr' instead.");
      if (attribute.equals("all_interfaces")) printLog("WARNING: parameter 'all_interfaces' is no more supported; use 'host_iaddr' for setting a specific interface or let it undefined.");
      if (attribute.equals("use_outbound")) printLog("WARNING: parameter 'use_outbound' is no more supported; use 'outbound_addr' for setting an outbound proxy or let it undefined.");
View Full Code Here

   super(hd);
   }

   /** Gets Call-Id of CallIdHeader */
   public String getCallId()
   {  return (new Parser(value)).getString();
   }
View Full Code Here

   // ***************** ParametricHeader's extended method *****************
  
   /** Returns the index of the first semicolon before the first parameter.
     * @returns the index of the semicolon before the first parameter, or -1 if no parameter is present. */
   protected int indexOfFirstSemi()
   {  Parser par=new Parser(value);
      par.goToSkippingQuoted('>');
      if (par.getPos()==value.length()) par.setPos(0);
      par.goToSkippingQuoted(';');
      if (par.getPos()<value.length()) return par.getPos();
      else return -1;
   }
View Full Code Here

TOP

Related Classes of org.zoolu.tools.Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.