Package org.apache.derby.impl.drda
Class ProtocolTestAdapter
- java.lang.Object
-
- org.apache.derby.impl.drda.ProtocolTestAdapter
-
public class ProtocolTestAdapter extends java.lang.Object
Adapter written to allow for protocol testing from the test package.The only purpose of this class is to make certain constants and methods that are package private available outside of this package for testing purposes. See DERBY-2031.
-
-
Field Summary
Fields Modifier and Type Field Description private CcsidManager
ccsidManager
static int
CP_CODPNT
static int
CP_MGRLVLLS
static int
CP_MGRLVLRM
private static CodePointNameTable
CP_NAMES
Shared code point name table (write once, then only reads/lookups).static int
CP_PRCCNVCD
static int
CP_PRCCNVRM
static int
CP_SECCHKCD
static int
CP_SECMEC
static int
CP_SQLCARD
static int
CP_SVRCOD
static int
CP_SYNERRCD
static int
CP_SYNTAXRM
private java.io.OutputStream
out
private DDMReader
reader
private java.net.Socket
socket
static byte
SPACE
private DDMWriter
writer
-
Constructor Summary
Constructors Constructor Description ProtocolTestAdapter(java.net.Socket socket)
Initializes the adapter for use with the given socket.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the resources associated with the adapter.byte[]
convertFromJavaString(java.lang.String str)
Converts a string to a byte array according to the CCSID manager.java.lang.Integer
decodeCodePoint(java.lang.String codePointName)
Returns the code point id for the given code point name.java.lang.String
lookupCodePoint(int codePoint)
Returns the name of the given code point.boolean
rMoreData()
boolean
rMoreDdmData()
boolean
rMoreDssData()
byte
rReadByte()
byte[]
rReadBytes()
int
rReadLengthAndCodePoint(boolean f)
int
rReadNetworkInt()
int
rReadNetworkShort()
void
rReadReplyDss()
java.lang.String
rReadString(int length, java.lang.String enc)
void
rSkipBytes()
void
rSkipDdm()
void
rSkipDss()
void
setUtf8Ccsid()
Instructs theDDMReader
andDDMWriter
to use UTF-8.void
wCreateDssObject()
void
wCreateDssReply()
void
wCreateDssRequest()
void
wEndDdm()
void
wEndDdmAndDss()
void
wEndDss()
void
wEndDss(byte b)
void
wFlush()
void
wPadBytes(byte ch, int len)
private static java.io.IOException
wrap(DRDAProtocolException dpe)
Wraps a protocol exception in a generic I/O exception, sinceDRDAProtocolException
is package private.void
wStartDdm(int cp)
void
wWriteByte(int b)
void
wWriteBytes(byte[] buf)
void
wWriteCodePoint4Bytes(int cp, int v)
void
wWriteInt(int v)
void
wWriteScalar1Byte(int cp, int value)
void
wWriteScalar2Bytes(int cp, int value)
void
wWriteScalarBytes(int cp, byte[] buf)
void
wWriteScalarPaddedBytes(int cp, byte[] buf, int length, byte ch)
void
wWriteScalarString(int cp, java.lang.String str)
void
wWriteShort(int v)
-
-
-
Field Detail
-
SPACE
public static final byte SPACE
-
CP_SQLCARD
public static final int CP_SQLCARD
- See Also:
- Constant Field Values
-
CP_SVRCOD
public static final int CP_SVRCOD
- See Also:
- Constant Field Values
-
CP_CODPNT
public static final int CP_CODPNT
- See Also:
- Constant Field Values
-
CP_PRCCNVCD
public static final int CP_PRCCNVCD
- See Also:
- Constant Field Values
-
CP_SYNERRCD
public static final int CP_SYNERRCD
- See Also:
- Constant Field Values
-
CP_MGRLVLLS
public static final int CP_MGRLVLLS
- See Also:
- Constant Field Values
-
CP_PRCCNVRM
public static final int CP_PRCCNVRM
- See Also:
- Constant Field Values
-
CP_SYNTAXRM
public static final int CP_SYNTAXRM
- See Also:
- Constant Field Values
-
CP_MGRLVLRM
public static final int CP_MGRLVLRM
- See Also:
- Constant Field Values
-
CP_SECMEC
public static final int CP_SECMEC
- See Also:
- Constant Field Values
-
CP_SECCHKCD
public static final int CP_SECCHKCD
- See Also:
- Constant Field Values
-
CP_NAMES
private static final CodePointNameTable CP_NAMES
Shared code point name table (write once, then only reads/lookups).
-
ccsidManager
private final CcsidManager ccsidManager
-
writer
private final DDMWriter writer
-
socket
private final java.net.Socket socket
-
reader
private final DDMReader reader
-
out
private final java.io.OutputStream out
-
-
Method Detail
-
close
public void close() throws java.io.IOException
Closes the resources associated with the adapter.- Throws:
java.io.IOException
-
lookupCodePoint
public java.lang.String lookupCodePoint(int codePoint)
Returns the name of the given code point.- Parameters:
codePoint
- code point to look up- Returns:
- Code point name, or
null
if code point is unknown.
-
decodeCodePoint
public java.lang.Integer decodeCodePoint(java.lang.String codePointName)
Returns the code point id for the given code point name.- Parameters:
codePointName
- the name of the code point to look up- Returns:
- The code point identifier, or
null
if the code point name is unknown.
-
convertFromJavaString
public byte[] convertFromJavaString(java.lang.String str)
Converts a string to a byte array according to the CCSID manager.
-
setUtf8Ccsid
public void setUtf8Ccsid()
Instructs theDDMReader
andDDMWriter
to use UTF-8.
-
wCreateDssRequest
public void wCreateDssRequest()
-
wCreateDssObject
public void wCreateDssObject()
-
wCreateDssReply
public void wCreateDssReply()
-
wEndDss
public void wEndDss()
-
wEndDss
public void wEndDss(byte b)
-
wEndDdm
public void wEndDdm()
-
wEndDdmAndDss
public void wEndDdmAndDss()
-
wStartDdm
public void wStartDdm(int cp)
-
wWriteScalarString
public void wWriteScalarString(int cp, java.lang.String str)
-
wWriteScalar2Bytes
public void wWriteScalar2Bytes(int cp, int value)
-
wWriteScalar1Byte
public void wWriteScalar1Byte(int cp, int value)
-
wWriteScalarBytes
public void wWriteScalarBytes(int cp, byte[] buf)
-
wWriteScalarPaddedBytes
public void wWriteScalarPaddedBytes(int cp, byte[] buf, int length, byte ch)
-
wWriteByte
public void wWriteByte(int b)
-
wWriteBytes
public void wWriteBytes(byte[] buf)
-
wWriteShort
public void wWriteShort(int v)
-
wWriteInt
public void wWriteInt(int v)
-
wWriteCodePoint4Bytes
public void wWriteCodePoint4Bytes(int cp, int v)
-
wPadBytes
public void wPadBytes(byte ch, int len)
-
wFlush
public void wFlush() throws java.io.IOException
- Throws:
java.io.IOException
-
rReadReplyDss
public void rReadReplyDss() throws java.io.IOException
- Throws:
java.io.IOException
-
rSkipDss
public void rSkipDss() throws java.io.IOException
- Throws:
java.io.IOException
-
rSkipDdm
public void rSkipDdm() throws java.io.IOException
- Throws:
java.io.IOException
-
rSkipBytes
public void rSkipBytes() throws java.io.IOException
- Throws:
java.io.IOException
-
rMoreData
public boolean rMoreData()
-
rMoreDssData
public boolean rMoreDssData()
-
rMoreDdmData
public boolean rMoreDdmData()
-
rReadNetworkShort
public int rReadNetworkShort() throws java.io.IOException
- Throws:
java.io.IOException
-
rReadByte
public byte rReadByte() throws java.io.IOException
- Throws:
java.io.IOException
-
rReadBytes
public byte[] rReadBytes() throws java.io.IOException
- Throws:
java.io.IOException
-
rReadLengthAndCodePoint
public int rReadLengthAndCodePoint(boolean f) throws java.io.IOException
- Throws:
java.io.IOException
-
rReadNetworkInt
public int rReadNetworkInt() throws java.io.IOException
- Throws:
java.io.IOException
-
rReadString
public java.lang.String rReadString(int length, java.lang.String enc) throws java.io.IOException
- Throws:
java.io.IOException
-
wrap
private static java.io.IOException wrap(DRDAProtocolException dpe)
Wraps a protocol exception in a generic I/O exception, sinceDRDAProtocolException
is package private.
-
-