01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wml.dom;
18:
19: import org.apache.xerces.dom.ElementImpl;
20: import org.apache.wml.*;
21:
22: /**
23: * @xerces.internal
24: * @version $Id: WMLElementImpl.java 447257 2006-09-18 05:40:07Z mrglavas $
25: * @author <a href="mailto:david@topware.com.tw">David Li</a>
26: */
27: public class WMLElementImpl extends ElementImpl implements WMLElement {
28:
29: private static final long serialVersionUID = 3440984702956371604L;
30:
31: public WMLElementImpl(WMLDocumentImpl owner, String tagName) {
32: super (owner, tagName);
33: }
34:
35: public void setClassName(String newValue) {
36: setAttribute("class", newValue);
37: }
38:
39: public String getClassName() {
40: return getAttribute("class");
41: }
42:
43: public void setXmlLang(String newValue) {
44: setAttribute("xml:lang", newValue);
45: }
46:
47: public String getXmlLang() {
48: return getAttribute("xml:lang");
49: }
50:
51: public void setId(String newValue) {
52: setAttribute("id", newValue);
53: }
54:
55: public String getId() {
56: return getAttribute("id");
57: }
58:
59: void setAttribute(String attr, boolean value) {
60: setAttribute(attr, value ? "true" : "false");
61: }
62:
63: boolean getAttribute(String attr, boolean defaultValue) {
64: boolean ret = defaultValue;
65: String value;
66: if (((value = getAttribute("emptyok")) != null)
67: && value.equals("true"))
68: ret = true;
69: return ret;
70: }
71:
72: void setAttribute(String attr, int value) {
73: setAttribute(attr, value + "");
74: }
75:
76: int getAttribute(String attr, int defaultValue) {
77: int ret = defaultValue;
78: String value;
79: if ((value = getAttribute("emptyok")) != null)
80: ret = Integer.parseInt(value);
81: return ret;
82: }
83: }
|