Passing the object after defining the type of data that will be written

@param theCreatedFile
@param theCreatedNullFile
@param dataObject
@return
@throws RasterWritingFailureException
181919
public boolean compressAndWriteObj( RandomAccessFile theCreatedFile, RandomAccessFile theCreatedNullFile, Object dataObject )
            throws RasterWritingFailureException {
        if (dataObject instanceof double[][]) {
            compressAndWrite(theCreatedFile, theCreatedNullFile, (double[][]) dataObject);
        } else {
            throw new RasterWritingFailureException("Raster type not supported.");
        }
34054
public TrmRouteData createTrmRouteData() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createTrmRouteData");
    TrmRouteData msg = null;
    try {
      msg = new TrmRouteDataImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createTrmRouteData");
    return msg;
  }
999542
public static FSDataOutputStream tryCreateFile(FileSystem fs, Path file) throws IOException {
    try {
      FSDataOutputStream os = fs.create(file, false);
      return os;
    } catch (FileAlreadyExistsException e) {
      return null;
    } catch (RemoteException e) {
      if( e.unwrapRemoteException() instanceof AlreadyBeingCreatedException ) {
        return null;
      } else { // unexpected error
        throw e;
      }
    }
  }
158530
public static void writeObject(DataOutput out, Object instance,
                                 Class declaredClass, 
                                 Configuration conf) throws IOException {

    if (instance == null) {                       // null
      instance = new NullInstance(declaredClass, conf);
      declaredClass = Writable.class;
    }
    
    // handle FastWritable first (including ShortVoid)
    if (instance instanceof FastWritable) {
      FastWritable fwInstance = (FastWritable) instance;
      byte[] serializedName = fwInstance.getSerializedName();
      out.write(serializedName, 0, serializedName.length);
      fwInstance.write(out);
      return;
    }
    
    // write declared name
    writeStringCached(out, declaredClass.getName());

    if (declaredClass.isArray()) {                // array
      int length = Array.getLength(instance);
      out.writeInt(length);
      for (int i = 0; i < length; i++) {
        writeObject(out, Array.get(instance, i),
                    declaredClass.getComponentType(), conf);
      }
      
    } else if (declaredClass == String.class) {   // String
      UTF8.writeStringOpt(out, (String)instance);
      
    } else if (declaredClass.isPrimitive()) {     // primitive type

      if (declaredClass == Boolean.TYPE) {        // boolean
        out.writeBoolean(((Boolean)instance).booleanValue());
      } else if (declaredClass == Character.TYPE) { // char
        out.writeChar(((Character)instance).charValue());
      } else if (declaredClass == Byte.TYPE) {    // byte
        out.writeByte(((Byte)instance).byteValue());
      } else if (declaredClass == Short.TYPE) {   // short
        out.writeShort(((Short)instance).shortValue());
      } else if (declaredClass == Integer.TYPE) { // int
        out.writeInt(((Integer)instance).intValue());
      } else if (declaredClass == Long.TYPE) {    // long
        out.writeLong(((Long)instance).longValue());
      } else if (declaredClass == Float.TYPE) {   // float
        out.writeFloat(((Float)instance).floatValue());
      } else if (declaredClass == Double.TYPE) {  // double
        out.writeDouble(((Double)instance).doubleValue());
      } else if (declaredClass == Void.TYPE) {    // void
      } else {
        throw new IllegalArgumentException("Not a primitive: "+declaredClass);
      }
    } else if (declaredClass.isEnum()) {         // enum
      writeStringCached(out, ((Enum)instance).name());
    } else if (Writable.class.isAssignableFrom(declaredClass)) { // Writable
      writeStringCached(out, instance.getClass().getName());
      ((Writable)instance).write(out);

    } else {
      throw new IOException("Can't write: "+instance+" as "+declaredClass);
    }
  }
1222061
public <T> void write(final OutputStream stream, final T object,
			final DataTypeDescriptor<T> descriptor, final boolean indent) throws IOException {
		if (stream == null) throw new NullPointerException("out");
		if (descriptor == null) throw new NullPointerException("descriptor");

		JsonGenerator generator = factory.createGenerator(stream);
		if (indent) {
			generator.useDefaultPrettyPrinter();
		}

		write(object, descriptor, generator);
		generator.flush();
	}
373312
public DataUrl build() throws NullPointerException {
        if (data == null) {
            throw new NullPointerException("data is null!");
        } else if (encoding == null) {
            throw new NullPointerException("encoding is null!");
        }
        return new DataUrl(data, encoding, mimeType, headers);
    }
614649
@Override
  public DataWriter<Object> build() throws IOException {
    return new MetadataWriterWrapper<byte[]>(new SimpleDataWriter(this, this.destination.getProperties()),
        byte[].class,
        this.branches,
        this.branch,
        this.destination.getProperties());
  }
1184634
private final void _writeNull() throws IOException
    {
        if ((_outputTail + 4) >= _outputEnd) {
            _flushBuffer();
        }
        int ptr = _outputTail;
        char[] buf = _outputBuffer;
        buf[ptr] = 'n';
        buf[++ptr] = 'u';
        buf[++ptr] = 'l';
        buf[++ptr] = 'l';
        _outputTail = ptr+1;
    }
1056470
WritableByteChannel createInternal(URI path, CreateFileOptions options)
      throws IOException {

    // Validate the given path. false == do not allow empty object name.
    StorageResourceId resourceId = pathCodec.validatePathAndGetId(path, false);
    if (options.getExistingGenerationId() != StorageResourceId.UNKNOWN_GENERATION_ID) {
      resourceId = new StorageResourceId(
          resourceId.getBucketName(),
          resourceId.getObjectName(),
          options.getExistingGenerationId());
    }
    WritableByteChannel channel = gcs.create(resourceId, objectOptionsFromFileOptions(options));
    tryUpdateTimestampsForParentDirectories(ImmutableList.of(path), ImmutableList.<URI>of());
    return channel;
  }
192045
@Override
    public void write(IChemObject object) throws UnsupportedChemObjectException {
        if (object instanceof ICrystal) {
            writeCrystal((ICrystal) object);
        } else if (object instanceof IChemSequence) {
            writeChemSequence((IChemSequence) object);
        } else {
            throw new UnsupportedChemObjectException("This object type is not supported.");
        }
    }
1180190
public static WritableRaster renderedImage2WritableRaster( RenderedImage renderedImage, boolean nullBorders ) {
        int width = renderedImage.getWidth();
        int height = renderedImage.getHeight();

        Raster data = renderedImage.getData();
        WritableRaster writableRaster = data.createCompatibleWritableRaster();
        writableRaster.setDataElements(0, 0, data);
        if (nullBorders) {
            for( int c = 0; c < width; c++ ) {
                writableRaster.setSample(c, 0, 0, doubleNovalue);
                writableRaster.setSample(c, height - 1, 0, doubleNovalue);
            }
            for( int r = 0; r < height; r++ ) {
                writableRaster.setSample(0, r, 0, doubleNovalue);
                writableRaster.setSample(width - 1, r, 0, doubleNovalue);
            }
        }

        return writableRaster;
    }
491046
function write_data(Schema $writers_schema, $datum, IOBinaryEncoder $encoder)
    {
        if (!Schema::is_valid_datum($writers_schema, $datum))
            throw new IOTypeException($writers_schema, $datum);

        switch ($writers_schema->type()) {
            case Schema::NULL_TYPE:
                return $encoder->write_null($datum);
            case Schema::BOOLEAN_TYPE:
                return $encoder->write_boolean($datum);
            case Schema::INT_TYPE:
                return $encoder->write_int($datum);
            case Schema::LONG_TYPE:
                return $encoder->write_long($datum);
            case Schema::FLOAT_TYPE:
                return $encoder->write_float($datum);
            case Schema::DOUBLE_TYPE:
                return $encoder->write_double($datum);
            case Schema::STRING_TYPE:
                return $encoder->write_string($datum);
            case Schema::BYTES_TYPE:
                return $encoder->write_bytes($datum);
            case Schema::ARRAY_SCHEMA:
                return $this->write_array($writers_schema, $datum, $encoder);
            case Schema::MAP_SCHEMA:
                return $this->write_map($writers_schema, $datum, $encoder);
            case Schema::FIXED_SCHEMA:
                return $this->write_fixed($writers_schema, $datum, $encoder);
            case Schema::ENUM_SCHEMA:
                return $this->write_enum($writers_schema, $datum, $encoder);
            case Schema::RECORD_SCHEMA:
            case Schema::ERROR_SCHEMA:
            case Schema::REQUEST_SCHEMA:
                return $this->write_record($writers_schema, $datum, $encoder);
            case Schema::UNION_SCHEMA:
                return $this->write_union($writers_schema, $datum, $encoder);
            default:
                throw new Exception(sprintf('Uknown type: %s',
                    $writers_schema->type));
        }
    }
1190765
public void writeObject(java.io.DataOutputStream dataOutputStream)
                    throws ObjectManagerException
    {
        final String methodName = "writeObject";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        methodName,
                        new Object[] { dataOutputStream });

        try {
            dataOutputStream.writeByte(simpleSerialVersion);
            super.writeObject(dataOutputStream);

            if (head == null) {
                dataOutputStream.writeByte(0);
            } else {
                dataOutputStream.writeByte(1);
                head.writeObject(dataOutputStream); // The first element in the list.
                tail.writeObject(dataOutputStream); // The final element in the list.
            } // if (head == null).
            dataOutputStream.writeLong(size);
        } catch (java.io.IOException exception) {
            // No FFDC Code Needed.
            ObjectManager.ffdc.processException(this, cclass, methodName, exception, "1:1565:1.40");

            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass,
                           methodName,
                           "via PermanentIOException");
            throw new PermanentIOException(this,
                                           exception);
        } // catch (java.io.IOException exception).

        // We cannot check size as we are subclassed.

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       methodName);
    }
