Class XMLFormatter
- java.lang.Object
-
- org.intermine.webservice.server.output.Formatter
-
- org.intermine.webservice.server.output.XMLFormatter
-
- Direct Known Subclasses:
HTMLTableFormatter
,UserDataFormatter
public class XMLFormatter extends Formatter
Formats data to XML format.- Author:
- Jakub Kulaviak
-
-
Constructor Summary
Constructors Constructor Description XMLFormatter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addElement(java.lang.StringBuilder sb, java.lang.String tag, java.lang.String contents)
Add an element with some content.protected java.lang.String
escapeAttribute(java.lang.Object attr)
protected java.lang.String
escapeElementContent(java.lang.String contents)
Escape the content of an element.java.lang.String
formatFooter(java.lang.String errorMessage, int errorCode)
Returns formatted footer.java.lang.String
formatHeader(java.util.Map<java.lang.String,java.lang.Object> attributes)
Returns formatted header.java.lang.String
formatResult(java.util.List<java.lang.String> resultRow)
Returns formatted result item.protected java.lang.String
getCauseElement()
protected java.lang.String
getErrorElement()
protected java.lang.String
getItemElement()
protected java.lang.String
getMessageElement()
protected java.lang.String
getProcessingInstruction()
protected java.lang.String
getRootElement()
protected java.lang.String
getRowElement()
protected void
handleHeaderAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.StringBuilder sb)
Serialise the headers to the current string builder.protected java.lang.String
popTag()
Say that we are finished with the current tag.protected void
pushTag(java.lang.String tag)
Set the current tag we are working within.
-
-
-
Method Detail
-
pushTag
protected void pushTag(java.lang.String tag)
Set the current tag we are working within.- Parameters:
tag
- The tag.
-
popTag
protected java.lang.String popTag()
Say that we are finished with the current tag.- Returns:
- What that tag was.
-
getRootElement
protected java.lang.String getRootElement()
- Returns:
- the root element of the document
-
getRowElement
protected java.lang.String getRowElement()
- Returns:
- the name of the tag for each row
-
getItemElement
protected java.lang.String getItemElement()
- Returns:
- the name of the tag for each item
-
getErrorElement
protected java.lang.String getErrorElement()
- Returns:
- the name of the tag when rendering an error
-
getMessageElement
protected java.lang.String getMessageElement()
- Returns:
- the name of the tag for showing a message
-
getCauseElement
protected java.lang.String getCauseElement()
- Returns:
- the name of the tag for rendering the cause of an error
-
getProcessingInstruction
protected java.lang.String getProcessingInstruction()
- Returns:
- an XML processing instruction, if any
-
formatHeader
public java.lang.String formatHeader(java.util.Map<java.lang.String,java.lang.Object> attributes)
Description copied from class:Formatter
Returns formatted header.- Specified by:
formatHeader
in classFormatter
- Parameters:
attributes
- attributes contained in header- Returns:
- formatted header
-
handleHeaderAttributes
protected void handleHeaderAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, java.lang.StringBuilder sb)
Serialise the headers to the current string builder.- Parameters:
attributes
- The headerssb
- The string builder.
-
escapeAttribute
protected java.lang.String escapeAttribute(java.lang.Object attr)
- Parameters:
attr
- an attribute to escape.- Returns:
- The escaped representation.
-
formatResult
public java.lang.String formatResult(java.util.List<java.lang.String> resultRow)
Returns formatted result item.}- Specified by:
formatResult
in classFormatter
- Parameters:
resultRow
- result row- Returns:
- formatted result row
-
addElement
protected void addElement(java.lang.StringBuilder sb, java.lang.String tag, java.lang.String contents)
Add an element with some content.- Parameters:
sb
- The current string builder.tag
- The tag to add.contents
- The content to add.
-
escapeElementContent
protected java.lang.String escapeElementContent(java.lang.String contents)
Escape the content of an element.- Parameters:
contents
- The content to escape.- Returns:
- The escaped representation.
-
formatFooter
public java.lang.String formatFooter(java.lang.String errorMessage, int errorCode)
Description copied from class:Formatter
Returns formatted footer.- Specified by:
formatFooter
in classFormatter
- Parameters:
errorMessage
- The error message, if sth went wrong.errorCode
- The error code, if sth went wrong.- Returns:
- formatted footer
-
-