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
9 Vicente Fernando - www.alfersoft.com.ar - Initial implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.internal.debug.core;
13 import java.util.Vector;
15 public class PHPDBGFrame {
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;
22 public PHPDBGFrame(int frameType) {
23 this.frameType= PHPDBGBase.IntToChar4(frameType);
24 frameSize+= FRAME_HEADER_SIZE;
27 public void addInt(int num) {
28 char[] newData= PHPDBGBase.IntToChar4(num);
29 frameData.add(newData);
33 public void addChar(char ch) {
34 char[] newData= new char[1];
36 frameData.add(newData);
40 public void addString(String str) {
42 frameSize+= str.length();
45 public int getSize() {
49 public int getSizeOfData() {
50 return frameSize - FRAME_HEADER_SIZE;
53 public char[] getHeader() {
54 char[] ret= new char[FRAME_HEADER_SIZE];
56 PHPDBGBase.copyChars(ret, frameType, 4);
57 PHPDBGBase.copyCharsTo(ret, PHPDBGBase.IntToChar4(getSizeOfData()), 4, 4);
61 public char[] getFrameData() {
62 char[] ret= new char[getSizeOfData()];
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);
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);