Package java.util.zip

Examples of java.util.zip.DataFormatException


    super();
    try
    {
      // msg type
      if (in[0] != MSG_TYPE_INITIALIZE_RCV_ACK)
        throw new DataFormatException("input is not a valid "
            + this.getClass().getCanonicalName());
      int pos = 1;

      // sender
      int length = getNextLength(in, pos);
      String senderString = new String(in, pos, length, "UTF-8");
      senderID = Integer.valueOf(senderString);
      pos += length +1;

      // destination
      length = getNextLength(in, pos);
      String serverIdString = new String(in, pos, length, "UTF-8");
      destination = Integer.valueOf(serverIdString);
      pos += length +1;

      // value fo the ack
      length = getNextLength(in, pos);
      String numAckStr = new String(in, pos, length, "UTF-8");
      pos += length +1;
      numAck = Integer.parseInt(numAckStr);
    } catch (UnsupportedEncodingException e)
    {
      throw new DataFormatException("UTF-8 is not supported by this jvm.");
    }
  }
View Full Code Here


  {
    try
    {
      if (in[0] != MSG_TYPE_ECL_UPDATE)
      {
        throw new DataFormatException("byte[] is not a valid " +
            this.getClass().getCanonicalName());
      }
      int pos = 1;

      // Decode the cookie
      int length = getNextLength(in, pos);
      String cookieStr = new String(in, pos, length, "UTF-8");
      this.cookie = new MultiDomainServerState(cookieStr);
      pos += length + 1;

      // Decode the serviceId
      length = getNextLength(in, pos);
      this.serviceId = new String(in, pos, length, "UTF-8");
      pos += length + 1;

      // Decode the draft changeNumber
      length = getNextLength(in, pos);
      this.draftChangeNumber = Integer.valueOf(
          new String(in, pos, length, "UTF-8"));
      pos += length + 1;

      // Decode the msg
      /* Read the mods : all the remaining bytes but the terminating 0 */
      length = in.length - pos - 1;
      byte[] encodedMsg = new byte[length];
      System.arraycopy(in, pos, encodedMsg, 0, length);
      ReplicationMsg rmsg =
        ReplicationMsg.generateMsg(
            encodedMsg, ProtocolVersion.getCurrentVersion());
      this.updateMsg = (LDAPUpdateMsg)rmsg;
    }
    catch (UnsupportedEncodingException e)
    {
      throw new DataFormatException("UTF-8 is not supported by this jvm.");
    }
  }
View Full Code Here

  {
    try
    {
      /* first byte is the type */
      if (in[0] != MSG_TYPE_ENTRY)
        throw new DataFormatException("input is not a valid " +
            this.getClass().getCanonicalName());
      int pos = 1;

      // sender
      int length = getNextLength(in, pos);
      String senderIDString = new String(in, pos, length, "UTF-8");
      this.senderID = Integer.valueOf(senderIDString);
      pos += length +1;

      // destination
      length = getNextLength(in, pos);
      String destinationString = new String(in, pos, length, "UTF-8");
      this.destination = Integer.valueOf(destinationString);
      pos += length +1;

      // msgCnt
      if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V4)
      {
        // msgCnt
        length = getNextLength(in, pos);
        String msgcntString = new String(in, pos, length, "UTF-8");
        this.msgId = Integer.valueOf(msgcntString);
        pos += length +1;
      }

      // data
      length = in.length - (pos + 1);
      this.entryByteArray = new byte[length];
      for (int i=0; i<length; i++)
      {
        entryByteArray[i] = in[pos+i];
      }
    }
    catch (UnsupportedEncodingException e)
    {
      throw new DataFormatException("UTF-8 is not supported by this jvm.");
    }
  }
View Full Code Here

   */
  public StopMsg(byte[] in) throws DataFormatException
  {
    // First byte is the type
    if (in[0] != MSG_TYPE_STOP)
      throw new DataFormatException("input is not a valid Stop message: " +
        in[0]);
  }
View Full Code Here

   */
  public WindowProbeMsg(byte[] in) throws DataFormatException
  {
    // WindowProbeMsg Message only contains its type.
    if (in[0] != MSG_TYPE_WINDOW_PROBE)
      throw new DataFormatException("input is not a valid Window Message");
  }
View Full Code Here

  {
    ByteSequenceReader reader = ByteString.wrap(in).asReader();
    try
    {
      if (reader.get() != MSG_TYPE_START_SESSION)
        throw new DataFormatException("input is not a valid " +
            this.getClass().getCanonicalName());

      /*
      status = ServerStatus.valueOf(asn1Reader.readOctetString().byteAt(0));
      assuredFlag = (asn1Reader.readOctetString().byteAt(0) == 1);
View Full Code Here

    try
    {
      /* first byte is the type */
      if (in.length < 1 || in[0] != MSG_TYPE_START_SESSION)
      {
        throw new DataFormatException(
          "Input is not a valid " + this.getClass().getCanonicalName());
      }

      /* Read the status */
      status = ServerStatus.valueOf(in[1]);

      /* Read the assured flag */
      if (in[2] == 1)
      {
        assuredFlag = true;
      } else
      {
        assuredFlag = false;
      }

      /* Read the assured mode */
      assuredMode = AssuredMode.valueOf(in[3]);

      /* Read the safe data level */
      safeDataLevel = in[4];

      /* Read the refferals URLs */
      int pos = 5;
      referralsURLs = new ArrayList<String>();
      while (pos < in.length)
      {
        /*
         * Read the next URL
         * first calculate the length then construct the string
         */
        int length = getNextLength(in, pos);
        referralsURLs.add(new String(in, pos, length, "UTF-8"));
        pos += length + 1;
      }
    } catch (UnsupportedEncodingException e)
    {
      throw new DataFormatException("UTF-8 is not supported by this jvm.");
    } catch (IllegalArgumentException e)
    {
      throw new DataFormatException(e.getMessage());
    }
  }
View Full Code Here

    {
      /* Read the changeNumber */
      /* First byte is the type */
      if (in[0] != MSG_TYPE_CT_HEARTBEAT)
      {
        throw new DataFormatException("byte[] is not a valid CT_HEARTBEAT msg");
      }
      int pos = 1;
      int length = getNextLength(in, pos);
      String changenumberStr = new String(in, pos, length, "UTF-8");
      changeNumber = new ChangeNumber(changenumberStr);
    }
    catch (UnsupportedEncodingException e)
    {
      throw new DataFormatException("UTF-8 is not supported by this jvm.");
    }
    catch (IllegalArgumentException e)
    {
      throw new DataFormatException(e.getMessage());
    }
  }
View Full Code Here

               int m = input.read(inputBuffer);
              
               if (m == -1)
               {
                  //it shouldn't be here, throw exception
                  throw new DataFormatException("Input is over while inflater still expecting data");
               }
               else
               {
                  //feed the data in
                  inflater.setInput(inputBuffer);
                  n = inflater.inflate(buf, offset, len);
                  if (n > 0)
                  {
                     read += n;
                     offset += n;
                     len -= n;
                  }
               }
            }
            else
            {
               //it shouldn't be here, throw
               throw new DataFormatException("Inflater is neither finished nor needing input.");
            }
         }
         else
         {
            read += n;
View Full Code Here

      }
      dstoff += n;
    }

    if (dstoff != sz) {
      throw new DataFormatException(MessageFormat.format(
          DhtText.get().shortCompressedObject,
          getChunkKey(),
          Integer.valueOf(offset)));
    }
    return dstbuf;
View Full Code Here

TOP

Related Classes of java.util.zip.DataFormatException

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.