/** * Sets the nested xml content of this element. */ public void setXmlContent(Element content) { addElement(content); }
/** * Gets the nested xml content of this element. This will return the first * xml element found inside this content. */ public Element getXmlContent() { Iterator<Element> iter = getElementIterator(); if (iter.hasNext()) { return iter.next(); } return null; }
/** @return the type of this content */ @Override public int getType() { if (getXml() != null || getXmlContent() != null) { return IContent.Type.OTHER_XML; } if (getMimeType().getMediaType().equals("text")) { return IContent.Type.OTHER_TEXT; } return IContent.Type.OTHER_BINARY; }
@Override protected void validate(ElementMetadata<?, ?> metadata, ValidationContext vc) { super.validate(metadata, vc); int maximumChildren = hasTextValue() ? 0 : 1; if (getElementCount() > maximumChildren) { vc.addError(this, "Content cannot contain more than " + maximumChildren + " child elements, but contains " + getElementCount()); } } }
/** @return the binary contents */ public byte[] getBytes() { String value = getText(); try { return value == null ? null : Base64.decode(value); } catch (Base64DecoderException e) { throw new IllegalStateException("Value was not base64 encoded: " + value); } }
/** @return the plain text contents */ public String getText() { return getTextValue(KEY); }
OtherContent.registerMetadata(registry); OutOfLineContent.registerMetadata(registry);
@Override protected void validate(ElementMetadata<?, ?> metadata, ValidationContext vc) { super.validate(metadata, vc); int maximumChildren = hasTextValue() ? 0 : 1; if (getElementCount() > maximumChildren) { vc.addError(this, "Content cannot contain more than " + maximumChildren + " child elements, but contains " + getElementCount()); } } }
/** @return the binary contents */ public byte[] getBytes() { String value = getText(); try { return value == null ? null : Base64.decode(value); } catch (Base64DecoderException e) { throw new IllegalStateException("Value was not base64 encoded: " + value); } }
/** @return the plain text contents */ public String getText() { return getTextValue(KEY); }
OtherContent.registerMetadata(registry); OutOfLineContent.registerMetadata(registry);
/** @return the type of this content */ @Override public int getType() { if (getXml() != null || getXmlContent() != null) { return IContent.Type.OTHER_XML; } if (getMimeType().getMediaType().equals("text")) { return IContent.Type.OTHER_TEXT; } return IContent.Type.OTHER_BINARY; }
@Override protected void validate(ElementMetadata<?, ?> metadata, ValidationContext vc) { super.validate(metadata, vc); int maximumChildren = hasTextValue() ? 0 : 1; if (getElementCount() > maximumChildren) { vc.addError(this, "Content cannot contain more than " + maximumChildren + " child elements, but contains " + getElementCount()); } } }
/** * Sets the nested xml content of this element. */ public void setXmlContent(Element content) { addElement(content); }
/** * Gets the nested xml content of this element. This will return the first * xml element found inside this content. */ public Element getXmlContent() { Iterator<Element> iter = getElementIterator(); if (iter.hasNext()) { return iter.next(); } return null; }
/** @return the binary contents */ public byte[] getBytes() { String value = getText(); try { return value == null ? null : Base64.decode(value); } catch (Base64DecoderException e) { throw new IllegalStateException("Value was not base64 encoded: " + value); } }
/** @return the plain text contents */ public String getText() { return getTextValue(KEY); }
OtherContent.registerMetadata(registry); OutOfLineContent.registerMetadata(registry);
/** @return the type of this content */ @Override public int getType() { if (getXml() != null || getXmlContent() != null) { return IContent.Type.OTHER_XML; } if (getMimeType().getMediaType().equals("text")) { return IContent.Type.OTHER_TEXT; } return IContent.Type.OTHER_BINARY; }
/** * Sets the nested xml content of this element. */ public void setXmlContent(Element content) { addElement(content); }