Examples of XInputStream


Examples of com.google.code.or.io.XInputStream

   *
   */
  @Override
  protected void doParse() throws Exception {
    //
    final XInputStream is = this.transport.getInputStream();
    final Context context = new Context(this.binlogFileName);
    while(isRunning()) {
      try {
        // Parse packet
        final int packetLength = is.readInt(3);
        final int packetSequence = is.readInt(1);
        is.setReadLimit(packetLength); // Ensure the packet boundary
       
        //
        final int packetMarker = is.readInt(1);
        if(packetMarker != OKPacket.PACKET_MARKER) { // 0x00
          if((byte)packetMarker == ErrorPacket.PACKET_MARKER) {
            final ErrorPacket packet = ErrorPacket.valueOf(packetLength, packetSequence, packetMarker, is);
            throw new NestableRuntimeException(packet.toString());
          } else if((byte)packetMarker == EOFPacket.PACKET_MARKER) {
            final EOFPacket packet = EOFPacket.valueOf(packetLength, packetSequence, packetMarker, is);
            throw new NestableRuntimeException(packet.toString());
          } else {
            throw new NestableRuntimeException("assertion failed, invalid packet marker: " + packetMarker);
          }
        }
       
        // Parse the event header
        final BinlogEventV4HeaderImpl header = new BinlogEventV4HeaderImpl();
        header.setTimestamp(is.readLong(4) * 1000L);
        header.setEventType(is.readInt(1));
        header.setServerId(is.readLong(4));
        header.setEventLength(is.readInt(4));
        header.setNextPosition(is.readLong(4));
        header.setFlags(is.readInt(2));
        header.setTimestampOfReceipt(System.currentTimeMillis());
        if(isVerbose() && LOGGER.isInfoEnabled()) {
          LOGGER.info("received an event, sequence: {}, header: {}", packetSequence, header);
        }
       
        // Parse the event body
        if(this.eventFilter != null && !this.eventFilter.accepts(header, context)) {
          this.defaultParser.parse(is, header, context);
        } else {
          BinlogEventParser parser = getEventParser(header.getEventType());
          if(parser == null) parser = this.defaultParser;
          parser.parse(is, header, context);
        }
       
        // Ensure the packet boundary
        if(is.available() != 0) {
          throw new NestableRuntimeException("assertion failed, available: " + is.available() + ", event type: " + header.getEventType());
        }
      } finally {
        is.setReadLimit(0);
      }
    }
  }
View Full Code Here

