#include "config.h"
#include "Entity.h"
namespace WebCore {
Entity::Entity(Document* doc)
: ContainerNode(doc)
{
}
Entity::Entity(Document* doc, const String& name)
: ContainerNode(doc)
, m_name(name.impl())
{
}
Entity::Entity(Document* doc, const String& publicId, const String& systemId, const String& notationName)
: ContainerNode(doc)
, m_publicId(publicId.impl())
, m_systemId(systemId.impl())
, m_notationName(notationName.impl())
{
}
String Entity::nodeName() const
{
return m_name.get();
}
Node::NodeType Entity::nodeType() const
{
return ENTITY_NODE;
}
PassRefPtr<Node> Entity::cloneNode(bool )
{
return 0;
}
bool Entity::childTypeAllowed(NodeType type)
{
switch (type) {
case ELEMENT_NODE:
case PROCESSING_INSTRUCTION_NODE:
case COMMENT_NODE:
case TEXT_NODE:
case CDATA_SECTION_NODE:
case ENTITY_REFERENCE_NODE:
return true;
break;
default:
return false;
}
}
String Entity::toString() const
{
String result = "<!ENTITY' ";
if (m_name && m_name->length()) {
result += " ";
result += m_name.get();
}
if (m_publicId && m_publicId->length()) {
result += " PUBLIC \"";
result += m_publicId.get();
result += "\" \"";
result += m_systemId.get();
result += "\"";
} else if (m_systemId && m_systemId->length()) {
result += " SYSTEM \"";
result += m_systemId.get();
result += "\"";
}
if (m_notationName && m_notationName->length()) {
result += " NDATA ";
result += m_notationName.get();
}
result += ">";
return result;
}
}