Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.edit.wizards
Class RPGWizardUtil

java.lang.Object
  extended by com.ibm.etools.iseries.edit.wizards.RPGWizardUtil
All Implemented Interfaces:
IISeriesRPGWizardConstants

public class RPGWizardUtil
extends Object
implements IISeriesRPGWizardConstants


Field Summary
static String copyright
           
 
Fields inherited from interface com.ibm.etools.iseries.editor.IISeriesRPGWizardConstants
BIN_IDX, BLANKLINE, CHAR_IDX, CLASSFILE_IMG, CMTLINE, CODEGEN_CURPROC, CODEGEN_CURSOR, CODEGEN_GLOBAL, CODEGENLOC_ALLAFTERCURLINE, CODEGENLOC_ALLINNEW, CODEGENLOC_APPROPRIATE, CONST_NAME_SUFFIX, CONSTANT, CRPG4TYPES, CSPEC_CALLP, CSPEC_EVAL, DATE_IDX, DCMTHDR, DECALLOWED, DEFAULT_CTORNAME_SUFFIX, DEFAULT_FIELDNAME_PREFIX, DEFAULT_FIELDNAME_SUFFIX, DEFAULT_OBJNAME_SUFFIX, DEFAULT_RETURNNAME_SUFFIX, DS, DSPEC_KEYWORDS_INDEX, EXTERNALDS, F, FIELD, FIELDS, FLT_IDX, FOLDERCLOSED_IMG, GRAPHIC_IDX, IND_IDX, INFDS, INT_IDX, INZ_CHAR, INZ_COMMON, INZ_DATE, INZ_EXP, INZ_IND, INZ_LIKEDS, INZ_OBJ, INZ_TIME, INZVALS, JAR_IMG, JAVA_NATURE, LENALLOWED, LINE_BODY, LINE_BODY_FREE, LINE_CLASS_PROTOTYPE, LINE_CONST, LINE_CSPEC, LINE_DS, LINE_DSPEC, LINE_DSPEC_CONST_O, LINE_DSPEC_JMC, LINE_DSPEC_S, LINE_DSPEC_SO, LINE_DSPEC2, LINE_DSPEC3, LINE_EDS, LINE_ESDS, LINE_ESUB, LINE_EUDS, LINE_FIELD, LINE_FIELD_DS, LINE_FREE_BEGIN, LINE_FREE_END, LINE_INTERFACE, LINE_INTERFACE_JMC, LINE_PARAMETER_CODE_HDR, LINE_PARAMETER_HDR, LINE_PISPEC, LINE_PROCBEGIN, LINE_PROCBEGIN_EXPORT, LINE_PROCBEGIN_SERIALIZE, LINE_PROCEDURE_CODE_HDR, LINE_PROCEDURE_CODE_NAME_HDR, LINE_PROCEDURE_CODE_PPS_HDR, LINE_PROCEDURE_CODE_RTN_HDR, LINE_PROCEDURE_HDR, LINE_PROCEDURE_NAME_HDR, LINE_PROCEDURE_PPS_HDR, LINE_PROCEDURE_RTN_HDR, LINE_PROCEND, LINE_PROGRAM_CODE_NAME_HDR, LINE_PROTOTYPE, LINE_PROTOTYPE_EXPORT1, LINE_PROTOTYPE_EXPORT2, LINE_PROTOTYPE_EXPORT3, LINE_PROTOTYPE_HDR, LINE_PROTOTYPE_HDR2, LINE_PROTOTYPE_JMC, LINE_PROTOTYPE_SHORT, LINE_PSPEC, LINE_PSPEC_BEG, LINE_PSPEC_END, LINE_RETFIELD, LINE_RETURN, LINE_RETURN_FREE, LINE_RETURN_HDR, LINE_SDS, LINE_UDS, LONGLINE, MAX_ARRAY_DIMENSION, MAX_CHAR_FIELD_LENGTH, MAX_CHAR_VARY_FIELD_LENGTH, MAX_POSITIONAL_LENGTH, MAX_UCS2_FIELD_LENGTH, MAX_UCS2_VARY_FIELD_LENGTH, MAXLEN, MAXLENGTH, MAXRCD, METHOD_NAME_SUFFIX, MIN_ARRAY_DIMENSION, MIN_CHAR_FIELD_LENGTH, MIN_UCS2_FIELD_LENGTH, MINLEN, MINLENGTH, MINRCD, NUMBERS, OBJ_IDX, PACKED_IDX, PATH_SEP, PCMTHDR, PKG_IMG, PPTR_IDX, PSDS, PSDS_FROM, PTR_IDX, SDS, SHORTLINE, SIMPLEDS, SPEC_COMMENTS_INDEX, SPEC_TYPE_INDEX, T, TIME_IDX, UCS2_IDX, UDS, UNSN_IDX, VARYING, ZONED_IDX
 
