public String encodeBandwidth(Bandwidth bandwidth) { StringBuffer s = new StringBuffer(""); if (bandwidth.getBandwidthLowerBound() != bandwidth.getBandwidthUpperBound()) { s.append(bandwidth.getBandwidthLowerBound()).append("-").append(bandwidth.getBandwidthUpperBound()); } else { s.append(bandwidth.getBandwidthLowerBound()); } return s.toString(); }
public static int encode(byte[] destination,int offset,Bandwidth bandwidth) { int usedLength=StringFunctions.encodeInt(destination,offset,bandwidth.getBandwidthLowerBound()); if(bandwidth.getBandwidthLowerBound()!=bandwidth.getBandwidthUpperBound()) { destination[offset+usedLength]=StringFunctions.MINUS_BYTE; usedLength++; usedLength+=StringFunctions.encodeInt(destination,offset+usedLength,bandwidth.getBandwidthUpperBound()); } return usedLength; } }
/** * Create Bandwidth object from given text. * * @param text * the text view of the Bandwidth object. * @return Bandwidth object. */ public Bandwidth decodeBandwidth(String value) throws ParseException { // bandwidth =1*4(DIGIT)["-"1*4(DIGIT)] int pos = value.indexOf('-'); if (pos < 0) { try { return new Bandwidth(Integer.parseInt(value)); } catch (Exception e) { throw new ParseException("Invalid packetization period:" + value, 0); } } else { String low = value.substring(0, pos).trim(); String hight = value.substring(pos + 1).trim(); try { return new Bandwidth(Integer.parseInt(low), Integer.parseInt(hight)); } catch (Exception e) { throw new ParseException("Invalid packetization period:" + value, 0); } } }
public static int encode(byte[] destination,int offset,Bandwidth bandwidth) { int usedLength=StringFunctions.encodeInt(destination,offset,bandwidth.getBandwidthLowerBound()); if(bandwidth.getBandwidthLowerBound()!=bandwidth.getBandwidthUpperBound()) { destination[offset+usedLength]=StringFunctions.MINUS_BYTE; usedLength++; usedLength+=StringFunctions.encodeInt(destination,offset+usedLength,bandwidth.getBandwidthUpperBound()); } return usedLength; } }
Bandwidth bandwidth = new Bandwidth(lower, upper); capabilityValue = new LocalOptVal(bandwidth);