Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tracing is commonly found in application code. It will usually look like:

Code Block
java
java

for (Enumerator e = users.getEnumeration(); e.hasMoreElements(); ) {
    User user = (User) e.nextElement();
    log.debug("user: " + user +
                    ", account: " + accounts.get(user) +
                   ", classes: " + classes.get(user));
    // business logic...
}

...

A more GC-friendly approach is to wrap all log requests (not just debug) with a conditional:

Code Block
java
java


for (Enumerator e = users.getEnumeration(); e.hasMoreElements(); ) {
    User user = (User) e.nextElement();
    if (log.isDebugEnabled()) {
        log.debug("user: " + user + 
                       ", account: " + accounts.get(user) +
                       ", classes: " + classes.get(user));
    }
    // business logic...

...

Entities are generally used in XML (and HTML) to allow special characters to exist within an XML document. For example:

Code Block
html
html
   <html>
       <body>
           This is my XML document:
               &amp;lt;xmldoc&amp;gt;
                      &amp;lt;data/&amp;gt;
               &amp;lt;/xmldoc&amp;gt;
       </body>
    </html>

If "<xmldoc>" had been placed in the body of the document, it would have caused a parsing exception since "<xmldoc>" is not a valid HTML element. The "&lt;<" and corresponding "&gt;>" are necessary for successful parsing.

...

When loading the file, all entities are stored in a HashMap keyed on an Integer object of the entity value. So, map.get(new Integer(160)) will return a String object value "nbsp" and when writing the character, would be replaced by "&nbsp; " (done by org.jasig.portal.serialize.BaseMarkupSerializer.printEscaped(int).

...