Examples of Bytestream


Examples of eu.planets_project.pp.plato.model.ByteStream

        log.debug("FileName: " + sampleRecordToUpload.getFullname());
        log.debug("Length of File: " + sampleRecordToUpload.getData().getSize());
        log.debug("added SampleObject: " + record.getFullname());
        log.debug("JHove initialized: " + (record.getJhoveXMLString() != null));
       
        sampleRecordToUpload.setData(new ByteStream());
       
        System.gc();
       
        return null;
    }
View Full Code Here

Examples of eu.scape_project.planning.model.ByteStream

     *             if an error occurred
     * @throws TavernaParserException
     *             if the executable plan could not be parsed
     */
    public void readT2flowExecutablePlan(InputStream stream) throws PlanningException, TavernaParserException {
        ByteStream bsData = this.convertToByteStream(stream);
        if (bsData == null) {
            throw new PlanningException("An error occurred while storing the executable plan");
        }

        T2FlowParser parser = T2FlowParser.createParser(new ByteArrayInputStream(bsData.getData()));

        String name = parser.getName();
        storeExecutablePlan(FileUtils.makeFilename(name) + ".t2flow", bsData);
    }
View Full Code Here

Examples of org.jfree.fonts.encoding.ByteStream

    else if ((buffer.getLength() * 2) < textLength)
    {
      buffer.ensureSize(textLength * 2);
    }

    final ByteStream target = new ByteStream(buffer, textLength);
    final int[] sourceArray = text.getData();
    final int endPos = text.getCursor();
    for (int i = text.getOffset(); i < endPos; i++)
    {
      final int sourceItem = sourceArray[i];
      if (sourceItem < 0 || sourceItem > MAX_CHAR)
      {
        continue;
      }

      if (sourceItem <= 0xFFFF)
      {
        if (sourceItem >= 0xD800 && sourceItem <= 0xDFFF)
        {
          // this is an error condition. We ignore it for now ..
          continue;
        }

        target.put((byte) ((sourceItem & 0xff00) >> 8));
        target.put((byte) (sourceItem & 0xff));
      }
      else
      {
        // compute the weird replacement mode chars ..
        final int derivedSourceItem = sourceItem - 0x10000;
        final int highWord = 0xD800 | ((derivedSourceItem & 0xFFC00) >> 10);
        target.put((byte) ((highWord & 0xff00) >> 8));
        target.put((byte) (highWord & 0xff));

        final int lowWord = 0xDC00 | (derivedSourceItem & 0x3FF);
        target.put((byte) ((lowWord & 0xff00) >> 8));
        target.put((byte) (lowWord & 0xff));
      }
    }

    target.close();
    return buffer;
  }
View Full Code Here

