com.sun.corba.se.impl.encoding.CodeSetConversion Java Examples

The following examples show how to use com.sun.corba.se.impl.encoding.CodeSetConversion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CDROutputStream_1_2.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.2, a wchar is encoded as an unsigned octet length
    // followed by the octets of the converted wchar.  This is good,
    // but it causes problems with our chunking code.  We don't
    // want that octet to get put in a different chunk at the end
    // of the previous fragment.
    //
    // Ensure that this won't happen by overriding write_wchar_array
    // and doing our own handleSpecialChunkBegin/End here.
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    handleSpecialChunkBegin(1 + converter.getNumBytes());

    write_octet((byte)converter.getNumBytes());

    byte[] result = converter.getBytes();

    // Write the bytes without messing with chunking
    // See CDROutputStream_1_0
    internalWriteOctetArray(result, 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}
 
Example #2
Source File: EncapsOutputStream.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
protected CodeSetConversion.CTBConverter createWCharCTBConverter() {
    if (getGIOPVersion().equals(GIOPVersion.V1_0))
        throw wrapper.wcharDataInGiop10(CompletionStatus.COMPLETED_MAYBE);

    // In the case of GIOP 1.1, we take the byte order of the stream and don't
    // use byte order markers since we're limited to a 2 byte fixed width encoding.
    if (getGIOPVersion().equals(GIOPVersion.V1_1))
        return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                        isLittleEndian(),
                                                        false);

    // Assume anything else meets GIOP 1.2 requirements
    //
    // Use byte order markers?  If not, use big endian in GIOP 1.2.
    // (formal 00-11-03 15.3.16)

    boolean useBOM = ((ORB)orb()).getORBData().useByteOrderMarkersInEncapsulations();

    return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                    false,
                                                    useBOM);
}
 
Example #3
Source File: CDRInputObject.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.BTCConverter createCharBTCConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharBTCConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getBTCConverter(charSet, isLittleEndian());
}
 
Example #4
Source File: EncapsInputStream.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
protected CodeSetConversion.BTCConverter createWCharBTCConverter() {
    // Wide characters don't exist in GIOP 1.0
    if (getGIOPVersion().equals(GIOPVersion.V1_0))
        throw wrapper.wcharDataInGiop10( CompletionStatus.COMPLETED_MAYBE);

    // In GIOP 1.1, we shouldn't have byte order markers.  Take the order
    // of the stream if we don't see them.
    if (getGIOPVersion().equals(GIOPVersion.V1_1))
        return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.UTF_16,
                                                        isLittleEndian());

    // Assume anything else adheres to GIOP 1.2 requirements.
    //
    // Our UTF_16 converter will work with byte order markers, and if
    // they aren't present, it will use the provided endianness.
    //
    // With no byte order marker, it's big endian in GIOP 1.2.
    // formal 00-11-03 15.3.16.
    return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.UTF_16,
                                                    false);
}
 
Example #5
Source File: CDROutputObject.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.CTBConverter createCharCTBConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharCTBConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getCTBConverter(charSet,
                                                    isLittleEndian(),
                                                    false);
}
 
Example #6
Source File: CDROutputStream_1_2.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.2, a wchar is encoded as an unsigned octet length
    // followed by the octets of the converted wchar.  This is good,
    // but it causes problems with our chunking code.  We don't
    // want that octet to get put in a different chunk at the end
    // of the previous fragment.
    //
    // Ensure that this won't happen by overriding write_wchar_array
    // and doing our own handleSpecialChunkBegin/End here.
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    handleSpecialChunkBegin(1 + converter.getNumBytes());

    write_octet((byte)converter.getNumBytes());

    byte[] result = converter.getBytes();

    // Write the bytes without messing with chunking
    // See CDROutputStream_1_0
    internalWriteOctetArray(result, 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}
 
Example #7
Source File: CDROutputStream_1_1.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.1, interoperability with wchar is limited
    // to 2 byte fixed width encodings.  CORBA formal 99-10-07 15.3.1.6.
    // Note that the following code prohibits UTF-16 with a byte
    // order marker (which would result in 4 bytes).
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    if (converter.getNumBytes() != 2)
        throw wrapper.badGiop11Ctb(CompletionStatus.COMPLETED_MAYBE);

    alignAndReserve(converter.getAlignment(),
                    converter.getNumBytes());

    parent.write_octet_array(converter.getBytes(),
                             0,
                             converter.getNumBytes());
}
 
