Package org.jruby.runtime.encoding

Examples of org.jruby.runtime.encoding.EncodingCapable


            IRubyObject key = unmarshalObject(false);
            if (i == 0) { // first ivar
                if (runtime.is1_9()
                        && (object instanceof RubyString || object instanceof RubyRegexp)
                        && count >= 1) { // 1.9 string encoding
                    EncodingCapable strObj = (EncodingCapable)object;

                    if (key.asJavaString().equals(MarshalStream.SYMBOL_ENCODING_SPECIAL)) {
                        // special case for USASCII and UTF8
                        if (unmarshalObject().isTrue()) {
                            strObj.setEncoding(UTF8Encoding.INSTANCE);
                        } else {
                            strObj.setEncoding(USASCIIEncoding.INSTANCE);
                        }
                        continue;
                    } else if (key.asJavaString().equals("encoding")) {
                        // read off " byte for the string
                        read();
                        ByteList encodingName = unmarshalString();
                        Entry entry = runtime.getEncodingService().findEncodingOrAliasEntry(encodingName);
                        if (entry == null) {
                            throw runtime.newArgumentError("invalid encoding in marshaling stream: " + encodingName);
                        }
                        Encoding encoding = entry.getEncoding();
                        strObj.setEncoding(encoding);
                        continue;
                    } // else fall through as normal ivar
                }
            }
            String name = key.asJavaString();
View Full Code Here


            IRubyObject key = unmarshalObject(false);
            if (i == 0) { // first ivar
                if (runtime.is1_9()
                        && (object instanceof RubyString || object instanceof RubyRegexp)
                        && count >= 1) { // 1.9 string encoding
                    EncodingCapable strObj = (EncodingCapable)object;

                    if (key.asJavaString().equals(MarshalStream.SYMBOL_ENCODING_SPECIAL)) {
                        // special case for USASCII and UTF8
                        if (unmarshalObject().isTrue()) {
                            strObj.setEncoding(UTF8Encoding.INSTANCE);
                        } else {
                            strObj.setEncoding(USASCIIEncoding.INSTANCE);
                        }
                        continue;
                    } else if (key.asJavaString().equals("encoding")) {
                        // read off " byte for the string
                        read();
                        ByteList encodingName = unmarshalString();
                        Entry entry = runtime.getEncodingService().findEncodingOrAliasEntry(encodingName);
                        if (entry == null) {
                            throw runtime.newArgumentError("invalid encoding in marshaling stream: " + encodingName);
                        }
                        Encoding encoding = entry.getEncoding();
                        strObj.setEncoding(encoding);
                        continue;
                    } // else fall through as normal ivar
                }
            }
            String name = key.asJavaString();
View Full Code Here

           
            IRubyObject key = unmarshalObject(false);
           
            if (runtime.is1_9() && object instanceof EncodingCapable) {
               
                EncodingCapable strObj = (EncodingCapable)object;

                if (key.asJavaString().equals(MarshalStream.SYMBOL_ENCODING_SPECIAL)) {
                   
                    // special case for USASCII and UTF8
                    if (unmarshalObject().isTrue()) {
                        strObj.setEncoding(UTF8Encoding.INSTANCE);
                    } else {
                        strObj.setEncoding(USASCIIEncoding.INSTANCE);
                    }
                    continue;
                   
                } else if (key.asJavaString().equals("encoding")) {
                   
                    IRubyObject encodingNameObj = unmarshalObject(false);
                    String encodingNameStr = encodingNameObj.asJavaString();
                    ByteList encodingName = new ByteList(ByteList.plain(encodingNameStr));

                    Entry entry = runtime.getEncodingService().findEncodingOrAliasEntry(encodingName);
                    if (entry == null) {
                        throw runtime.newArgumentError("invalid encoding in marshaling stream: " + encodingName);
                    }
                    Encoding encoding = entry.getEncoding();
                    strObj.setEncoding(encoding);
                    continue;
                   
                } // else fall through as normal ivar
            }
           
View Full Code Here

TOP

Related Classes of org.jruby.runtime.encoding.EncodingCapable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.