Constructor Summary
RPGWizardUtil()
           
 
Method Summary
static void addCommentLineToList(List codeList, char specType, int len, boolean isCursorInFreeForm)
          Add a comment line to the vector of generated code.
static void addDataSetType(Vector procCode, String dsType)
           
static void addDataStructureLength(Vector code, int length)
           
static void addDSpec(Vector code, String prefix, String spec, String attr)
           
static void addKeyword(List code, String keyword)
          Adds keyword to the keyword section of the previous line of code.
static void addKeyword(List code, StringBuffer sb, String keyword, boolean inFreeForm)
          Adds keyword to the keyword section of sb.
static void addKeywords(List code, Collection keywords)
          Adds a list of keywords to the last line in the list code.
static Vector addLikeField(StringBuffer value, String likeField)
           
static void addName(Vector code, INFDSpec dspec)
           
static StringBuffer addNameToSpec(List list, StringBuffer buffer, String name)
          Deprecated. use addNameToSpec(List, String, String) if possible
static void addNameToSpec(List list, String spec, String name)
          adds the spec to the list and returns a new string buffer that is a copy of the last element in the list, after it has been modified (ie returns last line that was generated and added to the list)
static Vector addNameToSpec(Vector vector, String spec, String name)
          Deprecated. use addNameToSpec(List list,String spec,String name) instead
static void addNonFreeFormLineToList(List codeList, String theLine, boolean isCursorInFreeForm)
           
static void addNonFreeFormLineToList(List codeList, StringBuffer theLine, boolean isCursorInFreeForm)
           
static Vector addSubfield(RPGDSpecSubField subfield)
           
static StringBuffer addTypeCodeToLine(StringBuffer prLine, String typeCode)
           
static StringBuffer appendToSB(StringBuffer sb, List codeLines)
           
static Vector combineFieldWithName(Vector code, Vector lenTypeDecs)
           
static Vector configureOptions(StringBuffer options)
           
static RPGKeywordComboEntry createKeywordComboEntry(Composite cmp, ModifyListener listener, String label, boolean readOnly, String[] items, String cmbTooltip)
           
static RPGKeywordComboEntry createKeywordComboEntry(Composite cmp, String label, boolean readOnly, String[] items)
           
static RPGKeywordTextEntry createKeywordEntry(Composite cmp, ModifyListener listener, String label, String tooltipId)
           
static RPGKeywordTextEntry createKeywordEntry(Composite cmp, String label)
           
static RPGKeywordLCComboEntry createKeywordLCComboEntry(Composite cmp, ModifyListener listener, String label, boolean readOnly, String[] items, String cmbTooltip, String specialChars)
           
static RPGKeywordLCComboEntry createKeywordLCComboEntry(Composite cmp, String label, boolean readOnly, String[] items, String specialChars)
           
static RPGKeywordTextComboEntry createKeywordTextComboEntry(Composite cmp, ModifyListener listener, String label, boolean readOnly, String[] items, String txtTooltip, String cmbTooltip)
           
static RPGKeywordTextComboEntry createKeywordTextComboEntry(Composite cmp, String label, boolean readOnly, String[] items)
           
