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-2016 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 any
* Object to serialize
*/
public static void serialize(Output out, Object any) {
Serializer.serialize(out, null, null, null, any);
}
/**
* 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 object
* Parent object
* @param value
* Object to serialize
*/
@SuppressWarnings("unchecked")
public static void serialize(Output out, Field field, Method getter, Object object, Object value) {
log.trace("serialize");
if (value instanceof IExternalizable) {
// make sure all IExternalizable objects are serialized as objects
out.writeObject(value);
} else if (value instanceof ByteArray) {
// write ByteArray objects directly
out.writeByteArray((ByteArray) value);
} else if (value instanceof Vector) {
log.trace("Serialize Vector");
// scan the vector to determine the generic type
Vector> vector = (Vector>) value;
int ints = 0;
int longs = 0;
int dubs = 0;
int nans = 0;
for (Object o : vector) {
if (o instanceof Integer) {
ints++;
} else if (o instanceof Long) {
longs++;
} else if (o instanceof Number || o instanceof Double) {
dubs++;
} else {
nans++;
}
}
// look at the type counts
if (nans > 0) {
// if we have non-number types, use object
((org.red5.io.amf3.Output) out).enforceAMF3();
out.writeVectorObject((Vector