public class XHTMLUtils extends Object
AttributeValueXHTML.getTheValue()
Modifier and Type | Method and Description |
---|---|
static AttachmentResolver |
createAttachmentResolver(File baseLocation)
Returns an instance of
AttachmentResolver that uses the specified base location
to resolve logical attachment paths to access to file content. |
static Collection<Attachment> |
getAttachments(AttributeValueXHTML value)
Parses all logical attachments contained in the specified XHTML attribute.
|
static Collection<Attachment> |
getAttachments(com.sodius.mdw.core.model.Model model)
Parses all logical attachments contained in all XHTML attributes of the specified Model.
|
static Collection<Attachment> |
getAttachments(String xhtml)
Parses all logical attachments contained in the specified ReqIF XHTML attribute value.
|
static String |
getMimeType(String filename,
String defaultType)
Returns the known MIME type (e.g.
|
static String |
tidy(String xhtml)
Formats the XHTML value to conforms to the ReqIF XHTML specification.
|
static String |
toXHTML(com.sodius.mdw.core.model.RichText text)
Converts the specified rich text into a ReqIF XHTML attribute value.
|
public static String toXHTML(com.sodius.mdw.core.model.RichText text)
text
- the rich text, which may contain XHTML formatting.public static String tidy(String xhtml)
<b>
tag by <strong>
.xhtml
- an XHTML content.public static String getMimeType(String filename, String defaultType)
image/jpeg
) associated with the specified file name,
based on the file extension.filename
- the file name for which MIME type is to be computeddefaultType
- the default MIME type to return, if one cannot be determined for the file namedefaultType
.public static Collection<Attachment> getAttachments(String xhtml)
An attachment might be embedded in an XHTML attribute as in the following snippet:
"<xhtml:html><xhtml:body><xhtml:p>Attachment: <xhtml:object data="myFile.docx"/></xhtml:p></xhtml:body></xhtml:html>"
The attachment content (i.e. the bytes) shall then be obtained with an AttachmentResolver
.
xhtml
- a ReqIF XHTML attribute value.AttachmentResolver
public static Collection<Attachment> getAttachments(AttributeValueXHTML value)
An attachment might be embedded in an XHTML attribute as in the following snippet:
"<xhtml:html><xhtml:body><xhtml:p>Attachment: <xhtml:object data="myFile.docx"/></xhtml:p></xhtml:body></xhtml:html>"
The attachment content (i.e. the bytes) shall then be obtained with an AttachmentResolver
.
value
- an XHTML attribute.AttachmentResolver
public static Collection<Attachment> getAttachments(com.sodius.mdw.core.model.Model model)
An attachment might be embedded in an XHTML attribute as in the following snippet:
"<xhtml:html><xhtml:body><xhtml:p>Attachment: <xhtml:object data="myFile.docx"/></xhtml:p></xhtml:body></xhtml:html>"
The attachment content (i.e. the bytes) shall then be obtained with an AttachmentResolver
.
model
- a ReqIF model.AttachmentResolver
public static AttachmentResolver createAttachmentResolver(File baseLocation)
AttachmentResolver
that uses the specified base location
to resolve logical attachment paths to access to file content.
If the base location is a directory, the resolver will combine this directory and the relative path of an attachment to resolve to a file and access its content. If the base location is a zip file, the resolver will look for entries inside the zip matching the attachment path.
baseLocation
- either a directory or a zip file.