Example #8
Source File: CDROutputStream_1_1.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.1, interoperability with wchar is limited
    // to 2 byte fixed width encodings.  CORBA formal 99-10-07 15.3.1.6.
    // Note that the following code prohibits UTF-16 with a byte
    // order marker (which would result in 4 bytes).
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    if (converter.getNumBytes() != 2)
        throw wrapper.badGiop11Ctb(CompletionStatus.COMPLETED_MAYBE);

    alignAndReserve(converter.getAlignment(),
                    converter.getNumBytes());

    parent.write_octet_array(converter.getBytes(),
                             0,
                             converter.getNumBytes());
}
 
Example #9
Source File: EncapsOutputStream.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected CodeSetConversion.CTBConverter createWCharCTBConverter() {
    if (getGIOPVersion().equals(GIOPVersion.V1_0))
        throw wrapper.wcharDataInGiop10(CompletionStatus.COMPLETED_MAYBE);

    // In the case of GIOP 1.1, we take the byte order of the stream and don't
    // use byte order markers since we're limited to a 2 byte fixed width encoding.
    if (getGIOPVersion().equals(GIOPVersion.V1_1))
        return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                        isLittleEndian(),
                                                        false);

    // Assume anything else meets GIOP 1.2 requirements
    //
    // Use byte order markers?  If not, use big endian in GIOP 1.2.
    // (formal 00-11-03 15.3.16)

    boolean useBOM = ((ORB)orb()).getORBData().useByteOrderMarkersInEncapsulations();

    return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                    false,
                                                    useBOM);
}
 
Example #10
Source File: CDROutputObject.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.CTBConverter createCharCTBConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharCTBConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getCTBConverter(charSet,
                                                    isLittleEndian(),
                                                    false);
}
 
Example #11
Source File: EncapsInputStream.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected CodeSetConversion.BTCConverter createWCharBTCConverter() {
    // Wide characters don't exist in GIOP 1.0
    if (getGIOPVersion().equals(GIOPVersion.V1_0))
        throw wrapper.wcharDataInGiop10( CompletionStatus.COMPLETED_MAYBE);

    // In GIOP 1.1, we shouldn't have byte order markers.  Take the order
    // of the stream if we don't see them.
    if (getGIOPVersion().equals(GIOPVersion.V1_1))
        return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.UTF_16,
                                                        isLittleEndian());

    // Assume anything else adheres to GIOP 1.2 requirements.
    //
    // Our UTF_16 converter will work with byte order markers, and if
    // they aren't present, it will use the provided endianness.
    //
    // With no byte order marker, it's big endian in GIOP 1.2.
    // formal 00-11-03 15.3.16.
    return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.UTF_16,
                                                    false);
}
 
Example #12
Source File: CDRInputObject.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.BTCConverter createCharBTCConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharBTCConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getBTCConverter(charSet, isLittleEndian());
}
 
Example #13
Source File: CDROutputStream_1_2.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.2, a wchar is encoded as an unsigned octet length
    // followed by the octets of the converted wchar.  This is good,
    // but it causes problems with our chunking code.  We don't
    // want that octet to get put in a different chunk at the end
    // of the previous fragment.
    //
    // Ensure that this won't happen by overriding write_wchar_array
    // and doing our own handleSpecialChunkBegin/End here.
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    handleSpecialChunkBegin(1 + converter.getNumBytes());

    write_octet((byte)converter.getNumBytes());

    byte[] result = converter.getBytes();

    // Write the bytes without messing with chunking
    // See CDROutputStream_1_0
    internalWriteOctetArray(result, 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}
 
Example #14
Source File: EncapsOutputStream.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
protected CodeSetConversion.CTBConverter createWCharCTBConverter() {
    if (getGIOPVersion().equals(GIOPVersion.V1_0))
        throw wrapper.wcharDataInGiop10(CompletionStatus.COMPLETED_MAYBE);

    // In the case of GIOP 1.1, we take the byte order of the stream and don't
    // use byte order markers since we're limited to a 2 byte fixed width encoding.
    if (getGIOPVersion().equals(GIOPVersion.V1_1))
        return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                        isLittleEndian(),
                                                        false);

    // Assume anything else meets GIOP 1.2 requirements
    //
    // Use byte order markers?  If not, use big endian in GIOP 1.2.
    // (formal 00-11-03 15.3.16)

    boolean useBOM = ((ORB)orb()).getORBData().useByteOrderMarkersInEncapsulations();

    return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                    false,
                                                    useBOM);
}
 