static RPGKeywordLCTextEntry createLCKeywordEntry(Composite cmp, ModifyListener listener, String label, String tooltipId, String specialChars)
           
static RPGKeywordLCTextEntry createLCKeywordEntry(Composite cmp, String label, String specialChars)
           
static int findEnd(LpexView view, int from)
           
static int findEndOfSpec(LpexView view, int from)
           
static int findEndOfSpec(LpexView view, int from, boolean ignoreLinesWithComments)
           
static int findFirstExec(LpexView view, int from)
          returns the line number of the first executable line after from
static int findLast(LpexView view, int from)
           
static boolean genCallCodeProcedureHeader(List procCode, String procedureName, int commentLength)
           
static void genDbInf(INFDSpec dspec, Vector code)
           
static void genDspfattInf(INFDSpec dspec, Vector code)
           
static void genDspfInf(INFDSpec dspec, Vector code)
           
static void genFileInf(INFDSpec dspec, Vector code)
           
static void genIcfattInf(INFDSpec dspec, Vector code)
           
static void genIcfInf(INFDSpec dspec, Vector code)
           
static void genIoInf(INFDSpec dspec, Vector code)
           
static Vector genLongLenTypeDecimals(StringBuffer value, String header)
           
static Vector genLongTextCode(String text, String header)
           
static void genOpenInf(INFDSpec dspec, Vector code)
           
static Vector genOtherKeywords(Vector keywds)
           
static StringBuffer genProtoTypeCodeInfo(StringBuffer prLine, String lentypedecs)
          Deprecated.  
static void genPrtfInf(INFDSpec dspec, Vector code)
           
static Vector genPSDS(PSDSpec dspec)
           
static String genRPGProcedureName(String javaMethodName)
           
static int getByteLength(RPGFieldType field)
          Get the number of bytes of the specified field multiplies the size if it's defind to be an array.
static int getEndOfSubfield(RPGDSpecSubField sf)
           
static int getEndPosition(RPGDSpecSubField sf)
           
static Vector getLengthTypeDecimals(RPGFieldType fieldType)
           
static Vector getLengthTypeDecimals(RPGFieldType fieldType, String dsName)
           
static RPGDSpecSubField getOverlayedSubfieldByName(String name, Vector fields)
           
static String getPackageName(Class c)
          Gets the package name via the fully qualified name of the class, not via the c.getPackage().getName() method
static String getPackageName(String fullyQualifiedClassName)
          Gets the package name via the fully qualified name of the class
static String[] getTooltips(ResourceBundle rb, String key, int count)
           
static String getUnqualifiedName(Class c)
          Handles classes that are arrays; if c is an array, returns unqualified name of c's content type[] Otherwise, returns the same as if you called getUnqualifiedName(String s).
static String getUnqualifiedName(String fullyQualifiedClassName)
          Turns a fully qualified name (as provided by someClass.getName()) into an unqualified name (ie the stuff after the last .); returns fullyQualifiedClassName if no .
static StringBuffer insertNameToSpec(StringBuffer spec, String name, int startIdx)
           
static boolean isCompileTimeData(String text)
           
static boolean isCursorInFreeForm(LpexView view)
           
static boolean isNumeric(RPGFieldType field)
           
static boolean isNumericLiteral(String text)
          check whether the string is a numeric literal
static boolean isOverlayDataStructure(RPGDSpecSubField sf, String dsName)
           
static boolean isOverlaySubfield(RPGDSpecSubField sf, String dsName)
           
static boolean isQuoted(String text)
          check whether or not the string is quoted
static String rightJustify(String input, int newLen, char padChar)
          Helper method to right justify a string padding it with the given character.
static void setFieldToPositionValue(RPGFieldType field)
           
static void setInzItems(RPGFieldType field, RPGKeywordLCComboEntry inz, boolean export)
           
static void setQuickMark(LpexView view)
          Set a quick mark at the position to insert the generated code This method has to be called after setting the LpexDocumentLocation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final String copyright
See Also:
Constant Field Values
Constructor Detail

