List of usage examples for org.w3c.dom DOMException INDEX_SIZE_ERR
short INDEX_SIZE_ERR
To view the source code for org.w3c.dom DOMException INDEX_SIZE_ERR.
Click Source Link
From source file:org.structr.web.entity.dom.Content.java
@Override public Text splitText(int offset) throws DOMException { checkWriteAccess();/* w w w . j av a 2 s . c o m*/ String text = getProperty(content); if (text != null) { int len = text.length(); if (offset < 0 || offset > len) { throw new DOMException(DOMException.INDEX_SIZE_ERR, INDEX_SIZE_ERR_MESSAGE); } else { final String firstPart = text.substring(0, offset); final String secondPart = text.substring(offset); final Document document = getOwnerDocument(); final Node parent = getParentNode(); if (document != null && parent != null) { try { // first part goes into existing text element setProperty(content, firstPart); // second part goes into new text element Text newNode = document.createTextNode(secondPart); // make new node a child of old parent parent.appendChild(newNode); return newNode; } catch (FrameworkException fex) { throw new DOMException(DOMException.INVALID_STATE_ERR, fex.toString()); } } else { throw new DOMException(DOMException.INVALID_STATE_ERR, CANNOT_SPLIT_TEXT_WITHOUT_PARENT); } } } throw new DOMException(DOMException.INDEX_SIZE_ERR, INDEX_SIZE_ERR_MESSAGE); }
From source file:org.structr.web.entity.dom.Content.java
@Override public String substringData(int offset, int count) throws DOMException { checkReadAccess();/* w w w . j ava2 s. com*/ String text = getProperty(content); if (text != null) { try { return text.substring(offset, offset + count); } catch (IndexOutOfBoundsException iobex) { throw new DOMException(DOMException.INDEX_SIZE_ERR, INDEX_SIZE_ERR_MESSAGE); } } return ""; }