Kenny MacLeod wrote:
> My question is whether there is a hidden option in the RI somewhere
> which will automatically intern the strings for me, removing the need to
> attach these type adapters all over the shop.
You can intern your unmarshalled strings with a simple global
customization where you override the standard parse method.
<jaxb:globalBindings>
<jaxb:javaType name="String"
xmlType="xsd:string"
parseMethod="faststring.StringInterner.parseStringToString"/>
</jaxb:globalBindings>
Here's the class StringInterner:
package faststring;
import javax.xml.bind.DatatypeConverter;
public class StringInterner {
public static String parseStringToString( String value ){
return DatatypeConverter.parseString( value ).intern();
}
}
I'm using 1.6.0_03.
Cheers
Wolfgang