Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSData


      if (jdbcInfoStream == null) {
        throw new IllegalStateException("Unable to find 'H2JDBCInfo.plist' in this plugin jar.");
      }

      try {
        jdbcInfo = (NSDictionary<String, Object>) NSPropertyListSerialization.propertyListFromData(new NSData(jdbcInfoStream, 2048), "US-ASCII");
      }
      catch (IOException e) {
        throw new RuntimeException("Failed to load 'H2JDBCInfo.plist' from this plugin jar: " + e, e);
      }
      finally {
View Full Code Here


      if (jdbcInfoStream == null) {
        throw new IllegalStateException("Unable to find 'FrontBaseJDBCInfo.plist' in this plugin jar.");
      }

      try {
        jdbcInfo = (NSDictionary<String, Object>) NSPropertyListSerialization.propertyListFromData(new NSData(jdbcInfoStream, 2048), "US-ASCII");
      }
      catch (IOException e) {
        throw new RuntimeException("Failed to load 'FrontBaseJDBCInfo.plist' from this plugin jar.", e);
      } finally {
        try { jdbcInfoStream.close(); } catch (IOException e) {}
View Full Code Here

    if (!flag)
      return blob;
    else {
      try {
        byte[] bytes = blob.getBytes(1, (int) blob.length());
        return new NSData(bytes, new NSRange(0, bytes.length), true);
      }
      catch (Exception ioexception) {
        throw new JDBCAdaptorException(ioexception.getMessage(), null);
      }
    }
View Full Code Here

      if (jdbcInfoStream == null) {
        throw new IllegalStateException("Unable to find 'JDBCInfo.plist' in this plugin jar.");
      }

      try {
        jdbcInfo = (NSDictionary<String, Object>) NSPropertyListSerialization.propertyListFromData(new NSData(jdbcInfoStream, 2048), "US-ASCII");
      } catch (IOException e) {
        throw new RuntimeException("Failed to load 'JDBCInfo.plist' from this plugin jar.", e);
      } finally {
        try { jdbcInfoStream.close(); } catch (IOException e) {}
      }
View Full Code Here

    return jdbcInfo;
  }

  @Override
  public Object fetchBLOB(ResultSet rs, int column, EOAttribute attribute, boolean materialize) throws SQLException {
    NSData data = null;
    Blob blob = rs.getBlob(column);
    if(blob == null) { return null; }
    if(!materialize) { return blob; }
    InputStream stream = blob.getBinaryStream();
    try {
      int chunkSize = (int)blob.length();
      if(chunkSize == 0) {
        data = NSData.EmptyData;
      } else {
        data = new NSData(stream, chunkSize);
      }
    } catch(IOException e) {
      throw new JDBCAdaptorException(e.getMessage(), null);
    } finally {
      try {if(stream != null) stream.close(); } catch(IOException e) { /* Nothing we can do */ };
View Full Code Here

    if (_captcha == null) {
      try {
        BufferedImage challenge = ERCaptcha.captchaService().getImageChallengeForID(context.elementID());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(challenge, "jpg", baos);
        _captcha = new NSData(baos.toByteArray());
      } catch (Throwable e) {
        log.error("Failed to create JPEG for Captcha.", e);
      }
    }
    super.appendToResponse(response, context);
View Full Code Here

      if (jdbcInfoStream == null) {
        throw new IllegalStateException("Unable to find 'JDBCInfo.plist' in this plugin jar.");
      }

      try {
        jdbcInfo = (NSDictionary) NSPropertyListSerialization.propertyListFromData(new NSData(jdbcInfoStream, 2048), "US-ASCII");
      }
      catch (IOException e) {
        throw new RuntimeException("Failed to load 'JDBCInfo.plist' from this plugin jar.", e);
      } finally {
        try { jdbcInfoStream.close(); } catch (IOException e) {}
View Full Code Here

      if(value instanceof NSDictionary) {
        dumpDictionary(sb, (NSDictionary)value, level);
      } else if (value instanceof NSArray) {
        dumpArray(sb, (NSArray)value, level);
      } else if (value instanceof NSData) {
        NSData data = (NSData)value;
      sb.append(byteArrayToHexString(data.bytes()));
      } else if (value instanceof EODatabaseOperation) {
        dumpDictionary(sb, databaseOperationAsDictionary((EODatabaseOperation)value), level);
      } else if (value instanceof EOAdaptorOperation) {
        dumpDictionary(sb, adaptorOperationAsDictionary((EOAdaptorOperation)value), level);
       } else {
View Full Code Here

        val = m.invoke(null, new Object[] {b});
        break;

      case EOAttribute.FactoryMethodArgumentIsData:
        if(encoding==null){throw new NullPointerException();}
        NSData d = new NSData(strVal, encoding);
        val = m.invoke(null, new Object[] {d});
        break;
       
      case EOAttribute.FactoryMethodArgumentIsString:
        val = m.invoke(null, new Object[] {strVal});
View Full Code Here

          long inputBytesLength;
          InputStream contentInputStream = response.contentInputStream();
          byte[] compressedData;
          if (contentInputStream != null) {
            inputBytesLength = response.contentInputStreamLength();
            NSData compressedNSData = ERXCompressionUtilities.gzipInputStreamAsNSData(contentInputStream, (int)inputBytesLength);
            //compressedData = compressedNSData._bytesNoCopy();
            compressedData = compressedNSData.bytes();
            response.setContentStream(null, 0, 0L);
          }
          else {
            NSData input = response.content();
            inputBytesLength = input.length();
            compressedData = (inputBytesLength > 0) ? ERXCompressionUtilities.gzipByteArray(input._bytesNoCopy()) : null;
          }
          if ( inputBytesLength > 0 ) {
            if (compressedData == null) {
              // something went wrong
            }
            else {
              response.setContent(new NSData(compressedData, new NSRange(0, compressedData.length), true));
              response.setHeader(String.valueOf(compressedData.length), "content-length");
              response.setHeader("gzip", "content-encoding");
              if (log.isDebugEnabled()) {
                log.debug("before: " + inputBytesLength + ", after " + compressedData.length + ", time: " + (System.currentTimeMillis() - start));
              }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSData

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.