summaryrefslogtreecommitdiff
path: root/NET/worlds/network/PropertyList.java
blob: 4ad228d2bb2e85cac074e2dc30bfa9953c750063 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*     */ package NET.worlds.network;
/*     */ 
/*     */ import java.io.IOException;
/*     */ import java.io.PrintStream;
/*     */ import java.io.UTFDataFormatException;
/*     */ import java.util.Vector;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class PropertyList
/*     */ {
/*     */   private Vector<net2Property> _propList;
/*     */   
/*     */   public PropertyList()
/*     */   {
/*  26 */     this._propList = new Vector();
/*     */   }
/*     */   
/*     */   public void addProperty(net2Property prop) {
/*  30 */     this._propList.addElement(prop);
/*     */   }
/*     */   
/*     */   public int size() {
/*  34 */     return this._propList.size();
/*     */   }
/*     */   
/*     */   public net2Property elementAt(int i) {
/*  38 */     return (net2Property)this._propList.elementAt(i);
/*     */   }
/*     */   
/*     */   public net2Property getProperty(int propID) {
/*  42 */     for (int i = this._propList.size() - 1; i >= 0; i--) {
/*  43 */       if (elementAt(i).property() == propID)
/*  44 */         return elementAt(i);
/*     */     }
/*  46 */     return null;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   void parseNetData(ServerInputStream data)
/*     */     throws IOException
/*     */   {
/*  54 */     this._propList = new Vector();
/*  55 */     while (!data.isEmpty()) {
/*     */       try {
/*  57 */         net2Property tmpProp = new net2Property();
/*  58 */         tmpProp.parseNetData(data);
/*  59 */         this._propList.addElement(tmpProp);
/*     */       }
/*     */       catch (UTFDataFormatException e) {
/*  62 */         System.out.println("Property list discarded; invalid UTF property.");
/*  63 */         this._propList.removeAllElements();
/*  64 */         data.skipBytes(data.bytesLeft());
/*  65 */         assert (data.isEmpty());
/*  66 */         return;
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   int packetSize() {
/*  72 */     int len = 0;
/*     */     
/*  74 */     for (int i = this._propList.size() - 1; i >= 0; i--) {
/*  75 */       net2Property tmpProp = (net2Property)this._propList.elementAt(i);
/*  76 */       len += tmpProp.packetSize();
/*     */     }
/*  78 */     return len;
/*     */   }
/*     */   
/*     */   void send(ServerOutputStream o) throws IOException {
/*  82 */     int maxidx = this._propList.size();
/*     */     
/*  84 */     for (int i = 0; i < maxidx; i++) {
/*  85 */       net2Property tmpProp = (net2Property)this._propList.elementAt(i);
/*  86 */       tmpProp.send(o);
/*     */     }
/*     */   }
/*     */   
/*     */   public String toString()
/*     */   {
/*  92 */     String out = "(";
/*  93 */     int maxidx = this._propList.size();
/*     */     
/*  95 */     for (int i = 0; i < maxidx; i++) {
/*  96 */       net2Property tmpProp = (net2Property)this._propList.elementAt(i);
/*  97 */       out = out + tmpProp + " ";
/*     */     }
/*  99 */     out = out + ")";
/* 100 */     return out;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\PropertyList.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */