Writes Lists out as a data type

@param out
Output write
@param listType
List type
@return boolean true if object was successfully serialized, false otherwise
169909
protected static boolean writeListType(Output out, Object listType) {
        log.trace("writeListType");
        if (listType instanceof List<?>) {
            writeList(out, (List<?>) listType);
        } else {
            return false;
        }
        return true;
    }
89571
public static <T> void writeListTo(LinkedBuffer buffer,
            List<T> messages, Schema<T> schema, boolean numeric)
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        if (messages.isEmpty())
        {
            System.arraycopy(EMPTY_ARRAY, 0, buffer.buffer, buffer.offset, EMPTY_ARRAY.length);
            buffer.offset += EMPTY_ARRAY.length;
            return;
        }

        final JsonXOutput output = new JsonXOutput(buffer, numeric, schema);

        try
        {
            output.writeStartArray();

            boolean first = true;
            for (T m : messages)
            {
                if (first)
                {
                    first = false;
                    output.writeStartObject();
                }
                else
                    output.writeCommaAndStartObject();

                schema.writeTo(output, m);
                if (output.isLastRepeated())
                    output.writeEndArray();

                output.writeEndObject().reset();
            }

            output.writeEndArray();
        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }
    }
432912
public void writeExternal(ObjectOutput out) throws IOException
   {
      out.writeInt(eventType);

      byte[] buff = sessionId.getBytes(Constants.DEFAULT_ENCODING);
      out.writeInt(buff.length);
      out.write(buff);

      int listSize = items.size();
      out.writeInt(listSize);
      for (int i = 0; i < listSize; i++)
      {
         out.writeObject(items.get(i));
      }

      if (pairId != null)
      {
         out.writeInt(NOT_NULL_VALUE);
         buff = pairId.getBytes(Constants.DEFAULT_ENCODING);
         out.writeInt(buff.length);
         out.write(buff);
      }
      else
      {
         out.writeInt(NULL_VALUE);
      }
   }
446293
public void write(DataOutput out) throws IOException {
        if (array == null) {
            out.write(NDARRAY_SER_VERSION_HEADER_NULL);
            return;
        }

        INDArray toWrite;
        if (array.isView()) {
            toWrite = array.dup();
        } else {
            toWrite = array;
        }

        //Write version header: this allows us to maintain backward compatibility in the future,
        // with features such as compression, sparse arrays or changes on the DataVec side
        out.write(NDARRAY_SER_VERSION_HEADER);
        Nd4j.write(toWrite, new DataOutputStream(new DataOutputWrapperStream(out)));
    }
860592
public void write(ObjectWriter out, PersistedPropertyData propData) throws IOException
   {
      // write id
      out.writeInt(SerializationConstants.PERSISTED_PROPERTY_DATA);

      out.writeString(propData.getQPath().getAsString());
      out.writeString(propData.getIdentifier());

      if (propData.getParentIdentifier() != null)
      {
         out.writeByte(SerializationConstants.NOT_NULL_DATA);
         out.writeString(propData.getParentIdentifier());
      }
      else
         out.writeByte(SerializationConstants.NULL_DATA);

      out.writeInt(propData.getPersistedVersion());
      // -------------------

      out.writeInt(propData.getType());
      out.writeBoolean(propData.isMultiValued());
      out.writeLong(propData.getPersistedSize());

      List<ValueData> values = propData.getValues();
      if (values != null)
      {
         out.writeByte(SerializationConstants.NOT_NULL_DATA);
         int listSize = values.size();
         out.writeInt(listSize);
         PersistedValueDataWriter wr = new PersistedValueDataWriter();
         for (int i = 0; i < listSize; i++)
         {
            wr.write(out, (PersistedValueData)values.get(i));
         }
      }
      else
      {
         out.writeByte(SerializationConstants.NULL_DATA);
      }

   }
1006252
public static void writeObject(CodedOutputStream out, int order, FieldType type, Object o, boolean list)
            throws IOException {
        writeObject(out, order, type, o, list, true);
    }
180149
@Override
  public void write(DataOutput out) throws IOException {
    Text.writeString(out,getJobId());
    out.writeDouble(getCpuMaxPercentageOnBox());
    out.writeDouble(getCpuPercentageOnCluster());
    out.writeDouble(getMemMaxPercentageOnBox());
    out.writeDouble(getMemMaxPercentageOnBoxAllTime());
    out.writeDouble(getMemPercentageOnCluster());
    out.writeDouble(getCpuCumulatedUsageTime());
    out.writeDouble(getMemCumulatedUsageTime());
    out.writeLong(getRunningTime());
    out.writeLong(getStoppedTime());
    out.writeDouble(getCpuGigaCycles());
  }
