use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class ElementImpl method querySelectorAll.
/**
* {@inheritDoc}
*/
@Override
public NodeList querySelectorAll(String selector) {
final ArrayList<Node> al = new ArrayList<>();
if (selector == null) {
return new NodeListImpl(al);
}
if (selector.isEmpty()) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "The provided selector is empty.");
}
if (selector.trim().isEmpty()) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "is not a valid selector.");
}
SelectorList selectorList = CSSUtilities.getSelectorList(selector);
if (selectorList != null) {
NodeListImpl childNodes = (NodeListImpl) getDescendents(new ElementFilter(null), true);
childNodes.forEach(child -> {
for (Selector select : selectorList) {
if (child instanceof Element && StyleSheetAggregator.selects(select, child, null)) {
al.add(child);
}
}
});
}
return new NodeListImpl(al);
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class HTMLTableRowElementImpl method insertCell.
/**
* {@inheritDoc}
*/
@Override
public HTMLTableCellElement insertCell() {
final Document doc = this.document;
if (doc == null) {
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "Orphan element");
}
HTMLTableCellElementImpl cellElement = (HTMLTableCellElementImpl) doc.createElement("TD");
appendChild(cellElement);
return cellElement;
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class HTMLTableElementImpl method insertRow.
/**
* {@inheritDoc}
*/
@Override
public HTMLTableRowElement insertRow() {
final Document doc = this.document;
if (doc == null) {
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "Orphan element");
}
final HTMLTableRowElement rowElement = (HTMLTableRowElement) doc.createElement("TR");
appendChild(rowElement);
return rowElement;
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class XPathExpressionImpl method evaluate.
/**
* {@inheritDoc}
*/
@Override
public Object evaluate(Node contextNode, short type, Object result) throws XPathException, DOMException {
// If the XPathEvaluator was determined by "casting" the document
if (m_doc != null) {
// Check that the context node is owned by the same document
if (!Objects.equals(contextNode, m_doc) && !contextNode.getOwnerDocument().equals(m_doc)) {
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_WRONG_DOCUMENT, null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, fmsg);
}
// Check that the context node is an acceptable node type
NodeType nodeType = contextNode.getNodeType();
switch(nodeType) {
case DOCUMENT_NODE:
case ELEMENT_NODE:
case ATTRIBUTE_NODE:
case TEXT_NODE:
case CDATA_SECTION_NODE:
case COMMENT_NODE:
case PROCESSING_INSTRUCTION_NODE:
break;
default:
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_WRONG_NODETYPE, null);
throw new UnsupportedOperationException(fmsg);
}
}
if (!XPathResultImpl.isValidType(type)) {
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_INVALID_XPATH_TYPE, new Object[] { (int) type });
throw new XPathException(XPathException.TYPE_ERR, fmsg);
}
XPathContext xpathSupport = new XPathContext(false);
XObject xobj = null;
return new XPathResultImpl(type, xobj, contextNode, m_xpath);
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class CSSStyleSheetImpl method deleteRule.
/**
* {@inheritDoc}
*/
@Override
public void deleteRule(int index) {
try {
cssStyleSheet.deleteRule(index);
this.cssRuleList.addStyleRule(cssStyleSheet.getCssRules());
} catch (Exception e) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, e.getMessage());
}
}
Aggregations