RPGWizardUtil

public RPGWizardUtil()
Method Detail

createKeywordEntry

public static RPGKeywordTextEntry createKeywordEntry(Composite cmp,
                                                     String label)

createKeywordEntry

public static RPGKeywordTextEntry createKeywordEntry(Composite cmp,
                                                     ModifyListener listener,
                                                     String label,
                                                     String tooltipId)

createLCKeywordEntry

public static RPGKeywordLCTextEntry createLCKeywordEntry(Composite cmp,
                                                         String label,
                                                         String specialChars)

createLCKeywordEntry

public static RPGKeywordLCTextEntry createLCKeywordEntry(Composite cmp,
                                                         ModifyListener listener,
                                                         String label,
                                                         String tooltipId,
                                                         String specialChars)

createKeywordTextComboEntry

public static RPGKeywordTextComboEntry createKeywordTextComboEntry(Composite cmp,
                                                                   String label,
                                                                   boolean readOnly,
                                                                   String[] items)

createKeywordTextComboEntry

public static RPGKeywordTextComboEntry createKeywordTextComboEntry(Composite cmp,
                                                                   ModifyListener listener,
                                                                   String label,
                                                                   boolean readOnly,
                                                                   String[] items,
                                                                   String txtTooltip,
                                                                   String cmbTooltip)

createKeywordComboEntry

public static RPGKeywordComboEntry createKeywordComboEntry(Composite cmp,
                                                           String label,
                                                           boolean readOnly,
                                                           String[] items)

createKeywordComboEntry

public static RPGKeywordComboEntry createKeywordComboEntry(Composite cmp,
                                                           ModifyListener listener,
                                                           String label,
                                                           boolean readOnly,
                                                           String[] items,
                                                           String cmbTooltip)

createKeywordLCComboEntry

public static RPGKeywordLCComboEntry createKeywordLCComboEntry(Composite cmp,
                                                               String label,
                                                               boolean readOnly,
                                                               String[] items,
                                                               String specialChars)

createKeywordLCComboEntry

public static RPGKeywordLCComboEntry createKeywordLCComboEntry(Composite cmp,
                                                               ModifyListener listener,
                                                               String label,
                                                               boolean readOnly,
                                                               String[] items,
                                                               String cmbTooltip,
                                                               String specialChars)

isNumeric

public static boolean isNumeric(RPGFieldType field)

setInzItems

public static void setInzItems(RPGFieldType field,
                               RPGKeywordLCComboEntry inz,
                               boolean export)

isCompileTimeData

public static boolean isCompileTimeData(String text)

genLongTextCode

public static Vector genLongTextCode(String text,
                                     String header)

addDataSetType

public static void addDataSetType(Vector procCode,
                                  String dsType)

addNameToSpec

public static Vector addNameToSpec(Vector vector,
                                   String spec,
                                   String name)
Deprecated. use addNameToSpec(List list,String spec,String name) instead


addNameToSpec

public static void addNameToSpec(List list,
                                 String spec,
                                 String name)
adds the spec to the list and returns a new string buffer that is a copy of the last element in the list, after it has been modified (ie returns last line that was generated and added to the list)

Parameters:
list -
spec -
name -

insertNameToSpec

public static StringBuffer insertNameToSpec(StringBuffer spec,
                                            String name,
                                            int startIdx)

genLongLenTypeDecimals

public static Vector genLongLenTypeDecimals(StringBuffer value,
                                            String header)

getLengthTypeDecimals

public static Vector getLengthTypeDecimals(RPGFieldType fieldType,
                                           String dsName)

getLengthTypeDecimals

public static Vector getLengthTypeDecimals(RPGFieldType fieldType)

rightJustify

public static String rightJustify(String input,
                                  int newLen,
                                  char padChar)
Helper method to right justify a string padding it with the given character. If given string is too short, it is truncated


addLikeField

public static Vector addLikeField(StringBuffer value,
                                  String likeField)

genOtherKeywords

public static Vector genOtherKeywords(Vector keywds)

