Examples of UTF8Reader


Examples of org.apache.derby.impl.jdbc.UTF8Reader

    Object synchronization = getConnectionSynchronization();
        synchronized (synchronization)
        {
            setupContextStack();

      UTF8Reader clobReader = null;
      try {

        clobReader = getCharacterStreamAtPos(pos, synchronization);
        if (clobReader == null)
          throw StandardException.newException(SQLState.BLOB_POSITION_TOO_LARGE, new Long(pos));

        StringBuffer sb = new StringBuffer(length);
        int remainToRead = length;
        while (remainToRead > 0) {

          int read = clobReader.readInto(sb, remainToRead);
          if (read == -1)
            break;

          remainToRead -= read;
        }
        clobReader.close();
        clobReader = null;

        return sb.toString();
      }
      catch (Throwable t)
      {
        throw noStateChangeLOB(t);
      }
      finally
      {
        if (clobReader != null)
          clobReader.close();
        restoreContextStack();
      }
    }
    }
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

  private UTF8Reader getCharacterStreamAtPos(long position, Object synchronization)
    throws IOException, StandardException
  {
        ((Resetable)myStream).resetStream();
    UTF8Reader clobReader = new UTF8Reader(myStream, 0, this, synchronization);

    // skip to the correct position (pos is one based)
    long remainToSkip = position - 1;
    while (remainToSkip > 0) {
      long skipBy = clobReader.skip(remainToSkip);
      if (skipBy == -1)
        return null;

      remainToSkip -= skipBy;
    }
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

restartPattern:
          for (;;) {

          //System.out.println("RESET " + start);
            UTF8Reader clobReader = getCharacterStreamAtPos(start, synchronization);
            if (clobReader == null)
              return -1;



            // start of any match of the complete pattern.

            int patternIndex = 0;
            char[] tmpPattern = null;
            boolean needPattern = true;

            // how many characters of the patter segment we have matched
            int matchCount = 0;

            long currentPosition = start;
            int clobOffset = -1;
            int read = -1;

            // absolute position of a possible match
            long matchPosition = -1;


            // absolute position of the next possible match
            long nextBestMatchPosition = -1;
            //System.out.println("restartPattern: " + start);


search:
            for (;;)
            {
              //System.out.println("search: " + needPattern + " -- " + clobOffset);
              if (needPattern) {

                String tmpPatternS;
                if ((patternLength - patternIndex) > 256)
                  tmpPatternS = searchStr.substring(patternIndex, 256);
                else
                  tmpPatternS = searchStr;

                tmpPattern = tmpPatternS.toCharArray();
                needPattern = false;
                matchCount = 0;

              }

              if (clobOffset == -1) {
               
                read = clobReader.read(tmpClob, 0, tmpClob.length);
              //System.out.println("MORE DATA " + read);
                if (read == -1)
                  return -1;

                if (read == 0)
                  continue search;

                clobOffset = 0;
              }


              // find matches within our two temp arrays.
compareArrays:
              for (; clobOffset < read; clobOffset++) {

                //System.out.println("compareArrays " + clobOffset);

                char clobC = tmpClob[clobOffset];


                if (clobC == tmpPattern[matchCount])
                {
                  if (matchPosition == -1) {
                    matchPosition = currentPosition + clobOffset;
                  }

                  matchCount++;

                  // have we matched the entire pattern segment
                  if (matchCount == tmpPattern.length)
                  {
                    // move onto the next segment.
                    patternIndex += tmpPattern.length;
                    if (patternIndex == patternLength) {
                      // complete match !!
                      clobReader.close();
                      //System.out.println("COMPLETE@" + matchPosition);
                      return matchPosition;
                    }

                    needPattern = true;
                    continue search;

                  }

                  if (clobC == tmpPattern[0]) {

                    // save the next best start position.

                    // must be the first character of the actual pattern
                    if (patternIndex == 0) {

                      // must not be just a repeat of the match of the first character
                      if (matchCount != 1) {

                        // must not have a previous next best.

                        if (nextBestMatchPosition == -1) {
                          nextBestMatchPosition = currentPosition + clobOffset;
                        }

                      }

                    }
                  }

                  continue compareArrays;
                }
                else
                {
                  // not a match
                  //
                  //
                  if (matchPosition != -1) {
                    // failed after we matched some amount of the pattern
                    matchPosition = -1;

                    // See if we found a next best match
                    if (nextBestMatchPosition == -1)
                    {
                      // NO - just continue on, re-starting at this character

                      if (patternIndex != 0) {
                        needPattern = true;
                        continue search;
                      }
                    }
                    else if (nextBestMatchPosition >= currentPosition)
                    {
                      // restart in the current array
                      clobOffset = (int) (nextBestMatchPosition - currentPosition);
                      nextBestMatchPosition = -1;
                 
                      if (patternIndex != 0) {
                        needPattern = true;
                        continue search;
                      }
                    }
                    else
                    {
                      clobReader.close();
                      start = nextBestMatchPosition;
                      continue restartPattern;
                    }

                    clobOffset--; // since the continue will increment it
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

    Object synchronization = getConnectionSynchronization();
        synchronized (synchronization)
        {
            setupContextStack();

      UTF8Reader clobReader = null;
      try {

        clobReader = getCharacterStreamAtPos(pos, synchronization);
        if (clobReader == null)
          throw StandardException.newException(SQLState.BLOB_POSITION_TOO_LARGE, new Long(pos));

        StringBuffer sb = new StringBuffer(length);
        int remainToRead = length;
        while (remainToRead > 0) {

          int read = clobReader.readInto(sb, remainToRead);
          if (read == -1)
            break;

          remainToRead -= read;
        }
        clobReader.close();
        clobReader = null;

        return sb.toString();
      }
      catch (Throwable t)
      {
        throw noStateChangeLOB(t);
      }
      finally
      {
        if (clobReader != null)
          clobReader.close();
        restoreContextStack();
      }
    }
    }
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

  private UTF8Reader getCharacterStreamAtPos(long position, Object synchronization)
    throws IOException, StandardException
  {
        ((Resetable)myStream).resetStream();
    UTF8Reader clobReader = new UTF8Reader(myStream, 0, this, synchronization);

    // skip to the correct position (pos is one based)
    long remainToSkip = position - 1;
    while (remainToSkip > 0) {
      long skipBy = clobReader.skip(remainToSkip);
      if (skipBy == -1)
        return null;

      remainToSkip -= skipBy;
    }
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

restartPattern:
          for (;;) {

          //System.out.println("RESET " + start);
            UTF8Reader clobReader = getCharacterStreamAtPos(start, synchronization);
            if (clobReader == null)
              return -1;



            // start of any match of the complete pattern.

            int patternIndex = 0;
            char[] tmpPattern = null;
            boolean needPattern = true;

            // how many characters of the patter segment we have matched
            int matchCount = 0;

            long currentPosition = start;
            int clobOffset = -1;
            int read = -1;

            // absolute position of a possible match
            long matchPosition = -1;


            // absolute position of the next possible match
            long nextBestMatchPosition = -1;
            //System.out.println("restartPattern: " + start);


search:
            for (;;)
            {
              //System.out.println("search: " + needPattern + " -- " + clobOffset);
              if (needPattern) {

                String tmpPatternS;
                if ((patternLength - patternIndex) > 256)
                  tmpPatternS = searchStr.substring(patternIndex, 256);
                else
                  tmpPatternS = searchStr;

                tmpPattern = tmpPatternS.toCharArray();
                needPattern = false;
                matchCount = 0;

              }

              if (clobOffset == -1) {
               
                read = clobReader.read(tmpClob, 0, tmpClob.length);
              //System.out.println("MORE DATA " + read);
                if (read == -1)
                  return -1;

                if (read == 0)
                  continue search;

                clobOffset = 0;
              }


              // find matches within our two temp arrays.
compareArrays:
              for (; clobOffset < read; clobOffset++) {

                //System.out.println("compareArrays " + clobOffset);

                char clobC = tmpClob[clobOffset];


                if (clobC == tmpPattern[matchCount])
                {
                  if (matchPosition == -1) {
                    matchPosition = currentPosition + clobOffset;
                  }

                  matchCount++;

                  // have we matched the entire pattern segment
                  if (matchCount == tmpPattern.length)
                  {
                    // move onto the next segment.
                    patternIndex += tmpPattern.length;
                    if (patternIndex == patternLength) {
                      // complete match !!
                      clobReader.close();
                      //System.out.println("COMPLETE@" + matchPosition);
                      return matchPosition;
                    }

                    needPattern = true;
                    continue search;

                  }

                  if (clobC == tmpPattern[0]) {

                    // save the next best start position.

                    // must be the first character of the actual pattern
                    if (patternIndex == 0) {

                      // must not be just a repeat of the match of the first character
                      if (matchCount != 1) {

                        // must not have a previous next best.

                        if (nextBestMatchPosition == -1) {
                          nextBestMatchPosition = currentPosition + clobOffset;
                        }

                      }

                    }
                  }

                  continue compareArrays;
                }
                else
                {
                  // not a match
                  //
                  //
                  if (matchPosition != -1) {
                    // failed after we matched some amount of the pattern
                    matchPosition = -1;

                    // See if we found a next best match
                    if (nextBestMatchPosition == -1)
                    {
                      // NO - just continue on, re-starting at this character

                      if (patternIndex != 0) {
                        needPattern = true;
                        continue search;
                      }
                    }
                    else if (nextBestMatchPosition >= currentPosition)
                    {
                      // restart in the current array
                      clobOffset = (int) (nextBestMatchPosition - currentPosition);
                      nextBestMatchPosition = -1;
                 
                      if (patternIndex != 0) {
                        needPattern = true;
                        continue search;
                      }
                    }
                    else
                    {
                      clobReader.close();
                      start = nextBestMatchPosition;
                      continue restartPattern;
                    }

                    clobOffset--; // since the continue will increment it
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

    Object synchronization = getConnectionSynchronization();
        synchronized (synchronization)
        {
            setupContextStack();

      UTF8Reader clobReader = null;
      try {

        clobReader = getCharacterStreamAtPos(pos, synchronization);
        if (clobReader == null)
          throw StandardException.newException(SQLState.BLOB_POSITION_TOO_LARGE, new Long(pos));

        StringBuffer sb = new StringBuffer(length);
        int remainToRead = length;
        while (remainToRead > 0) {

          int read = clobReader.readInto(sb, remainToRead);
          if (read == -1)
            break;

          remainToRead -= read;
        }
        clobReader.close();
        clobReader = null;

        return sb.toString();
      }
      catch (Throwable t)
      {
        throw noStateChangeLOB(t);
      }
      finally
      {
        if (clobReader != null)
          clobReader.close();
        restoreContextStack();
      }
    }
    }
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

  private UTF8Reader getCharacterStreamAtPos(long position, Object synchronization)
    throws IOException, StandardException
  {
        ((Resetable)myStream).resetStream();
    UTF8Reader clobReader = new UTF8Reader(myStream, 0, this, synchronization);

    // skip to the correct position (pos is one based)
    long remainToSkip = position - 1;
    while (remainToSkip > 0) {
      long skipBy = clobReader.skip(remainToSkip);
      if (skipBy == -1)
        return null;

      remainToSkip -= skipBy;
    }
View Full Code Here

Examples of org.apache.derby.impl.jdbc.UTF8Reader

restartPattern:
          for (;;) {

          //System.out.println("RESET " + start);
            UTF8Reader clobReader = getCharacterStreamAtPos(start, synchronization);
            if (clobReader == null)
              return -1;



            // start of any match of the complete pattern.

            int patternIndex = 0;
            char[] tmpPattern = null;
            boolean needPattern = true;

            // how many characters of the patter segment we have matched
            int matchCount = 0;

            long currentPosition = start;
            int clobOffset = -1;
            int read = -1;

            // absolute position of a possible match
            long matchPosition = -1;


            // absolute position of the next possible match
            long nextBestMatchPosition = -1;
            //System.out.println("restartPattern: " + start);


search:
            for (;;)
            {
              //System.out.println("search: " + needPattern + " -- " + clobOffset);
              if (needPattern) {

                String tmpPatternS;
                if ((patternLength - patternIndex) > 256)
                  tmpPatternS = searchStr.substring(patternIndex, 256);
                else
                  tmpPatternS = searchStr;

                tmpPattern = tmpPatternS.toCharArray();
                needPattern = false;
                matchCount = 0;

              }

              if (clobOffset == -1) {
               
                read = clobReader.read(tmpClob, 0, tmpClob.length);
              //System.out.println("MORE DATA " + read);
                if (read == -1)
                  return -1;

                if (read == 0)
                  continue search;

                clobOffset = 0;
              }


              // find matches within our two temp arrays.
compareArrays:
              for (; clobOffset < read; clobOffset++) {

                //System.out.println("compareArrays " + clobOffset);

                char clobC = tmpClob[clobOffset];


                if (clobC == tmpPattern[matchCount])
                {
                  if (matchPosition == -1) {
                    matchPosition = currentPosition + clobOffset;
                  }

                  matchCount++;

                  // have we matched the entire pattern segment
                  if (matchCount == tmpPattern.length)
                  {
                    // move onto the next segment.
                    patternIndex += tmpPattern.length;
                    if (patternIndex == patternLength) {
                      // complete match !!
                      clobReader.close();
                      //System.out.println("COMPLETE@" + matchPosition);
                      return matchPosition;
                    }

                    needPattern = true;
                    continue search;

                  }

                  if (clobC == tmpPattern[0]) {

                    // save the next best start position.

                    // must be the first character of the actual pattern
                    if (patternIndex == 0) {

                      // must not be just a repeat of the match of the first character
                      if (matchCount != 1) {

                        // must not have a previous next best.

                        if (nextBestMatchPosition == -1) {
                          nextBestMatchPosition = currentPosition + clobOffset;
                        }

                      }

                    }
                  }

                  continue compareArrays;
                }
                else
                {
                  // not a match
                  //
                  //
                  if (matchPosition != -1) {
                    // failed after we matched some amount of the pattern
                    matchPosition = -1;

                    // See if we found a next best match
                    if (nextBestMatchPosition == -1)
                    {
                      // NO - just continue on, re-starting at this character

                      if (patternIndex != 0) {
                        needPattern = true;
                        continue search;
                      }
                    }
                    else if (nextBestMatchPosition >= currentPosition)
                    {
                      // restart in the current array
                      clobOffset = (int) (nextBestMatchPosition - currentPosition);
                      nextBestMatchPosition = -1;
                 
                      if (patternIndex != 0) {
                        needPattern = true;
                        continue search;
                      }
                    }
                    else
                    {
                      clobReader.close();
                      start = nextBestMatchPosition;
                      continue restartPattern;
                    }

                    clobOffset--; // since the continue will increment it
View Full Code Here

Examples of org.apache.xerces.impl.io.UTF8Reader

        String ENCODING = encoding.toUpperCase(Locale.ENGLISH);
        if (ENCODING.equals("UTF-8")) {
            if (DEBUG_ENCODINGS) {
                System.out.println("$$$ creating UTF8Reader");
            }
            return new UTF8Reader(inputStream, fBufferSize, fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), fErrorReporter.getLocale() );
        }
        if(ENCODING.equals("ISO-10646-UCS-4")) {
            if(isBigEndian != null) {
                boolean isBE = isBigEndian.booleanValue();
                if(isBE) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.