• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ByteBufferBackedInputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream的典型用法代码示例。如果您正苦于以下问题:Java ByteBufferBackedInputStream类的具体用法?Java ByteBufferBackedInputStream怎么用?Java ByteBufferBackedInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: apply

import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; //导入依赖的package包/类
@Override
public List<CSVReportEntry> apply(final GetCredentialReportResult report) {
    Assert.state(Textcsv.toString().equals(report.getReportFormat()), "unknown credential report format: " + report.getReportFormat());

    try (final Reader r = new BufferedReader(new InputStreamReader(new ByteBufferBackedInputStream(report.getContent())))) {
        final CSVParser parser = new CSVParser(r, CSV_FORMAT);
        final Map<String, Integer> headers = parser.getHeaderMap();

        Assert.state(headers.containsKey("user"), "Header 'user' not found in CSV");
        Assert.state(headers.containsKey("arn"), "Header 'arn' not found in CSV");
        Assert.state(headers.containsKey("password_enabled"), "Header 'password_enabled' not found in CSV");
        Assert.state(headers.containsKey("mfa_active"), "Header 'mfa_active' not found in CSV");
        Assert.state(headers.containsKey("access_key_1_active"), "Header 'access_key_1_active' not found in CSV");
        Assert.state(headers.containsKey("access_key_2_active"), "Header 'access_key_2_active' not found in CSV");

        return stream(parser.spliterator(), false).map(this::toCSVReportEntry).filter(Objects::nonNull).collect(toList());
    } catch (final IOException e) {
        throw new RuntimeException("Could not read csv report", e);
    }
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:21,代码来源:CredentialReportCSVParserImpl.java


示例2: deserialize

import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; //导入依赖的package包/类
/**
 * Deserializes the given message.
 * 
 * @param action
 * @return
 * @throws Exception
 */
public T deserialize(WebSocketAction action) throws Exception {
	// first deserialize
	T message = null;
	
	if (messageClass != null) {
		message = serDe.deserialize(new ByteBufferBackedInputStream(rawData), messageClass);
	}
	
	// then validate
	if (message != null && action.shouldValidatePayload()) {
		SpringValidatorAdapter validatorAdapter = new SpringValidatorAdapter(messageValidator);
		
		BeanPropertyBindingResult result = new BeanPropertyBindingResult(message, messageClass.getName());
		
		validatorAdapter.validate(message, result);
		
		if (result.hasErrors()) {
			throw new MethodArgumentNotValidException(new MethodParameter(action.getMethod(), action.getPayloadParameterIndex()), result);
		}
	}
	
	return message;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:31,代码来源:RawWebSocketMessage.java


示例3: deserialize

import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; //导入依赖的package包/类
@Override
public <U> U deserialize(BinaryData rawPayload, Class<U> targetType) {
    try {
        return objectMapper.readValue(new ByteBufferBackedInputStream(rawPayload.toByteBuffer()), targetType);
    } catch (IOException e) {
        throw new IllegalArgumentException("Error deserializing payload", e);
    }
}
 
开发者ID:unbroken-dome,项目名称:jsonwebtoken,代码行数:9,代码来源:DefaultPayloadDeserializer.java


示例4: deserialize

import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public JoseHeader deserialize(BinaryData data) throws JwtMalformedTokenException {
    try {
        Map<String, Object> headerValues = objectMapper.readValue(
                new ByteBufferBackedInputStream(data.toByteBuffer()), Map.class);
        return new DefaultJoseHeader(headerValues);
    } catch (IOException e) {
        throw new JwtMalformedTokenException("Error deserializing JWS header", e);
    }
}
 
开发者ID:unbroken-dome,项目名称:jsonwebtoken,代码行数:12,代码来源:DefaultHeaderDeserializer.java


示例5: decode

import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; //导入依赖的package包/类
@Override
public T decode(ByteBuffer bytes) throws DecodeException {
    try {
        return mapper.readValue(new ByteBufferBackedInputStream(bytes), objectClass);
    } catch (IOException e) {
        throw new DecodeException(bytes, "decode json error", e);
    }
}
 
开发者ID:icode,项目名称:ameba,代码行数:9,代码来源:JacksonDecoder.java


示例6: willDecode

import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; //导入依赖的package包/类
@Override
public boolean willDecode(ByteBuffer bytes) {
    try {
        mapper.readTree(new ByteBufferBackedInputStream(bytes));
    } catch (IOException e) {
        logger.warn("invalidate json", e);
        return false;
    }
    return true;
}
 
开发者ID:icode,项目名称:ameba,代码行数:11,代码来源:JacksonDecoder.java


示例7: readData

import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; //导入依赖的package包/类
/**
 * Reads the data field of the record.  If the record is compressed, this
 * will involve decompressing it.  Currently both bz2 and lz4 compression
 * are supported.
 * Do not call this method more than once, and do not call it if the channel
 * used to create this record has been closed.
 * @throws BagReaderException
 */
public void readData() throws BagReaderException {
    myData = ByteBuffer.allocate(myDataLength);
    try {
        myChannel.position(myDataOffset);
        myChannel.read(myData);

        // Chunks can have bz2 or lz4-compressed myData in them, which we need to
        // decompress in order to do anything useful with.
        if (myHeader.getType() == RecordType.CHUNK) {
            String compression = myHeader.getValue("compression");
            switch (compression) {
                case "none":
                    // Do nothing here if not compressed
                    break;
                case "bz2":
                case "lz4":
                {
                    int decompressedSize = myHeader.getInt("size");
                    myData.flip();
                    try (ByteBufferBackedInputStream inStream = new ByteBufferBackedInputStream(myData);
                         InputStream compressedStream = openCompressedStream(compression, inStream)) {
                        final byte[] buffer = new byte[decompressedSize];
                        int n = IOUtils.readFully(compressedStream, buffer);
                        if (n != decompressedSize) {
                            throw new BagReaderException("Read " + n + " bytes from a " +
                                                         "compressed chunk but expected " +
                                                         decompressedSize + ".");
                        }

                        myData = ByteBuffer.wrap(buffer);
                    }
                    break;
                }
                default:
                    myLogger.warn("Unknown compression format: " + compression);
                    break;
            }
        }
        myData.order(ByteOrder.LITTLE_ENDIAN);
    }
    catch (IOException e) {
        throw new BagReaderException(e);
    }
}
 
开发者ID:swri-robotics,项目名称:bag-reader-java,代码行数:53,代码来源:Record.java



注:本文中的com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Configuration类代码示例发布时间:2022-05-23
下一篇:
Java RequestContext类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap