Package java.io

Examples of java.io.ObjectStreamField


        if (checked.containsKey(objVals[i]))
        {
          continue;
        }

        ObjectStreamField fieldDesc = fields[numPrimFields + i];
        Field field;
        try
        {
          field = (Field)GET_FIELD_METHOD.invoke(fieldDesc, (Object[])null);
        }
View Full Code Here


        if (checked.containsKey(objVals[i]))
        {
          continue;
        }

        ObjectStreamField fieldDesc = fields[numPrimFields + i];
        Field field;
        try
        {
          field = (Field)GET_FIELD_METHOD.invoke(fieldDesc, (Object[])null);
        }
View Full Code Here

        if (checked.containsKey(objVals[i]))
        {
          continue;
        }

        ObjectStreamField fieldDesc = fields[numPrimFields + i];
        Field field;
        try
        {
          field = (Field)GET_FIELD_METHOD.invoke(fieldDesc, (Object[])null);
        }
View Full Code Here

        if (checked.containsKey(objVals[i]))
        {
          continue;
        }

        ObjectStreamField fieldDesc = fields[numPrimFields + i];
        Field field;
        try
        {
          field = (Field)GET_FIELD_METHOD.invoke(fieldDesc, (Object[])null);
        }
View Full Code Here

        // Regression for HARMONY-2674
        ObjectStreamClass objectStreamClass = ObjectStreamClass
                .lookup(File.class);
        ObjectStreamField[] objectStreamFields = objectStreamClass.getFields();
        assertEquals(1, objectStreamFields.length);
        ObjectStreamField objectStreamField = objectStreamFields[0];
        assertEquals("path", objectStreamField.getName());
        assertEquals(String.class, objectStreamField.getType());
    }
View Full Code Here

    public void testSerilizationDescriptor() throws Exception {

        // Regression for HARMONY-2787
        ObjectStreamClass objectStreamClass = ObjectStreamClass
                .lookup(CodeSource.class);
        ObjectStreamField objectStreamField = objectStreamClass
                .getField("location");
        assertEquals("Ljava/net/URL;", objectStreamField.getTypeString());
    }
View Full Code Here

                for (Iterator iterator = fields.keySet().iterator(); iterator.hasNext();) {
                    String name = (String) iterator.next();
                    if (!mapper.shouldSerializeMember(currentType[0], name)) {
                        continue;
                    }
                    ObjectStreamField field = objectStreamClass.getField(name);
                    Object value = fields.get(name);
                    if (field == null) {
                        throw new ObjectAccessException("Class " + value.getClass().getName()
                                + " may not write a field named '" + name + "'");
                    }
                    if (value != null) {
                        ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(source.getClass(), name), field.getType());
                        if (field.getType() != value.getClass() && !field.getType().isPrimitive()) {
                            String attributeName = mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS);
                            if (attributeName != null) {
                                writer.addAttribute(attributeName, mapper.serializedClass(value.getClass()));
                            }
                        }
                        context.convertAnother(value);
                        writer.endNode();
                    }
                }
                writer.endNode();
            }

            public void defaultWriteObject() {
                boolean writtenDefaultFields = false;

                ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(currentType[0]);

                if (objectStreamClass == null) {
                    return;
                }

                ObjectStreamField[] fields = objectStreamClass.getFields();
                for (int i = 0; i < fields.length; i++) {
                    ObjectStreamField field = fields[i];
                    Object value = readField(field, currentType[0], source);
                    if (value != null) {
                        if (!writtenClassWrapper[0]) {
                            writer.startNode(mapper.serializedClass(currentType[0]));
                            writtenClassWrapper[0] = true;
                        }
                        if (!writtenDefaultFields) {
                            writer.startNode(ELEMENT_DEFAULT);
                            writtenDefaultFields = true;
                        }
                        if (!mapper.shouldSerializeMember(currentType[0], field.getName())) {
                            continue;
                        }

                        ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(source.getClass(), field.getName()), field.getType());

                        Class actualType = value.getClass();
                        Class defaultType = mapper.defaultImplementationOf(field.getType());
                        if (!actualType.equals(defaultType)) {
                            String attributeName = mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS);
                            if (attributeName != null) {
                                writer.addAttribute(attributeName, mapper.serializedClass(actualType));
                            }
View Full Code Here

                String classAttribute = HierarchicalStreams.readClassAttribute(reader, mapper);
                            Class type;
                            if (classAttribute != null) {
                                type = mapper.realClass(classAttribute);
                            } else {
                                ObjectStreamField field = objectStreamClass.getField(name);
                                if (field == null) {
                                    throw new ObjectAccessException("Class " + currentType[0]
                                            + " does not contain a field named '" + name + "'");
                                }
                                type = field.getType();
                            }
                            Object value = context.convertAnother(result, type);
                            fields.put(name, value);
                        }
                        reader.moveUp();
View Full Code Here

        if (checked.containsKey(objVals[i]))
        {
          continue;
        }

        ObjectStreamField fieldDesc = fields[numPrimFields + i];
        Field field;
        try
        {
          field = (Field)GET_FIELD_METHOD.invoke(fieldDesc, (Object[])null);
        }
View Full Code Here

                field.setAccessible(true);
                map.put(field.getName(), field);
            }
            SerializableField[] fields = new SerializableField[objectStreamFields.length];
            for (int i = 0; i < objectStreamFields.length; i++) {
                ObjectStreamField field = objectStreamFields[i];
                final String name = field.getName();
                final Field realField = map.get(name);
                if (realField != null && realField.getType() == field.getType()) {
                    // allow direct updating of the field data since the types match
                    fields[i] = new SerializableField(field.getType(), name, field.isUnshared(), realField);
                } else {
                    // no direct update possible
                    fields[i] = new SerializableField(field.getType(), name, field.isUnshared(), null);
                }
            }
            Arrays.sort(fields, NAME_COMPARATOR);
            return fields;
        }
        final ArrayList<SerializableField> fields = new ArrayList<SerializableField>(declaredFields.length);
        for (Field field : declaredFields) {
            if ((field.getModifiers() & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) {
                field.setAccessible(true);
                fields.add(new SerializableField(field.getType(), field.getName(), false, field));
            }
        }
        Collections.sort(fields, NAME_COMPARATOR);
        return fields.toArray(new SerializableField[fields.size()]);
    }
View Full Code Here

TOP

Related Classes of java.io.ObjectStreamField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.