Package org.apache.derby.impl.drda
Class ProtocolTestAdapter
- java.lang.Object
-
- org.apache.derby.impl.drda.ProtocolTestAdapter
-
public class ProtocolTestAdapter extends java.lang.ObjectAdapter 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 CcsidManagerccsidManagerstatic intCP_CODPNTstatic intCP_MGRLVLLSstatic intCP_MGRLVLRMprivate static CodePointNameTableCP_NAMESShared code point name table (write once, then only reads/lookups).static intCP_PRCCNVCDstatic intCP_PRCCNVRMstatic intCP_SECCHKCDstatic intCP_SECMECstatic intCP_SQLCARDstatic intCP_SVRCODstatic intCP_SYNERRCDstatic intCP_SYNTAXRMprivate java.io.OutputStreamoutprivate DDMReaderreaderprivate java.net.Socketsocketstatic byteSPACEprivate DDMWriterwriter
-
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 voidclose()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.IntegerdecodeCodePoint(java.lang.String codePointName)Returns the code point id for the given code point name.java.lang.StringlookupCodePoint(int codePoint)Returns the name of the given code point.booleanrMoreData()booleanrMoreDdmData()booleanrMoreDssData()byterReadByte()byte[]rReadBytes()intrReadLengthAndCodePoint(boolean f)intrReadNetworkInt()intrReadNetworkShort()voidrReadReplyDss()java.lang.StringrReadString(int length, java.lang.String enc)voidrSkipBytes()voidrSkipDdm()voidrSkipDss()voidsetUtf8Ccsid()Instructs theDDMReaderandDDMWriterto use UTF-8.voidwCreateDssObject()voidwCreateDssReply()voidwCreateDssRequest()voidwEndDdm()voidwEndDdmAndDss()voidwEndDss()voidwEndDss(byte b)voidwFlush()voidwPadBytes(byte ch, int len)private static java.io.IOExceptionwrap(DRDAProtocolException dpe)Wraps a protocol exception in a generic I/O exception, sinceDRDAProtocolExceptionis package private.voidwStartDdm(int cp)voidwWriteByte(int b)voidwWriteBytes(byte[] buf)voidwWriteCodePoint4Bytes(int cp, int v)voidwWriteInt(int v)voidwWriteScalar1Byte(int cp, int value)voidwWriteScalar2Bytes(int cp, int value)voidwWriteScalarBytes(int cp, byte[] buf)voidwWriteScalarPaddedBytes(int cp, byte[] buf, int length, byte ch)voidwWriteScalarString(int cp, java.lang.String str)voidwWriteShort(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.IOExceptionCloses 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
nullif 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
nullif 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 theDDMReaderandDDMWriterto 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, sinceDRDAProtocolExceptionis package private.
-
-