Example #15
Source File: CDROutputStream_1_2.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.2, a wchar is encoded as an unsigned octet length
    // followed by the octets of the converted wchar.  This is good,
    // but it causes problems with our chunking code.  We don't
    // want that octet to get put in a different chunk at the end
    // of the previous fragment.
    //
    // Ensure that this won't happen by overriding write_wchar_array
    // and doing our own handleSpecialChunkBegin/End here.
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    handleSpecialChunkBegin(1 + converter.getNumBytes());

    write_octet((byte)converter.getNumBytes());

    byte[] result = converter.getBytes();

    // Write the bytes without messing with chunking
    // See CDROutputStream_1_0
    internalWriteOctetArray(result, 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}
 
Example #16
Source File: CDRInputObject.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.BTCConverter createCharBTCConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharBTCConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getBTCConverter(charSet, isLittleEndian());
}
 
Example #17
Source File: EncapsInputStream.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected CodeSetConversion.BTCConverter createWCharBTCConverter() {
    // Wide characters don't exist in GIOP 1.0
    if (getGIOPVersion().equals(GIOPVersion.V1_0))
        throw wrapper.wcharDataInGiop10( CompletionStatus.COMPLETED_MAYBE);

    // In GIOP 1.1, we shouldn't have byte order markers.  Take the order
    // of the stream if we don't see them.
    if (getGIOPVersion().equals(GIOPVersion.V1_1))
        return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.UTF_16,
                                                        isLittleEndian());

    // Assume anything else adheres to GIOP 1.2 requirements.
    //
    // Our UTF_16 converter will work with byte order markers, and if
    // they aren't present, it will use the provided endianness.
    //
    // With no byte order marker, it's big endian in GIOP 1.2.
    // formal 00-11-03 15.3.16.
    return CodeSetConversion.impl().getBTCConverter(OSFCodeSetRegistry.UTF_16,
                                                    false);
}
 
Example #18
Source File: CDROutputStream_1_2.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.2, a wchar is encoded as an unsigned octet length
    // followed by the octets of the converted wchar.  This is good,
    // but it causes problems with our chunking code.  We don't
    // want that octet to get put in a different chunk at the end
    // of the previous fragment.
    //
    // Ensure that this won't happen by overriding write_wchar_array
    // and doing our own handleSpecialChunkBegin/End here.
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    handleSpecialChunkBegin(1 + converter.getNumBytes());

    write_octet((byte)converter.getNumBytes());

    byte[] result = converter.getBytes();

    // Write the bytes without messing with chunking
    // See CDROutputStream_1_0
    internalWriteOctetArray(result, 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}
 
Example #19
Source File: CDRInputObject.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.BTCConverter createCharBTCConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharBTCConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getBTCConverter(charSet, isLittleEndian());
}
 
Example #20
Source File: CDROutputObject.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.CTBConverter createCharCTBConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharCTBConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getCTBConverter(charSet,
                                                    isLittleEndian(),
                                                    false);
}
 
Example #21
Source File: CDRInputObject.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Override the default CDR factory behavior to get the
 * negotiated code sets from the connection.
 *
 * These are only called once per message, the first time needed.
 *
 * In the local case, there is no Connection, so use the
 * local code sets.
 */
protected CodeSetConversion.BTCConverter createCharBTCConverter() {
    CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

    // If the connection doesn't have its negotiated
    // code sets by now, fall back on the defaults defined
    // in CDRInputStream.
    if (codesets == null)
        return super.createCharBTCConverter();

    OSFCodeSetRegistry.Entry charSet
        = OSFCodeSetRegistry.lookupEntry(codesets.getCharCodeSet());

    if (charSet == null)
        throw wrapper.unknownCodeset( charSet ) ;

    return CodeSetConversion.impl().getBTCConverter(charSet, isLittleEndian());
}
 
