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

项目:lams    文件:HTMLFormElementImpl.java   
private String getEffectiveUrl() throws IOException {
    StringBuffer spec = new StringBuffer( getAction() );
    if ("get".equalsIgnoreCase( getMethod() )) {
        URLEncodedString parameters = new URLEncodedString();
        HTMLCollection controls = getElements();
        for (int i = 0; i < controls.getLength(); i++) {
            ((HTMLControl) controls.item( i )).addValues( parameters, "us-ascii" );
        }
        if ((spec.indexOf( "?" ) >= 0) && !(spec.toString().endsWith( "?" ))) {
            spec.append( '&' );
        } else {
            spec.append( '?' );
        }
        spec.append( parameters.getString() );
    }
    return new URL( getDomWindow().getUrl(), spec.toString() ).toExternalForm();
}
项目:SplitCharater    文件:HTMLTableRowElementImpl.java   
public void setCells( HTMLCollection cells )
{
    Node    child;
    int        i;

    child = getFirstChild();
    while ( child != null ) {
        removeChild( child );
        child = child.getNextSibling();
    }
    i = 0;
    child = cells.item( i );
    while ( child != null ) {
        appendChild ( child );
        ++i;
        child = cells.item( i );
    }
}
项目:lams    文件:WebForm.java   
/**
 * Returns an array of form parameter attributes for this form.
 **/
private FormControl[] getFormControls() {
    HTMLCollection controlElements = _domElement.getElements();
    FormControl[] controls = new FormControl[ controlElements.getLength() ];
    for (int i = 0; i < controls.length; i++) {
        controls[i] = getControlForNode( controlElements.item( i ) );
    }
    return controls;
}
项目:lams    文件:HTMLFormElementImpl.java   
public Object get( String propertyName, Scriptable scriptable ) {
    HTMLCollection elements = getElements();
    for (int i=0; i < elements.getLength(); i++) {
        Node node = elements.item( i );
        NamedNodeMap attributes = node.getAttributes();
        AttrImpl nameAttribute = (AttrImpl) attributes.getNamedItem( "name" );
        if (nameAttribute != null && propertyName.equals( nameAttribute.getValue() )) return node;
        AttrImpl idAttribute = (AttrImpl) attributes.getNamedItem( "id" );
        if (idAttribute != null && propertyName.equals( idAttribute.getValue() )) return node;
    }
    return  super.get( propertyName, scriptable );
}
项目:lams    文件:HTMLFormElementImpl.java   
public HTMLCollection getElements() {
    ArrayList elements = new ArrayList();
    String[] names = new String[]{"INPUT", "TEXTAREA", "BUTTON", "SELECT"};
    for (Iterator each = preOrderIteratorAfterNode(); each.hasNext();) {
        Node node = (Node) each.next();
        if (node instanceof HTMLFormElement) break;

        if (node.getNodeType() != ELEMENT_NODE) continue;
        String tagName = ((Element) node).getTagName();
        for (int i = 0; i < names.length; i++) {
            if (tagName.equalsIgnoreCase( names[i] )) elements.add( node );
        }
    }
    return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) );
}
项目:lams    文件:HTMLFormElementImpl.java   
public void reset() {
    HTMLCollection elements = getElements();
    for (int i = 0; i < elements.getLength(); i++) {
        Node node = elements.item(i);
        if (node instanceof HTMLControl) ((HTMLControl) node).reset();
    }
}
项目:lams    文件:HTMLControl.java   
private HTMLFormElement getPreviousForm( HTMLFormElement nextForm ) {
    HTMLCollection forms = getHtmlDocument().getForms();
    for (int i = 0; i < forms.getLength(); i++) {
        if (nextForm == forms.item( i )) return i == 0 ? null : (HTMLFormElement) forms.item( i-1 );
    }
    return null;
}
项目:lams    文件:HTMLSelectElementImpl.java   
public int getSelectedIndex() {
    HTMLCollection options = getOptions();
    for (int i = 0; i < options.getLength(); i++) {
        if (((HTMLOptionElement)options.item(i)).getSelected()) return i;
    }
    return isMultiSelect() ? -1 : 0;
}
项目:lams    文件:HTMLSelectElementImpl.java   
public String getValue() {
    HTMLCollection options = getOptions();
    for (int i = 0; i < options.getLength(); i++) {
        HTMLOptionElement optionElement = ((HTMLOptionElement)options.item(i));
        if (optionElement.getSelected()) return optionElement.getValue();
    }
    return (isMultiSelect() || options.getLength() == 0) ? null : ((HTMLOptionElement)options.item(0)).getValue();
}
项目:lams    文件:HTMLSelectElementImpl.java   
public void setSelectedIndex( int selectedIndex ) {
    HTMLCollection options = getOptions();
    for (int i = 0; i < options.getLength(); i++) {
        HTMLOptionElementImpl optionElement = (HTMLOptionElementImpl) options.item(i);
        optionElement.setSelected( i == selectedIndex );
    }
}
项目:lams    文件:HTMLSelectElementImpl.java   
int getIndexOf( HTMLOptionElementImpl option ) {
    HTMLCollection options = getOptions();
    for (int i = 0; i < options.getLength(); i++) {
        if (options.item(i) == option) return i;
    }
    throw new IllegalStateException( "option is not part of this select" );
}
项目:lams    文件:HTMLSelectElementImpl.java   
void addValues( ParameterProcessor processor, String characterSet ) throws IOException {
    HTMLCollection options = getOptions();
    String name = getName();
    for (int i = 0; i < options.getLength();i++) {
        ((HTMLOptionElementImpl) options.item( i )).addValueIfSelected( processor, name, characterSet );
    }
}
项目:lams    文件:HTMLSelectElementImpl.java   
public void reset() {
    HTMLCollection options = getOptions();
    for (int i = 0; i < options.getLength(); i++) {
        HTMLControl optionElement = (HTMLControl) options.item(i);
        optionElement.reset();
    }
}
项目:lams    文件:HTMLInputElementImpl.java   
public void setChecked( boolean checked ) {
    if (checked) {
        HTMLCollection elements = getForm().getElements();
        for (int i = 0; i < elements.getLength(); i++) {
            Node node = elements.item(i);
            if (!(node instanceof HTMLInputElementImpl)) continue;
            HTMLInputElementImpl input = (HTMLInputElementImpl) node;
            if (getName().equals( input.getName() ) && input.getType().equalsIgnoreCase( "radio" )) input.setState( false );
        }
    }
    setState( checked );
}
项目:lams    文件:HTMLContainerDelegate.java   
/**
 * get Links for a given Node
 * @param rootNode
 * @return
 */
