List of usage examples for org.w3c.dom DOMException INVALID_STATE_ERR
short INVALID_STATE_ERR
To view the source code for org.w3c.dom DOMException INVALID_STATE_ERR.
Click Source Link
From source file:org.structr.web.entity.dom.Content.java
@Override public void deleteData(final int offset, final int count) throws DOMException { checkWriteAccess();// w w w.j av a 2 s .com // finally, set content to concatenated left and right parts try { String text = getProperty(content); String leftPart = text.substring(0, offset); String rightPart = text.substring(offset + count); setProperty(content, leftPart.concat(rightPart)); } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.toString()); } }
From source file:org.structr.web.entity.dom.Content.java
@Override public void replaceData(final int offset, final int count, final String data) throws DOMException { checkWriteAccess();/*from w ww .j a v a2s .c om*/ // finally, set content to concatenated left and right parts try { String text = getProperty(content); String leftPart = text.substring(0, offset); String rightPart = text.substring(offset + count); StringBuilder buf = new StringBuilder(leftPart.length() + data.length() + rightPart.length()); buf.append(leftPart); buf.append(data); buf.append(rightPart); setProperty(content, buf.toString()); } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.toString()); } }
From source file:org.structr.web.entity.dom.DOMElement.java
@Override public void setAttribute(final String name, final String value) throws DOMException { try {/*from w w w. j a v a2 s.c om*/ HtmlProperty htmlProperty = findOrCreateAttributeKey(name); if (htmlProperty != null) { htmlProperty.setProperty(securityContext, DOMElement.this, value); } } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.getMessage()); } }
From source file:org.structr.web.entity.dom.DOMElement.java
@Override public void removeAttribute(final String name) throws DOMException { try {/* ww w .ja v a 2 s. co m*/ HtmlProperty htmlProperty = findOrCreateAttributeKey(name); if (htmlProperty != null) { htmlProperty.setProperty(securityContext, DOMElement.this, null); } } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.getMessage()); } }
From source file:org.structr.web.entity.dom.DOMElement.java
@Override public void setIdAttribute(final String idString, boolean isId) throws DOMException { checkWriteAccess();/*from w w w . j a va2 s .c o m*/ try { setProperty(DOMElement._id, idString); } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.toString()); } }
From source file:org.structr.web.entity.dom.DOMNode.java
@Override public Node insertBefore(final Node newChild, final Node refChild) throws DOMException { // according to DOM spec, insertBefore with null refChild equals appendChild if (refChild == null) { return appendChild(newChild); }/*from w w w . ja va 2 s . com*/ checkWriteAccess(); checkSameDocument(newChild); checkSameDocument(refChild); checkHierarchy(newChild); checkHierarchy(refChild); if (newChild instanceof DocumentFragment) { // When inserting document fragments, we must take // care of the special case that the nodes already // have a NEXT_LIST_ENTRY relationship coming from // the document fragment, so we must first remove // the node from the document fragment and then // add it to the new parent. final DocumentFragment fragment = (DocumentFragment) newChild; Node currentChild = fragment.getFirstChild(); while (currentChild != null) { // save next child in fragment list for later use Node savedNextChild = currentChild.getNextSibling(); // remove child from document fragment fragment.removeChild(currentChild); // insert child into new parent insertBefore(currentChild, refChild); // next currentChild = savedNextChild; } } else { final Node _parent = newChild.getParentNode(); if (_parent != null) { _parent.removeChild(newChild); } try { // do actual tree insertion here treeInsertBefore((DOMNode) newChild, (DOMNode) refChild); } catch (FrameworkException frex) { if (frex.getStatus() == 404) { throw new DOMException(DOMException.NOT_FOUND_ERR, frex.getMessage()); } else { throw new DOMException(DOMException.INVALID_STATE_ERR, frex.getMessage()); } } // allow parent to set properties in new child handleNewChild(newChild); } return refChild; }
From source file:org.structr.web.entity.dom.DOMNode.java
@Override public Node replaceChild(final Node newChild, final Node oldChild) throws DOMException { checkWriteAccess();/*w ww .j a v a 2 s .co m*/ checkSameDocument(newChild); checkSameDocument(oldChild); checkHierarchy(newChild); checkHierarchy(oldChild); if (newChild instanceof DocumentFragment) { // When inserting document fragments, we must take // care of the special case that the nodes already // have a NEXT_LIST_ENTRY relationship coming from // the document fragment, so we must first remove // the node from the document fragment and then // add it to the new parent. // replace indirectly using insertBefore and remove final DocumentFragment fragment = (DocumentFragment) newChild; Node currentChild = fragment.getFirstChild(); while (currentChild != null) { // save next child in fragment list for later use final Node savedNextChild = currentChild.getNextSibling(); // remove child from document fragment fragment.removeChild(currentChild); // add child to new parent insertBefore(currentChild, oldChild); // next currentChild = savedNextChild; } // finally, remove reference element removeChild(oldChild); } else { Node _parent = newChild.getParentNode(); if (_parent != null && _parent instanceof DOMNode) { _parent.removeChild(newChild); } try { // replace directly treeReplaceChild((DOMNode) newChild, (DOMNode) oldChild); } catch (FrameworkException frex) { if (frex.getStatus() == 404) { throw new DOMException(DOMException.NOT_FOUND_ERR, frex.getMessage()); } else { throw new DOMException(DOMException.INVALID_STATE_ERR, frex.getMessage()); } } // allow parent to set properties in new child handleNewChild(newChild); } return oldChild; }
From source file:org.structr.web.entity.dom.DOMNode.java
@Override public Node appendChild(final Node newChild) throws DOMException { checkWriteAccess();/*from w w w . j av a 2 s . com*/ checkSameDocument(newChild); checkHierarchy(newChild); try { if (newChild instanceof DocumentFragment) { // When inserting document fragments, we must take // care of the special case that the nodes already // have a NEXT_LIST_ENTRY relationship coming from // the document fragment, so we must first remove // the node from the document fragment and then // add it to the new parent. // replace indirectly using insertBefore and remove final DocumentFragment fragment = (DocumentFragment) newChild; Node currentChild = fragment.getFirstChild(); while (currentChild != null) { // save next child in fragment list for later use final Node savedNextChild = currentChild.getNextSibling(); // remove child from document fragment fragment.removeChild(currentChild); // append child to new parent appendChild(currentChild); // next currentChild = savedNextChild; } } else { final Node _parent = newChild.getParentNode(); if (_parent != null && _parent instanceof DOMNode) { _parent.removeChild(newChild); } treeAppendChild((DOMNode) newChild); // allow parent to set properties in new child handleNewChild(newChild); } } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.toString()); } return newChild; }
From source file:org.structr.web.entity.dom.DOMNode.java
@Override public Node cloneNode(boolean deep) { if (deep) {/*from ww w . j a v a 2 s .co m*/ return cloneAndAppendChildren(securityContext, this); } else { final PropertyMap properties = new PropertyMap(); for (Iterator<PropertyKey> it = getPropertyKeys(uiView.name()).iterator(); it.hasNext();) { final PropertyKey key = it.next(); // omit system properties (except type), parent/children and page relationships if (key.equals(GraphObject.type) || (!key.isUnvalidated() && !key.equals(GraphObject.id) && !key.equals(DOMNode.ownerDocument) && !key.equals(DOMNode.pageId) && !key.equals(DOMNode.parent) && !key.equals(DOMNode.parentId) && !key.equals(DOMElement.syncedNodes) && !key.equals(DOMNode.children) && !key.equals(DOMNode.childrenIds))) { properties.put(key, getProperty(key)); } } // htmlView is necessary for the cloning of DOM nodes - otherwise some properties won't be cloned for (Iterator<PropertyKey> it = getPropertyKeys(DOMElement.htmlView.name()).iterator(); it.hasNext();) { final PropertyKey key = it.next(); // omit system properties (except type), parent/children and page relationships if (key.equals(GraphObject.type) || (!key.isUnvalidated() && !key.equals(GraphObject.id) && !key.equals(DOMNode.ownerDocument) && !key.equals(DOMNode.pageId) && !key.equals(DOMNode.parent) && !key.equals(DOMNode.parentId) && !key.equals(DOMElement.syncedNodes) && !key.equals(DOMNode.children) && !key.equals(DOMNode.childrenIds))) { properties.put(key, getProperty(key)); } } if (this instanceof LinkSource) { final LinkSource linkSourceElement = (LinkSource) this; properties.put(LinkSource.linkable, linkSourceElement.getProperty(LinkSource.linkable)); } final App app = StructrApp.getInstance(securityContext); try { final DOMNode node = app.create(getClass(), properties); return node; } catch (FrameworkException ex) { throw new DOMException(DOMException.INVALID_STATE_ERR, ex.toString()); } } }
From source file:org.structr.web.entity.dom.DOMNode.java
@Override public Node doAdopt(final Page _page) throws DOMException { if (_page != null) { try {//from ww w.j a va2 s. com setProperty(ownerDocument, _page); } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.getMessage()); } } return this; }