Example #22
Source File: CDROutputStream_1_1.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void write_wchar(char x)
{
    // In GIOP 1.1, interoperability with wchar is limited
    // to 2 byte fixed width encodings.  CORBA formal 99-10-07 15.3.1.6.
    // Note that the following code prohibits UTF-16 with a byte
    // order marker (which would result in 4 bytes).
    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(x);

    if (converter.getNumBytes() != 2)
        throw wrapper.badGiop11Ctb(CompletionStatus.COMPLETED_MAYBE);

    alignAndReserve(converter.getAlignment(),
                    converter.getNumBytes());

    parent.write_octet_array(converter.getBytes(),
                             0,
                             converter.getNumBytes());
}
 
Example #23
Source File: EncapsOutputStream.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected CodeSetConversion.CTBConverter createWCharCTBConverter() {
    if (getGIOPVersion().equals(GIOPVersion.V1_0))
        throw wrapper.wcharDataInGiop10(CompletionStatus.COMPLETED_MAYBE);

    // In the case of GIOP 1.1, we take the byte order of the stream and don't
    // use byte order markers since we're limited to a 2 byte fixed width encoding.
    if (getGIOPVersion().equals(GIOPVersion.V1_1))
        return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                        isLittleEndian(),
                                                        false);

    // Assume anything else meets GIOP 1.2 requirements
    //
    // Use byte order markers?  If not, use big endian in GIOP 1.2.
    // (formal 00-11-03 15.3.16)

    boolean useBOM = ((ORB)orb()).getORBData().useByteOrderMarkersInEncapsulations();

    return CodeSetConversion.impl().getCTBConverter(OSFCodeSetRegistry.UTF_16,
                                                    false,
                                                    useBOM);
}
 
Example #24
Source File: CDROutputStream_1_0.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void write_char(char x)
{
    CodeSetConversion.CTBConverter converter = getCharConverter();

    converter.convert(x);

    // CORBA formal 99-10-07 15.3.1.6: "In the case of multi-byte encodings
    // of characters, a single instance of the char type may only
    // hold one octet of any multi-byte character encoding."
    if (converter.getNumBytes() > 1)
        throw wrapper.invalidSingleCharCtb(CompletionStatus.COMPLETED_MAYBE);

    write_octet(converter.getBytes()[0]);
}
 
Example #25
Source File: CDRInputStream_1_0.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
char[] getConvertedChars(int numBytes,
                         CodeSetConversion.BTCConverter converter) {

    // REVISIT - Look at CodeSetConversion.BTCConverter to see
    //           if it can work with an NIO ByteBuffer. We should
    //           avoid getting the bytes into an array if possible.

    // To be honest, I doubt this saves much real time
    if (bbwi.buflen - bbwi.position() >= numBytes) {
        // If the entire string is in this buffer,
        // just convert directly from the bbwi rather than
        // allocating and copying.
        byte[] tmpBuf;
        if (bbwi.byteBuffer.hasArray())
        {
            tmpBuf = bbwi.byteBuffer.array();
        }
        else
        {
             tmpBuf = new byte[bbwi.buflen];
             // Microbenchmarks are showing a loop of ByteBuffer.get(int)
             // being faster than ByteBuffer.get(byte[], int, int).
             for (int i = 0; i < bbwi.buflen; i++)
                 tmpBuf[i] = bbwi.byteBuffer.get(i);
        }
        char[] result = converter.getChars(tmpBuf,bbwi.position(),numBytes);

        bbwi.position(bbwi.position() + numBytes);
        return result;
    } else {
        // Stretches across buffers.  Unless we provide an
        // incremental conversion interface, allocate and
        // copy the bytes.
        byte[] bytes = new byte[numBytes];
        read_octet_array(bytes, 0, bytes.length);

        return converter.getChars(bytes, 0, numBytes);
    }
}
 
