本文整理汇总了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());
}
}
示例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());
}
}
示例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));
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}