Examples of org.jfree.fonts.encoding.ByteStream

      buffer.ensureSize(textLength / 2);
    }


    final int[] targetData = buffer.getData();
    final ByteStream sourceBuffer = new ByteStream(text, 10);

    // this construct gives us an even number ...
    int position = buffer.getOffset();
    while (sourceBuffer.getReadSize() >= 2)
    {
      final int highByte = (sourceBuffer.get() & 0xff);
      final int lowByte = (sourceBuffer.get() & 0xff);

      if ((highByte & 0xFC) == 0xD8)
      {
        if (sourceBuffer.getReadSize() < 2)
        {
          // we reached the end of the parsable stream ...
          // this is an error condition
          // Log.debug("Reached the end ..");
          break;
        }

        final int highByteL = (sourceBuffer.get() & 0xff);
        final int lowByteL = (sourceBuffer.get() & 0xff);


        if ((highByteL & 0xFC) == 0xDC)
        {
          // decode the extended CodePoint ...
View Full Code Here

Examples of org.jfree.fonts.encoding.ByteStream

      buffer.ensureSize(textLength / 2);
    }


    final int[] targetData = buffer.getData();
    final ByteStream sourceBuffer = new ByteStream(text, 10);

    // this construct gives us an even number ...
    int position = buffer.getOffset();
    while (sourceBuffer.getReadSize() >= 2)
    {
      final int highByte = (sourceBuffer.get() & 0xff);
      final int lowByte = (sourceBuffer.get() & 0xff);

      if ((highByte & 0xFC) == 0xD8)
      {
        if (sourceBuffer.getReadSize() < 2)
        {
          // we reached the end of the parsable stream ...
          // this is an error condition
          // Log.debug("Reached the end ..");
          break;
        }

        final int highByteL = (sourceBuffer.get() & 0xff);
        final int lowByteL = (sourceBuffer.get() & 0xff);


        if ((highByteL & 0xFC) == 0xDC)
        {
          // decode the extended CodePoint ...
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream

    public void shouldFailIfRequestHasNoStreamHosts() throws Exception {

        try {

            // build SOCKS5 Bytestream initialization request with no SOCKS5 proxies
            Bytestream bytestreamInitialization = Socks5PacketUtils.createBytestreamInitiation(
                            initiatorJID, targetJID, sessionID);

            // get SOCKS5 Bytestream manager for connection
            Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream

    public void shouldFailIfRequestHasInvalidStreamHosts() throws Exception {

        try {

            // build SOCKS5 Bytestream initialization request
            Bytestream bytestreamInitialization = Socks5PacketUtils.createBytestreamInitiation(
                            initiatorJID, targetJID, sessionID);
            // add proxy that is not running
            bytestreamInitialization.addStreamHost(proxyJID, proxyAddress, 7778);

            // get SOCKS5 Bytestream manager for connection
            Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);

            // build SOCKS5 Bytestream request with the bytestream initialization
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream

     */
    @Test
    public void shouldBlacklistInvalidProxyAfter2Failures() throws Exception {

        // build SOCKS5 Bytestream initialization request
        Bytestream bytestreamInitialization = Socks5PacketUtils.createBytestreamInitiation(
                        initiatorJID, targetJID, sessionID);
        bytestreamInitialization.addStreamHost("invalid." + proxyJID, "127.0.0.2", 7778);

        // get SOCKS5 Bytestream manager for connection
        Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);

        // try to connect several times
        for (int i = 0; i < 2; i++) {
            try {
                // build SOCKS5 Bytestream request with the bytestream initialization
                Socks5BytestreamRequest byteStreamRequest = new Socks5BytestreamRequest(
                                byteStreamManager, bytestreamInitialization);

                // set timeouts
                byteStreamRequest.setTotalConnectTimeout(600);
                byteStreamRequest.setMinimumConnectTimeout(300);

                // accept the stream (this is the call that is tested here)
                byteStreamRequest.accept();

                fail("exception should be thrown");
            }
            catch (XMPPException e) {
                assertTrue(e.getMessage().contains(
                                "Could not establish socket with any provided host"));
            }

            // verify targets response
            assertEquals(1, protocol.getRequests().size());
            Packet targetResponse = protocol.getRequests().remove(0);
            assertTrue(IQ.class.isInstance(targetResponse));
            assertEquals(initiatorJID, targetResponse.getTo());
            assertEquals(IQ.Type.ERROR, ((IQ) targetResponse).getType());
            assertEquals(XMPPError.Condition.item_not_found.toString(),
                            ((IQ) targetResponse).getError().getCondition());
        }

        // create test data for stream
        byte[] data = new byte[] { 1, 2, 3 };
        Socks5TestProxy socks5Proxy = Socks5TestProxy.getProxy(7779);

        assertTrue(socks5Proxy.isRunning());

        // add a valid SOCKS5 proxy
        bytestreamInitialization.addStreamHost(proxyJID, proxyAddress, 7779);

        // build SOCKS5 Bytestream request with the bytestream initialization
        Socks5BytestreamRequest byteStreamRequest = new Socks5BytestreamRequest(byteStreamManager,
                        bytestreamInitialization);

View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream

        // disable blacklisting
        Socks5BytestreamRequest.setConnectFailureThreshold(0);

        // build SOCKS5 Bytestream initialization request
        Bytestream bytestreamInitialization = Socks5PacketUtils.createBytestreamInitiation(
                        initiatorJID, targetJID, sessionID);
        bytestreamInitialization.addStreamHost("invalid." + proxyJID, "127.0.0.2", 7778);

        // get SOCKS5 Bytestream manager for connection
        Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);

        // try to connect several times
View Full Code Here

Examples of org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream

        // create a fake SOCKS5 proxy that doesn't respond to a request
        ServerSocket serverSocket = new ServerSocket(7779);

        // build SOCKS5 Bytestream initialization request
        Bytestream bytestreamInitialization = Socks5PacketUtils.createBytestreamInitiation(
                        initiatorJID, targetJID, sessionID);
        bytestreamInitialization.addStreamHost(proxyJID, proxyAddress, 7779);
        bytestreamInitialization.addStreamHost(proxyJID, proxyAddress, 7778);

        // create test data for stream
        byte[] data = new byte[] { 1, 2, 3 };

        // get SOCKS5 Bytestream manager for connection
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.