@Test public void testAddHref() { search = null; search = new TextNavigation("^delete", doc); while (search.hasNext()) { TextSelection item = (TextSelection) search.getCurrentItem(); try { item.addHref(new URL("http: } catch (InvalidNavigationException e) { Assert.fail(e.getMessage()); } catch (MalformedURLException e) { Assert.fail(e.getMessage()); Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'"); } } try { doc.save(ResourceUtilities.newTestOutputFile(SAVE_FILE_HREF)); } catch (Exception e) { Logger.getLogger(TextSelectionTest.class.getName()).log(Level.SEVERE, e.getMessage(), e); Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'"); } }
public void addHref(URL url) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } OdfElement parentElement = getContainerElement(); int leftLength = getText().length(); int index = mIndexInContainer; addHref(index, leftLength, parentElement, url.toString()); }
TextSelection extends Selection { public void addHref(URL url) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } OdfElement parentElement = getContainerElement(); int leftLength = getText().length(); int index = mIndexInContainer; addHref(index, leftLength, parentElement, url.toString()); } }
TextSelection extends Selection { public void addHref(URL url) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } OdfElement parentElement = getContainerElement(); int leftLength = getText().length(); int index = mIndexInContainer; addHref(index, leftLength, parentElement, url.toString()); } TextSelection(String text, OdfElement containerElement, int index); }
TextSelection extends Selection { public void addHref(URL url) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } OdfElement parentElement = getContainerElement(); int leftLength = getText().length(); int index = mIndexInContainer; addHref(index, leftLength, parentElement, url.toString()); } TextSelection(String text, OdfElement containerElement, int index); @Override OdfElement getElement(); OdfElement getContainerElement(); @Override int getIndex(); String getText(); @Override void cut(); void applyStyle(OdfStyleBase style); void replaceWith(String newText); @Override void pasteAtFrontOf(Selection positionItem); @Override void pasteAtEndOf(Selection positionItem); void addHref(URL url); @Override String toString(); }
TextSelection extends Selection { public void addHref(URL url) throws InvalidNavigationException { if (validate() == false) { throw new InvalidNavigationException("No matched string at this position"); } OdfElement parentElement = getContainerElement(); int leftLength = getText().length(); int index = mIndexInContainer; addHref(index, leftLength, parentElement, url.toString()); } TextSelection(String text, OdfElement containerElement, int index); @Override OdfElement getElement(); OdfElement getContainerElement(); @Override int getIndex(); String getText(); @Override void cut(); void applyStyle(OdfStyleBase style); void replaceWith(String newText); @Override void pasteAtFrontOf(Selection positionItem); @Override void pasteAtEndOf(Selection positionItem); void addHref(URL url); @Override String toString();  }