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;
  }