FileDocCategorySizeDatePackage
AttributeField.javaAPI DocphoneME MR2 API (J2ME)5163Wed May 02 18:00:42 BST 2007gov.nist.javax.sdp.fields

AttributeField

public class AttributeField extends SDPField
Attribute Field. This code is in the public domain.

Fields Summary
protected NameValue
attribute
Current attribute.
Constructors Summary
public AttributeField()
Default constructor.

	super(ATTRIBUTE_FIELD);
    
Methods Summary
public java.lang.Objectclone()
Copies the current instance.

return
the copy of this object

	AttributeField retval = new AttributeField();
	if (attribute != null) 
	    retval.attribute = (NameValue) this.attribute.clone();
	return retval;
    
public java.lang.Stringencode()
Gets the string encoded version of this object.

return
encoding string of attribute contents
since
v1.0

	String encoded_string = ATTRIBUTE_FIELD;
	if (attribute != null) encoded_string += attribute.encode();
	return  encoded_string + Separators.NEWLINE; 
    
public NameValuegetAttribute()
Gets the current attribute.

return
the current attribute.

	return attribute;
    
public java.lang.StringgetName()
Returns the name of this attribute

throws
SdpParseException if the name is not well formatted.
return
a String identity or null.

	NameValue nameValue = getAttribute();
	if (nameValue == null) 
	    return null;
	else {
            String name = nameValue.getName();
            if (name == null)
		return null; 
            else return name;
	}
    
public java.lang.StringgetValue()
Returns the value of this attribute.

throws
SdpParseException if the value is not well formatted.
return
the value; null if the attribute has no associated value.

	NameValue nameValue = getAttribute();
	if (nameValue == null)
	    return null;
	else { 
            Object value = nameValue.getValue();
            if (value == null) 
		return null;
            else if (value instanceof String) 
		return (String)value;
	    else
		return value.toString();
	}
    
public booleanhasValue()
Determines if this attribute has an associated value.

throws
SdpParseException if the value is not well formatted.
return
true if the attribute has a value.

	NameValue nameValue = getAttribute();
	if (nameValue == null)
	    return false;
	else {
            Object value = nameValue.getValue();
            if (value == null) 
		return false;
            else return true;
	}
    
public voidsetAttribute(NameValue a)
Sets the attribute member.

param
a the new attribute value

 
	attribute = a; 
	attribute.setSeparator(Separators.COLON); 
    
public voidsetName(java.lang.String name)
Sets the id of this attribute.

param
name the string name/id of the attribute.
throws
SdpException if the name is null

        if (name == null)
	    throw new SdpException("The name is null"); 
        else {
	    NameValue nameValue = getAttribute();
	    if (nameValue == null) 
		nameValue = new NameValue();
	    nameValue.setName(name);
	    setAttribute(nameValue);
        }
    
public voidsetValue(java.lang.String value)
Sets the value of this attribute.

param
value the - attribute value
throws
SdpException if the value is null.

 
	if (value == null)
	    throw new SdpException("The value is null"); 
        else {
	    NameValue nameValue = getAttribute();
	    if (nameValue == null)
		nameValue = new NameValue();
	    nameValue.setValue(value);
	    setAttribute(nameValue);
        }
    
public java.lang.StringtoString()
Returns the encoded string of the attribute field contents.

return
encoded string of attribute contents.

	return this.encode();