当前位置: 首页>>代码示例>>Java>>正文


Java Sequence.EMPTY_SEQUENCE属性代码示例

本文整理汇总了Java中org.exist.xquery.value.Sequence.EMPTY_SEQUENCE属性的典型用法代码示例。如果您正苦于以下问题:Java Sequence.EMPTY_SEQUENCE属性的具体用法?Java Sequence.EMPTY_SEQUENCE怎么用?Java Sequence.EMPTY_SEQUENCE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.exist.xquery.value.Sequence的用法示例。


在下文中一共展示了Sequence.EMPTY_SEQUENCE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eval

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    if(args[0].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }
    
    InputStream inputImage = null;
    byte[] outputImage = null;
    
    try {
        
        //get the image data
        inputImage = ((BinaryValue) args[0].itemAt(0)).getInputStream();

        if (inputImage == null) {
            LOGGER.error("Unable to read image data!");
            return Sequence.EMPTY_SEQUENCE;
        }
        
        outputImage = Convert.convert2ImageFormat(inputImage, "jpg");
        
        if (outputImage != null) {
            return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(outputImage));
        }
        return Sequence.EMPTY_SEQUENCE;
    } catch (IOException | InterruptedException | IM4JavaException ex) {
         throw new XPathException(this, ex.getMessage());
    }
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:29,代码来源:Convert2JPGFunction.java

示例2: eval

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    if(args[0].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }
    
    InputStream inputImage = null;
    byte[] outputImage = null;
    
    try {
        
        //get the image data
        inputImage = ((BinaryValue) args[0].itemAt(0)).getInputStream();

        if (inputImage == null) {
            LOGGER.error("Unable to read image data!");
            return Sequence.EMPTY_SEQUENCE;
        }
        
        outputImage = Convert.convert2ImageFormat(inputImage, "png");
        
        if (outputImage != null) {
            return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(outputImage));
        }
        return Sequence.EMPTY_SEQUENCE;
    } catch (IOException | InterruptedException | IM4JavaException ex) {
         throw new XPathException(this, ex.getMessage());
    }
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:29,代码来源:Convert2PNGFunction.java

示例3: eval

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    if(args[0].isEmpty() || args[1].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }
    byte[] image = convertWithOptions(((BinaryValue)args[0].itemAt(0)).getInputStream(), ((StringValue) args[1]).toString());
    return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(image));
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:8,代码来源:ConvertFunction.java

示例4: eval

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    //was an image and a mime-type speficifed
    if (args[0].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }

    InputStream inputImage = null;
    
    try {
        //get the image data
        inputImage = ((BinaryValue) args[0].itemAt(0)).getInputStream();

        if (inputImage == null) {
            LOGGER.error("Unable to read image data!");
            return Sequence.EMPTY_SEQUENCE;
        }
        
        Info info = new Info("-", inputImage, false);
        
        LOGGER.debug("ImageFormat: " + info.getImageFormat());
        LOGGER.debug("ImageWidth: " + info.getImageWidth());
        LOGGER.debug("ImageHeight: " + info.getImageHeight());
        LOGGER.debug("ImageGeometry: " + info.getImageGeometry());
        LOGGER.debug("ImageDepth: " + info.getImageDepth());
        LOGGER.debug("ImageClass: " + info.getImageClass());
         
        

        return Sequence.EMPTY_SEQUENCE;
    } catch (InfoException e) {
        throw new XPathException(this, e.getMessage());
    }
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:34,代码来源:InfoFunction.java

示例5: eval

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
     LOGGER.debug("------------ CropFunction ---------------");        
    //was an image and a mime-type speficifed
    if (args[0].isEmpty() || args[3].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }
    
    //get the maximum dimensions to scale to
    int height = HEIGHT;
    int width = WIDTH;
    int rheight = RHEIGHT;
    int rwidth = RWIDTH;
    int offsetX = OFFSETX;
    int offsetY = OFFSETY;
    boolean repage = REPAGE;

    if (!args[1].isEmpty()) {
        width = ((IntegerValue) args[1].itemAt(0)).getInt();
        if (args[1].hasMany()) {
            height = ((IntegerValue) args[1].itemAt(1)).getInt();
        }
    }
    
    if (!args[2].isEmpty()) {
        offsetX = ((IntegerValue) args[2].itemAt(0)).getInt();
        if (args[1].hasMany()) {
            offsetY = ((IntegerValue) args[2].itemAt(1)).getInt();
        }
    }
    
    if (!args[4].isEmpty()) {
        rwidth = ((IntegerValue) args[4].itemAt(0)).getInt();
        if (args[4].hasMany()) {
            rheight = ((IntegerValue) args[4].itemAt(1)).getInt();
        }
    }

    String mimeType = args[3].itemAt(0).getStringValue();
    String formatName = mimeType.substring(mimeType.indexOf("/") + 1);
    
    //TODO currently ONLY tested for JPEG!!!
    InputStream inputImage = null;
    byte[] outputImage = null;
    
    try {
        //get the image data
        inputImage = ((BinaryValue) args[0].itemAt(0)).getInputStream();

        if (inputImage == null) {
            LOGGER.error("Unable to read image data!");
            return Sequence.EMPTY_SEQUENCE;
        }
        
        //scale the image
        outputImage = Convert.crop(inputImage, width, height, offsetX, offsetY, formatName, rwidth, rheight);

        if (outputImage == null) {
            LOGGER.error("Unable to get output image data!");
            return Sequence.EMPTY_SEQUENCE;
        }
        
        //return the new scaled image data
        return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(outputImage));
    } catch (IOException | InterruptedException | IM4JavaException | XPathException e) {
        throw new XPathException(this, e.getMessage());
    }
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:68,代码来源:CropFunction.java