Examples of com.google.code.or.io.XInputStream

  /**
   *
   */
  protected XInputStream open(String path) throws Exception {
    //
    final XInputStream is = new XInputStreamImpl(new RamdomAccessFileInputStream(new File(path)));
    try {
      // Check binlog magic
      final byte[] magic = is.readBytes(MySQLConstants.BINLOG_MAGIC.length);
      if(!CodecUtils.equals(magic, MySQLConstants.BINLOG_MAGIC)) {
        throw new NestableRuntimeException("invalid binlog magic, file: " + path);
      }
     
      //
      if(this.startPosition > MySQLConstants.BINLOG_MAGIC.length) {
        is.skip(this.startPosition - MySQLConstants.BINLOG_MAGIC.length);
      }
      return is;
    } catch(Exception e) {
      IOUtils.closeQuietly(is);
      throw e;
View Full Code Here

Examples of com.sun.star.io.XInputStream

      // close the output part of the temporary stream
      // the output part must present since we already wrote to the stream
      if ( !m_aTestHelper.closeOutput( xTempFileStream ) )
        return false;

      XInputStream xTempInStream = m_aTestHelper.getInputStream( xTempFileStream );
      if ( xTempInStream == null )
        return false;

      // open input stream
      // since no mode is provided the result storage must be opened readonly
View Full Code Here

Examples of com.sun.star.io.XInputStream

            String filename = util.utils.getOfficeTemp(
                                      (XMultiServiceFactory) tParam.getMSF()) +
                              "LayerWriter.xcu";
            log.println("Going to parse: " + filename);

            XInputStream xStream = simpleAccess.openFileRead(filename);

            xSink.setInputStream(xStream);

            XLayer xLayer = (XLayer) UnoRuntime.queryInterface(XLayer.class,
                                                               LayerParser);
View Full Code Here

Examples of com.sun.star.io.XInputStream

    /**
     * reopen the parsed file again, to avoid the wrapped target exception.
     */
    private void reopenFile() {
        XSimpleFileAccess simpleAccess = null;
        XInputStream xStream = null;
        try {
            Object fileacc = ((XMultiServiceFactory)tParam.getMSF()).createInstance("com.sun.star.comp.ucb.SimpleFileAccess");
            simpleAccess = (XSimpleFileAccess)
                            UnoRuntime.queryInterface(XSimpleFileAccess.class,fileacc)
            log.println("Going to parse: "+filename);
View Full Code Here

Examples of com.sun.star.io.XInputStream

        try {
            String dirnameTo = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF()) ;
            String fileURL = dirnameTo + "XSimpleFileAccess_new.txt";
            String dirname = util.utils.getFullTestURL("XSimpleFileAccess");
            String filename = dirname+"XSimpleFileAccess.txt";
            XInputStream iStream = oObj.openFileRead(filename);
            oObj.writeFile(fileURL,iStream);
            shortWait();
            result = oObj.exists(fileURL);
            oObj.kill(fileURL);
            tRes.tested("writeFile()",result);
View Full Code Here

Examples of com.sun.star.io.XInputStream

     * @see com.sun.star.io.XInputStream
     */
    private void checkMediaDescriptorXInputStream(
                             String fileAlias, String fileURL, String fileType){
       
        XInputStream xStream = null;
       
        try{
            xStream = helper.getFileStream( fileURL );
        } catch (NotConnectedException e) {
            failed("Could not get XInputStream from file :'" + fileURL + "'",true);
View Full Code Here

Examples of com.sun.star.io.XInputStream

      // close the output part of the temporary stream
      // the output part must present since we already wrote to the stream
      if ( !m_aTestHelper.closeOutput( xTempFileStream ) )
        return false;

      XInputStream xTempInStream = m_aTestHelper.getInputStream( xTempFileStream );
      if ( xTempInStream == null )
        return false;

   
      // open input stream
View Full Code Here

Examples of com.sun.star.io.XInputStream

    {
        XInterface oFacc = (XInterface)xMSF.createInstance(
            "com.sun.star.comp.ucb.SimpleFileAccess");
        XSimpleFileAccess xFacc = (XSimpleFileAccess)UnoRuntime.queryInterface
            (XSimpleFileAccess.class, oFacc) ;
        XInputStream oIn = xFacc.openFileRead(fileURL) ;

        XInterface oParser = (XInterface)xMSF.createInstance(
            "com.sun.star.xml.sax.Parser");
        XParser xParser = (XParser) UnoRuntime.queryInterface(XParser.class, oParser);

        xParser.setDocumentHandler(handler) ;
        InputSource inSrc = new InputSource() ;
        inSrc.aInputStream = oIn ;
        xParser.parseStream(inSrc) ;

        oIn.closeInput();
    }
View Full Code Here

Examples of com.sun.star.io.XInputStream

            XOutputStream xFooOut =
                new StreamSimulator(tempDir + "empty.rdf", false, param);
            xRep.exportGraph(FileFormat.RDF_XML, xFooOut, foo, base);
            xFooOut.closeOutput();

            XInputStream xFooIn =
                new StreamSimulator(tempDir + "empty.rdf", true, param);
            xRep.importGraph(FileFormat.RDF_XML, xFooIn, bar, base);
            assure("no bar graph", null != xRep.getGraph(bar));

            log.println("...done");
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.