also used in serialization
345216
static long transform(
        int relgregyear,
        int dayOfYear
    ) {

        if (relgregyear >= 1873) {
            return PlainDate.of(relgregyear, dayOfYear).getDaysSinceEpochUTC();
        } else {
            return START_OF_YEAR[relgregyear - 701] + dayOfYear - 1;
        }

    }
75288
@Override
    public void writeExternal(ObjectOutput output) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Serializing: " + this);
        }
        super.writeExternal(output);
        output.writeShort(getStatusCodeAsInt());
        writeByteArray(output, this.myReasonBytes);
    }
211468
private void writeObject(ObjectOutputStream oos) throws IOException
   {
      ObjectOutputStream.PutField fields =  oos.putFields();
      String name = serialPersistentFields[TYPE_IDX].getName();
      fields.put(name, type);
      name = serialPersistentFields[WORK_IDX].getName();
      fields.put(name, work);
      name = serialPersistentFields[EXCPEPTION_IDX].getName();
      fields.put(name, e);
      name = serialPersistentFields[DURATION_IDX].getName();
      fields.put(name, startDuration);
      oos.writeFields();
   }
1265972
public void serializePrimitive(S rec, String fieldName, float value) {
        serializePrimitive(rec, fieldName, Float.valueOf(value));
    }
554329
public static final byte[] serialize(Serializable serializable) throws IOException {
	
		if (serializable == null) {
			return null;
		}
		
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		ObjectOutputStream objectOutputStream = null;
		byte[] result = null;

		if (null != _instance ){
			SerializationService ss = _instance.serializationServiceRef.getService();
			if (null != ss){
				objectOutputStream = ss.createObjectOutputStream(byteArrayOutputStream);
			}
		} 
		
		if (null == objectOutputStream){
			objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
		}
		
		try {
			objectOutputStream.writeObject(serializable);
			result = byteArrayOutputStream.toByteArray();
		} finally {

			if (byteArrayOutputStream != null) {
				byteArrayOutputStream.close();
			}
			if (objectOutputStream != null) {
				objectOutputStream.close();
			}
		}

		return result;
	}
90144
public void serializePrimitive(S rec, String fieldName, int value) {
        serializePrimitive(rec, fieldName, Integer.valueOf(value));
    }
815918
public void serialize(final DataOutput pOutput) throws TTIOException {
        try {
            pOutput.writeLong(getFirstChildKey());
            pOutput.writeLong(getRightSiblingKey());
            pOutput.writeLong(getLeftSiblingKey());
            pOutput.writeLong(getChildCount());
        } catch (final IOException exc) {
            throw new TTIOException(exc);
        }
    }
59607
public static void serialize(Serializable obj, ByteArrayOutputStream bout) {
		try {
			ObjectOutputStream out = new ObjectOutputStream(bout);
			out.writeObject(obj);
			out.close();
		} catch (IOException e) {
			throw new IllegalStateException("Could not serialize " + obj, e);
		}
	}
506810
@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<Object>) value);
            } else if (dubs == 0 && longs == 0) {
                // no doubles or longs
                out.writeVectorInt((Vector<Integer>) value);
            } else if (dubs == 0 && ints == 0) {
                // no doubles or ints
                out.writeVectorUInt((Vector<Long>) value);
            } else {
                // handle any other types of numbers
                ((org.red5.io.amf3.Output) out).enforceAMF3();
                out.writeVectorNumber((Vector<Double>) value);
            }
        } else {
            if (writeBasic(out, value)) {
                log.trace("Wrote as basic");
            } else if (!writeComplex(out, value)) {
                log.trace("Unable to serialize: {}", value);
            }
        }
    }
1218342
public void serialize(Writer writer, boolean verbose) throws IOException {
        Serializer serializer;

        //Try to avoid double-buffering or buffering in-memory
        //writers.
        Class writerClass = writer.getClass();
        if (!StringWriter.class.isAssignableFrom(writerClass) &&
            !CharArrayWriter.class.isAssignableFrom(writerClass) &&
            !BufferedWriter.class.isAssignableFrom(writerClass)) {
            writer = new BufferedWriter(writer);
        }

        if (verbose)
        {
            serializer = new SerializerVerbose(writer);
        }
        else
        {
            serializer = new Serializer(writer);
        }
        serializer.writeObject(this).flush();
    }
179846
private void _serializeList(String name, List list, StringBuilder sb, Set<Object> done) throws ConverterException {

	if (useShortcuts) sb.append("[];");
	else sb.append("new Array();");

	ListIterator it = list.listIterator();
	int index = -1;
	while (it.hasNext()) {
	    // if(index!=-1)sb.append(",");
	    index = it.nextIndex();
	    sb.append(name + "[" + index + "]=");
	    _serialize(name + "[" + index + "]", it.next(), sb, done);
	    // sb.append(";");
	}
    }
