Package org.jsmdr.base

Examples of org.jsmdr.base.CDR


  public ExampleAsterixParser() {
   
  }
 
  public CDR parse(String line) {
    CDR cdr = new CDR();
    String processedLine = line.replaceAll("\"", "");
    processedLine = processedLine.replaceFirst("SIP.Ext([0-9]{3}).....", "$1");
    if (processedLine.indexOf("internal")>=0) {
      cdr.setCallType(CallType.INCOMING_CALL);
    }
    String[] bits = processedLine.split(",");
    if (bits.length<13)
      return null;
   
    cdr.setExtensionID(bits[5]);
    setDate(bits[9], "yyyy-MM-dd HH:mm:ss", cdr);
    cdr.setDestinationOrCallID(bits[2]);
    setDuration(bits[12], cdr);
    return cdr;
  }
View Full Code Here


  public void addListener(SMDRParserListener listener) {
    this.listener = listener;
  }

  public void handleLine(String line) {
    CDR cdr = parse(line);
    if ((listener != null) && (cdr != null))
      listener.handleCDR(cdr);
  }
View Full Code Here

    if (processor != null)
      line = processor.preprocess(line);
     
    if (parser != null)
    {
      CDR cdr = parser.parse(line);
      tableModel.setCDR(cdr);
    }
  }
View Full Code Here

  }
  public CDR parse(String line) {
    for (int i=0; i<parsers.size(); i++)
    {
      SMDRParser parser = (SMDRParser)parsers.get(i);
      CDR cdr = parser.parse(line);
      if (cdr != null)
        return cdr;
    }
    return null;
  }
View Full Code Here

    return null;
  }
  public void handleLine(String line) {
    if (listener != null)
    {
      CDR cdr = parse(line);
      if (cdr != null)
        listener.handleCDR(cdr);
   
  }
View Full Code Here

   
    Matcher m = lineMatch.matcher(line);
    if (!m.matches())
      return null;
   
    CDR cdr = new CDR();
    for (int i=0; i<attributeList.size(); i++) {
      AttributeBase attr = null;
      try
      {
        attr = (AttributeBase)attributeList.get(i);
        AttributeType type = AttributeType.lookup(attr.getType());
       
        if (type == AttributeType.EXTENSION_ID)
          cdr.setExtensionID(attr.getValueString(line));
        else if (type == AttributeType.DESTINATION_CLI)
          cdr.setDestinationOrCallID(attr.getValueString(line));
        else if (type == AttributeType.DURATION_ANSWERED)
          cdr.setDurationAnswered(((DurationAttribute)attr).getDurationSeconds(line));
        else if (type == AttributeType.CALL_TYPE)
          cdr.setCallType(CallType.lookup(
              ((CallTypeAttribute)attr).getTypeString(line)
              ));
        else if (type == AttributeType.DATE_ANSWERED)
          cdr.setDateTimeAnswered(((DateAttribute)attr).getDate(line));
        else if (type == AttributeType.TIME_ANSWERED)
          cdr.setDateTimeAnswered(((TimeAttribute)attr).getDate(cdr.getDateTimeAnswered(), line));

      }
      catch(StringIndexOutOfBoundsException e) {
        System.out.println("Failed to parser attr " + attr + "for line " + line);
      }
View Full Code Here

    }
    return cdr;
  }
 
  public void handleLine(String line) {
    CDR cdr = parse(line);
    if ((cdr != null) && (listener != null))
      this.listener.handleCDR(cdr);
  }
View Full Code Here

      System.out.println("Line " + line + " doesn't match " + m.pattern().pattern());
      return null;
    }
   
    String[] lineParts = line.split(delimiter);
    CDR cdr = new CDR();
    for (int i=0; i<attributeList.size(); i++) {
      AttributeBase attr = null;
      try
      {
        attr = (AttributeBase)attributeList.get(i);
        AttributeType type = AttributeType.lookup(attr.getType());
       
        if (type == AttributeType.EXTENSION_ID)
          cdr.setExtensionID(attr.getValueString(lineParts));
        else if (type == AttributeType.DATE_ANSWERED)
          cdr.setDateTimeAnswered(((DateAttribute)attr).getDate(lineParts));
        else if (type == AttributeType.TIME_ANSWERED)
          cdr.setDateTimeAnswered(((TimeAttribute)attr).getDate(cdr.getDateTimeAnswered(), lineParts));
        else if (type == AttributeType.CALL_TYPE)
          cdr.setCallType(CallType.lookup(
              ((CallTypeAttribute)attr).getTypeString(lineParts)
              ));       
        else if (type == AttributeType.DESTINATION_CLI)
          cdr.setDestinationOrCallID(attr.getValueString(lineParts));
        else if (type == AttributeType.DURATION_ANSWERED)
          cdr.setDurationAnswered(((DurationAttribute)attr).getDurationSeconds(lineParts));

      }
      catch(StringIndexOutOfBoundsException e) {
        System.out.println("Failed to parser attr " + attr + "for line " + line);
      }
View Full Code Here

    } // For
    return cdr;
  }

  public void handleLine(String line) {
    CDR cdr = parse(line);
    if ((cdr != null) && (listener != null))
      this.listener.handleCDR(cdr);
  }
View Full Code Here

TOP

Related Classes of org.jsmdr.base.CDR

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.