示例6: eval

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    LOGGER.debug("------------ ScaleFunction ---------------");        
    //was an image and a mime-type speficifed
    if (args[0].isEmpty() || args[1].isEmpty() || args[2].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }

    double degrees = ((DoubleValue) args[1].itemAt(0)).getDouble();
    
    //get the mime-type
    String mimeType = args[2].itemAt(0).getStringValue();
    String formatName = mimeType.substring(mimeType.indexOf("/") + 1);

    //TODO currently ONLY tested for JPEG!!!
    InputStream inputImage = null;
    byte[] outputImage = null;
    
    try {
        

        //get the image data
        inputImage = ((BinaryValue) args[0].itemAt(0)).getInputStream();

        if (inputImage == null) {
            LOGGER.error("Unable to read image data!");
            return Sequence.EMPTY_SEQUENCE;
        }

        //scale the image
        outputImage = Convert.rotate(inputImage, degrees, formatName);

        if (outputImage == null) {
            LOGGER.error("Unable to get output image data!");
            return Sequence.EMPTY_SEQUENCE;
        }
        
        //return the new scaled image data
        return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(outputImage));
    } catch (IOException | InterruptedException | IM4JavaException | XPathException e) {
        throw new XPathException(this, e.getMessage());
    }
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:43,代码来源:RotateFunction.java

示例7: eval

@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    LOGGER.debug("------------ ScaleFunction ---------------");        
    //was an image and a mime-type speficifed
    if (args[0].isEmpty() || args[2].isEmpty()) {
        return Sequence.EMPTY_SEQUENCE;
    }

    //get the maximum dimensions to scale to
    int maxHeight = MAXHEIGHT;
    int maxWidth = MAXWIDTH;
    boolean keepAspectRatio = KEEPASPECTRATIO;

    if (!args[1].isEmpty()) {
        maxWidth = ((IntegerValue) args[1].itemAt(0)).getInt();
        if (args[1].hasMany()) {
            maxHeight = ((IntegerValue) args[1].itemAt(1)).getInt();
        }
    }
    
    if (!args[3].isEmpty()) {
        keepAspectRatio = ((BooleanValue) args[3].itemAt(0)).getValue();
    }

    LOGGER.debug("MAXHEIGHT: " + maxHeight);
    LOGGER.debug("MAXWIDTH: " + maxWidth);
    
    //get the mime-type
    String mimeType = args[2].itemAt(0).getStringValue();
    String formatName = mimeType.substring(mimeType.indexOf("/") + 1);

    //TODO currently ONLY tested for JPEG!!!
    InputStream inputImage = null;
    byte[] outputImage = null;
    
    try {
        

        //get the image data
        inputImage = ((BinaryValue) args[0].itemAt(0)).getInputStream();

        if (inputImage == null) {
            LOGGER.error("Unable to read image data!");
            return Sequence.EMPTY_SEQUENCE;
        }

        //scale the image
        outputImage = Convert.resize(inputImage, maxWidth, maxHeight, formatName, keepAspectRatio);

        if (outputImage == null) {
            LOGGER.error("Unable to get output image data!");
            return Sequence.EMPTY_SEQUENCE;
        }
        
        //return the new scaled image data
        return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(outputImage));
    } catch (IOException | InterruptedException | IM4JavaException | XPathException e) {
        throw new XPathException(this, e.getMessage());
    }
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:60,代码来源:ScaleFunction.java


注:本文中的org.exist.xquery.value.Sequence.EMPTY_SEQUENCE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。