com.ibm.as400.util.commtrace.Data Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400 Show documentation
Show all versions of jt400 Show documentation
The Open Source version of the IBM Toolbox for Java
The newest version!
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: Data.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 2002 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
package com.ibm.as400.util.commtrace;
/**
* Represents the data that is contained in the packet.
*/
public class Data {
private BitBuf data;
private final static String DATA = "Data";
/**
* Initializes the data.
* @param data the raw packet of data.
*/
Data(BitBuf data) {
this.data = data;
}
/**
* Creates a hexadecimal and Ascii representation of this data. One line is 32 characters ASCII and 64 bytes hexadecimal plus formatting characters in length.
* @return String containing a printable representation of the data.
*/
public String toString() {
if(data.getByteSize()==0) { // If there is no data return
return "";
}
StringBuffer fmtdata = new StringBuffer(data.getByteSize()*3); // The return data
StringBuffer hexdata = new StringBuffer(32); // The output hexadecimal data
StringBuffer chardata= new StringBuffer(32); // The output character representation
boolean first = true; // Set to true until the first line of data is printed.
int length = data.getByteSize(), i;
fmtdata.append("\t" + DATA + " . . . . . . : ");
for(i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy