Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* RED5 Open Source Media Server - https://github.com/Red5/ Copyright 2006-2023 by respective authors (see below). All rights reserved. Licensed under the Apache License, Version
* 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless
* required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
package org.red5.io.object;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.apache.commons.beanutils.BeanMap;
import org.red5.annotations.DontSerialize;
import org.red5.annotations.RemoteClass;
import org.red5.io.amf3.ByteArray;
import org.red5.io.amf3.IExternalizable;
import org.red5.io.utils.ObjectMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
/**
* The Serializer class writes data output and handles the data according to the core data types
*
* @author The Red5 Project
* @author Luke Hubbard, Codegent Ltd ([email protected])
* @author Harald Radi ([email protected])
* @author Paul Gregoire ([email protected])
*/
public class Serializer {
protected static Logger log = LoggerFactory.getLogger(Serializer.class);
private Serializer() {
}
/**
* Serializes output to a core data type object
*
* @param out
* Output writer
* @param obj
* Object to serialize
*/
public static void serialize(Output out, Object obj) {
Serializer.serialize(out, null, null, null, obj);
}
/**
* Serializes output to a core data type object
*
* @param out
* Output writer
* @param field
* The field to serialize
* @param getter
* The getter method if not a field
* @param parent
* Parent object
* @param obj
* Object to serialize
*/
@SuppressWarnings("unchecked")
public static void serialize(Output out, Field field, Method getter, Object parent, Object obj) {
log.trace("serialize: {}", obj);
if (obj == null) {
out.writeNull();
} else if (IExternalizable.class.isAssignableFrom(obj.getClass())) {
// make sure all IExternalizable objects are serialized as objects
log.trace("write externalizable: {}", obj);
out.writeObject(obj);
} else if (obj instanceof ByteArray) {
// write ByteArray objects directly
out.writeByteArray((ByteArray) obj);
} else if (out.isCustom(obj)) {
log.trace("write custom: {}", obj);
// Write custom data
out.writeCustom(obj);
} else {
if (writeBasic(out, obj)) {
log.trace("Wrote as basic");
} else if (obj.getClass().isArray() && obj.getClass().getComponentType().isPrimitive()) {
log.trace("write array: {}", obj);
out.writeArray(obj);
} else if (obj instanceof Object[]) {
log.trace("write object array: {}", obj);
out.writeArray((Object[]) obj);
} else if (obj instanceof Collection) {
log.trace("write collection");
out.writeArray((Collection