...
Tracing is commonly found in application code. It will usually look like:
Code Block | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
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> <body> This is my XML document: &lt;xmldoc&gt; &lt;data/&gt; &lt;/xmldoc&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 "<<" and corresponding ">>" 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 " " (done by org.jasig.portal.serialize.BaseMarkupSerializer.printEscaped(int)
.
...