001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.spi;
018
019/**
020 * Allows {@link org.apache.camel.Message} to store a {@link DataType} which
021 * represents the data type of the Message. Sometimes message content is marshaled
022 * into {@code String}, {@code InputStream} or etc, and the data type structure is
023 * not available until it's unmarshaled into Java object. The {@link DataType} stored
024 * in a DataTypeAware message carries that missing data type information even if it's
025 * marshaled, and whatever the Java class of the body is. This type information is used
026 * to detect required {@link Transformer} and {@link Validator}.
027 * 
028 * @see {@link DataType} {@link Transformer} {@link Validator}
029 */
030public interface DataTypeAware {
031
032    /**
033     * Set the data type of the message.
034     * @param type data type
035     */
036    void setDataType(DataType type);
037
038    /**
039     * Get the data type of the message.
040     * @return data type
041     */
042    DataType getDataType();
043
044    /**
045     * Set the message body with data type.
046     * @param body message body
047     * @param type data type
048     */
049    void setBody(Object body, DataType type);
050
051}