Class Yggdrasil
 Yggdrasil uses String IDs to identify classes, thus all classes to be (de)serialised have to be registered to Yggdrasil before doing anything (they can also be registered while
 Yggdrasil is working, but you must make sure that all classes are registered in time when deserialising). A ClassResolver or YggdrasilSerializer can also be used
 to find classes and IDs dynamically.
 
Default behaviour
 A Java object can be serialised and deserialised if it is a primitive, a primitive wrapper, a String, an enum or PseudoEnum (both require an ID), or its class meets all
 of the following requirements:
 
- It implements YggdrasilSerializable
- It has an ID assigned to it (using the methods described above)
- It provides a nullary constructor (any access modifier) (in particular anonymous and non-static inner classes can't be serialised)
- All its non-transient and non-static fields are serialisable according to these requirements
Yggdrasil will generate errors if an object loaded either has too many fields and/or is missing some in the stream.
Customisation
 Any object that does not meet the above requirements for serialisation can still be (de)serialised using an YggdrasilSerializer (useful for objects of an external API),
 or by implementing YggdrasilSerializable.YggdrasilExtendedSerializable.
 
 The behaviour in case of an invalid or outdated stream can be defined likewise, or one can implement YggdrasilSerializable.YggdrasilRobustSerializable or YggdrasilSerializable.YggdrasilRobustEnum
 respectively.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic shortlatest protocol versionstatic intMagic Number: "Ygg\0"short
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidexcessiveField(Object o, Fields.FieldContext field)Class<?>getEnumConstant(Class<T> c, String id)static Stringstatic StringGets the ID of a field.voidincompatibleField(Object o, Field f, Fields.FieldContext field)booleanisSerializable(Class<?> c)<T> @Nullable TloadFromFile(File f, Class<T> expectedType)static voidvoidmissingField(Object o, Field f)newOutputStream(OutputStream out)Deprecated.Deprecated.voidvoidvoidregisterSingleClass(Class<?> c)Registers a class and uses itsYggdrasilIDas id.voidregisterSingleClass(Class<?> c, String id)voidsaveToFile(Object o, File f)
- 
Field Details- 
MAGIC_NUMBERpublic static final int MAGIC_NUMBERMagic Number: "Ygg\0"hex: 0x59676700 - See Also:
- Constant Field Values
 
- 
LATEST_VERSIONpublic static final short LATEST_VERSIONlatest protocol version- See Also:
- Constant Field Values
 
- 
versionpublic final short version
 
- 
- 
Constructor Details- 
Yggdrasilpublic Yggdrasil()
- 
Yggdrasilpublic Yggdrasil(short version)
 
- 
- 
Method Details- 
newOutputStream- Throws:
- IOException
 
- 
newInputStream- Throws:
- IOException
 
- 
newXMLOutputStreamDeprecated.- Throws:
- IOException
 
- 
newXMLInputStreamDeprecated.- Throws:
- IOException
 
- 
registerClassResolver
- 
registerSingleClass
- 
registerSingleClassRegisters a class and uses itsYggdrasilIDas id.
- 
registerFieldHandler
- 
isSerializable
- 
getClass- Throws:
- StreamCorruptedException
 
- 
getID- Throws:
- NotSerializableException
 
- 
getIDGets the ID of a field.This method performs no checks on the given field. - Parameters:
- f-
- Returns:
- The field's id as given by its YggdrasilIDannotation, or its name if it's not annotated.
 
- 
getID
- 
getEnumConstantpublic static <T extends Enum<T>> Enum<T> getEnumConstant(Class<T> c, String id) throws StreamCorruptedException- Throws:
- StreamCorruptedException
 
- 
excessiveField- Throws:
- StreamCorruptedException
 
- 
missingField- Throws:
- StreamCorruptedException
 
- 
incompatibleFieldpublic void incompatibleField(Object o, Field f, Fields.FieldContext field) throws StreamCorruptedException- Throws:
- StreamCorruptedException
 
- 
saveToFile- Throws:
- IOException
 
- 
loadFromFile- Throws:
- IOException
 
- 
main
 
-