Here you can find the source of findLinkElementUp(Element elem)
Parameter | Description |
---|---|
elem | the element to start looking at |
public static Element findLinkElementUp(Element elem)
//package com.java2s; /*/* w w w. j ava 2s. co m*/ * This file is part of the Scriba source distribution. This is free, open-source * software. For full licensing information, please see the LicensingInformation file * at the root level of the distribution. * * Copyright (c) 2006-2007 Kobrix Software, Inc. */ import javax.swing.text.AttributeSet; import javax.swing.text.Element; import javax.swing.text.html.HTML; public class Main { /** * find the next link attribute from a given element upwards through the * element hierarchy * * @param elem the element to start looking at * * @return the link attribute found, or null, if none was found */ public static Element findLinkElementUp(Element elem) { Element e = null; Object linkAttr = null; Object href = null; while ((elem != null) && (linkAttr == null)) { e = elem; linkAttr = elem.getAttributes().getAttribute(HTML.Tag.A); if (linkAttr != null) { href = ((AttributeSet) linkAttr).getAttribute(HTML.Attribute.HREF); } elem = elem.getParentElement(); } if (linkAttr != null && href != null) return e; else return null; } }