1 /* Copyright (c) 2003,2004, Stefan Haustein, Oberhausen, Rhld., Germany 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a copy 4 * of this software and associated documentation files (the "Software"), to deal 5 * in the Software without restriction, including without limitation the rights 6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or 7 * sell copies of the Software, and to permit persons to whom the Software is 8 * furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 * IN THE SOFTWARE. */ 20 21 package org.ksoap2.serialization; 22 23 import java.io.*; 24 import org.xmlpull.v1.*; 25 26 /** 27 * Interface for custom (de)serialization. 28 */ 29 30 public interface Marshal { 31 32 /** 33 * This methods reads an instance from the given parser. For implementation, 34 * please note that the start and and tag must be consumed. This is not 35 * symmetric to writeInstance, but otherwise it would not be possible to 36 * access the attributes of the start tag here. 37 * 38 * @param parser 39 * the xml parser 40 * @param namespace 41 * the namespace. 42 * @return the object read from the xml stream. 43 */ readInstance(XmlPullParser parser, String namespace, String name, PropertyInfo expected)44 public Object readInstance(XmlPullParser parser, String namespace, String name, 45 PropertyInfo expected) 46 throws IOException, XmlPullParserException; 47 48 /** 49 * Write the instance to the given XmlSerializer. In contrast to 50 * readInstance, it is not neccessary to care about the surrounding start 51 * and end tags. Additional attributes must be writen before anything else 52 * is written. 53 * 54 * @param writer 55 * the xml serializer. 56 * @param instance 57 * the instance to write to the writer. 58 */ writeInstance(XmlSerializer writer, Object instance)59 public void writeInstance(XmlSerializer writer, Object instance) throws IOException; 60 61 /** 62 * Register this Marshal with Envelope 63 * 64 * @param envelope 65 * the soap serialization envelope. 66 */ register(SoapSerializationEnvelope envelope)67 public void register(SoapSerializationEnvelope envelope); 68 } 69