Package org.exist.xquery.value

Examples of org.exist.xquery.value.BinaryValue


    {
        // is there some data to GZip?
        if(args[0].isEmpty())
            return Sequence.EMPTY_SEQUENCE;

        BinaryValue bin = (BinaryValue) args[0].itemAt(0);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        // gzip the data
        try
        {
            GZIPOutputStream gzos = new GZIPOutputStream(baos);
            bin.streamTo(gzos);
            gzos.close();

            return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(baos.toByteArray()));
        }
        catch(IOException ioe)
View Full Code Here


    {
        // is there some data to unGZip?
        if(args[0].isEmpty())
            return Sequence.EMPTY_SEQUENCE;

        BinaryValue bin = (BinaryValue) args[0].itemAt(0);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        // ungzip the data
        try
        {
            GZIPInputStream gzis = new GZIPInputStream(bin.getInputStream());
            int size;
            byte[] b = new byte[4096];
            while ((size = gzis.read(b, 0, 4096)) != -1)
            {
                baos.write(b, 0, size);
View Full Code Here

        if(entryDataFunctionSig.getArgumentCount() < 3)
            throw new XPathException("entry-data function must take at least 3 arguments");

        storeParam = args[4];
       
        BinaryValue compressedData = ((BinaryValue)args[0].itemAt(0));
       
        try {
      return processCompressedData(compressedData);
    } catch (XMLDBException e) {
      throw new XPathException(e);
View Full Code Here

                    if(mimeType != null && !mimeType.isXMLType()) {

                        //binary data
                        try {
                           
                            final BinaryValue binaryValue = BinaryValueFromInputStream.getInstance(binaryValueManager, new Base64BinaryValueType(), is);
                            if(binaryValue != null) {
                                result = new SequenceImpl<BinaryValue>(new BinaryTypedValue(binaryValue));
                            }
                        } catch(final XPathException xpe) {
                            throw new RestXqServiceException(RestXqErrorCodes.RQDY0014, xpe);
View Full Code Here

        ContentExtraction ce = new ContentExtraction();

        if (isCalledAs("stream-content")) {

            /* binary content */
            BinaryValue binary = (BinaryValue) args[0].itemAt(0);

            /* callback function */
            FunctionReference ref = (FunctionReference) args[2].itemAt(0);

            Map<String, String> mappings = new HashMap<>();
View Full Code Here

                        // Assume it's a binary body and Base64 encode it
                        builder.addAttribute( new QName( "type", null, null ), "binary" );
                        builder.addAttribute( new QName( "encoding", null, null ), "Base64Encoded" );

                        BinaryValue binary = null;
                        try {
                            binary = BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), cfis);
                            builder.characters(binary.getStringValue());
                        } finally {
                            // free resources
                            if (binary != null) {
                                binary.destroy(context, null);
                            }
                        }
                    }
                }
            } finally {
View Full Code Here

        final Iterator<TypedValue> itResult = result.iterator();
        while(itResult.hasNext()) {
            final TypedValue typedValue = itResult.next();
            if(typedValue.getType() == Type.BASE64_BINARY || typedValue.getType() == Type.HEX_BINARY) {
               
                final BinaryValue binaryValue = (BinaryValue)typedValue.getValue();
                OutputStream os = null;
                try {
                    os = response.getOutputStream();
                    binaryValue.streamBinaryTo(os);
                } catch(final IOException ioe) {
                    throw new RestXqServiceException("Error while serializing binary: " + ioe.toString(), ioe);
                } finally {
                    if(os != null) {
                        try {
View Full Code Here

    if (args[0].isEmpty()) {
                    return Sequence.EMPTY_SEQUENCE;
    }
       
                //get the images raw binary data
    BinaryValue imageData = (BinaryValue)args[0].itemAt(0);

                if(args[1].isEmpty()) {
                    return Sequence.EMPTY_SEQUENCE;
                }
                //get the format of metadata to return
                boolean nativeFormat = args[1].effectiveBooleanValue();

                try {
                    //get an input stream
                    ImageInputStream iis = ImageIO.createImageInputStream(imageData.getInputStream());
                    return parseWithImageIO(iis, nativeFormat);
                } catch(IOException ioe) {
                    throw (new XPathException(this, ioe.getMessage(), ioe));
                }  
  }
View Full Code Here

      throws XPathException {
    if(args[0].isEmpty()) {
            return Sequence.EMPTY_SEQUENCE;
        }
    try {
      BinaryValue exiBinary = ((BinaryValue)args[0].itemAt(0));
     
      MemTreeBuilder builder = context.getDocumentBuilder();
     
      // create default factory and EXI grammar for schema
      EXIFactory exiFactory = DefaultEXIFactory.newInstance();
      if(args.length > 1) {
        if(!args[1].isEmpty()) {
          Item xsdItem = args[1].itemAt(0);
          InputStream xsdInputStream = EXIUtils.getInputStream(xsdItem, context);
          GrammarFactory grammarFactory = GrammarFactory.newInstance();
          Grammar grammar = grammarFactory.createGrammar(xsdInputStream);
          exiFactory.setGrammar(grammar);
        }
      }
      SAXDecoder decoder = new SAXDecoder(exiFactory);
      SAXAdapter adapter = new AppendingSAXAdapter(builder);
            decoder.setContentHandler(adapter);
            decoder.parse(new InputSource(exiBinary.getInputStream()));
       
        NodeValue node  = (NodeValue)builder.getDocument().getDocumentElement();
        return node;
    }
    catch(EXIException exie) {
View Full Code Here

        long connectionUID = ((IntegerValue)args[0].itemAt(0)).getLong();
        FTPClient ftp = FTPClientModule.retrieveConnection(context, connectionUID);
        if(ftp != null) {
            String remoteDirectory = args[1].getStringValue();
            String fileName = args[2].getStringValue();
            BinaryValue data = (BinaryValue)args[3].itemAt(0);
           
            result = sendBinaryFile(ftp, remoteDirectory, fileName, data);
       
        }
       
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.BinaryValue

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.