public boolean isLegalReplacement ( byte [ ] repl ) { /* J2ObjC: Removed use of WeakReference. WeakReference<CharsetDecoder> wr = cachedDecoder; CharsetDecoder dec = null; if ((wr == null) || ((dec = wr.get()) == null)) {*/ CharsetDecoder dec = cachedDecoder ; if ( dec == null ) { dec = charset ( ) . newDecoder ( ) ; dec . onMalformedInput ( CodingErrorAction . REPORT ) ; dec . onUnmappableCharacter ( CodingErrorAction . REPORT ) ; //cachedDecoder = new WeakReference<CharsetDecoder>(dec); cachedDecoder = dec ; } else { dec . reset ( ) ; } ByteBuffer bb = ByteBuffer . wrap ( repl ) ; CharBuffer cb = CharBuffer . allocate ( ( int ) ( bb . remaining ( ) * dec . maxCharsPerByte ( ) ) ) ; CoderResult cr = dec . decode ( bb , cb , true ) ; return ! cr . isError ( ) ; }
Tells whether or not the given byte array is a legal replacement value for this encoder .