+
+ Material asMaterial() {
+ return Material.newUserMaterial(type.getORMaterialType(), name, density);
+ }
+
+
+ /**
+ * Special directive to the JAXB system. After the object is parsed from xml,
+ * we replace the '2' with Chars.SQUARED, and '3' with Chars.CUBED. Just the
+ * opposite transformation as doen in beforeMarshal.
+ * @param unmarshaller
+ * @param parent
+ */
+ @SuppressWarnings("unused")
+ private void afterUnmarshal( Unmarshaller unmarshaller, Object parent ) {
+ if (uom != null) {
+ uom = uom.replace('2', Chars.SQUARED);
+ uom = uom.replace('3', Chars.CUBED);
+ }
+ }
+
+ /**
+ * Special directive to the JAXB system. Before the object is serialized into xml,
+ * we strip out the special unicode characters for cubed and squared so they appear
+ * as simple "3" and "2" chars. The reverse transformation is done in afterUnmarshal.
+ * @param marshaller
+ */
+ @SuppressWarnings("unused")
+ private void beforeMarshal( Marshaller marshaller ) {
+ if (uom != null ) {
+ uom = uom.replace(Chars.SQUARED, '2');
+ uom = uom.replace(Chars.CUBED, '3');
+ }
+ }