When trimming spaces, skip read-only attributes.
Check for read-only object as well. Thanks, Johann!
Merge pull request #495 from fbarthez/DontTrimReadOnly

When trimming spaces, skip read-only attributes.
some optimizations for #495
use StringBuilder instead of StringBuffer
remove unnecessary brackets around StringBuilder constructor
pass char instead of String to StringBuilder/StringBuffer where appropriate
small optimization