/** * Read the value base from the given input stream. Determines the required * class from the repository id. This includes operations that are not * required when an unitialised instance or at least class of the value type * is known. Hence it may be faster to use the alternative methods, * read(InputStream, Class) or read(InputStream, Serializable). * * @param input a stream to read from. * @param repository_id a repository id of the object being read, may be null. * * @return the loaded value. * * @throws MARSHAL if the reading has failed due any reason. */ public static Serializable read(InputStream input, String repository_id) { try { final int position = getCurrentPosition(input); // We may need to jump back if the value is read via value factory. input.mark(512); int value_tag = input.read_long(); checkTag(value_tag); String codebase = null; String[] ids = null; String id = repository_id; // Check for the agreed null value. if (value_tag == vt_NULL) return null; else if (value_tag == vt_INDIRECTION) return readIndirection(input); else { // Read the value. if ((value_tag & vf_CODEBASE) != 0) { // The codebase is present. The codebase is a space // separated list of URLs from where the implementing // code can be downloaded. codebase = read_string(input); } if ((value_tag & vf_MULTIPLE_IDS) != 0) { // Multiple supported repository ids are present. ids = read_string_array(input); } else if ((value_tag & vf_ID) != 0) { // Single supported repository id is present. id = read_string(input); } } BoxedValueHelper helper = getHelper(null, id); // The existing implementing object. java.lang.Object ox = null; if (helper != null) ox = null; // Helper will care about the instantiating. else if (id.equals(WStringValueHelper.id())) helper = m_StringValueHelper; else ox = createInstance(id, ids, codebase); return (Serializable) read_instance(input, position, ox, value_tag, helper, id, ids, codebase); } catch (Exception ex) { MARSHAL m = new MARSHAL(); m.minor = Minor.Value; m.initCause(ex); throw m; } }