1 /*** 2 * Copyright 2006 Joseph M. Ferner 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.fernsroth.easyio; 17 18 import java.io.IOException; 19 import java.lang.reflect.Field; 20 import java.util.Queue; 21 22 import com.fernsroth.easyio.exception.EasyIOException; 23 24 /*** 25 * 26 * @author Joseph M. Ferner (Near Infinity Corporation) 27 */ 28 public interface FieldHandler { 29 30 /*** 31 * reads a field into an object. 32 * It is the responsibility of this function to remove read fields from the 33 * fieldsQueue. 34 * @param in the input stream to read from. 35 * @param obj the object to populate. 36 * @param fieldsQueue the queue of all fields (field, is head of queue). 37 * @throws EasyIOException 38 * @throws IOException 39 */ 40 void read(EasyIOInputStream in, Object obj, Queue<Field> fieldsQueue) 41 throws EasyIOException, IOException; 42 43 /*** 44 * writes a field into an output stream. 45 * It is the responsibility of this function to remove written fields from the 46 * fieldsQueue. 47 * @param out the output stream to write the field to. 48 * @param obj the object to read from. 49 * @param fieldsQueue the queue of fields to read (field, is head of queue). 50 * @throws EasyIOException 51 * @throws IOException 52 */ 53 void write(EasyIOOutputStream out, Object obj, Queue<Field> fieldsQueue) 54 throws EasyIOException, IOException; 55 56 }