Using Doclets in J2C applications

Adding tags to the Java™ source code in J2C applications allows you to utilize the J2C doclet functionality.

Doclet tags are annotation-programming tags that provide an extensible processing mechanism for generating application artifacts that are ready to be deployed in a J2EE environment. When you add Doclet tags to the Java source code in your J2C application, these artifacts are generated automatically (once you press CTRL-S to save).
Doclet tags are inserted into your Java source as Javadoc-style comments. Attributes of annotation-based programming tags include Scope (where in your code the tag resides) and Multiplicity (how often a tag can be used).

Doclet Tags Supported:

The following types of tags are available to you to add to your Java source code in developing J2C applications:
  1. Scope Scope refers to the location of the tags within the Java source file. Four valid scope options are package, class, method, and field.
    • Package

      Added to the package comment. This scope provides information applicable to the entire Java package, to the module, or to the application as a whole.

    • Class

      Added to the class comment. This scope provides information about the Java type or interface as a whole.

    • Method

      Added to the comments of a particular method within the class. This scope provides information about the referenced method within the class.

    • Field

      Added to the comments of a particular field within the class. This scope provides information specific to the referenced field within the class.

  2. Multiplicity: Multiplicity refers to the number of times a particular tag can appear in one Java source file. In Doclet notation, multiplicity is indicated in parenthesis following the tag name
    • 0..1: indicates that the tag can be used zero or one time in a Java source file.
    • 0..n: indicates that the tag can be used zero to an infinite number of times in a Java source file.
Example: The following example is derived from the IMS™ Multisegment Output tutorial:
  1. In the Project Explorer view, expand your project, expand the Java Resources, and expand the JavaSource section.
  2. Right click on the your package (sample.ims, in this case), and select New > Class to launch the New Class wizard.
  3. Type CCIBuffer as the name of the class. Accept all default settings.
  4. Click Finish, and the CCIBuffer class opens in the Java editor.
  5. In the comment section of the CCIBuffer class, add the tag @type-descriptor.message-buffer, in this way:
    Add doclet tag
  6. Press CTRL-S to save the changes. The following code will be automatically generated in the CCIBuffer.java class file:
    /*
     * Created on Oct 13, 2004
     *
     * TODO To change the template for this generated file go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    package sample.ims;
    
    /**
     * @author ivyho
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     * @type-descriptor.message-buffer
     */
    public class CCIBuffer implements javax.resource.cci.Record,
    		javax.resource.cci.Streamable, com.ibm.etools.marshall.RecordBytes {
    
    	private byte[] buffer_ = null;
    
    	/**
    	 * @generated
    	 */
    	public CCIBuffer() {
    		return;
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#getRecordShortDescription()
    	 */
    	public String getRecordShortDescription() {
    		return (this.getClass().getName());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#hashCode()
    	 */
    	public int hashCode() {
    		return (super.hashCode());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Streamable#write(OutputStream)
    	 */
    	public void write(java.io.OutputStream outputStream)
    			throws java.io.IOException {
    		outputStream.write(buffer_);
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#setRecordShortDescription(String)
    	 */
    	public void setRecordShortDescription(String shortDescription) {
    		return;
    	}
    
    	/**
    	 * @generated
    	 */
    	public int getSize() {
    		if (buffer_ != null)
    			return (buffer_.length);
    		else
    			return (0);
    	}
    
    	/**
    	 * @generated
    	 * @see java.lang.Object#toString
    	 */
    	public String toString() {
    		StringBuffer sb = new StringBuffer(super.toString());
    		sb.append("\n");
    		com.ibm.etools.marshall.util.ConversionUtils.dumpBytes(sb, buffer_);
    		return (sb.toString());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#getRecordName()
    	 */
    	public String getRecordName() {
    		return (this.getClass().getName());
    	}
    
    	/**
    	 * @generated
    	 */
    	public byte[] getBytes() {
    		return (buffer_);
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#clone()
    	 */
    	public Object clone() throws CloneNotSupportedException {
    		return (super.clone());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#setRecordName(String)
    	 */
    	public void setRecordName(String recordName) {
    		return;
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#equals()
    	 */
    	public boolean equals(Object object) {
    		return (super.equals(object));
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Streamable#read(InputStream)
    	 */
    	public void read(java.io.InputStream inputStream)
    			throws java.io.IOException {
    		byte[] input = new byte[inputStream.available()];
    		inputStream.read(input);
    		buffer_ = input;
    	}
    
    	/**
    	 * @generated
    	 */
    	public void setBytes(byte[] bytes) {
    		buffer_ = bytes;
    	}
    
    }
Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.