/** * Generates the corresponding MAL Element from a certain MAL Element List * * @param obj The MAL Element List * @return The MAL Element * @throws java.lang.Exception */ public static Element elementList2element(ElementList obj) throws Exception { if (obj == null) { return null; } long l = obj.getShortForm(); long ll = (-((l) & 0xFFFFFFL)) & 0xFFFFFFL + (l & 0xFFFFFFFFFF000000L); MALElementFactory eleFact = MALContextFactory.getElementFactoryRegistry().lookupElementFactory(ll); if (eleFact == null) { Logger.getLogger(HelperMisc.class.getName()).log(Level.SEVERE, "The element could not be found in the MAL ElementFactory! The object type is: '" + obj.getClass().getSimpleName() + "'. Maybe the service Helper for this object was not initialized. " + "Try initializing the Service Helper of this object."); } return (Element) eleFact.createElement(); }
/** * Generates the corresponding MAL Element List from a certain MAL Element * * @param obj The MAL Element * @return The MAL Element List * @throws java.lang.Exception */ public static ElementList element2elementList(Object obj) throws Exception { if (obj == null) { return null; } if (obj instanceof Element) { long l = ((Element) obj).getShortForm(); long ll = (-((l) & 0xFFFFFFL)) & 0xFFFFFFL + (l & 0xFFFFFFFFFF000000L); MALElementFactory eleFact = MALContextFactory.getElementFactoryRegistry().lookupElementFactory(ll); if (eleFact == null) { Logger.getLogger(HelperMisc.class.getName()).log(Level.SEVERE, "The element could not be found in the MAL ElementFactory! The object type is: '" + obj.getClass().getSimpleName() + "'. Maybe the service Helper for this object was not initialized. " + "Try initializing the Service Helper of this object."); } return (ElementList) eleFact.createElement(); } else { return HelperAttributes.generateElementListFromJavaType(obj); } }
public Object getObject() { Element elem = null; if (this.obj != null) { try { final BinaryDecoder binDec = new BinaryDecoder(this.obj); final MALElementFactory eleFact = MALContextFactory.getElementFactoryRegistry().lookupElementFactory(binDec.decodeLong()); elem = binDec.decodeNullableElement((Element) eleFact.createElement()); } catch (MALException ex) { Logger.getLogger(COMObjectEntity.class.getName()).log(Level.SEVERE, "The object body could not be decoded! Usually happens when there's " + "an update in the APIs. (1) " + this.toString(), ex); } catch (IllegalArgumentException ex) { Logger.getLogger(COMObjectEntity.class.getName()).log(Level.SEVERE, "The object body could not be decoded! Usually happens when there's " + "an update in the APIs. (2) " + this.toString(), ex); } catch (Exception ex) { Logger.getLogger(COMObjectEntity.class.getName()).log(Level.SEVERE, "The object body could not be decoded! Usually happens when there's " + "an update in the APIs. (3) " + this.toString(), ex); } } return HelperAttributes.attribute2JavaType(elem); }
protected Object decodeSubElement(final Long shortForm, final MALEncodingContext ctx) throws MALException { if (null == shortForm) { return null; } final MALElementFactory ef = MALContextFactory.getElementFactoryRegistry().lookupElementFactory(shortForm); if (null == ef) { throw new MALException("GEN transport unable to find element factory for short type: " + shortForm); } return dec.decodeElement((Element) ef.createElement()); } }
if (null != ef) element = (Element) ef.createElement();
/** * Decodes a single part of the message body. * * @param meel The encoded element list. * @return The decoded chunk. * @throws MALException if any error detected. */ protected Object decodeEncodedElementListBodyPart(final MALEncodedElementList meel) throws MALException { long sf = (Long) meel.getShortForm(); final MALElementFactory ef = MALContextFactory.getElementFactoryRegistry().lookupElementFactory(sf); if (null == ef) { throw new MALException("GEN transport unable to find element factory for short type: " + sf); } // create list of correct type long lsf = (-((sf) & 0xFFFFFFL)) & 0xFFFFFFL + (sf & 0xFFFFFFFFFF000000L); ElementList rv = (ElementList) MALContextFactory.getElementFactoryRegistry().lookupElementFactory(lsf).createElement(); for (MALEncodedElement ele : meel) { final ByteArrayInputStream lbais = new ByteArrayInputStream(ele.getEncodedElement().getValue()); MALElementInputStream lenc = encFactory.createInputStream(lbais); rv.add(lenc.readElement(ef.createElement(), ctx)); } return rv; }
final BinaryDecoder binDec = new BinaryDecoder(blob.getValue()); final MALElementFactory eleFact = MALContextFactory.getElementFactoryRegistry().lookupElementFactory(binDec.decodeLong()); elem = binDec.decodeNullableElement((Element) eleFact.createElement()); } catch (MALException ex) { Logger.getLogger(COMObjectEntity.class.getName()).log(Level.SEVERE,