@Override public Element decodeElement(final Element element) throws IllegalArgumentException, MALException { return element.decode(this); }
@Override public void encodeElement(final Element value) throws MALException { checkForNull(value); value.encode(this); }
public static void writeListElement(int index, List srcList, MALElementOutputStream enc) throws MALException { Object e = srcList.get(index); List l = (List) ((Element) srcList).createElement(); l.add(e); enc.writeElement(l, null); }
protected void encodeSubElement(final Element e, final Object sf, final MALEncodingContext ctx) throws MALException { if (null == sf) { // dirty check to see if we are trying to decode an abstract Attribute (and not a list of them either) Object[] finalEleShortForms = null; if (null != ctx) { finalEleShortForms = ctx.getOperation().getOperationStage(ctx.getHeader().getInteractionStage()).getLastElementShortForms(); } if ((null != finalEleShortForms) && (Attribute._URI_TYPE_SHORT_FORM == finalEleShortForms.length) && ((((Long) finalEleShortForms[0]) & 0x800000L) == 0)) { enc.encodeNullableOctet(enc.internalEncodeAttributeType(e.getTypeShortForm().byteValue())); } else { enc.encodeAbstractElementType(e.getShortForm(), true); } // now encode the element enc.encodeElement(e); } else { enc.encodeNullableElement(e); } }
/** * 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); } }
final ByteArrayOutputStream bodyBaos = new ByteArrayOutputStream(); final BinaryEncoder be = new BinaryEncoder(bodyBaos); be.encodeLong(ele.getShortForm()); be.encodeNullableElement(ele); this.obj = bodyBaos.toByteArray();
@Override public void encodeElement(final Element value) throws MALException { checkForNull(value); value.encode(this); }
@Override public Element decodeElement(final Element element) throws IllegalArgumentException, MALException { return element.decode(this); }
notifyLists[i] = (List) ((Element) updateLists[i]).createElement();
@Override public void encodeNullableElement(final Element value) throws MALException { try { if (null != value) { outputStream.addNotNull(); value.encode(this); } else { outputStream.addIsNull(); } } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public Element decodeNullableElement(final Element element) throws MALException { if (sourceBuffer.isNotNull()) { return element.decode(this); } return null; }
@Override public void encodeNullableElement(final Element value) throws MALException { try { if (null != value) { outputStream.addNotNull(); value.encode(this); } else { outputStream.addIsNull(); } } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public Element decodeNullableElement(final Element element) throws MALException { if (sourceBuffer.isNotNull()) { return element.decode(this); } return null; }
@Override public void encodeNullableElement(final Element value) throws MALException { try { if (null != value) { // Initial delim to represent not-null outputStream.addString(""); value.encode(this); } else { outputStream.addIsNull(); } } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public Element decodeNullableElement(final Element element) throws MALException { final String strVal = sourceBuffer.getString(); // Check if object is not null... if (!strVal.equals(STR_NULL)) { return element.decode(this); } return null; }
((Element) element).encode(enc); ((Element) element).encode(enc); case MALPubSubOperation._PUBLISH_REGISTER_STAGE: case MALPubSubOperation._DEREGISTER_STAGE: ((Element) element).encode(enc); return; case MALPubSubOperation._PUBLISH_STAGE: ((Element) element).encode(enc); ((Element) element).encode(enc);