Alachisoft.NCache.Common.XmlSerialization.XMLDocSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
package Alachisoft.NCache.Common.XmlSerialization;
/*
* Mansoor: It will be converted later on.
***/
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
//#if VS2005
/**
* XML serialization and deserialization of strongly typed objects to/from an XML file.
*/
//C# TO JAVA CONVERTER TODO TASK: The C# 'class' constraint has no equivalent in Java:
public final class XMLDocSerializer {
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
// ///#region Load methods
//
// /**
// Loads an object from an XML file in Document format.
//
// @param path Path of the file to load the object from.
// @return Object loaded from an XML file in Document format.
// */
// public static T Load(String path) {
// T serializableObject = LoadFromDocumentFormat(path);
// return serializableObject;
// }
//
//
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
// ///#endregion
//
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
// ///#region Save methods
//
// /**
// Saves an object to an XML file in Document format.
//
// @param serializableObject Serializable object to be saved to file.
// @param path Path of the file to save the object to.
// */
// public static void Save(T serializableObject, String path) {
// SaveToDocumentFormat(serializableObject, path);
// }
//
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
// ///#endregion
//
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
// ///#region Private
//
// private static FileStream CreateFileStream(String path) {
// FileStream fileStream = null;
// fileStream = new FileStream(path, FileMode.OpenOrCreate);
//
// return fileStream;
// }
//
// private static T LoadFromDocumentFormat(String path) {
// T serializableObject = null;
//
////C# TO JAVA CONVERTER NOTE: The following 'using' block is replaced by its Java equivalent:
//// using (TextReader textReader = CreateTextReader(path))
// TextReader textReader = CreateTextReader(path);
// try {
// XmlSerializer xmlSerializer = CreateXmlSerializer();
// Object tempVar = xmlSerializer.Deserialize(textReader);
// serializableObject = (T)((tempVar instanceof T) ? tempVar : null);
//
// } finally {
// textReader.dispose();
// }
//
// return serializableObject;
// }
//
// private static TextReader CreateTextReader(String path) {
// TextReader textReader = null;
// textReader = new StreamReader(path);
//
// return textReader;
// }
//
// private static TextWriter CreateTextWriter(String path) {
// TextWriter textWriter = null;
// textWriter = new StreamWriter(path);
//
// return textWriter;
// }
//
// private static XmlSerializer CreateXmlSerializer() {
// java.lang.Class ObjectType = T.class;
//
// XmlSerializer xmlSerializer = null;
// xmlSerializer = new XmlSerializer(ObjectType);
//
// return xmlSerializer;
// }
//
// private static void SaveToDocumentFormat(T serializableObject, String path) {
////C# TO JAVA CONVERTER NOTE: The following 'using' block is replaced by its Java equivalent:
//// using (TextWriter textWriter = CreateTextWriter(path))
// TextWriter textWriter = CreateTextWriter(path);
// try {
// XmlSerializer xmlSerializer = CreateXmlSerializer();
// xmlSerializer.Serialize(textWriter, serializableObject);
// } finally {
// textWriter.dispose();
// }
// }
//
// private static void SaveToBinaryFormat(T serializableObject, String path) {
////C# TO JAVA CONVERTER NOTE: The following 'using' block is replaced by its Java equivalent:
//// using (FileStream fileStream = CreateFileStream(path))
// FileStream fileStream = CreateFileStream(path);
// try {
// BinaryFormatter binaryFormatter = new BinaryFormatter();
// binaryFormatter.Serialize(fileStream, serializableObject);
// } finally {
// fileStream.dispose();
// }
// }
//
////C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
// ///#endregion
}