Package org.exquery.xquery

Examples of org.exquery.xquery.TypedValue


   
    @Override
    protected void serializeBinaryBody(final Sequence result, final HttpResponse response) throws RestXqServiceException {
        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 {
                            os.close();
                        } catch (final IOException ioe) {
                            LOG.warn(ioe);
                        }
                    }
                }
               
                return; //TODO support more than one binary result -- multipart?
            } else {
                throw new RestXqServiceException("Expected binary value, but found: " + typedValue.getType().name());
            }
        }
    }
View Full Code Here


            return;
        }
       
        final Iterator<TypedValue> itResult = result.iterator();
        if(itResult.hasNext()) {
            final TypedValue firstResultPart = itResult.next();
           
            //determine if the first element in the sequence is rest:response
            Element elem = null;
           
            if(firstResultPart.getType().equals(Type.DOCUMENT)) {
                elem = ((Document)firstResultPart.getValue()).getDocumentElement();
            } else if(firstResultPart.getType().equals(Type.ELEMENT)) {
                elem = (Element)firstResultPart.getValue();
            }
           
            final Map<SerializationProperty, String> serializationProperties = new EnumMap<SerializationProperty, String>(SerializationProperty.class);
            serializationProperties.putAll(getDefaultSerializationProperties());
           
View Full Code Here

TOP

Related Classes of org.exquery.xquery.TypedValue

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.