use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class CSSStyleSheetImpl method insertRule.
/**
* {@inheritDoc}
*/
@Override
public long insertRule(String rule, int index) {
try {
this.cssStyleSheet.insertRule(rule, index);
this.cssRuleList.addStyleRule(cssStyleSheet.getCssRules());
} catch (Exception e) {
throw new DOMException(DOMException.INDEX_SIZE_ERR, e.getMessage());
}
return index;
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class HTMLAllCollectionImpl method tags.
/**
* Returns all tags by name.
*
* @param tag the name of tag
* @return a {@link HTMLAllCollection} object.
*/
@Override
public HTMLAllCollection tags(String tag) {
final Document doc = this.rootNode.getOwnerDocument();
if (doc == null) {
return null;
}
final HTMLAllCollection list = (HTMLAllCollection) doc.getElementsByTagName(tag);
if (list.getLength() == 0) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "is not a valid tag name.");
}
return list;
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class DOMTokenListImpl method setValue.
/**
* {@inheritDoc}
*/
@Override
public void setValue(String value) throws DOMException {
if (value == null) {
throw new DOMException(DOMException.SYNTAX_ERR, "Token cannot be null");
}
tokenset.clear();
StringTokenizer st = new StringTokenizer(value);
while (st.hasMoreTokens()) {
tokenset.add(st.nextToken());
}
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class DocumentImpl method createTextNode.
/**
* {@inheritDoc}
*/
@Override
public Text createTextNode(String data) {
if (data == null) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, "null data");
}
final TextImpl node = new TextImpl(data);
node.setOwnerDocument(this);
return node;
}
use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class DocumentImpl 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.");
}
try {
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);
} catch (Exception e) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, "Is not a valid selector.");
}
}
Aggregations