Java Tutorial

Creating a Rule Set

Rule Sets provide Globalyzer with the specific instructions needed to analyze source code and report internationalization problems. In this lesson, you will create a new Rule Set for scanning Java source code.

  1. From your Home Page on the server, select Create Rule Set. The Create Rule Set page appears.

  2. Fill in the fields as follows :

    • Enter my_ruleset in the Name field.
    • Select java from the Language-Variant dropdown menu.
    • Leave the Shared checkbox unchecked to indicate that this rule set won't be shared with other team members.

  3. Click Create. The Customize Rule Set page appears, for the newly created Rule Set, my_ruleset

    The rule set my_ruleset can be configured from this page.

    Each rule set consists of the file extension configuration and four types of rules: Embedded String Scan Rules, Locale-Sensitive Method Scan Rules, General Pattern Scan Rules, and Static File Reference Scan Rules.

  4. Click the File Extensions link just to the right of the Detection Rules label under Source File Extensions. The Edit File Extensions for my_ruleset page appears.

    Globalyzer will only scan source files that have the listed extensions; all other file types will be ignored.

    Notice that the extensions java, jsp, jspf, and jspx are already listed and selected. This is because you picked java as the programming language for your Rule Set. Unless your application uses non-standard source file extensions, it is usually not necessary to modify the default File Extensions that Globalyzer provides.

    If you do need to add an extension, click on New File Extension in the middle of the screen above the list of extensions. This will display the Create File Extension for my_ruleset page. You can also uncheck a default extension if you want Globalyzer to ignore those source files.

  5. Click on the Back to Summary link to return to the previous page.

    In addition to the file extensions, there are four scan rules (Embedded String Scan Rules, Locale-Sensitive Method Scan Rules, General Pattern Scan Rules, and Static File Reference Scan Rules). They are each divided into two categories. Embedded Strings have Filtering Rules and Retention Rules; the other three categories have Detection Rules and Filtering Rules.

    Detection Rules and Retention Rules specify conditions that the Globalyzer source code scanner will detect in your source code and report to you. For instance, click the Locale-Sensitive Methods link under to Locale-Sensitive Method Scan Rules, to the right of Detection Rules.

    By default, for the Java language, there are seven method groups under that heading. By clicking on New Locale-Sensitive Method Group, another method group can be added to the default set.

    The Enabled checkbox's for these groups allows the user to enable or disable a set of methods all at once rather than checking or unchecking individual methods within each group.


    Note: If you are a Demo User, you will not be able to view the Locale-Sensitive Methods. Please contact Lingoport at sales@lingoport.com for a more thorough evaluation.
  6. Click on the Collation method group link.

    The screen capture below shows the default methods in that group; the Collator.getInstance method is listed. If this method is detected in your Java source code the scanner will report it to you. Globalyzer provides custom help for most locale-sensitive methods: Click on the Help Page for the method for a description of specific internationalization issues associated with Collator.getInstance.

  7. Click Back to Summary to return to the previous page.

    Filtering Rules specify conditions that the scanner will overlook. For instance, Globalyzer detects embedded strings. However, there may be methods or functions in your source that are passed string arguments that you know do not pose internationalization problems, as they will not be displayed to the user.

    Click String Method Filters located under Embedding String Scan Rules, to the right of Filtering Rules. Look for the filter named HTTP Parameter. The method getParameter is listed because

    javax.servlet.ServletRequestWrapper.getParameter(String s)

    takes a string argument, but this string would never appear as text visible to a user in a User Interface. Therefore, getParameter is listed as a String Method Filter by default. When Globalyzer detects an embedded string during the string scanning process, before reporting it as an issue, it will first check to make sure that it is not an argument passed into any of the methods in this list.

  8. Click Back to Summary to return to the previous page.

    One important concept when creating rule sets is the idea of Inheritance. Much like the concept of inheritance in Java methods, you can create rule sets that inherit the properties of their "parent rule sets". This is done by the use of the Extend link at the bottom of the page. Click it to create an inherited rule set.

    This allows for easy creation of related rule sets that may differ slightly, but are applied to related projects. For example, if you assign a team to scan code related to one particular application in a whole suite of applications, they can use an inherited rule set to make edits that are necessary for that application, but their edits will not affect the parent rule set from which it was derived.

    Name your extended, or "child" rule set: my_ruleset_extended. Click Save to create the extended rule set.

    We will return to this rule set in the next step of the tutorial. For now, return to your original my_ruleset. A more detailed example, as well as additional reference on inheritance can be found in the reference section of the Globalyzer Help.

Take a few minutes to examine (but not change) the other rules, such as General Pattern Scan Rules or Static File Reference Scan Rules by clicking the links to the right of Detection Rules or Filtering Rules.

In the next lesson, you will edit the Rule Set to further refine the scanner's capabilities.