476349
public void write(RowOutputInterface out) {

        out.writeSize(storageSize);
        out.writeData(rowData, tTable.colTypes);
        out.writeEnd();

        hasDataChanged = false;
    }
129620
public static <T> int writeListTo(OutputStream out, List<T> messages, Schema<T> schema,
            LinkedBuffer buffer) throws IOException
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        final ProtobufOutput output = new ProtobufOutput(buffer);
        int totalSize = 0;
        for (T m : messages)
        {
            schema.writeTo(output, m);
            final int size = output.getSize();
            ProtobufOutput.writeRawVarInt32Bytes(out, size);
            final int msgSize = LinkedBuffer.writeTo(out, buffer);

            assert size == msgSize;

            totalSize += size;
            output.clear();
        }
        return totalSize;
    }
1248429
protected static boolean writeCustomType(Output out, Object obj) {
        if (out.isCustom(obj)) {
            // Write custom data
            out.writeCustom(obj);
            return true;
        } else {
            return false;
        }
    }
1090446
private void writeType(String type)
        throws IOException
    {
        flushIfFull();

        int len = type.length();
        if (len == 0) {
            throw new IllegalArgumentException("empty type is not allowed");
        }

        if (_typeRefs == null)
            _typeRefs = new HashMap<String, Integer>();

        Integer typeRefV = (Integer) _typeRefs.get(type);

        if (typeRefV != null) {
            int typeRef = typeRefV.intValue();

            writeInt(typeRef);
        }
        else {
            _typeRefs.put(type, Integer.valueOf(_typeRefs.size()));

            writeString(type);
        }
    }
1023528
private void writeOutTypeListArray(BytecodeContext bc, boolean isArray) throws TransformerException {
	ForVisitor forVisitor = new ForVisitor();
	loopVisitor = forVisitor;
	GeneratorAdapter adapter = bc.getAdapter();

	// List.listToArrayRemoveEmpty("", 'c')
	int array = adapter.newLocal(Types.ARRAY);
	int len = adapter.newLocal(Types.INT_VALUE);

	if (isArray) {
	    getAttribute("array").getValue().writeOut(bc, Expression.MODE_REF);
	}
	else {
	    // array=List.listToArrayRemoveEmpty(list, delimter)
	    getAttribute("list").getValue().writeOut(bc, Expression.MODE_REF);
	    if (containsAttribute("delimiters")) {
		getAttribute("delimiters").getValue().writeOut(bc, Expression.MODE_REF);
		adapter.invokeStatic(Types.LIST_UTIL, LIST_TO_ARRAY_REMOVE_EMPTY_SS);
	    }
	    else {
		adapter.visitIntInsn(Opcodes.BIPUSH, 44);// ','
		// adapter.push(',');
		adapter.invokeStatic(Types.LIST_UTIL, LIST_TO_ARRAY_REMOVE_EMPTY_SC);
	    }
	}
	adapter.storeLocal(array);

	// int len=array.size();
	adapter.loadLocal(array);
	adapter.invokeInterface(Types.ARRAY, SIZE);
	adapter.storeLocal(len);

	// VariableInterpreter.getVariableReference(pc,Caster.toString(index));
	Attribute attrIndex = getAttribute("index");
	int index = -1;
	if (attrIndex != null) {
	    index = adapter.newLocal(Types.VARIABLE_REFERENCE);
	    adapter.loadArg(0);
	    attrIndex.getValue().writeOut(bc, Expression.MODE_REF);
	    adapter.invokeStatic(Types.VARIABLE_INTERPRETER, GET_VARIABLE_REFERENCE);
	    adapter.storeLocal(index);
	}

	// VariableInterpreter.getVariableReference(pc,Caster.toString(item));
	Attribute attrItem = getAttribute("item");
	int item = -1;
	if (attrItem != null) {
	    item = adapter.newLocal(Types.VARIABLE_REFERENCE);
	    adapter.loadArg(0);
	    attrItem.getValue().writeOut(bc, Expression.MODE_REF);
	    adapter.invokeStatic(Types.VARIABLE_INTERPRETER, GET_VARIABLE_REFERENCE);
	    adapter.storeLocal(item);
	}

	int obj = 0;
	if (isArray) obj = adapter.newLocal(Types.OBJECT);

	// for(int i=1;i<=len;i++) {
	int i = forVisitor.visitBegin(adapter, 1, false);
	// index.set(pc, list.get(i));

	if (isArray) {

	    // value
	    adapter.loadLocal(array);
	    adapter.visitVarInsn(Opcodes.ILOAD, i);
	    ASMConstants.NULL(adapter);
	    adapter.invokeInterface(Types.ARRAY, GET);
	    adapter.dup();
	    adapter.storeLocal(obj);
	    Label endIf = new Label();
	    // adapter.loadLocal(obj);
	    adapter.visitJumpInsn(Opcodes.IFNONNULL, endIf);
	    adapter.goTo(forVisitor.getContinueLabel());
	    adapter.visitLabel(endIf);

	    if (item == -1) adapter.loadLocal(index);
	    else adapter.loadLocal(item);

	    adapter.loadArg(0);

	    adapter.loadLocal(obj);

	}
	else {
	    if (item == -1) adapter.loadLocal(index);
	    else adapter.loadLocal(item);
	    adapter.loadArg(0);
	    adapter.loadLocal(array);
	    adapter.visitVarInsn(Opcodes.ILOAD, i);
	    adapter.invokeInterface(Types.ARRAY, GETE);

	}
	adapter.invokeVirtual(Types.VARIABLE_REFERENCE, SET);
	adapter.pop();

	// key
	if (index != -1 && item != -1) {
	    adapter.loadLocal(index);
	    adapter.loadArg(0);
	    adapter.visitVarInsn(Opcodes.ILOAD, i);
	    adapter.cast(Types.INT_VALUE, Types.DOUBLE_VALUE);
	    adapter.invokeStatic(Types.CASTER, Methods_Caster.TO_DOUBLE[Methods_Caster.DOUBLE]);
	    adapter.invokeVirtual(Types.VARIABLE_REFERENCE, SET);
	    adapter.pop();
	}

	getBody().writeOut(bc);
	forVisitor.visitEnd(bc, len, true, getStart());
    }
