Package org.apache.poi.hdgf.chunks

Examples of org.apache.poi.hdgf.chunks.Chunk$Command


    byte[] contents = getStore().getContents();
    while(pos < contents.length) {
      // Ensure we have enough data to create a chunk from
      int headerSize = ChunkHeader.getHeaderSize(chunkFactory.getVersion());
      if(pos+headerSize <= contents.length) {
        Chunk chunk = chunkFactory.createChunk(contents, pos);
        chunksA.add(chunk);

        pos += chunk.getOnDiskSize();
      } else {
        System.err.println("Needed " + headerSize + " bytes to create the next chunk header, but only found " + (contents.length-pos) + " bytes, ignoring rest of data");
        pos = contents.length;
      }
    }
View Full Code Here


    }
    assertTrue(hasText);
    // Which is the 72nd command
    assertEquals("Text", cs.getChunks()[72].getName());

    Chunk text = cs.getChunks()[72];
    assertEquals("Text", text.getName());

    // Which contains our text
    assertEquals(1, text.getCommands().length);
    assertEquals("Test View\n", text.getCommands()[0].getValue());


    // Almost at the end is some more text
    assertEquals("Text", cs.getChunks()[128].getName());
    text = cs.getChunks()[128];
    assertEquals("Text", text.getName());

    assertEquals(1, text.getCommands().length);
    assertEquals("Some random text, on a page\n", text.getCommands()[0].getValue());
  }
View Full Code Here

      }
    }
    if(stream instanceof ChunkStream) {
      ChunkStream cs = (ChunkStream)stream;
      for(int i=0; i<cs.getChunks().length; i++) {
        Chunk chunk = cs.getChunks()[i];
        if(chunk != null &&
            chunk.getName() != null &&
            chunk.getName().equals("Text") &&
            chunk.getCommands().length > 0) {
          
          // First command
          Command cmd = chunk.getCommands()[0];
          if(cmd != null && cmd.getValue() != null) {
             // Capture the text, as long as it isn't
             //  simply an empty string
             String str = cmd.getValue().toString();
             if(str.equals("") || str.equals("\n")) {
View Full Code Here

      ChunkStream cs = (ChunkStream)stream;
      System.out.println(ind + "  Has " + cs.getChunks().length +
          " chunks:");

      for(int i=0; i<cs.getChunks().length; i++) {
        Chunk chunk = cs.getChunks()[i];
        System.out.println(ind2 + "" + chunk.getName());
        System.out.println(ind2 + "  Length is " + chunk._getContents().length + " (" + Integer.toHexString(chunk._getContents().length) + ")");
        System.out.println(ind2 + "  OD Size is " + chunk.getOnDiskSize() + " (" + Integer.toHexString(chunk.getOnDiskSize()) + ")");
        System.out.println(ind2 + "  T / S is " + chunk.getTrailer() + " / " + chunk.getSeparator());
        System.out.println(ind2 + "  Holds " + chunk.getCommands().length + " commands");
        for(int j=0; j<chunk.getCommands().length; j++) {
          Command command = chunk.getCommands()[j];
          System.out.println(ind3 + "" +
              command.getDefinition().getName() +
              " " + command.getValue()
          );
        }
View Full Code Here

    try {
      while(pos < contents.length) {
        // Ensure we have enough data to create a chunk from
        int headerSize = ChunkHeader.getHeaderSize(chunkFactory.getVersion());
        if(pos+headerSize <= contents.length) {
          Chunk chunk = chunkFactory.createChunk(contents, pos);
          chunksA.add(chunk);

          pos += chunk.getOnDiskSize();
        } else {
          logger.log(POILogger.WARN, "Needed " + headerSize + " bytes to create the next chunk header, but only found " + (contents.length-pos) + " bytes, ignoring rest of data");
          pos = contents.length;
        }
      }
View Full Code Here

    }
    assertTrue(hasText);
    // Which is the 72nd command
    assertEquals("Text", cs.getChunks()[72].getName());

    Chunk text = cs.getChunks()[72];
    assertEquals("Text", text.getName());

    // Which contains our text
    assertEquals(1, text.getCommands().length);
    assertEquals("Test View\n", text.getCommands()[0].getValue());


    // Almost at the end is some more text
    assertEquals("Text", cs.getChunks()[128].getName());
    text = cs.getChunks()[128];
    assertEquals("Text", text.getName());

    assertEquals(1, text.getCommands().length);
    assertEquals("Some random text, on a page\n", text.getCommands()[0].getValue());
  }
View Full Code Here

      }
    }
    if(stream instanceof ChunkStream) {
      ChunkStream cs = (ChunkStream)stream;
      for(int i=0; i<cs.getChunks().length; i++) {
        Chunk chunk = cs.getChunks()[i];
        if(chunk != null &&
            chunk.getName() != null &&
            chunk.getName().equals("Text") &&
            chunk.getCommands().length > 0) {
          
          // First command
          Command cmd = chunk.getCommands()[0];
          if(cmd != null && cmd.getValue() != null) {
             // Capture the text, as long as it isn't
             //  simply an empty string
             String str = cmd.getValue().toString();
             if(str.equals("") || str.equals("\n")) {
View Full Code Here

        } else {
          throw new IOException("Unexpected character");
        }
      }
      try {
        out.add(new Command(bytes));
      } finally {
        bytes = null;
        arguments = 0;
      }
    } else if (in.readByte() == '*') {
      long l = readLong(in);
      if (l > Integer.MAX_VALUE) {
        throw new IllegalArgumentException("Java only supports arrays up to " + Integer.MAX_VALUE + " in size");
      }
      int numArgs = (int) l;
      if (numArgs < 0) {
        throw new RedisException("Invalid size: " + numArgs);
      }
      bytes = new byte[numArgs][];
      checkpoint();
      decode(ctx, in, out);
    } else {
      // Go backwards one
      in.readerIndex(in.readerIndex() - 1);
      // Read command -- can't be interupted
      byte[][] b = new byte[1][];
      b[0] = in.readBytes(in.bytesBefore((byte) '\r')).array();
      in.skipBytes(2);
      out.add(new Command(b, true));
    }
  }
View Full Code Here

        boolean isOff = _hasTrueInput(off);
        boolean isOn = _hasTrueInput(on);

        if ((brightLevel >= 0) && (brightLevel <= 100)) {
            _transmit(new Command((_destination), x10.Command.BRIGHT,
                    brightLevel));
        }

        if ((dimLevel >= 0) && (dimLevel <= 100)) {
            _transmit(new Command((_destination), x10.Command.DIM, dimLevel));
        }

        if (isOn) {
            _transmit(new Command((_destination), x10.Command.ON));
        }

        if (isOff) {
            _transmit(new Command((_destination), x10.Command.OFF));
        }
    }
View Full Code Here

    public void fire() throws IllegalActionException {
        super.fire();

        // Check whether a command is ready.
        if (_commandReady()) {
            Command command = _getCommand();
            receivedCommand.send(0, new StringToken(_commandToString(command)));
        } else {
            receivedCommand.send(0, _EMPTY_STRING);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hdgf.chunks.Chunk$Command

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.