001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.html.dom;
018:
019: import org.w3c.dom.Node;
020: import org.w3c.dom.NodeList;
021: import org.w3c.dom.html.HTMLCollection;
022: import org.w3c.dom.html.HTMLFormElement;
023:
024: /**
025: * @xerces.internal
026: * @version $Revision: 447255 $ $Date: 2006-09-18 01:36:42 -0400 (Mon, 18 Sep 2006) $
027: * @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
028: * @see org.w3c.dom.html.HTMLFormElement
029: * @see org.apache.xerces.dom.ElementImpl
030: */
031: public class HTMLFormElementImpl extends HTMLElementImpl implements
032: HTMLFormElement {
033:
034: private static final long serialVersionUID = -7324749629151493210L;
035:
036: public HTMLCollection getElements() {
037: if (_elements == null)
038: _elements = new HTMLCollectionImpl(this ,
039: HTMLCollectionImpl.ELEMENT);
040: return _elements;
041: }
042:
043: public int getLength() {
044: return getElements().getLength();
045: }
046:
047: public String getName() {
048: return getAttribute("name");
049: }
050:
051: public void setName(String name) {
052: setAttribute("name", name);
053: }
054:
055: public String getAcceptCharset() {
056: return getAttribute("accept-charset");
057: }
058:
059: public void setAcceptCharset(String acceptCharset) {
060: setAttribute("accept-charset", acceptCharset);
061: }
062:
063: public String getAction() {
064: return getAttribute("action");
065: }
066:
067: public void setAction(String action) {
068: setAttribute("action", action);
069: }
070:
071: public String getEnctype() {
072: return getAttribute("enctype");
073: }
074:
075: public void setEnctype(String enctype) {
076: setAttribute("enctype", enctype);
077: }
078:
079: public String getMethod() {
080: return capitalize(getAttribute("method"));
081: }
082:
083: public void setMethod(String method) {
084: setAttribute("method", method);
085: }
086:
087: public String getTarget() {
088: return getAttribute("target");
089: }
090:
091: public void setTarget(String target) {
092: setAttribute("target", target);
093: }
094:
095: public void submit() {
096: // No scripting in server-side DOM. This method is moot.
097: }
098:
099: public void reset() {
100: // No scripting in server-side DOM. This method is moot.
101: }
102:
103: /*
104: * Explicit implementation of getChildNodes() to avoid problems with
105: * overriding the getLength() method hidden in the super class.
106: */
107: public NodeList getChildNodes() {
108: return getChildNodesUnoptimized();
109: }
110:
111: /**
112: * Explicit implementation of cloneNode() to ensure that cache used
113: * for getElements() gets cleared.
114: */
115: public Node cloneNode(boolean deep) {
116: HTMLFormElementImpl clonedNode = (HTMLFormElementImpl) super
117: .cloneNode(deep);
118: clonedNode._elements = null;
119: return clonedNode;
120: }
121:
122: /**
123: * Constructor requires owner document.
124: *
125: * @param owner The owner HTML document
126: */
127: public HTMLFormElementImpl(HTMLDocumentImpl owner, String name) {
128: super (owner, name);
129: }
130:
131: /**
132: * Collection of all elements contained in this FORM.
133: */
134: private HTMLCollectionImpl _elements;
135:
136: }
|