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 * <p/> 028 * Data type are automatic turned on if one ore more routes has been explicit configured with input and output types. 029 * Otherwise data type is default off. 030 * 031 * @see DataType 032 * @see Transformer 033 * @see Validator 034 */ 035public interface DataTypeAware { 036 037 /** 038 * Set the data type of the message. 039 * 040 * @param type data type 041 */ 042 void setDataType(DataType type); 043 044 /** 045 * Get the data type of the message. 046 * 047 * @return data type 048 */ 049 DataType getDataType(); 050 051 /** 052 * Whether any data type has been configured 053 */ 054 boolean hasDataType(); 055 056 /** 057 * Set the message body with data type. 058 * 059 * @param body message body 060 * @param type data type 061 */ 062 void setBody(Object body, DataType type); 063 064}