943893
public final void writeObject(java.io.DataOutputStream dataOutputStream)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "writeObject",
                        "DataOutputStream="
                                        + dataOutputStream);

        try {
            dataOutputStream.writeByte(SimpleSerialVersion);
            super.writeObject(dataOutputStream);
            // The owning ConcurrentLinkedlist.
            concurrentListToken.writeObject(dataOutputStream);

        } catch (java.io.IOException exception) {
            // No FFDC Code Needed.
            ObjectManager.ffdc.processException(this, cclass, "witeObject", exception, "1:431:1.23");

            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass
                           , "writeObject"
                           , "via PermanentIOException"
                                );
            throw new PermanentIOException(this,
                                           exception);
        } // catch (java.io.IOException exception).

        // Did we exceed the size limits?
        if (dataOutputStream.size() > maximumSerializedSize())
        {
            if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
                trace.debug(this, cclass
                            , "writeObject"
                            , "maximumSerializedSize()=" + maximumSerializedSize() + "(long)"
                              + "dataOutputStream.size()=" + dataOutputStream.size() + "(int)"
                                );
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass
                           , "writeObject"
                           , "via SimplifiedSerializationSizeException"
                                );
            throw new SimplifiedSerializationSizeException(this,
                                                           maximumSerializedSize(),
                                                           dataOutputStream.size());
        } // if (dataOutputStream.size() > maximumSerializedSize())

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "writeObject");
    }
333427
@Override
    public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)
            throws IOException {
        throw new IOException("Create not supported for EmoFileSystem: " + f);
    }
203399
public static void printWritableRasterData(Raster raster) {
        RandomIter iter = RandomIterFactory.create(raster, null);
        int cols = raster.getWidth();
        int rows = raster.getHeight();
        for (int r = 0; r < rows; r++) {
            for (int c = 0; c < cols; c++) {
                printer.print(iter.getSampleDouble(c, r, 0));
                printer.print(separator);
            }
            printer.println();
        }
        iter.done();
    }
5601
@Override
    public void writeObject(Object object)
        throws IOException
    {
        if (object == null) {
            writeNull();
            return;
        }

        Serializer serializer = findSerializerFactory().getObjectSerializer(object.getClass());

        serializer.writeObject(object, this);
    }