Java 类org.w3c.dom.html.HTMLElement 实例源码

项目:oiosaml.java    文件:LoginHandlerTest.java   
@Test
public void testPost() throws Exception {
    cfg.setProperty(WSFedConstants.PROP_USE_REDIRECT, false);

    StringWriter sw = new StringWriter();
    when(res.getWriter()).thenReturn(new PrintWriter(sw));

    LoginHandler lh = new LoginHandler();
    lh.handleGet(rc);

    WebWindow win = mock(WebWindow.class);
    when(win.getScriptObject()).thenThrow(new RuntimeException("test"));
    when(win.getWebClient()).thenReturn(new WebClient(BrowserVersion.FIREFOX_2));

    DOMParser parser = new DOMParser();
    parser.parse(new InputSource(new ByteArrayInputStream(sw.toString().getBytes())));
    HTMLElement e = (HTMLElement) parser.getDocument().getDocumentElement();

    NodeList forms = e.getElementsByTagName("form");
    assertEquals(1, forms.getLength());
    Element form = (Element)forms.item(0);
    assertEquals("loginform", form.getAttribute("name"));
    assertEquals(rc.getIdpMetadata().getFirstMetadata().getSingleSignonServiceLocation(WSFedConstants.WSFED_PROTOCOL), form.getAttribute("action"));

    verify(res, never()).sendRedirect(anyString());
}
项目:LoboBrowser    文件:HtmlContent.java   
public String getDescription() {
  final NodeList nodeList = this.document.getElementsByTagName("meta");
  if (nodeList == null) {
    return null;
  }
  final int length = nodeList.getLength();
  for (int i = 0; i < length; i++) {
    final Node node = nodeList.item(i);
    if (node instanceof HTMLElement) {
      final HTMLElement element = (HTMLElement) node;
      final String name = element.getAttribute("name");
      if ((name != null) && name.equalsIgnoreCase("description")) {
        return element.getAttribute("description");
      }
    }
  }
  return null;
}
项目:OpenSPIFe    文件:PlanDiffOutputAsTreeHTML.java   
private void appendObjectInfo (PlanDiffObjectNode node, HTMLElement description, HTMLElement startTime) {       
    EObject object = node.getObject();
    if (object.eContainer() instanceof EActivityGroup
            && !node.parentObjectMentionedAboveInTree()) {
        description.appendChild(element("SPAN", " "));
        description.appendChild(document.createEntityReference("laquo"));
        description.appendChild(element("SPAN", " "));
        description.appendChild(element("SPAN", node.getParentName(), "parent-name"));
    }
    if (object instanceof EPlanElement) {
        TemporalMember temporalMember = ((EPlanElement)object).getMember(TemporalMember.class);
        if (!temporalMember.getScheduled()) description.setClassName("unscheduled");
        String startTimeString = dateStringifier.getDisplayString(temporalMember.getStartTime());
        startTime.appendChild(element("SPAN", startTimeString, "start-time"));
    }
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public synchronized String getTitle()
{
    HTMLElement head;
    NodeList    list;
    Node        title;

    // Get the HEAD element and look for the TITLE element within.
    // When found, make sure the TITLE is a direct child of HEAD,
    // and return the title's text (the Text node contained within).
    head = getHead();
    list = head.getElementsByTagName( "TITLE" );
    if ( list.getLength() > 0 ) {
        title = list.item( 0 );
        return ( (HTMLTitleElement) title ).getText();
    }
    // No TITLE found, return an empty string.
    return "";
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public synchronized void setTitle( String newTitle )
{
    HTMLElement head;
    NodeList    list;
    Node        title;

    // Get the HEAD element and look for the TITLE element within.
    // When found, make sure the TITLE is a direct child of HEAD,
    // and set the title's text (the Text node contained within).
    head = getHead();
    list = head.getElementsByTagName( "TITLE" );
    if ( list.getLength() > 0 ) {
        title = list.item( 0 );
        if ( title.getParentNode() != head )
            head.appendChild( title );
        ( (HTMLTitleElement) title ).setText( newTitle );
    }
    else
    {
        // No TITLE found, create a new element and place it at the end
        // of the HEAD element.
        title = new HTMLTitleElementImpl( this, "TITLE" );
        ( (HTMLTitleElement) title ).setText( newTitle );
        head.appendChild( title );
    }
}
项目:SplitCharater    文件:HTMLOptionElementImpl.java   
public int getIndex()
{
    Node        parent;
    NodeList    options;
    int            i;

    // Locate the parent SELECT. Note that this OPTION might be inside a
    // OPTGROUP inside the SELECT. Or it might not have a parent SELECT.
    // Everything is possible. If no parent is found, return -1.
    parent = getParentNode();
    while ( parent != null && ! ( parent instanceof HTMLSelectElement ) )
        parent = parent.getParentNode();
    if ( parent != null )
    {
        // Use getElementsByTagName() which creates a snapshot of all the
        // OPTION elements under the SELECT. Access to the returned NodeList
        // is very fast and the snapshot solves many synchronization problems.
        options = ( (HTMLElement) parent ).getElementsByTagName( "OPTION" );
        for ( i = 0 ; i < options.getLength() ; ++i )
            if ( options.item( i ) == this )
                return i;
    }
    return -1;
}
项目:SplitCharater    文件:HTMLTableRowElementImpl.java   
int getRowIndex( Node parent )
{
    NodeList    rows;
    int            i;

    // Use getElementsByTagName() which creates a snapshot of all the
    // TR elements under the TABLE/section. Access to the returned NodeList
    // is very fast and the snapshot solves many synchronization problems.
    rows = ( (HTMLElement) parent ).getElementsByTagName( "TR" );
    for ( i = 0 ; i < rows.getLength() ; ++i ) {
        if ( rows.item( i ) == this ) {
            return i;
        }
    }
    return -1;
}
项目:SplitCharater    文件:HTMLTableRowElementImpl.java   
public HTMLElement insertCell( int index )
{
    Node        child;
    HTMLElement    newCell;

    newCell = new HTMLTableCellElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TD" );
    child = getFirstChild();
    while ( child != null ) {
        if ( child instanceof HTMLTableCellElement ) {
            if ( index == 0 ) {
                insertBefore( newCell, child );
                return newCell;
            }
            --index;
        }
        child = child.getNextSibling();
    }
    appendChild( newCell );
    return newCell;
}
项目:ScriptBox    文件:Html5DocumentImpl.java   
/**
 * Returns base element if there is any inside Document.
 * 
 * @return Base element if there is any inside Document.
 */
public HTMLBaseElement getBaseElement() {
    // FIXME: We should not wait for completeness, but try to get base address from actual loaded elements - proper synchronized section is needed.
    if (_documentReadiness == DocumentReadyState.COMPLETE) {
        HTMLElement head = getHead();
        NodeList baseElements = head.getElementsByTagName("base");

        if (baseElements.getLength() > 0) {
            Node baseElement = baseElements.item(0);

            if (baseElement instanceof HTMLBaseElement) {
                return (HTMLBaseElement)baseElement;
            }
        }
    }

    return null;
}
项目:lams    文件:HTMLCollectionImpl.java   
public Node namedItem( String name ) {
    if (name == null) return null;

    Node nodeByName = null;
    for (int i = 0; null == nodeByName && i < getLength(); i++) {
        Node node = item(i);
        if (!(node instanceof HTMLElementImpl)) continue;
        if (name.equalsIgnoreCase( ((HTMLElement) node).getId() )) return node;
        if (name.equalsIgnoreCase( ((HTMLElementImpl) node).getAttributeWithNoDefault( "name" )) ) nodeByName = node;
    }
    return nodeByName;
}
项目:lams    文件:DocumentImpl.java   
public Element getElementById( String elementId ) {
    for (Iterator each = preOrderIterator(); each.hasNext();) {
        Node node = (Node) each.next();
        if (!(node instanceof HTMLElement)) continue;
        HTMLElement element = (HTMLElement) node;
        if (elementId.equals( element.getId() )) return element;
    }
    return null;
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public boolean onMiddleClick(final HTMLElement element, final MouseEvent event) {
  final Runnable task = getMiddleClickTask(element);
  if (task != null) {
    SwingUtilities.invokeLater(task);
    return false;
  }
  return true;
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public boolean onContextMenu(final HTMLElement element, final MouseEvent event) {
  final JPopupMenu popupMenu = new JPopupMenu();
  if (popupMenu.isPopupTrigger(event)) {
    populatePopup(element, popupMenu);

    popupMenu.show(event.getComponent(), event.getX(), event.getY());
    return false;
  }
  return true;
}
项目:LoboBrowser    文件:HtmlClientlet.java   
private void addHttpEquivElement(final HTMLElement element) {
  Collection<HTMLElement> httpEquivElements = this.httpEquivElements;
  if (httpEquivElements == null) {
    httpEquivElements = new LinkedList<>();
    this.httpEquivElements = httpEquivElements;
  }
  httpEquivElements.add(element);
}
项目:LoboBrowser    文件:HtmlClientlet.java   
private final static boolean mayBeVisibleElement(final NodeImpl node) {
  if (node instanceof HTMLElement) {
    final HTMLElement element = (HTMLElement) node;
    final boolean visible = !NON_VISIBLE_ELEMENTS.contains(element.getTagName().toLowerCase());
    if (visible && logger.isLoggable(Level.INFO)) {
      logger.info("mayBeVisibleElement(): Found possibly visible element: " + element.getTagName());
    }
    return visible;
  } else {
    return false;
  }
}
项目:LoboBrowser    文件:HtmlClientlet.java   
private Map<String, String> getHttpEquivData() {
  final Collection<HTMLElement> httpEquivElements = this.httpEquivElements;
  if (httpEquivElements == null) {
    return null;
  }
  final Map<String, String> httpEquivData = new HashMap<>(0);
  for (final Element element : httpEquivElements) {
    final String httpEquiv = element.getAttribute("http-equiv");
    if (httpEquiv != null) {
      final String content = element.getAttribute("content");
      httpEquivData.put(httpEquiv, content);
    }
  }
  return httpEquivData;
}
项目:SplitCharater    文件:HTMLTableSectionElementImpl.java   
public HTMLElement insertRow( int index )
{
    HTMLTableRowElementImpl    newRow;

    newRow = new HTMLTableRowElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TR" );
    newRow.insertCell( 0 );
    if ( insertRowX( index, newRow ) >= 0 )
        appendChild( newRow );
    return newRow;
}
项目:SplitCharater    文件:HTMLTableElementImpl.java   
public synchronized HTMLElement createCaption()
{
    HTMLElement    section;

    section = getCaption();
    if ( section != null )
        return section;
    section = new HTMLTableCaptionElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "CAPTION" );
    appendChild( section );
    return section;
}
项目:SplitCharater    文件:HTMLTableElementImpl.java   
public synchronized HTMLElement createTHead()
{
    HTMLElement    section;

    section = getTHead();
    if ( section != null )
        return section;
    section = new HTMLTableSectionElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "THEAD" );
    appendChild( section );
    return section;
}
项目:SplitCharater    文件:HTMLTableElementImpl.java   
public synchronized HTMLElement createTFoot()
{
    HTMLElement    section;

    section = getTFoot();
    if ( section != null )
        return section;
    section = new HTMLTableSectionElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TFOOT" );
    appendChild( section );
    return section;
}
项目:SplitCharater    文件:HTMLTableElementImpl.java   
public HTMLElement insertRow( int index )
{
    HTMLTableRowElementImpl    newRow;

    newRow = new HTMLTableRowElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TR" );
    //newRow.insertCell( 0 );
    insertRowX( index, newRow );
    return newRow;
}
项目:SplitCharater    文件:HTMLOptionElementImpl.java   
public void setIndex( int index )
{
    Node        parent;
    NodeList    options;
    Node        item;

    // Locate the parent SELECT. Note that this OPTION might be inside a
    // OPTGROUP inside the SELECT. Or it might not have a parent SELECT.
    // Everything is possible. If no parent is found, just return.
    parent = getParentNode();
    while ( parent != null && ! ( parent instanceof HTMLSelectElement ) )
        parent = parent.getParentNode();
    if ( parent != null )
    {
        // Use getElementsByTagName() which creates a snapshot of all the
        // OPTION elements under the SELECT. Access to the returned NodeList
        // is very fast and the snapshot solves many synchronization problems.
        // Make sure this OPTION is not replacing itself.
        options = ( (HTMLElement) parent ).getElementsByTagName( "OPTION" );
        if ( options.item( index ) != this )
        {
            // Remove this OPTION from its parent. Place this OPTION right
            // before indexed OPTION underneath it's direct parent (might
            // be an OPTGROUP).
            getParentNode().removeChild( this );
            item = options.item( index );
            item.getParentNode().insertBefore( this, item );
        }
    }
}
项目:lams    文件:HTMLSelectElementImpl.java   
public void add( HTMLElement element, HTMLElement before ) throws DOMException {
}
项目:lams    文件:HTMLTableRowElementImpl.java   
public HTMLElement insertCell( int index ) throws DOMException {
    return null;  //To change body of implemented methods use File | Settings | File Templates.
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public void linkClicked(final HTMLElement linkNode, final @NonNull URL url, final String target) {
  this.navigateImpl(url, target, RequestType.CLICK, linkNode);
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public HtmlObject getHtmlObject(final HTMLElement element) {
  // TODO
  return null;
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public void onMouseOut(final HTMLElement element, final MouseEvent event) {
  if (element instanceof HTMLLinkElementImpl) {
    this.clientletFrame.setStatus(null);
  }
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public void onMouseOver(final HTMLElement element, final MouseEvent event) {
  if (element instanceof HTMLLinkElementImpl) {
    final HTMLLinkElementImpl linkElement = (HTMLLinkElementImpl) element;
    this.clientletFrame.setStatus(linkElement.getAbsoluteHref());
  }
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public boolean onDoubleClick(final HTMLElement element, final MouseEvent event) {
  return true;
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public boolean onMouseClick(final HTMLElement element, final MouseEvent event) {
  return true;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public synchronized Element getDocumentElement()
{
    Node    html;
    Node    child;
    Node    next;

    // The document element is the top-level HTML element of the HTML
    // document. Only this element should exist at the top level.
    // If the HTML element is found, all other elements that might
    // precede it are placed inside the HTML element.
    html = getFirstChild();
    while ( html != null )
    {
        if ( html instanceof HTMLHtmlElement )
        {
            // REVISIT: [Q] Why is this code even here? In fact, the
            //          original code is in error because it will
            //          try to move ALL nodes to be children of the
            //          HTML tag. This is not the intended behavior
            //          for comments and processing instructions
            //          outside the root element; it will throw a
            //          hierarchy request error exception for doctype
            //          nodes; *and* this code shouldn't even be
            //          needed because the parser should never build
            //          a document that contains more than a single
            //          root element, anyway! -Ac
            /***
            synchronized ( html )
            {
                child = getFirstChild();
                while ( child != null && child != html )
                {
                    next = child.getNextSibling();
                    html.appendChild( child );
                    child = next;
                }
            }
            /***/
            return (HTMLElement) html;
        }
        html = html.getNextSibling();
    }

    // HTML element must exist. Create a new element and dump the
    // entire contents of the document into it in the same order as
    // they appear now.
    html = new HTMLHtmlElementImpl( this, "HTML" );
    child = getFirstChild();
    while ( child != null )
    {
        next = child.getNextSibling();
        html.appendChild( child );
        child = next;
    }
    appendChild( html );
    return (HTMLElement) html;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
/**
 * Obtains the &lt;HEAD&gt; element in the document, creating one if does
 * not exist before. The &lt;HEAD&gt; element is the first element in the
 * &lt;HTML&gt; in the document. The &lt;HTML&gt; element is obtained by
 * calling {@link #getDocumentElement}. If the element does not exist, one
 * is created.
 * <P>
 * Called by {@link #getTitle}, {@link #setTitle}, {@link #getBody} and
 * {@link #setBody} to assure the document has the &lt;HEAD&gt; element
 * correctly placed.
 *
 * @return The &lt;HEAD&gt; element
 */
public synchronized HTMLElement getHead()
{
    Node    head;
    Node    html;
    Node    child;
    Node    next;

    // Call getDocumentElement() to get the HTML element that is also the
    // top-level element in the document. Get the first element in the
    // document that is called HEAD. Work with that.
    html = getDocumentElement();
    synchronized ( html )
    {
        head = html.getFirstChild();
        while ( head != null && ! ( head instanceof HTMLHeadElement ) )
            head = head.getNextSibling();
        // HEAD exists but might not be first element in HTML: make sure
        // it is and return it.
        if ( head != null )
        {
            synchronized ( head )
            {
                child = html.getFirstChild();
                while ( child != null && child != head )
                {
                    next = child.getNextSibling();
                    head.insertBefore( child, head.getFirstChild() );
                    child = next;
                }
            }
            return (HTMLElement) head;
        }

        // Head does not exist, create a new one, place it at the top of the
        // HTML element and return it.
        head = new HTMLHeadElementImpl( this, "HEAD" );
        html.insertBefore( head, html.getFirstChild() );
    }
    return (HTMLElement) head;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public synchronized HTMLElement getBody()
{
    Node    html;
    Node    head;
    Node    body;
    Node    child;
    Node    next;

    // Call getDocumentElement() to get the HTML element that is also the
    // top-level element in the document. Get the first element in the
    // document that is called BODY. Work with that.
    html = getDocumentElement();
    head = getHead();
    synchronized ( html )
    {
        body = head.getNextSibling();
        while ( body != null && ! ( body instanceof HTMLBodyElement )
                && ! ( body instanceof HTMLFrameSetElement ) )
            body = body.getNextSibling();

        // BODY/FRAMESET exists but might not be second element in HTML
        // (after HEAD): make sure it is and return it.
        if ( body != null )
        {
            synchronized ( body )
            {
                child = head.getNextSibling();
                while ( child != null && child != body )
                {
                    next = child.getNextSibling();
                    body.insertBefore( child, body.getFirstChild() );
                    child = next;
                }
            }
            return (HTMLElement) body;
        }

        // BODY does not exist, create a new one, place it in the HTML element
        // right after the HEAD and return it.
        body = new HTMLBodyElementImpl( this, "BODY" );
        html.appendChild( body );
    }
    return (HTMLElement) body;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public synchronized void setBody( HTMLElement newBody )
{
    Node    html;
    Node    body;
    Node    head;
    Node    child;
    NodeList list;

    synchronized ( newBody )
    {
        // Call getDocumentElement() to get the HTML element that is also the
        // top-level element in the document. Get the first element in the
        // document that is called BODY. Work with that.
        html = getDocumentElement();
        head = getHead();
        synchronized ( html )
        {
            list = this.getElementsByTagName( "BODY" );
            if ( list.getLength() > 0 ) {
                // BODY exists but might not follow HEAD in HTML. If not,
                // make it so and replce it. Start with the HEAD and make
                // sure the BODY is the first element after the HEAD.
                body = list.item( 0 );
                synchronized ( body )
                {
                    child = head;
                    while ( child != null )
                    {
                        if ( child instanceof Element )
                        {
                            if ( child != body )
                                html.insertBefore( newBody, child );
                            else
                                html.replaceChild( newBody, body );
                            return;
                        }
                        child = child.getNextSibling();
                    }
                    html.appendChild( newBody );
                }
                return;
            }
            // BODY does not exist, place it in the HTML element
            // right after the HEAD.
            html.appendChild( newBody );
        }
    }
}
项目:SplitCharater    文件:HTMLSelectElementImpl.java   
public void add( HTMLElement element, HTMLElement before )
{
    insertBefore( element, before );
}
项目:ScriptBox    文件:Html5DocumentImpl.java   
@ScriptGetter
@Override
public synchronized HTMLElement getBody() {
    return super.getBody();
}
项目:ui4j    文件:WebKitElement.java   
@Override
public boolean isHtmlElement() {
    return element instanceof HTMLElement;
}
项目:swingx-ws    文件:SimpleHtmlDocument.java   
public HTMLElement getBody() {
    return dom.getBody();
}
项目:swingx-ws    文件:SimpleHtmlDocument.java   
public void setBody(HTMLElement body) {
    dom.setBody(body);
}
项目:griffon-swingx-ws-plugin    文件:SimpleHtmlDocument.java   
public HTMLElement getBody() {
    return dom.getBody();
}