]> sjero.net Git - linphone/blob - p2pproxy/dependencies-src/jstun-src-0.7.1/de/javawi/jstun/attribute/Dummy.java
8e780dcc0cbe79b6b908ecfee2fc2d8fc4f1160e
[linphone] / p2pproxy / dependencies-src / jstun-src-0.7.1 / de / javawi / jstun / attribute / Dummy.java
1 /*
2  * This file is part of JSTUN. 
3  * 
4  * Copyright (c) 2005 Thomas King <king@t-king.de> - All rights
5  * reserved.
6  * 
7  * This software is licensed under either the GNU Public License (GPL),
8  * or the Apache 2.0 license. Copies of both license agreements are
9  * included in this distribution.
10  */
11
12 package de.javawi.jstun.attribute;
13
14 import de.javawi.jstun.util.Utility;
15 import de.javawi.jstun.util.UtilityException;
16
17 public class Dummy extends MessageAttribute {
18         int lengthValue;
19         public Dummy() {
20                 super(MessageAttributeType.Dummy);
21         }
22         
23         public void setLengthValue(int length) {
24                 this.lengthValue = length;
25         }
26
27         public byte[] getBytes() throws UtilityException {
28                 byte[] result = new byte[lengthValue + 4];
29                 //      message attribute header
30                 // type
31                 System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2);
32                 // length
33                 System.arraycopy(Utility.integerToTwoBytes(lengthValue), 0, result, 2, 2);
34                 return result;
35         }
36         
37         public static Dummy parse(byte[] data) {
38                 Dummy dummy = new Dummy();
39                 dummy.setLengthValue(data.length);
40                 return dummy;
41         }
42 }