Examples of Domino32KLimitException


Examples of org.openntf.domino.exceptions.Domino32KLimitException

      } else if (value.getClass().isArray()) {
        int lh = Array.getLength(value);
        if (lh > MAX_NATIVE_FIELD_SIZE) {        // Then skip making dominoFriendly if it's a primitive
          String cn = value.getClass().getName();
          if (cn.length() == 2)            // It is primitive
            throw new Domino32KLimitException();
        }
        dominoFriendly = new Vector<Object>(lh);
        for (int i = 0; i < lh; i++) {
          Object o = Array.get(value, i);
          if (o != null) { // CHECKME: Should NULL values be discarded?
            if (o instanceof BigString)
              isNonSummary = true;
            dominoFriendly.add(toItemFriendly(o, this, recycleThis));
          }
        }
      } else {
        // Scalar
        dominoFriendly = new Vector<Object>(1);
        if (value instanceof BigString)
          isNonSummary = true;
        dominoFriendly.add(toItemFriendly(value, this, recycleThis));
      }

      // empty vectors are treated as "null"
      if (dominoFriendly.size() == 0) {
        return replaceItemValueLotus(itemName, null, isSummary, returnItem);
      }

      Object firstElement = dominoFriendly.get(0);

      int payloadOverhead = 0;

      if (dominoFriendly.size() > 1) {  // compute overhead first
        // String lists have an global overhead of 2 bytes (maybe the count of values) + 2 bytes for the length of value
        if (firstElement instanceof String)
          payloadOverhead = 2 + 2 * dominoFriendly.size();
        else
          payloadOverhead = 4;
      }

      // Next step: Type checking + length computation
      //
      // Remark: The special case of a String consisting of only ONE @NewLine (i.e.
      //     if (s.equals("\n") || s.equals("\r") || s.equals("\r\n"))
      // where Domino is a bit ailing) won't be extra considered any longer.
      // Neither serialization nor throwing an exception would be reasonable here.

      int payload = payloadOverhead;
      Class<?> firstElementClass;
      if (firstElement instanceof String)
        firstElementClass = String.class;
      else if (firstElement instanceof Number)
        firstElementClass = Number.class;
      else if (firstElement instanceof lotus.domino.DateTime)
        firstElementClass = lotus.domino.DateTime.class;
      else if (firstElement instanceof lotus.domino.DateRange)
        firstElementClass = lotus.domino.DateRange.class;
      // Remark: Domino Java API doesn't accept any Vector of DateRanges (cf. DateRange.java), so the implementation
      // here will work only with Vectors of size 1 (or Vectors of size >= 2000, when Mime Beaning is enabled).
      else
        throw new DataNotCompatibleException(firstElement.getClass() + " is not a supported data type");
      for (Object o : dominoFriendly)
        payload += getLotusPayload(o, firstElementClass);
      if (payload > MAX_NATIVE_FIELD_SIZE) {
        // the datatype is OK, but there's no way to store the data in the Document
        throw new Domino32KLimitException();
      }
      if (firstElementClass == String.class) {   // Strings have to be further inspected, because
        // each sign may demand up to 3 bytes in LMBCS
        int calc = ((payload - payloadOverhead) * 3) + payloadOverhead;
        if (calc >= MAX_NATIVE_FIELD_SIZE) {
          payload = payloadOverhead + getLMBCSPayload(dominoFriendly);
          if (payload > MAX_NATIVE_FIELD_SIZE)
            throw new Domino32KLimitException();
        }
      }
      if (payload > MAX_SUMMARY_FIELD_SIZE) {
        isNonSummary = true;
      }
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.