HTMLCollection getLinks( NodeImpl rootNode ) {
    ArrayList elements = new ArrayList();
    for (Iterator each = rootNode.preOrderIteratorAfterNode( _iteratorMask ); each.hasNext();) {
        Node node = (Node) each.next();
        if (node.getNodeType() != Node.ELEMENT_NODE) continue;

        if (ParsedHTML.isWebLink(node)) {
            elements.add( node );
        }
    }
    return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) );
}
项目:lams    文件:HTMLContainerDelegate.java   
HTMLCollection getForms( NodeImpl rootNode ) {
    ArrayList elements = new ArrayList();
    for (Iterator each = rootNode.preOrderIteratorAfterNode( _iteratorMask ); each.hasNext();) {
        Node node = (Node) each.next();
        if (node.getNodeType() != Node.ELEMENT_NODE) continue;

        if ("form".equalsIgnoreCase( ((Element) node).getTagName() )) {
            elements.add( node );
        }
    }
    return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) );
}
项目:lams    文件:HTMLContainerDelegate.java   
HTMLCollection getAnchors( NodeImpl rootNode ) {
    NodeList nodeList = rootNode.getElementsByTagName( "A" );
    ArrayList elements = new ArrayList();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item( i );
        if (node.getAttributes().getNamedItem( "name" ) != null) {
            elements.add( node );
        }
    }
    return HTMLCollectionImpl.createHTMLCollectionImpl( new NodeListImpl( elements ) );
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
private void navigateImpl(final @NonNull URL href, final String target, final RequestType requestType, final Object linkObject) {
  if (logger.isLoggable(Level.INFO)) {
    logger.info("navigateImpl(): href=" + href + ",target=" + target);
  }
  // First check if target is a frame identifier.
  TargetType targetType;
  if (target != null) {
    final HtmlRendererContext topCtx = this.getTop();
    final HTMLCollection frames = topCtx.getFrames();
    if (frames != null) {
      final Node frame = frames.namedItem(target);
      if (frame instanceof FrameNode) {
        final BrowserFrame bframe = ((FrameNode) frame).getBrowserFrame();
        if (bframe == null) {
          throw new IllegalStateException("Frame node without a BrowserFrame instance: " + frame);
        }
        if (bframe.getHtmlRendererContext() != this) {
          bframe.loadURL(href);
          return;
        }
      }
    }
    // Now try special target types.
    targetType = HtmlRendererContextImpl.getTargetType(target);
  } else {
    targetType = TargetType.SELF;
  }
  if (requestType == RequestType.CLICK) {
    this.clientletFrame.linkClicked(href, targetType, linkObject);
  } else {
    this.clientletFrame.navigate(href, "GET", null, targetType, requestType);
  }
}
项目:LoboBrowser    文件:HtmlRendererContextImpl.java   
public HTMLCollection getFrames() {
  final Object rootNode = this.htmlPanel.getRootNode();
  if (rootNode instanceof HTMLDocumentImpl) {
    return ((HTMLDocumentImpl) rootNode).getFrames();
  } else {
    return null;
  }
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public HTMLCollection getImages()
{
    // For more information see HTMLCollection#collectionMatch
    if ( _images == null )
        _images = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.IMAGE );
    return _images;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public HTMLCollection getApplets()
{
    // For more information see HTMLCollection#collectionMatch
    if ( _applets == null )
        _applets = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.APPLET );
    return _applets;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public HTMLCollection getLinks()
{
    // For more information see HTMLCollection#collectionMatch
    if ( _links == null )
        _links = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.LINK );
    return _links;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public HTMLCollection getForms()
{
    // For more information see HTMLCollection#collectionMatch
    if ( _forms == null )
        _forms = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.FORM );
    return _forms;
}
项目:SplitCharater    文件:HTMLDocumentImpl.java   
public HTMLCollection getAnchors()
{
    // For more information see HTMLCollection#collectionMatch
    if ( _anchors == null )
        _anchors = new HTMLCollectionImpl( getBody(), HTMLCollectionImpl.ANCHOR );
    return _anchors;
}
项目:SplitCharater    文件:HTMLTableRowElementImpl.java   
public HTMLCollection  getCells()
{
    if ( _cells == null ) {
        _cells = new HTMLCollectionImpl( this, HTMLCollectionImpl.CELL );
    }
    return _cells;
}
项目:swingx-ws    文件:SimpleHtmlCollection.java   
/** 
 * Creates a new instance of SimpleHtmlCollection.
 * 
 * @param list the HTMLCollection to wrap.
 */