Example #26
Source File: CDROutputStream_1_2.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void write_wstring(String value) {
    if (value == null) {
        throw wrapper.nullParam(CompletionStatus.COMPLETED_MAYBE);
    }

    // In GIOP 1.2, wstrings are not terminated by a null.  The
    // length is the number of octets in the converted format.
    // A zero length string is represented with the 4 byte length
    // value of 0.
    if (value.length() == 0) {
        write_long(0);
        return;
    }

    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(value);

    handleSpecialChunkBegin(computeAlignment(4) + 4 + converter.getNumBytes());

    write_long(converter.getNumBytes());

    // Write the octet array without tampering with chunking
    internalWriteOctetArray(converter.getBytes(), 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}
 
Example #27
Source File: CDROutputStream_1_0.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected int writeString(String value)
{
    if (value == null) {
        throw wrapper.nullParam(CompletionStatus.COMPLETED_MAYBE);
    }

    CodeSetConversion.CTBConverter converter = getCharConverter();

    converter.convert(value);

    // A string is encoded as an unsigned CORBA long for the
    // number of bytes to follow (including a terminating null).
    // There is only one octet per character in the string.
    int len = converter.getNumBytes() + 1;

    handleSpecialChunkBegin(computeAlignment(4) + 4 + len);

    write_long(len);
    int indirection = get_offset() - 4;

    internalWriteOctetArray(converter.getBytes(), 0, converter.getNumBytes());

    // Write the null ending
    write_octet((byte)0);

    handleSpecialChunkEnd();
    return indirection;
}
 
Example #28
Source File: CDROutputStream_1_2.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void write_wstring(String value) {
    if (value == null) {
        throw wrapper.nullParam(CompletionStatus.COMPLETED_MAYBE);
    }

    // In GIOP 1.2, wstrings are not terminated by a null.  The
    // length is the number of octets in the converted format.
    // A zero length string is represented with the 4 byte length
    // value of 0.
    if (value.length() == 0) {
        write_long(0);
        return;
    }

    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(value);

    handleSpecialChunkBegin(computeAlignment(4) + 4 + converter.getNumBytes());

    write_long(converter.getNumBytes());

    // Write the octet array without tampering with chunking
    internalWriteOctetArray(converter.getBytes(), 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}
 
Example #29
Source File: CDRInputObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected CodeSetConversion.BTCConverter createWCharBTCConverter() {

        CodeSetComponentInfo.CodeSetContext codesets = getCodeSets();

        // If the connection doesn't have its negotiated
        // code sets by now, we have to throw an exception.
        // See CORBA formal 00-11-03 13.9.2.6.
        if (codesets == null) {
            if (getConnection().isServer())
                throw omgWrapper.noClientWcharCodesetCtx() ;
            else
                throw omgWrapper.noServerWcharCodesetCmp() ;
        }

        OSFCodeSetRegistry.Entry wcharSet
            = OSFCodeSetRegistry.lookupEntry(codesets.getWCharCodeSet());

        if (wcharSet == null)
            throw wrapper.unknownCodeset( wcharSet ) ;

        // For GIOP 1.2 and UTF-16, use big endian if there is no byte
        // order marker.  (See issue 3405b)
        //
        // For GIOP 1.1 and UTF-16, use the byte order the stream if
        // there isn't (and there shouldn't be) a byte order marker.
        //
        // GIOP 1.0 doesn't have wchars.  If we're talking to a legacy ORB,
        // we do what our old ORBs did.
        if (wcharSet == OSFCodeSetRegistry.UTF_16) {
            if (getGIOPVersion().equals(GIOPVersion.V1_2))
                return CodeSetConversion.impl().getBTCConverter(wcharSet, false);
        }

        return CodeSetConversion.impl().getBTCConverter(wcharSet, isLittleEndian());
    }
 
Example #30
Source File: CDROutputStream_1_2.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void write_wstring(String value) {
    if (value == null) {
        throw wrapper.nullParam(CompletionStatus.COMPLETED_MAYBE);
    }

    // In GIOP 1.2, wstrings are not terminated by a null.  The
    // length is the number of octets in the converted format.
    // A zero length string is represented with the 4 byte length
    // value of 0.
    if (value.length() == 0) {
        write_long(0);
        return;
    }

    CodeSetConversion.CTBConverter converter = getWCharConverter();

    converter.convert(value);

    handleSpecialChunkBegin(computeAlignment(4) + 4 + converter.getNumBytes());

    write_long(converter.getNumBytes());

    // Write the octet array without tampering with chunking
    internalWriteOctetArray(converter.getBytes(), 0, converter.getNumBytes());

    handleSpecialChunkEnd();
}