// 262135 - NPE during format of empty document
if (node == null)
return null;
short nodeType = ((Node) node).getNodeType();
IStructuredFormatter formatter = null;
switch (nodeType) {
case Node.ELEMENT_NODE : {
formatter = new ElementNodeFormatter();
break;
}
case Node.TEXT_NODE : {
formatter = new TextNodeFormatter();
break;
}
case Node.CDATA_SECTION_NODE : {
formatter = new NoMoveFormatter();
break;
}
case Node.COMMENT_NODE : {
formatter = new CommentNodeFormatter();
break;
}
case Node.PROCESSING_INSTRUCTION_NODE : {
formatter = new NodeFormatter();
break;
}
case Node.DOCUMENT_NODE : {
formatter = new DocumentNodeFormatter();
break;
}
case Node.ENTITY_REFERENCE_NODE : {
formatter = new NoMoveFormatter();
break;
}
default : {
formatter = new NodeFormatter();
}
}
// init fomatter
formatter.setFormatPreferences(getFormatPreferences());
formatter.setProgressMonitor(fProgressMonitor);
return formatter;
}