public SimpleHtmlCollection(HTMLCollection list) {
    if (list == null) {
        throw new NullPointerException();
    }
    this.list = list;
}
项目:griffon-swingx-ws-plugin    文件:SimpleHtmlCollection.java   
/** 
 * Creates a new instance of SimpleHtmlCollection.
 * 
 * @param list the HTMLCollection to wrap.
 */
public SimpleHtmlCollection(HTMLCollection list) {
    if (list == null) {
        throw new NullPointerException();
    }
    this.list = list;
}
项目:lams    文件:HTMLFormElementImpl.java   
private void silenceSubmitButtons() {
    HTMLCollection controls = getElements();
    for (int i = 0; i < controls.getLength(); i++) {
        ((HTMLControl) controls.item( i )).silenceSubmitButton();
    }
}
项目:lams    文件:HTMLControl.java   
private HTMLFormElement getLastFormInDocument() {
    HTMLCollection forms = getHtmlDocument().getForms();
    return forms.getLength() == 0 ? null : (HTMLFormElement) forms.item( forms.getLength()-1 );
}
项目:lams    文件:HTMLTableCellElementImpl.java   
public HTMLCollection getLinks() {
    return getHtmlDocument().getContainerDelegate().getLinks( this );
}
项目:lams    文件:HTMLTableCellElementImpl.java   
public HTMLCollection getImages() {
    return getHtmlDocument().getContainerDelegate().getImages( this );
}
项目:lams    文件:HTMLTableCellElementImpl.java   
public HTMLCollection getApplets() {
    return getHtmlDocument().getContainerDelegate().getApplets( this );
}
项目:lams    文件:HTMLTableCellElementImpl.java   
public HTMLCollection getForms() {
    return getHtmlDocument().getContainerDelegate().getForms( this );
}
项目:lams    文件:HTMLTableCellElementImpl.java   
public HTMLCollection getAnchors() {
    return getHtmlDocument().getContainerDelegate().getAnchors( this );
}
项目:lams    文件:HTMLSelectElementImpl.java   
public HTMLCollection getOptions() {
    return HTMLCollectionImpl.createHTMLCollectionImpl( getElementsByTagName( getHtmlDocument().toNodeCase( "option" ) ) );
}
项目:lams    文件:HTMLTableRowElementImpl.java   
public HTMLCollection getCells() {
    return HTMLCollectionImpl.createHTMLCollectionImpl( getElementsByTagNames( new String[] { "td", "th " } ) );
}
项目:lams    文件:HTMLParagraphElementImpl.java   
public HTMLCollection getLinks() {
    return getHtmlDocument().getContainerDelegate().getLinks( this );
}
项目:lams    文件:HTMLParagraphElementImpl.java   
public HTMLCollection getImages() {
    return getHtmlDocument().getContainerDelegate().getImages( this );
}
项目:lams    文件:HTMLParagraphElementImpl.java   
public HTMLCollection getApplets() {
    return getHtmlDocument().getContainerDelegate().getApplets( this );
}
项目:lams    文件:HTMLParagraphElementImpl.java   
public HTMLCollection getForms() {
    return getHtmlDocument().getContainerDelegate().getForms( this );
}