Avoid "uninitialized variable" message after new keyword
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / PHPDBGFrame.java
1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
7
8 Contributors:
9         Vicente Fernando - www.alfersoft.com.ar - Initial implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.internal.debug.core;
12
13 import java.util.Vector;
14
15 public class PHPDBGFrame {
16
17         public static final int FRAME_HEADER_SIZE= 8;
18         private char[] frameType= new char[4];
19         private Vector frameData= new Vector();
20         private int frameSize= 0;
21
22         public PHPDBGFrame(int frameType) {
23                 this.frameType= PHPDBGBase.IntToChar4(frameType);
24                 frameSize+= FRAME_HEADER_SIZE;
25         }
26         
27         public void addInt(int num) {
28                 char[] newData= PHPDBGBase.IntToChar4(num);
29                 frameData.add(newData);
30                 frameSize+= 4;
31         }
32
33         public void addChar(char ch) {
34                 char[] newData= new char[1];
35                 newData[0]= ch;
36                 frameData.add(newData);
37                 frameSize+= 1;
38         }
39
40         public void addString(String str) {
41                 frameData.add(str);
42                 frameSize+= str.length();
43         }
44
45         public int getSize() {
46                 return frameSize;
47         }
48
49         public int getSizeOfData() {
50                 return frameSize - FRAME_HEADER_SIZE;
51         }
52
53         public char[] getHeader() {
54                 char[] ret= new char[FRAME_HEADER_SIZE];
55
56                 PHPDBGBase.copyChars(ret, frameType, 4);
57                 PHPDBGBase.copyCharsTo(ret, PHPDBGBase.IntToChar4(getSizeOfData()), 4, 4);
58                 return ret;
59         }
60         
61         public char[] getFrameData() {
62                 char[] ret= new char[getSizeOfData()];
63                 int i, pos= 0;
64
65                 for(i=0; i < frameData.size(); i++) {
66                         if(frameData.get(i).getClass().getName().equals("[C")) {
67                                 char[] conv= (char[])frameData.get(i);
68                                 PHPDBGBase.copyCharsTo(ret, conv, conv.length, pos);
69                                 pos+= conv.length;
70                         } else {
71                                 if(frameData.get(i).getClass().getName().equals("java.lang.String")) {
72                                         String conv= (String)frameData.get(i);
73                                         PHPDBGBase.copyCharsTo(ret, conv.toCharArray(), conv.length(), pos);
74                                         pos+= conv.length();
75                                 }
76                         }
77                 }
78                 return ret;
79         }
80 }