889728
protected void writeListNumbers(final OutputStream result) throws IOException {

        if(listLevel > 0) {
            result.write(RtfList.LIST_LEVEL_NUMBER);
            result.write(intToByteArray(listLevel));
        }
    }
183421
@SuppressWarnings("rawtypes")
    protected static boolean writeBasic(Output out, Object basic) {
        if (basic == null) {
            out.writeNull();
        } else if (basic instanceof Boolean) {
            out.writeBoolean((Boolean) basic);
        } else if (basic instanceof Number) {
            out.writeNumber((Number) basic);
        } else if (basic instanceof String) {
            out.writeString((String) basic);
        } else if (basic instanceof Enum) {
            out.writeString(((Enum) basic).name());
        } else if (basic instanceof Date) {
            out.writeDate((Date) basic);
        } else {
            return false;
        }
        return true;
    }
263122
public boolean writeListBegin(int length, String type)
        throws IOException
    {
        os.write('V');

        if (type != null) {
            os.write('t');
            printLenString(type);
        }

        if (length >= 0) {
            os.write('l');
            os.write(length >> 24);
            os.write(length >> 16);
            os.write(length >> 8);
            os.write(length);
        }

        return true;
    }
1294410
public void writeData(Object[] data, Type[] types) {
        writeData(types.length, types, data, null, null);
    }
558945
@Override
    @Deprecated
    public void write(ObjectOutput output) throws IOException {
        if (!output.equals(oos)) {
            throw new IllegalArgumentException("Attempting to write to a different stream than the one that created this PutField");
        }
        for (EmulatedFields.ObjectSlot slot : emulatedFields.slots()) {
            Object fieldValue = slot.getFieldValue();
            Class<?> type = slot.getField().getType();
            if (type == int.class) {
                output.writeInt(fieldValue != null ? ((Integer) fieldValue).intValue() : 0);
            } else if (type == byte.class) {
                output.writeByte(fieldValue != null ? ((Byte) fieldValue).byteValue() : 0);
            } else if (type == char.class) {
                output.writeChar(fieldValue != null ? ((Character) fieldValue).charValue() : 0);
            } else if (type == short.class) {
                output.writeShort(fieldValue != null ? ((Short) fieldValue).shortValue() : 0);
            } else if (type == boolean.class) {
                output.writeBoolean(fieldValue != null ? ((Boolean) fieldValue).booleanValue() : false);
            } else if (type == long.class) {
                output.writeLong(fieldValue != null ? ((Long) fieldValue).longValue() : 0);
            } else if (type == float.class) {
                output.writeFloat(fieldValue != null ? ((Float) fieldValue).floatValue() : 0);
            } else if (type == double.class) {
                output.writeDouble(fieldValue != null ? ((Double) fieldValue).doubleValue() : 0);
            } else {
                // Either array or Object
                output.writeObject(fieldValue);
            }
        }
    }