Fields Summary |
---|
private TimeDescriptionImpl | currentTimeDescriptionDescriptive label for current time. |
private MediaDescriptionImpl | currentMediaDescriptionDescriptive lavel for current media. |
protected ProtoVersionField | versionImplProtocol version. |
protected OriginField | originImplSession originator. |
protected SessionNameField | sessionNameImplCurrent session name. |
protected InformationField | infoImplDescriptive session information. |
protected URIField | uriImplCurrent URi. |
protected ConnectionField | connectionImplCurrent connection. |
protected KeyField | keyImplKey field. |
protected Vector | timeDescriptionsVector of time descriptions. |
protected Vector | mediaDescriptionsVector of media types. |
protected Vector | zoneAdjustmentsVector of time zone adjustments. |
protected Vector | emailListVector of email addresses. |
protected Vector | phoneListVector of phone numbers. |
protected Vector | bandwidthListVector of bandwidths. |
protected Vector | attributesListVector of connection attributes. |
Methods Summary |
---|
public void | addField(SDPField sdpField)Adds a new SDP field.
try {
if (sdpField instanceof ProtoVersionField) {
versionImpl = (ProtoVersionField)sdpField;
} else if (sdpField instanceof OriginField) {
originImpl = (OriginField) sdpField;
} else if (sdpField instanceof SessionNameField) {
sessionNameImpl = (SessionNameField) sdpField;
} else if (sdpField instanceof InformationField) {
if (currentMediaDescription != null)
currentMediaDescription.setInformationField
((InformationField) sdpField);
else this.infoImpl = (InformationField) sdpField;
} else if (sdpField instanceof URIField) {
uriImpl = (URIField) sdpField;
} else if (sdpField instanceof ConnectionField) {
if (currentMediaDescription != null)
currentMediaDescription.setConnectionField
((ConnectionField) sdpField);
else this.connectionImpl = (ConnectionField) sdpField;
} else if (sdpField instanceof KeyField) {
if (currentMediaDescription != null)
currentMediaDescription.setKey((KeyField)sdpField);
else keyImpl = (KeyField) sdpField;
} else if (sdpField instanceof EmailField) {
emailList.addElement(sdpField);
} else if (sdpField instanceof PhoneField) {
phoneList.addElement(sdpField);
} else if (sdpField instanceof TimeField) {
currentTimeDescription = new TimeDescriptionImpl
((TimeField)sdpField);
timeDescriptions.addElement(currentTimeDescription);
} else if (sdpField instanceof RepeatField) {
if (currentTimeDescription == null) {
throw new ParseException("no time specified", 0);
} else {
currentTimeDescription.addRepeatField
((RepeatField) sdpField);
}
} else if (sdpField instanceof ZoneField) {
zoneAdjustments.addElement(sdpField);
} else if (sdpField instanceof BandwidthField) {
if (currentMediaDescription != null) {
currentMediaDescription.addBandwidthField
((BandwidthField) sdpField);
} else {
bandwidthList.addElement(sdpField);
}
} else if (sdpField instanceof AttributeField) {
if (currentMediaDescription != null) {
AttributeField af = (AttributeField) sdpField;
String s = af.getName();
currentMediaDescription.addAttribute
((AttributeField) sdpField);
} else {
attributesList.addElement(sdpField);
}
} else if (sdpField instanceof MediaField) {
currentMediaDescription = new MediaDescriptionImpl();
mediaDescriptions.addElement(currentMediaDescription);
currentMediaDescription.setMediaField((MediaField)sdpField);
}
} catch (SdpException ex) {
throw new ParseException(sdpField.encode(), 0);
}
|
public java.lang.Object | clone()Public clone declaration.
Class myClass = this.getClass();
SessionDescriptionImpl hi;
try {
hi = (SessionDescriptionImpl) myClass.newInstance();
} catch (InstantiationException ex) {
return null;
} catch (IllegalAccessException ex) {
return null;
}
hi.versionImpl = (ProtoVersionField) this.versionImpl.clone();
hi.originImpl = (OriginField) this.originImpl.clone();
hi.sessionNameImpl = (SessionNameField) this.sessionNameImpl.clone();
hi.infoImpl = (InformationField) this.infoImpl.clone();
hi.uriImpl = (URIField) this.uriImpl.clone();
hi.connectionImpl = (ConnectionField) this.connectionImpl.clone();
hi.keyImpl = (KeyField) this.keyImpl.clone();
hi.timeDescriptions = cloneVector(this.timeDescriptions);
hi.emailList = cloneVector(this.emailList);
hi.phoneList = cloneVector(this.phoneList);
hi.zoneAdjustments = cloneVector(this.zoneAdjustments);
hi.bandwidthList = cloneVector(this.bandwidthList);
hi.attributesList = cloneVector(this.attributesList);
hi.mediaDescriptions = cloneVector(this.mediaDescriptions);
return hi;
|
private java.util.Vector | cloneVector(java.util.Vector v)Utility method for cloning a Vector
Acknowledgement - this code was contributed by Sverker Abrahamsson.
Vector clone = new Vector(v.capacity());
int size = v.size();
for (int i = 0; i < size; i++) {
clone.setElementAt(v.elementAt(i), i);
}
return clone;
|
private java.lang.String | encodeVector(java.util.Vector vector)Returns an encoded string of vector contents.
StringBuffer encBuff = new StringBuffer();
for (int i = 0; i < vector.size(); i++)
encBuff.append(vector.elementAt(i));
return encBuff.toString();
|
public java.lang.String | getAttribute(java.lang.String name)Returns the value of the specified attribute.
if (name == null)
return null;
else if (attributesList == null)
return null;
for (int i = 0; i < attributesList.size(); i++) {
Object o = attributesList.elementAt(i);
if (o instanceof AttributeField) {
AttributeField a = (AttributeField)o;
String n = a.getName();
if (n != null) {
if (name.equals(n)) {
return a.getValue();
}
}
}
}
return null;
|
public java.util.Vector | getAttributes(boolean create)Returns the set of attributes for this Description as a Vector
of Attribute objects in the order they were parsed.
if (attributesList == null) {
if (create)
attributesList = new Vector();
}
return attributesList;
|
public int | getBandwidth(java.lang.String name)Returns the integer value of the specified bandwidth name.
if (name == null)
return -1;
else if (bandwidthList == null)
return -1;
for (int i = 0; i < bandwidthList.size(); i++) {
Object o = bandwidthList.elementAt(i);
if (o instanceof BandwidthField) {
BandwidthField b = (BandwidthField)o;
String type = b.getType();
if (type != null) {
if (name.equals(type)) {
return b.getValue();
}
}
}
}
return -1;
|
public java.util.Vector | getBandwidths(boolean create)Returns the Bandwidth of the specified type.
if (bandwidthList == null) {
if (create)
bandwidthList = new Vector();
}
return bandwidthList;
|
public ConnectionField | getConnection()Returns the connection information associated with this object. This may
be null for SessionDescriptions if all Media objects have a connection
object and may be null
for Media objects if the corresponding session connection is non-null.
return connectionImpl;
|
public java.util.Vector | getEmails(boolean create)Returns an email address to contact for further information
about the session.
This corresponds to the e= field of the SDP data.
if (emailList == null) {
if (create)
emailList = new Vector();
}
return emailList;
|
public InformationField | getInfo()Returns value of the info field (i=) of this object.
return infoImpl;
|
public KeyField | getKey()Returns the key data.
return keyImpl;
|
public java.util.Vector | getMediaDescriptions(boolean create)Adds a MediaDescription to the session description.
These correspond to the m=
fields of the SDP data.
if (mediaDescriptions == null) {
if (create)
mediaDescriptions = new Vector();
}
return mediaDescriptions;
|
public OriginField | getOrigin()Returns information about the originator of the session.
This corresponds to the o= field of the SDP data.
return originImpl;
|
public java.util.Vector | getPhones(boolean create)Returns a phone number to contact for further information about
the session. This corresponds to the p= field of the SDP data.
if (phoneList == null) {
if (create)
phoneList = new Vector();
}
return phoneList;
|
public SessionNameField | getSessionName()Returns the name of the session.
This corresponds to the s= field of the SDP data.
return sessionNameImpl;
|
public java.util.Vector | getTimeDescriptions(boolean create)Returns a TimeField indicating the start, stop, repetition and time zone
information of the
session. This corresponds to the t= field of the SDP data.
if (timeDescriptions == null) {
if (create)
timeDescriptions = new Vector();
}
return timeDescriptions;
|
public URIField | getURI()Returns a uri to the location of more details about the session.
This corresponds to the u=
field of the SDP data.
return uriImpl;
|
public ProtoVersionField | getVersion()Returns the version of SDP in use.
This corresponds to the v= field of the SDP data.
return versionImpl;
|
public java.util.Vector | getZoneAdjustments(boolean create)Returns the time zone adjustments for the Session
if (zoneAdjustments == null) {
if (create)
zoneAdjustments = new Vector();
}
return zoneAdjustments;
|
public void | removeAttribute(java.lang.String name)Removes the attribute specified by the value parameter.
if (name != null)
if (attributesList != null) {
for (int i = 0; i < attributesList.size(); i++) {
Object o = attributesList.elementAt(i);
if (o instanceof AttributeField) {
AttributeField a = (AttributeField)o;
try {
String n = a.getName();
if (n != null) {
if (name.equals(n)) {
attributesList.removeElement(a);
}
}
}
catch (SdpParseException e) {}
}
}
}
|
public void | removeBandwidth(java.lang.String name)Removes the specified bandwidth type.
if (name != null)
if (bandwidthList != null) {
for (int i = 0; i < bandwidthList.size(); i++) {
Object o = bandwidthList.elementAt(i);
if (o instanceof BandwidthField) {
BandwidthField b = (BandwidthField)o;
try {
String type = b.getType();
if (type != null) {
if (name.equals(type)) {
bandwidthList.removeElement(b);
}
}
}
catch (SdpParseException e) {}
}
}
}
|
public void | setAttribute(java.lang.String name, java.lang.String value)Sets the value of the specified attribute.
if (name == null || value == null)
throw new SdpException("The parameter is null");
else
if (attributesList != null) {
for (int i = 0; i < attributesList.size(); i++) {
Object o = attributesList.elementAt(i);
if (o instanceof AttributeField) {
AttributeField a = (AttributeField)o;
String n = a.getName();
if (n != null) {
if (name.equals(n)) {
a.setValue(value);
}
}
}
}
}
|
public void | setAttributes(java.util.Vector attributes)Adds the specified Attribute to this Description object.
if (attributes == null)
throw new SdpException("The parameter is null");
else attributesList = attributes;
|
public void | setBandwidth(java.lang.String name, int value)Sets the value of the specified bandwidth type.
if (name == null)
throw new SdpException("The parameter is null");
else
if (bandwidthList != null) {
for (int i = 0; i < bandwidthList.size(); i++) {
Object o = bandwidthList.elementAt(i);
if (o instanceof BandwidthField) {
BandwidthField b = (BandwidthField)o;
String type = b.getType();
if (type != null) {
if (name.equals(type)) {
b.setValue(value);
}
}
}
}
}
|
public void | setBandwidths(java.util.Vector bandwidthList)Sets the value of the Bandwidth with the specified type.
if (bandwidthList == null)
throw new SdpException("The parameter is null");
else
this.bandwidthList = bandwidthList;
|
public void | setConnection(ConnectionField conn)Sets the connection data for this entity.
if (conn == null)
throw new SdpException("The parameter is null");
if (conn instanceof ConnectionField) {
ConnectionField c = (ConnectionField)conn;
connectionImpl = c;
} else
throw new
SdpException("Bad implementation class ConnectionField");
|
public void | setEmails(java.util.Vector emails)Sets a an email address to contact for further information
about the session.
This corresponds to the e= field of the SDP data.
if (emails == null)
throw new SdpException("The parameter is null");
else
emailList = emails;
|
public void | setInfo(InformationField i)Sets the i= field of this object.
if (i == null)
throw new SdpException("The parameter is null");
if (i instanceof InformationField) {
InformationField info = (InformationField)i;
infoImpl = info;
} else
throw new SdpException("The parameter must be "
+ "an instance of InformationField");
|
public void | setKey(KeyField key)Sets encryption key information.
This consists of a method and an encryption key included inline.
if (key == null)
throw new SdpException("The parameter is null");
if (key instanceof KeyField) {
KeyField k = (KeyField)key;
keyImpl = k;
} else
throw new
SdpException("The parameter must be an instance of KeyField");
|
public void | setMediaDescriptions(java.util.Vector mediaDescriptions)Removes all MediaDescriptions from the session description.
if (mediaDescriptions == null)
throw new SdpException("The parameter is null");
else this.mediaDescriptions = mediaDescriptions;
|
public void | setOrigin(OriginField origin)Sets information about the originator of the session.
This corresponds to the o= field of the SDP data.
if (origin == null)
throw new SdpException("The parameter is null");
if (origin instanceof OriginField) {
OriginField o = (OriginField)origin;
originImpl = o;
} else
throw new SdpException("The parameter must be "
+ "an instance of OriginField");
|
public void | setPhones(java.util.Vector phones)Sets a phone number to contact for further information about
the session. This corresponds to the p= field of the SDP data.
if (phones == null)
throw new SdpException("The parameter is null");
else
phoneList = phones;
|
public void | setSessionName(SessionNameField sessionName)Sets the name of the session.
This corresponds to the s= field of the SDP data.
if (sessionName == null)
throw new SdpException("The parameter is null");
if (sessionName instanceof SessionNameField) {
SessionNameField s = (SessionNameField)sessionName;
sessionNameImpl = s;
} else
throw new SdpException("The parameter must be "
+ "an instance of SessionNameField");
|
public void | setTimeDescriptions(java.util.Vector times)Sets a TimeField indicating the start, stop, repetition and time zone
information of the
session. This corresponds to the t= field of the SDP data.
if (times == null)
throw new SdpException("The parameter is null");
else {
timeDescriptions = times;
}
|
public void | setURI(URIField uri)Sets the uri to the location of more details about the session. This
corresponds to the u=
field of the SDP data.
if (uri == null)
throw new SdpException("The parameter is null");
if (uri instanceof URIField) {
URIField u = (URIField)uri;
uriImpl = u;
} else
throw new SdpException
("The parameter must be an instance of URIField");
|
public void | setVersion(ProtoVersionField v)Sets the version of SDP in use.
This corresponds to the v= field of the SDP data.
if (v == null)
throw new SdpException("The parameter is null");
if (v instanceof ProtoVersionField) {
versionImpl = (ProtoVersionField)v;
} else
throw new SdpException
("The parameter must be an instance of VersionField");
|
public void | setZoneAdjustments(java.util.Vector zoneAdjustments)Sets the time zone adjustment for the TimeField.
if (zoneAdjustments == null)
throw new SdpException("The parameter is null");
else this.zoneAdjustments = zoneAdjustments;
|
public java.lang.String | toString()Returns the canonical string representation of the
current SessionDescrption. Acknowledgement - this code
StringBuffer encBuff = new StringBuffer();
// Encode single attributes
encBuff.append(getVersion() == null ? "" : getVersion().toString());
encBuff.append(getOrigin() == null ? "" : getOrigin().toString());
encBuff.append(getSessionName() == null ? "" : getSessionName().toString
());
encBuff.append(getInfo() == null ? "" : getInfo().toString());
// Encode attribute vectors
try {
encBuff.append(getURI() == null ? "" : getURI().toString());
encBuff.append(encodeVector(getEmails(true)));
encBuff.append(encodeVector(getPhones(true)));
encBuff.append(getConnection() == null ? "" :
getConnection().toString
());
encBuff.append(encodeVector(getBandwidths(true)));
encBuff.append(encodeVector(getTimeDescriptions(true)));
encBuff.append(encodeVector(getZoneAdjustments(true)));
encBuff.append(getKey() == null ? "" : getKey().toString());
encBuff.append(encodeVector(getAttributes(true)));
encBuff.append(encodeVector(getMediaDescriptions(true)));
// adds the final crlf
}
catch (SdpException exc) {
// add exception handling if necessary
}
return encBuff.toString();
|