001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.serializer; 018 019import java.io.IOException; 020import java.io.OutputStream; 021 022/** 023 * A strategy interface for streaming an object to an OutputStream. 024 * 025 * @author Gary Russell 026 * @author Mark Fisher 027 * @since 3.0.5 028 */ 029public interface Serializer<T> { 030 031 /** 032 * Write an object of type T to the given OutputStream. 033 * <p>Note: Implementations should not close the given OutputStream 034 * (or any decorators of that OutputStream) but rather leave this up 035 * to the caller. 036 * @param object the object to serialize 037 * @param outputStream the output stream 038 * @throws IOException in case of errors writing to the stream 039 */ 040 void serialize(T object, OutputStream outputStream) throws IOException; 041 042}