Editing source code using J2C Doclets

You can add to the Java™ source code in J2C applications to utilize the J2C doclet functionality.

Before you begin

Doclet tags are annotation-programming tags that provide an extensible processing mechanism for generating application artifacts that are ready to be deployed in a Java EE environment. When you add doclet tags to the Java source code in your J2C application, these artifacts are generated automatically (after you press CTRL+S to save).

About this task

Doclet tags are inserted into your Java source as Javadoc-style comments. Attributes of annotation-based programming tags include scope (where the tag is in your code) and multiplicity (how often a tag can be used).

Supported doclet tags:

The following types of tags are available to you to add to your Java source code in developing J2C applications:
  • J2C tags
  • Type Descriptor tags:

Doclet Tag Attributes

Procedure

  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.
    Table 1. Scope attributes
    Attributes Definition
    Package Added to the package comment. This scope attribute 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 attribute 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 attribute provides information about the referenced method within the class.
    Field Added to the comments of a particular field within the class. This scope attribute 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
    Table 2. Multiplicity
    Header Header
    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.

Results

Example

Example: The following example is derived from the IMS™ multisegment outputtutorial:
  1. In the Enterprise Explorer view, expand your project, expand the Java Resources, and expand the JavaSource section.
  2. Right click the Java package file (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 is 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;
    	}
    
    }

Feedback