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

KeyField

public class KeyField extends SDPField
Key field part of an SDP header
version
JSR141-PUBLIC-REVIEW (subject to change)

Fields Summary
protected String
type
Type of key.
protected String
keyData
Key data.
Constructors Summary
public KeyField()
Default constructor.

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

return
the copy of this object

	KeyField retval = new KeyField();
	retval.type = type;
	retval.keyData = keyData;
	return retval;
    
public java.lang.Stringencode()
Gets the string encoded version of this object.

return
the encoded string of object contents
since
v1.0

	String encoded_string; 
	encoded_string = KEY_FIELD + type;
	if (Utils.compareToIgnoreCase(type, SDPKeywords.PROMPT) == 0) {
	    if (Utils.compareToIgnoreCase(type, SDPKeywords.URI) == 0) {
		encoded_string += Separators.COLON;
		encoded_string += keyData;
	    } else {
		if (keyData != null) {
		    encoded_string += Separators.COLON;
		    encoded_string += keyData;
		}
	    }
	}
	encoded_string += Separators.NEWLINE;
	return encoded_string;
    
public java.lang.StringgetKey()
Returns the value of this attribute.

throws
SdpParseException if a parsing error occurs
return
the value of this attribute

	return getKeyData();
    
public java.lang.StringgetKeyData()
Gets the key data.

return
the key data

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

throws
SdpParseException if a parsing error occurs
return
the name of this attribute

	return this.type;
    
public java.lang.StringgetType()
Gets the type member.

return
thetype

 return type; 
public booleanhasKey()
Determines if this attribute has an associated value.

throws
SdpParseException if a parsing error occurs
return
if this attribute has an associated value.

	String key = getKeyData();
	return key != null;
    
public voidsetKey(java.lang.String key)
Sets the value of this attribute.

param
key to set
throws
SdpException if key is null

	if (key == null)
	    throw new SdpException("The key is null");
	else setKeyData(key); 
    
public voidsetKeyData(java.lang.String k)
Sets the key data member.

param
k the new key data

	keyData = k;
    
public voidsetMethod(java.lang.String name)
Sets the id of this attribute.

param
name to set
throws
SdpException if the name is null

	this.type = name;
    
public voidsetType(java.lang.String t)
Sets the type member.

param
t the new key type

	type = t;