public AttributeField attributeField() throws ParseException {
    try {
      AttributeField attributeField = new AttributeField();

      this.lexer.match('a');

      this.lexer.SPorHT();
      this.lexer.match('=');

      this.lexer.SPorHT();

      NameValue nameValue = new NameValue();

      int ptr = this.lexer.markInputPosition();
      try {
        String name = lexer.getNextToken(':');
        this.lexer.consume(1);
        String value = lexer.getRest();
        nameValue = new NameValue(name.trim(), value.trim());
      } catch (ParseException ex) {
        this.lexer.rewindInputPosition(ptr);
        String rest = this.lexer.getRest();
        if (rest == null) throw new ParseException(this.lexer.getBuffer(), this.lexer.getPtr());
        nameValue = new NameValue(rest.trim(), ""); // jvB: use empty string for flag values
      }
      attributeField.setAttribute(nameValue);

      this.lexer.SPorHT();

      return attributeField;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ParseException(e.getMessage(), 0);
    }
  }
예제 #2
0
  /**
   * Returns Attribute object with the specified values.
   *
   * @param name the namee of the attribute
   * @param value the value of the attribute
   * @return Attribute
   */
  public Attribute createAttribute(String name, String value) {
    AttributeField attributeImpl = new AttributeField();
    try {

      attributeImpl.setName(name);
      attributeImpl.setValue(value);

    } catch (SdpException s) {
      s.printStackTrace();
    }
    return attributeImpl;
  }
예제 #3
0
 /* HSC CHANGES START */
 public static SessionDescriptor sdpMediaProduct(
     SessionDescriptor sdp, Vector<MediaDescriptor> m_descs) {
   Vector<MediaDescriptor> new_media = new Vector<MediaDescriptor>();
   if (m_descs != null) {
     for (Enumeration<MediaDescriptor> e = m_descs.elements(); e.hasMoreElements(); ) {
       MediaDescriptor spec_md = e.nextElement();
       // System.out.print("DEBUG: SDP: sdp_select:
       // "+spec_md.toString());
       MediaDescriptor prev_md = sdp.getMediaDescriptor(spec_md.getMedia().getMedia());
       // System.out.print("DEBUG: SDP: sdp_origin:
       // "+prev_md.toString());
       if (prev_md != null) {
         Vector<AttributeField> spec_attributes = spec_md.getAttributes();
         Vector<AttributeField> prev_attributes = prev_md.getAttributes();
         if (spec_attributes.size() == 0 || prev_attributes.size() == 0) {
           new_media.addElement(prev_md);
         } else {
           Vector<AttributeField> new_attributes = new Vector<AttributeField>();
           for (Enumeration<AttributeField> i = spec_attributes.elements();
               i.hasMoreElements(); ) {
             AttributeField spec_attr = i.nextElement();
             String spec_name = spec_attr.getAttributeName();
             String spec_value = spec_attr.getAttributeValue();
             for (Enumeration<AttributeField> k = prev_attributes.elements();
                 k.hasMoreElements(); ) {
               AttributeField prev_attr = k.nextElement();
               String prev_name = prev_attr.getAttributeName();
               String prev_value = prev_attr.getAttributeValue();
               if (prev_name.equals(spec_name) && prev_value.equalsIgnoreCase(spec_value)) {
                 new_attributes.addElement(prev_attr);
                 break;
               }
             }
           }
           if (new_attributes.size() > 0)
             new_media.addElement(
                 new MediaDescriptor(prev_md.getMedia(), prev_md.getConnection(), new_attributes));
         }
       }
     }
   }
   SessionDescriptor new_sdp = new SessionDescriptor(sdp);
   new_sdp.removeMediaDescriptors();
   new_sdp.addMediaDescriptors(new_media);
   return new_sdp;
 }