/*
(non-Javadoc)

@see org.jsmpp.PDUReader#readPDU(java.io.InputStream, int, int,
int, int)
975228
public byte[] readPDU(DataInputStream in, int commandLength, int commandId,
            int commandStatus, int sequenceNumber) throws IOException {
        synchronized (in) {
            return pduReader.readPDU(in, commandLength, commandId,
                    commandStatus, sequenceNumber);
        }
    }
310732
protected int readFully(InputStream in, byte buffer[], int offset, int len)
        throws java.io.IOException {
        for (int i = 0; i < len; i++) {
            int q = in.read();
            if (q == -1)
                return ((i == 0) ? -1 : i);
            buffer[i+offset] = (byte)q;
        }
        return len;
    }
707498
public void readData(InputStream inputStream) throws IOException {
        if (inputStream == null) {
            return;
        }

        data = ParserUtils.parseBinary(inputStream, (int) size.getValue());
    }
341958
@Override
    public InputStream read()
        throws EFapsException
    {
        StoreResourceInputStream in = null;
        ConnectionResource res = null;
        try {
            res = Context.getThreadContext().getConnectionResource();

            final Statement stmt = res.createStatement();
            final StringBuffer cmd = new StringBuffer()
                .append("select ").append(JDBCStoreResource.COLNAME_FILECONTENT).append(" ")
                .append("from ").append(JDBCStoreResource.TABLENAME_STORE).append(" ")
                .append("where ID =").append(getGeneralID());
            final ResultSet resultSet = stmt.executeQuery(cmd.toString());
            if (resultSet.next()) {
                if (Context.getDbType().supportsBinaryInputStream())  {
                    in = new JDBCStoreResourceInputStream(this,
                                                          res,
                                                          resultSet.getBinaryStream(1));
                } else  {
                    in = new JDBCStoreResourceInputStream(this,
                                                          res,
                                                          resultSet.getBlob(1));
                }
            }
            resultSet.close();
            stmt.close();
        } catch (final IOException e) {
            JDBCStoreResource.LOG.error("read of content failed", e);
            throw new EFapsException(JDBCStoreResource.class, "read.SQLException", e);
        } catch (final SQLException e) {
            JDBCStoreResource.LOG.error("read of content failed", e);
            throw new EFapsException(JDBCStoreResource.class, "read.SQLException", e);
        }
        return in;
    }
947730
public static void readFrom(InputStream is, int needed, ByteBuffer buffer) throws IOException {
        ByteBuffer tmp = allocate(8192);

        while (needed > 0 && buffer.hasRemaining()) {
            int l = is.read(tmp.array(), 0, 8192);
            if (l < 0)
                break;
            tmp.position(0);
            tmp.limit(l);
            buffer.put(tmp);
        }
    }
1219936
public static Problem readFromStream(InputStream inputStream, double bias) throws IOException, InvalidInputDataException {
        return Train.readProblem(inputStream, bias);
    }
1301019
public void read(InputStream in, int lengthToRead) throws IOException {
    int read = 0;
    do {
      grow(length);
      read = data.setBytes(length, in, Math.min(lengthToRead, data.length() - length));
      length += read;
      lengthToRead -= read;
    } while (lengthToRead > 0);
  }
76963
public Structure parsePDBFile(InputStream inStream)
			throws IOException
	{

		BufferedReader buf = getBufferedReader(inStream);

		return parsePDBFile(buf);

	}
53334
public byte[] readPDU(DataInputStream in, Command pduHeader) throws IOException {
        return readPDU(in, pduHeader.getCommandLength(), pduHeader
                .getCommandId(), pduHeader.getCommandStatus(), pduHeader
                .getSequenceNumber());
    }
921776
protected boolean checkPdu (ProtocolDataUnit pdu) {
        final BasicHeaderSegment bhs = pdu.getBasicHeaderSegment();
        final LoginRequestParser parser = (LoginRequestParser) bhs.getParser();
        if (bhs.getOpCode() == OperationCode.LOGIN_REQUEST && parser.getCurrentStageNumber() == stageNumber && bhs.getInitiatorTaskTag() == initiatorTaskTag) return true;
        return false;
    }
476548
@Override
  public synchronized P readPage(int pageID) {
    countRead();
    P page = map.get(pageID);
    if(page != null) {
      if(LOG.isDebuggingFine()) {
        LOG.debugFine("Read from cache: " + pageID);
      }
    }
    else {
      if(LOG.isDebuggingFine()) {
        LOG.debugFine("Read from backing: " + pageID);
      }
      page = file.readPage(pageID);
      map.put(pageID, page);
    }
    return page;
  }
222955
void readFrom(InputStream in) throws IOException {
		//TODO could optimize for aligned instances
		final int size = finish - start;
		final int length = (size + 7) >> 3;
		if (length == 0) return;
		int p = size & 7;
		final int q = finish - p;
		if (p != 0) performAdj(SET, q, (long) in.read(), p);
		p = q;
		while (p > start) {
			p -= 8;
			performAdj(SET, p, (long) in.read(), 8);
		}
	}
967218
@Override
    public int[] read(ScanBuffer buffer) {
        int length = getLength(buffer);
        if (length<0) return null;
        return buffer.getInts(length);
    }
606605
public Command readPDUHeader(DataInputStream in)
            throws InvalidCommandLengthException, IOException {
        synchronized (in) {
            return pduReader.readPDUHeader(in);
        }
    }
28218
public void read(ByteBuffer buffer) {
        Persistables.persistable(streamableNoBuffers()).read(buffer);

        final int n = getNumDataBuffers();
        int lengthsPosition = buffer.position();
        buffer.position(buffer.position() + 2 * n); // skip positions
        for (int i = 0; i < n; i++) {
            final int size = buffer.getShort(lengthsPosition) & 0xFFFF; // big-endian
            lengthsPosition += 2;

            final ByteBuffer b1 = Persistables.slice(buffer, size);
            setDataBuffer(i, b1);
        }
    }
242556
public void readState(DataInputStream stream) throws IOException
        {
        int len = mt.length;
        for(int x=0;x<len;x++) mt[x] = stream.readInt();
        
        len = mag01.length;
        for(int x=0;x<len;x++) mag01[x] = stream.readInt();
        
        mti = stream.readInt();
        __nextNextGaussian = stream.readDouble();
        __haveNextNextGaussian = stream.readBoolean();
        }
184180
@Override
  public final Map<String, String> readAttributes(final Reader pReader,
    final Map<String, Object> pAddParam) throws Exception {
    Map<String, String> attributesMap = new HashMap<String, String>();
    StringBuffer sb = new StringBuffer();
    int chi;
    while ((chi = pReader.read()) != -1) {
      char ch = (char) chi;
      if (ch == '>') {
        break;
      }
      switch (ch) {
        case '\\':
          sb.append("\\");
          break;
        case '"':
          sb.append("\"");
          break;
        case '\n':
          sb.append("\n");
          break;
        case '\r':
          sb.append("\r");
          break;
        case '\t':
          sb.append("\t");
          break;
        default:
          sb.append(ch);
          break;
      }
      evalAttributes(sb, attributesMap);
    }
    return attributesMap;
  }