- java.lang.Object
-
- java.io.ObjectStreamClass
-
- All Implemented Interfaces:
- Serializable
public class ObjectStreamClass extends Object implements Serializable
Serialization's descriptor for classes. It contains the name and serialVersionUID of the class. The ObjectStreamClass for a specific class loaded in this Java VM can be found/created using the lookup method.The algorithm to compute the SerialVersionUID is described in Object Serialization Specification, Section 4.6, Stream Unique Identifiers.
- Since:
- JDK1.1
- See Also:
ObjectStreamField
, Object Serialization Specification, Section 4, Class Descriptors, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static ObjectStreamField[]
NO_FIELDS
serialPersistentFields value indicating no serializable fields
-
Method Summary
Methods Modifier and Type Method and Description Class<?>
forClass()
Return the class in the local VM that this version is mapped to.ObjectStreamField
getField(String name)
Get the field of this class by name.ObjectStreamField[]
getFields()
Return an array of the fields of this serializable class.String
getName()
Returns the name of the class described by this descriptor.long
getSerialVersionUID()
Return the serialVersionUID for this class.static ObjectStreamClass
lookup(Class<?> cl)
Find the descriptor for a class that can be serialized.static ObjectStreamClass
lookupAny(Class<?> cl)
Returns the descriptor for any class, regardless of whether it implementsSerializable
.String
toString()
Return a string describing this ObjectStreamClass.
-
-
-
Field Detail
-
NO_FIELDS
public static final ObjectStreamField[] NO_FIELDS
serialPersistentFields value indicating no serializable fields
-
-
Method Detail
-
lookup
public static ObjectStreamClass lookup(Class<?> cl)
Find the descriptor for a class that can be serialized. Creates an ObjectStreamClass instance if one does not exist yet for class. Null is returned if the specified class does not implement java.io.Serializable or java.io.Externalizable.- Parameters:
cl
- class for which to get the descriptor- Returns:
- the class descriptor for the specified class
-
lookupAny
public static ObjectStreamClass lookupAny(Class<?> cl)
Returns the descriptor for any class, regardless of whether it implementsSerializable
.- Parameters:
cl
- class for which to get the descriptor- Returns:
- the class descriptor for the specified class
- Since:
- 1.6
-
getName
public String getName()
Returns the name of the class described by this descriptor. This method returns the name of the class in the format that is used by theClass.getName()
method.- Returns:
- a string representing the name of the class
-
getSerialVersionUID
public long getSerialVersionUID()
Return the serialVersionUID for this class. The serialVersionUID defines a set of classes all with the same name that have evolved from a common root class and agree to be serialized and deserialized using a common format. NonSerializable classes have a serialVersionUID of 0L.- Returns:
- the SUID of the class described by this descriptor
-
forClass
public Class<?> forClass()
Return the class in the local VM that this version is mapped to. Null is returned if there is no corresponding local class.- Returns:
- the
Class
instance that this descriptor represents
-
getFields
public ObjectStreamField[] getFields()
Return an array of the fields of this serializable class.- Returns:
- an array containing an element for each persistent field of this class. Returns an array of length zero if there are no fields.
- Since:
- 1.2
-
getField
public ObjectStreamField getField(String name)
Get the field of this class by name.- Parameters:
name
- the name of the data field to look for- Returns:
- The ObjectStreamField object of the named field or null if there is no such named field.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/11/2024 23:48:12 Cette version de la page est en cache (à la date du 21/11/2024 23:48:12) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 07/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/io/ObjectStreamClass.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.