All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.com.ibm.as400.access.WriterJob Maven / Gradle / Ivy

There is a newer version: 11.1
Show newest version
///////////////////////////////////////////////////////////////////////////////
//                                                                             
// JTOpen (IBM Toolbox for Java - OSS version)                              
//                                                                             
// Filename: WriterJob.java
//                                                                             
// The source code contained herein is licensed under the IBM Public License   
// Version 1.0, which has been approved by the Open Source Initiative.         
// Copyright (C) 1997-2000 International Business Machines Corporation and     
// others. All rights reserved.                                                
//                                                                             
///////////////////////////////////////////////////////////////////////////////

package com.ibm.as400.access;

import java.io.IOException;

/**
 * The WriterJob class represents a writer job.
 * An instance of this class can be used to manipulate an individual
 * writer.  Use the start method to obtain a instance of this class.
 *
 * See Writer Job Attributes for
 * valid attributes.
 *
 **/

public class WriterJob extends PrintObject
{
    private static final String copyright = "Copyright (C) 1997-2000 International Business Machines Corporation and others.";
    
    static final long serialVersionUID = 4L;

    // We have decided that writer jobs are too transient to
    // be a JavaBean.

    // constructor used internally (not externalized since it takes
    // an ID code point
    WriterJob(AS400 system, NPCPIDWriter id, NPCPAttribute attrs)
    {
       super(system, id, attrs, NPConstants.WRITER_JOB);
    }



    // A1A - Added chooseImpl() method
    /**
     * Chooses the appropriate implementation.
     **/
    void chooseImpl()
    throws IOException, AS400SecurityException
    {
        // We need to get the system to connect to...
        AS400 system = getSystem();
        if (system == null) {
            Trace.log( Trace.ERROR, "Attempt to use WriterJob before setting system." );
            throw new ExtendedIllegalStateException("system",
                                    ExtendedIllegalStateException.PROPERTY_NOT_SET);
        }

        impl_ = (WriterJobImpl) system.loadImpl2("com.ibm.as400.access.WriterJobImplRemote",
                                                 "com.ibm.as400.access.WriterJobImplProxy");
        super.setImpl();
    }



    /**
     * Ends a writer on the system.
     *
     * @param endType When to end the writer.
     *  May be any of the following values:
     * 
    *
  • *CNTRLD - The writer is ended at the end of the current spooled file. *
  • *IMMED - The writer is ended immediately. *
  • *PAGEEND - The writer is ended at the end of the current page. *
* endType may be null. If endType is not specified, the default is * *IMMED. * * @exception AS400Exception If the system returns an error message. * @exception AS400SecurityException If a security or authority error occurs. * @exception ErrorCompletingRequestException If an error occurs before the request is completed. * @exception IOException If an error occurs while communicating with the system. * @exception InterruptedException If this thread is interrupted. * @exception RequestNotSupportedException If the requested function is not supported because the * system operating system is not at the correct level. **/ public void end(String endType) throws AS400Exception, AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException, RequestNotSupportedException { if (impl_ == null) chooseImpl(); ((WriterJobImpl) impl_).end(endType); } // end end /** * Returns the name of the writer. * * @return The name of the writer. **/ public String getName() { NPCPID IDCodePoint = getIDCodePoint(); if( IDCodePoint == null ) { return EMPTY_STRING; // "" } else { return IDCodePoint.getStringValue(ATTR_WTRJOBNAME); } } /** * Starts a writer on the system. * Use this method to start a new writer job on the given system * with the specified parameters. * @param system The system on which to start the writer job. * @param printer The printer that should be used * to start the writer job. This printer * must reside on the same system that the * writer job is being started on. * @param options Optional. A print parameter list that contains * a list of attributes to start the writer job. * The output queue parameters set in this list override the * output queue parameter. * The following parameters may be set: * *
* * @param outputQueue Optional. The output queue to start the * writer job. The output queue must reside on * the same system that the writer job * is being created on. * * @return A writer job object that was created. * * @exception AS400Exception If the system returns an error message. * @exception AS400SecurityException If a security or authority error occurs. * @exception ErrorCompletingRequestException If an error occurs before the request is completed. * @exception IOException If an error occurs while communicating with the system. * @exception InterruptedException If this thread is interrupted. **/ public static WriterJob start(AS400 system, Printer printer, PrintParameterList options, OutputQueue outputQueue) throws AS400Exception, AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException { // note: This is a static method // First check the required parameters of system and printer if (system == null) { Trace.log(Trace.ERROR, "Parameter 'system' is null."); throw new NullPointerException("system"); } if (printer == null) { Trace.log(Trace.ERROR, "Parameter 'printer' is null."); throw new NullPointerException("printer"); } if (printer.getImpl() == null) { printer.chooseImpl(); } OutputQueueImpl oqi = null; if (outputQueue != null) { if (outputQueue.getImpl() == null) { outputQueue.chooseImpl(); } oqi = (OutputQueueImpl) outputQueue.getImpl(); } WriterJobImpl impl = (WriterJobImpl) system.loadImpl2("com.ibm.as400.access.WriterJobImplRemote", "com.ibm.as400.access.WriterJobImplProxy"); // Changed below line to send in the Impls, and receive the // NPCPIDWriter instead of a WriterJob NPCPIDWriter cpWriterID = ((WriterJobImpl) impl).start(system.getImpl(), (PrintObjectImpl) printer.getImpl(), options, oqi); return new WriterJob(system, cpWriterID, null); } // end start } // end WriterJob class




© 2015 - 2024 Weber Informatics LLC | Privacy Policy