Package org.zoolu.tools

Examples of org.zoolu.tools.Parser


   return (new Parser(value)).skipString().skipString().getString();
   }

   /** Gets the address type. */
   public String getAddressType()
   {  return (new Parser(value)).skipString().skipString().skipString().skipString().getString();
   }
View Full Code Here


   return (new Parser(value)).skipString().skipString().skipString().skipString().getString();
   }

  /** Gets the address. */
   public String getAddress()
   {  return (new Parser(value)).skipString().skipString().skipString().skipString().skipString().getString();
   }
View Full Code Here

            return;
        }
       
        SessionDescriptor localSdp = new SessionDescriptor( call.getLocalSessionDescriptor() );       
        SessionDescriptor remoteSdp = new SessionDescriptor( call.getRemoteSessionDescriptor() );
        String remoteMediaAddress = (new Parser(remoteSdp.getConnection().toString())).skipString().skipString().getString();
        int remoteAudioPort = getRemoteAudioPort(remoteSdp);
        int localAudioPort = getLocalAudioPort(localSdp);
       
        log.debug("[localAudioPort=" + localAudioPort + ",remoteAudioPort=" + remoteAudioPort + "]");
View Full Code Here

  
   /** Gets value of ExpiresHeader as delta-seconds */
   public int getDeltaSeconds()
   {  int secs=-1;
      if (isDate())
      {  Date date=(new SipParser((new Parser(value)).getStringUnquoted())).getDate();
         secs=(int)((date.getTime()-System.currentTimeMillis())/1000);
         if (secs<0) secs=0;
      }
      else secs=(new SipParser(value)).getInt();

View Full Code Here

   /** Gets value of ExpiresHeader as absolute date */
   public Date getDate()
   {  Date date=null;
      if (isDate())
      {  date=(new SipParser((new Parser(value)).getStringUnquoted())).getDate();
      }
      else
      long secs=getDeltaSeconds();
         if (secs>=0) date=new Date(System.currentTimeMillis()+secs*1000);
      }
View Full Code Here


   /** Parses a single line of the 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("is_registrar")) { is_registrar=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("expires"))        { expires=par.getInt(); return; }
      if (attribute.equals("register_new_users")) { register_new_users=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("is_open_proxy")) { is_open_proxy=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("location_service")) { location_service=par.getString(); return; }
      if (attribute.equals("location_db")) { location_db=par.getString(); return; }
      if (attribute.equals("clean_location_db")) { clean_location_db=(par.getString().toLowerCase().startsWith("y")); return; }

      if (attribute.equals("do_authentication")) { do_authentication=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("do_proxy_authentication")) { do_proxy_authentication=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("authentication_scheme")) { authentication_scheme=par.getString(); return; }
      if (attribute.equals("authentication_realm")) { authentication_realm=par.getString(); return; }
      if (attribute.equals("authentication_service")) { authentication_service=par.getString(); return; }
      if (attribute.equals("authentication_db")) { authentication_db=par.getString(); return; }

      if (attribute.equals("call_log")) { call_log=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("on_route")) { on_route=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("loose_route")) { loose_route=(par.getString().toLowerCase().startsWith("y")); return; }
      if (attribute.equals("loop_detection")) { loop_detection=(par.getString().toLowerCase().startsWith("y")); return; }

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

      if (attribute.equals("domain_names"))
      {  char[] delim={' ',','};
         Vector aux=new Vector();
         do
         String domain=par.getWord(delim);
            if (domain.equals(SipProvider.AUTO_CONFIGURATION))
            {  // auto configuration
               String host_addr=null;
               String host_name=null;
               try
               InetAddress address=java.net.InetAddress.getLocalHost();
                  host_addr=address.getHostAddress();
                  host_name=address.getHostName();
               }
               catch (java.net.UnknownHostException e)
               {  if (host_addr==null) host_addr="127.0.0.1";
                  if (host_name==null) host_name="localhost";
               }
               aux.addElement(host_addr);
               aux.addElement(host_name);
            }
            else
            // manual configuration
               aux.addElement(domain);
            }
         }
         while (par.hasMore());
         domain_names=new String[aux.size()];
         for (int i=0; i<aux.size(); i++) domain_names[i]=(String)aux.elementAt(i);
         return;
      }
     
      if (attribute.equals("phone_routing_rules"))
      {  char[] delim={' ',',','}'};
         Vector aux=new Vector();
         par.goTo('{');
         while (par.hasMore())
         {  par.goTo("prefix").skipN(6).goTo('=').skipChar();
            String prefix=par.getWord(delim);
            if (prefix.equals("*")) prefix=PrefixRoutingRule.DEFAULT_PREFIX;
            par.goTo("nexthop").skipN(7).goTo('=').skipChar();
            String nexthop=par.getWord(delim);
            aux.addElement(new PrefixRoutingRule(prefix,new SocketAddress(nexthop)));
            par.goTo('{');
         }
         phone_routing_rules=new RoutingRule[aux.size()];
         for (int i=0; i<aux.size(); i++) phone_routing_rules[i]=(RoutingRule)aux.elementAt(i);
         return;
      }

      if (attribute.equals("domain_routing_rules"))
      {  char[] delim={' ',',','}'};
         Vector aux=new Vector();
         par.goTo('{');
         while (par.hasMore())
         {  par.goTo("domain").skipN(6).goTo('=').skipChar();
            String prefix=par.getWord(delim);
            par.goTo("nexthop").skipN(7).goTo('=').skipChar();
            String nexthop=par.getWord(delim);
            aux.addElement(new DomainRoutingRule(prefix,new SocketAddress(nexthop)));
            par.goTo('{');
         }
         domain_routing_rules=new RoutingRule[aux.size()];
         for (int i=0; i<aux.size(); i++) domain_routing_rules[i]=(RoutingRule)aux.elementAt(i);
         return;
      }
View Full Code Here

         try { line=in.readLine(); } catch (Exception e) { e.printStackTrace(); System.exit(0); }  

         if (line==null)
            break;

         Parser par=new Parser(line);

         if (line.startsWith("#"))
            continue;        
         if (line.startsWith("user"))
         {  if (user!=null) addUser(user,key);
            user=par.goTo('=').skipChar().getString()
            key=NULL_ARRAY;
            continue;
         }
         if (line.startsWith("key"))
         {  key=Base64.decode(par.goTo('=').skipChar().getString());        
            continue;
         }
         if (line.startsWith("passwd"))
         {  key=par.goTo('=').skipChar().getString().getBytes();        
            continue;
         }
      }
      if (user!=null) addUser(user,key);
View Full Code Here

         if (line==null)
            break;
         if (line.startsWith("#"))
            continue;
         if (line.startsWith("To"))
         {  Parser par=new Parser(line);
            user=par.skipString().getString();
            //System.out.println("add user: "+user);
            addUser(user);
            continue;
         }
         if (line.startsWith(SipHeaders.Contact))
         {  SipParser par=new SipParser(line);
            name_address=((SipParser)par.skipString()).getNameAddress();
            //System.out.println("DEBUG: "+name_address);
            expire=(new SipParser(par.goTo("expires=").skipN(8).getStringUnquoted())).getDate();
            //System.out.println("DEBUG: "+expire);
            getUserBindingInfo(user).addContact(name_address,expire);
            continue;
        
      }
View Full Code Here

   }

   /** Gets host of SipURL */
   public String getHost() { 
     char[] host_terminators={':',';','?'};
     Parser par = new Parser(url);
     int begin = par.indexOf('@'); // skip "sip:user@"
     if (begin < 0) begin = 4; // skip "sip:"
     else begin++; // skip "@"
    
     par.setPos(begin);
     int end = par.indexOf(host_terminators);
     if (end < 0) return url.substring(begin);
       else return url.substring(begin,end);
   }
View Full Code Here

   }

   /** Gets port of SipURL; returns -1 if port is not specidfied */
   public int getPort() { 
     char[] port_terminators={';','?'};
     Parser par = new Parser(url,4); // skip "sip:"
     int begin = par.indexOf(':');
     if (begin < 0) return -1;
     else
       begin++;
       par.setPos(begin);
       int end = par.indexOf(port_terminators);
       if (end < 0) return Integer.parseInt(url.substring(begin));
       else return Integer.parseInt(url.substring(begin,end));
      }
   }
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.