Package java.io

Examples of java.io.UTFDataFormatException


      }
      else if ((char1 & 0x60) == 0x40) // we know the top bit is set here
      {
        // two byte character, make sure read of next byte is in bounds.
                if (pos >= end_pos)
          throw new UTFDataFormatException();     

                char2 = (data[pos++] & 0xff);

        if ((char2 & 0xC0) != 0x80)
          throw new UTFDataFormatException();     

        str[strlen++] = (char)(((char1 & 0x1F) << 6) | (char2 & 0x3F));
      }
      else if ((char1 & 0x70) == 0x60) // we know the top bit is set here
      {
        // three byte character

        // 3 byte character, make sure read of next 2 bytes in bounds.
                if (pos + 1 >= end_pos)
          throw new UTFDataFormatException();     

                char2 = (data[pos++] & 0xff);
                char3 = (data[pos++] & 0xff);

        if ((char1 == 0xE0) &&
                    (char2 ==    0) &&
                    (char3 ==    0) &&
                    (utflen == 0))
        {
          // we reached the end of a long string,
          // that was terminated with
          // (11100000, 00000000, 00000000)
                    break;
        }
                else if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
                {
          throw new UTFDataFormatException();     
                }
                else
                {
                    str[strlen++] = (char)
                        (((char1 & 0x0F) << 12) |
                         ((char2 & 0x3F) <<  6) |
                         ((char3 & 0x3F) <<  0));
                }
      }
      else
            {
        throw new UTFDataFormatException();
      }

    }

        // update global on successful read exit.
View Full Code Here


     * cleaning up the reader state.
     */
    private IOException utfFormatException(String s) {
        noMoreReads = true;
        closeIn();
        return new UTFDataFormatException(s);
    }
View Full Code Here

                    offset += 3;
                } else {
                    // This shouldn't happen, as the data is coming from the
                    // store and is supposed to be well-formed.
                    // If it happens, fail and print some internal information.
                    throw new UTFDataFormatException("Invalid UTF-8 encoding: "
                            + Integer.toHexString(c) + ", charCount=" +
                            charCount + ", offset=" + offset);
                }
                charCount++;
            }
View Full Code Here

            else if ((c & 0x60) == 0x40) // we know the top bit is set here
            {
                // two byte character
                count += 2;
                if (utflen != 0 && count > utflen)
                    throw new UTFDataFormatException();      
                char2 = in.readUnsignedByte();
                if ((char2 & 0xC0) != 0x80)
                    throw new UTFDataFormatException();      
                actualChar = (char)(((c & 0x1F) << 6) | (char2 & 0x3F));
            }
            else if ((c & 0x70) == 0x60) // we know the top bit is set here
            {
                // three byte character
                count += 3;
                if (utflen != 0 && count > utflen)
                    throw new UTFDataFormatException();      
                char2 = in.readUnsignedByte();
                char3 = in.readUnsignedByte();
                if ((c == 0xE0) && (char2 == 0) && (char3 == 0)
                    && (utflen == 0))
                {
                    // we reached the end of a long string,
                    // that was terminated with
                    // (11100000, 00000000, 00000000)
                    break readingLoop;
                }

                if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
                    throw new UTFDataFormatException();      
               
               
                actualChar = (char)(((c & 0x0F) << 12) |
                                           ((char2 & 0x3F) << 6) |
                                           ((char3 & 0x3F) << 0));
            }
            else {
                throw new UTFDataFormatException(
                        "Invalid code point: " + Integer.toHexString(c));
            }

            str[strlen++] = actualChar;
        }
View Full Code Here

    //

    /** Throws an exception for expected byte. */
    private void expectedByte(int position, int count)
        throws UTFDataFormatException {
        throw new UTFDataFormatException(MESSAGES.errorUtf8ExpectedByte(position, count));
    } // expectedByte(int,int,int)
View Full Code Here

    } // expectedByte(int,int,int)

    /** Throws an exception for invalid byte. */
    private void invalidByte(int position, int count, int c)
        throws UTFDataFormatException {
        throw new UTFDataFormatException(MESSAGES.errorUtf8InvalidByte(position, count));
    } // invalidByte(int,int,int,int)
View Full Code Here

        throw new UTFDataFormatException(MESSAGES.errorUtf8InvalidByte(position, count));
    } // invalidByte(int,int,int,int)

    /** Throws an exception for invalid surrogate bits. */
    private void invalidSurrogate(int uuuuu) throws UTFDataFormatException {
        throw new UTFDataFormatException(MESSAGES.errorUtf8InvalidHighSurrogate(Integer.toHexString(uuuuu)));
    } // invalidSurrogate(int)
View Full Code Here

    /** Throws an exception for expected byte. */
    private void expectedByte(int position, int count)
        throws UTFDataFormatException {

        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.expectedByte",
                                     Integer.toString(position),
                                     Integer.toString(count)));

    }
View Full Code Here

    /** Throws an exception for invalid byte. */
    private void invalidByte(int position, int count)
        throws UTFDataFormatException {

        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.invalidByte",
                                     Integer.toString(position),
                                     Integer.toString(count)));
    }
View Full Code Here

    }

    /** Throws an exception for invalid surrogate bits. */
    private void invalidSurrogate(int uuuuu) throws UTFDataFormatException {
       
        throw new UTFDataFormatException(
                Localizer.getMessage("jsp.error.xml.invalidHighSurrogate",
                                     Integer.toHexString(uuuuu)));
    }
View Full Code Here

TOP

Related Classes of java.io.UTFDataFormatException

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.