548616
@GwtIncompatible("ObjectOutputStream")
  public void serialize(OutputStream objectOutputStream) throws IOException {
    new java.io.ObjectOutputStream(objectOutputStream).writeObject(this);
  }
1078841
private static void serialize(Map<String, AbstractDataMarshaller<?>> marshallerMap,
            DataOutputStream dOut, DataNode primaryNode, boolean ignoreMissingMarshallers,
            ProgressListener progressListener) throws IOException {

        //a map containing all serialized objects. This is used
        //to make sure that we store each deSerializedObject only once.
        final Map<SerializedObject, SerializedObject> serializedObjects = new HashMap<>();

        final Deque<SerializationFrame> stack = new LinkedList<>();
        final DataNodeSerializationFrame primaryDataNodeFrame = new DataNodeSerializationFrame(null, primaryNode);

        progressListener.onTotalSteps(primaryDataNodeFrame.entries.size());
        stack.add(primaryDataNodeFrame);


        final SerializedObject testSerializedObject = new SerializedObject();

        while (!stack.isEmpty()) {
            final SerializationFrame frame = stack.peek();

            //writes the header for that frame (if needed)
            frame.writeHeader(dOut);

            if (frame.hasNext()) {
                while (frame.hasNext()) {
                    if (frame.next(stack, dOut, marshallerMap,
                            serializedObjects, testSerializedObject,
                            ignoreMissingMarshallers)) {
                        if (frame == primaryDataNodeFrame) {
                            progressListener.onStep();
                        }
                        break;
                    }
                    if (frame == primaryDataNodeFrame) {
                        progressListener.onStep();
                    }
                }
            } else {
                stack.pop();

                //remember serialized deSerializedObject's addresses
                if (frame instanceof DataNodeSerializationFrame) {
                    DataNodeSerializationFrame dataNodeFrame = (DataNodeSerializationFrame) frame;
                    SerializedObject newSerializedObject = new SerializedObject();
                    newSerializedObject.object = frame.object;
                    newSerializedObject.positionInStream = dataNodeFrame.positionInStream;
                    serializedObjects.put(newSerializedObject, newSerializedObject);
                }
            }
        }
    }
414310
private void _serializeList(List list, StringBuilder sb, Set<Object> done) throws ConverterException {

	sb.append(goIn());
	sb.append("[");
	boolean doIt = false;
	ListIterator it = list.listIterator();
	while (it.hasNext()) {
	    if (doIt) sb.append(',');
	    doIt = true;
	    _serialize(it.next(), sb, done);
	}

	sb.append(']');
    }
702450
private Object serializationClone(Object source) {
		ObjectOutputStream oos = null;
		ObjectInputStream ois = null;
		try {
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			oos = new ObjectOutputStream(bos);
			oos.writeObject(source);
			oos.flush();
			ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
			ois = new ObjectInputStream(bin);
			return ois.readObject();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			close(oos);
			close(ois);
		}
	}
506062
@Override
	protected void serializeTo(RawDataBuffer out)
    {
        super.serializeTo(out);
        out.writeNullableUTF(userName);
        out.writeNullableUTF(password);
        out.writeNullableUTF(clientID);
    }
736015
protected final void serializeTo( RawDataBuffer out )
    {
    	// Level 1 - Always unserialized
    	byte lvl1Flags = (byte)((priority & 0x0F)+
    	                        (redelivered ? (1 << 4) : 0)+
    	                        (deliveryMode == DeliveryMode.PERSISTENT ? (1 << 5) : 0)+
    	                        (expiration != 0 ? (1 << 6) : 0)+ // Expiration value present
    	                        (id != null ? (1 << 7) : 0)); // ID value present
    	out.writeByte(lvl1Flags);
    	if (expiration != 0)
    		out.writeLong(expiration);
    	if (id != null)
    		out.writeUTF(id);
    	DestinationSerializer.serializeTo(destination, out);
    	
        // Level 2 - Unserialized if required by a message selector
    	byte lvl2Flags = (byte)((correlId != null ? (1 << 0) : 0)+
    	                        (replyTo != null ? (1 << 1) : 0)+
    	                        (timestamp != 0 ? (1 << 2) : 0)+
    	                        (type != null ? (1 << 3) : 0)+
    	                        (propertyMap != null && !propertyMap.isEmpty() ? (1 << 4) : 0));
    	out.writeByte(lvl2Flags);
    	if (correlId != null)
    		out.writeUTF(correlId);
    	if (replyTo != null)
    		DestinationSerializer.serializeTo(replyTo, out);
    	if (timestamp != 0)
    		out.writeLong(timestamp);
    	if (type != null)
    		out.writeUTF(type);
    	if (propertyMap != null && !propertyMap.isEmpty())
    		writeMapTo(propertyMap, out);
        
        // Level 3 - Body - Only unserialized on the client side
        serializeBodyTo(out);
    }