本文整理汇总了Java中gov.nist.javax.sdp.fields.AttributeField类的典型用法代码示例。如果您正苦于以下问题:Java AttributeField类的具体用法?Java AttributeField怎么用?Java AttributeField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AttributeField类属于gov.nist.javax.sdp.fields包,在下文中一共展示了AttributeField类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
/**
* Returns the value of the specified attribute.
*
* @param name name - the name of the attribute
* @throws SdpParseException
* @return the value of the named attribute
*/
public String getAttribute(String name) throws SdpParseException {
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;
}
示例2: removeAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
/**
* Removes the attribute specified by the value parameter.
*
* @param name name - the name of the attribute
*/
public void removeAttribute(String name) {
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.remove(a);
}
}
} catch (SdpParseException e) {}
}
}
}
}
示例3: setAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
/**
* Sets the value of the specified attribute.
*
* @param name name - the name of the attribute.
* @param value value - the value of the named attribute.
* @throws SdpException if the name or the value is null
*/
public void setAttribute(String name, String value) throws SdpException {
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);
}
}
}
}
}
}
示例4: testAttribEquals
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
public void testAttribEquals() throws Exception {
AttributeField f1 = new AttributeFieldParser("a=sendrecv").attributeField();
AttributeField f2 = new AttributeFieldParser("a=sendrecv").attributeField();
AttributeField f3 = new AttributeFieldParser("a=sendonly").attributeField();
AttributeField f4 = new AttributeFieldParser("a=f:sendonly").attributeField();
AttributeField f5 = new AttributeFieldParser("a=f:sendonly").attributeField();
AttributeField f6 = new AttributeFieldParser("a=ff:sendonly").attributeField();
f1.equals(f2); // NPE here Issue 25
assertEquals(f1, f2);
assertFalse(f2.equals(f3));
assertFalse(f4.equals(f3));
assertEquals(f5, f4);
assertFalse(f5.equals(f6));
}
示例5: hasAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
protected boolean hasAttribute(String name) {
for (int i = 0; i < this.attributeFields.size(); i++) {
AttributeField af = (AttributeField) this.attributeFields.elementAt(i);
if (af.getAttribute().getName().equals(name)) return true;
}
return false;
}
示例6: getAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
/**
* Returns the value of the specified attribute.
*
* @param name the name of the attribute.
* @throws SdpParseException
* @return the value of the named attribute
*/
public String getAttribute(String name) throws SdpParseException {
if (name != null) {
for (int i = 0; i < this.attributeFields.size(); i++) {
AttributeField af = (AttributeField) this.attributeFields.elementAt(i);
if (name.equals(af.getAttribute().getName())) return (String) af.getAttribute().getValue();
}
return null;
} else
throw new NullPointerException("null arg!");
}
示例7: removeAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
/**
* Removes the attribute specified by the value parameter.
*
* @param name the name of the attribute.
*/
public void removeAttribute(String name) {
if (name == null) throw new NullPointerException("null arg!");
if (name != null) {
int i = 0;
for (i = 0; i < this.attributeFields.size(); i++) {
AttributeField af = (AttributeField) this.attributeFields.elementAt(i);
if (af.getAttribute().getName().equals(name)) break;
}
if (i < attributeFields.size()) attributeFields.removeElementAt(i);
}
}
示例8: createAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
/**
* 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;
}
示例9: getAudioData
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public final ArrayList<AudioData> getAudioData()
{
if (getMessage().getRawContent() == null)
return null;
ArrayList<AudioData> list = new ArrayList<AudioData>();
String content = new String(getMessage().getRawContent());
logger.debug("content=<" + content + ">");
try {
SessionDescription sdp = sdpFactory.createSessionDescription(content);
String ipAddy = sdp.getConnection().getAddress();
Vector<MediaDescriptionImpl> descriptors = (Vector<MediaDescriptionImpl>)sdp.getMediaDescriptions(true);
Iterator<MediaDescriptionImpl> it = descriptors.iterator();
while (it.hasNext()) {
MediaDescriptionImpl mediaDescription = it.next();
MediaField field = mediaDescription.getMediaField();
if (field == null) {
logger.warn("Missing media field");
continue;
}
AudioData audio = new AudioData();
audio.ipAddy = ipAddy;
audio.rtpPort = field.getPort();
Vector formats = field.getFormats();
if (formats == null) {
list.add(audio);
continue;
}
if (formats.size() < 1) {
list.add(audio);
continue;
}
audio.payloadType = (String) field.getFormats().get(0);
Vector attributes = mediaDescription.getAttributeFields();
if (attributes == null) {
list.add(audio);
continue;
}
Iterator ait = attributes.iterator();
while (ait.hasNext()) {
Object objay = ait.next();
if (! (objay instanceof AttributeField))
continue;
AttributeField afield = (AttributeField)objay;
if (! "rtpmap".equals(afield.getName()))
continue;
String [] parsed = afield.getValue().split("[ /]");
if (parsed.length < 3)
continue;
if (! parsed[0].equals(audio.payloadType))
continue;
audio.payloadDescription = parsed[1];
audio.sampleRate = parsed[2];
}
list.add(audio);
logger.info(getCallId() + " audio=" + audio.toString());
}
return list;
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
示例10: addAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
protected void addAttribute(AttributeField af) {
this.attributeFields.add(af);
}
示例11: addAttribute
import gov.nist.javax.sdp.fields.AttributeField; //导入依赖的package包/类
/**
* <p>Add Media Attribute based on an AttributeField value</p>
*
* issued by Miguel Freitas (IT) PTInovacao
* @param at AttributeField
*/
public void addAttribute(AttributeField at);