combineFieldWithName

public static Vector combineFieldWithName(Vector code,
                                          Vector lenTypeDecs)

configureOptions

public static Vector configureOptions(StringBuffer options)

addKeywords

public static void addKeywords(List code,
                               Collection keywords)
Adds a list of keywords to the last line in the list code.

Parameters:
code -
keywords -

addKeyword

public static void addKeyword(List code,
                              String keyword)
Adds keyword to the keyword section of the previous line of code. If there already was a keyword in that previous line, a new line will be added to the end of the list (with the same spectype as the last line) and the keyword will be added to this new line instead. If the line that the keyword is being added to does not have enough space, the keyword will continue to a new spec that is of the same spec type as the previous line. Cavaets:
  • This function was designed for DSpec; use for other specs at own risk!
  • If you have words that cannot be split mid word using ... (ie *xxx), then you should place a space before and after that word
  • Parameters:
    code - the list of generated code
    keyword - the keyword string to add

    addKeyword

    public static void addKeyword(List code,
                                  StringBuffer sb,
                                  String keyword,
                                  boolean inFreeForm)
    Adds keyword to the keyword section of sb.

    Parameters:
    code -
    sb -
    keyword -

    genFileInf

    public static void genFileInf(INFDSpec dspec,
                                  Vector code)

    addName

    public static void addName(Vector code,
                               INFDSpec dspec)

    addDSpec

    public static void addDSpec(Vector code,
                                String prefix,
                                String spec,
                                String attr)

    genOpenInf

    public static void genOpenInf(INFDSpec dspec,
                                  Vector code)

    genIoInf

    public static void genIoInf(INFDSpec dspec,
                                Vector code)

    genPrtfInf

    public static void genPrtfInf(INFDSpec dspec,
                                  Vector code)

    genDspfInf

    public static void genDspfInf(INFDSpec dspec,
                                  Vector code)

    genIcfInf

    public static void genIcfInf(INFDSpec dspec,
                                 Vector code)

    genDbInf

    public static void genDbInf(INFDSpec dspec,
                                Vector code)

    genDspfattInf

    public static void genDspfattInf(INFDSpec dspec,
                                     Vector code)

    genIcfattInf

    public static void genIcfattInf(INFDSpec dspec,
                                    Vector code)

    genPSDS

    public static Vector genPSDS(PSDSpec dspec)

    addSubfield

    public static Vector addSubfield(RPGDSpecSubField subfield)
    Parameters:
    code - the main Vector to contain generated code
    subfield - the subfield to be added of the generated data structure
    Returns:

    setFieldToPositionValue

    public static void setFieldToPositionValue(RPGFieldType field)
    Parameters:
    subfield -
    field -

    getByteLength

    public static int getByteLength(RPGFieldType field)
    Get the number of bytes of the specified field multiplies the size if it's defind to be an array.

    Parameters:
    field - a field of type RPGFieldType
    Returns:
    the total byte length of the specified field

    isOverlaySubfield

    public static boolean isOverlaySubfield(RPGDSpecSubField sf,
                                            String dsName)

    isOverlayDataStructure

    public static boolean isOverlayDataStructure(RPGDSpecSubField sf,
                                                 String dsName)

    getEndPosition

    public static int getEndPosition(RPGDSpecSubField sf)

    getEndOfSubfield

    public static int getEndOfSubfield(RPGDSpecSubField sf)

    findEndOfSpec

    public static int findEndOfSpec(LpexView view,
                                    int from)

    findEndOfSpec

    public static int findEndOfSpec(LpexView view,
                                    int from,
                                    boolean ignoreLinesWithComments)

    findEnd

    public static int findEnd(LpexView view,
                              int from)

    findLast

    public static int findLast(LpexView view,
                               int from)

    findFirstExec

    public static int findFirstExec(LpexView view,
                                    int from)
    returns the line number of the first executable line after from

    Parameters:
    view - the view to search
    from - the line to search from
    Returns:
    the first executable line, if there is none, returns from

    getPackageName

    public static String getPackageName(Class c)
    Gets the package name via the fully qualified name of the class, not via the c.getPackage().getName() method

    Parameters:
    c -
    Returns:

    getPackageName

    public static String getPackageName(String fullyQualifiedClassName)
    Gets the package name via the fully qualified name of the class

    Parameters:
    fullyQualifiedClassName - Fully qualified class name of the class that you want the package name of
    Returns:

    getUnqualifiedName

    public static String getUnqualifiedName(String fullyQualifiedClassName)
    Turns a fully qualified name (as provided by someClass.getName()) into an unqualified name (ie the stuff after the last .); returns fullyQualifiedClassName if no .

    Parameters:
    fullyQualifiedClassName -
    Returns:

    getUnqualifiedName

    public static String getUnqualifiedName(Class c)
    Handles classes that are arrays; if c is an array, returns unqualified name of c's content type[] Otherwise, returns the same as if you called getUnqualifiedName(String s). Use this if you have a class so arrays can be displayed nicely.

    Parameters:
    c -
    Returns:

    addCommentLineToList

    public static void addCommentLineToList(List codeList,
                                            char specType,
                                            int len,
                                            boolean isCursorInFreeForm)
    Add a comment line to the vector of generated code. The comment line is all dashes to the given length. The spec type must be given (eg 'D')


    addNameToSpec

    public static StringBuffer addNameToSpec(List list,
                                             StringBuffer buffer,
                                             String name)
    Deprecated. use addNameToSpec(List, String, String) if possible

    Adds a field name to an RPG spec, continuing the name if its too big


    genProtoTypeCodeInfo

    public static StringBuffer genProtoTypeCodeInfo(StringBuffer prLine,
                                                    String lentypedecs)
    Deprecated. 

    Helper method to insert native RPG return type information into prototype line


    addTypeCodeToLine

    public static StringBuffer addTypeCodeToLine(StringBuffer prLine,
                                                 String typeCode)

    genRPGProcedureName

    public static String genRPGProcedureName(String javaMethodName)

    genCallCodeProcedureHeader

    public static boolean genCallCodeProcedureHeader(List procCode,
                                                     String procedureName,
                                                     int commentLength)

    appendToSB

    public static StringBuffer appendToSB(StringBuffer sb,
                                          List codeLines)

    getTooltips

    public static String[] getTooltips(ResourceBundle rb,
                                       String key,
                                       int count)

    isCursorInFreeForm

    public static boolean isCursorInFreeForm(LpexView view)
    Parameters:
    view -
    Returns:
    true if the cursor is in a freeform section; false otherwise

    setQuickMark

    public static void setQuickMark(LpexView view)
    Set a quick mark at the position to insert the generated code This method has to be called after setting the LpexDocumentLocation.

    Parameters:
    view - the LPEX editor view to hold the specified file

    addDataStructureLength

    public static void addDataStructureLength(Vector code,
                                              int length)
    Parameters:
    code -
    i -

    addNonFreeFormLineToList

    public static void addNonFreeFormLineToList(List codeList,
                                                StringBuffer theLine,
                                                boolean isCursorInFreeForm)

    addNonFreeFormLineToList

    public static void addNonFreeFormLineToList(List codeList,
                                                String theLine,
                                                boolean isCursorInFreeForm)

    getOverlayedSubfieldByName

    public static RPGDSpecSubField getOverlayedSubfieldByName(String name,
                                                              Vector fields)

    isQuoted

    public static boolean isQuoted(String text)
    check whether or not the string is quoted

    Parameters:
    text - the text to check
    Returns:
    true if the string starts with a single quote and ends with a single quote
    Since:
    5.1.2

    isNumericLiteral

    public static boolean isNumericLiteral(String text)
    check whether the string is a numeric literal

    Parameters:
    text - the string to check
    Returns:
    true if the string is numeric, false otherwise
    Since:
    5.1.2

    Rational Developer for Power Systems Software
    V7.6

    Copyright © 2011 IBM Corp. All Rights Reserved.

    Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.