1 20 21 25 26 package org.ozoneDB.xml.dom; 27 28 import java.io.*; 29 import org.w3c.dom.*; 30 import org.w3c.dom.html.HTMLDocument; 31 32 33 58 public final class AttrImpl extends NodeImpl implements AttrProxy, Externalizable { 59 60 final static long serialVersionUID = 1; 61 62 63 public Element getOwnerElement() { 64 return (Element)getParentNode(); 65 } 66 67 68 public final short getNodeType() { 69 return ATTRIBUTE_NODE; 70 } 71 72 73 public final String getName() { 74 return getNodeName(); 75 } 76 77 78 public final boolean getSpecified() { 79 return _specified; 80 } 81 82 83 public void setSpecified( boolean value ) { 84 _specified = value; 85 } 86 87 88 public String getValue() { 89 return getNodeValue(); 90 } 91 92 93 public void setNodeValue( String value ) { 94 super.setNodeValue( value ); 95 _specified = true; 96 } 97 98 99 public void setValue( String value ) { 100 super.setNodeValue( value ); 101 _specified = true; 102 } 103 104 119 120 public String toString() { 121 String value; 122 123 value = getValue(); 124 if (value.length() > 32) { 125 value = value.substring( 0, 32 ) + ".."; 126 } 127 return "Attribute node: [" + getName() + "] [" + value + (_specified ? "] SPECIFIED" : "]"); 128 } 129 130 131 protected boolean supportsChildern() { 132 return true; 133 } 134 135 136 public final Object clone() { 137 AttrProxy clone = null; 138 try { 139 clone = (AttrProxy)database().createObject( AttrImpl.class.getName() ); 140 clone.init( _ownerDocument, getNodeName(), getNodeValue() ); 141 cloneInto( clone, true ); 142 } catch (Exception except) { 143 throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() ); 144 } 145 return clone; 146 } 147 148 149 public final Node cloneNode( boolean deep ) { 150 AttrProxy clone = null; 151 try { 152 clone = (AttrProxy)database().createObject( AttrImpl.class.getName() ); 153 clone.init( _ownerDocument, getNodeName(), getNodeValue() ); 154 cloneInto( clone, deep ); 155 } catch (Exception except) { 156 throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() ); 157 } 158 return clone; 159 } 160 161 162 public synchronized void cloneInto( NodeProxy into, boolean deep ) { 163 super.cloneInto( into, deep ); 164 ((AttrProxy)into).setSpecified( getSpecified() ); 165 } 166 167 168 174 protected Node castNewChild( Node newChild ) throws DOMException { 175 176 if (newChild == null) { 177 throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR, "Child reference is null." ); 178 } 179 if (!(newChild instanceof Text || newChild instanceof EntityReference)) { 180 throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR, 181 "Child is not a compatible type for this node." ); 182 } 183 return newChild; 184 } 185 186 187 188 public void writeExternal( ObjectOutput out ) throws IOException { 189 super.writeExternal( out ); 190 out.writeBoolean( _specified ); 191 } 192 193 194 195 public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { 196 super.readExternal( in ); 197 _specified = in.readBoolean(); 198 } 199 200 201 215 AttrImpl( DocumentImpl owner, String name, String defValue ) { 216 super( owner, owner instanceof HTMLDocument ? name.toLowerCase() : name, defValue, true ); 217 _specified = false; 222 } 223 224 225 public AttrImpl() { 226 super(); 227 _specified = false; 228 } 229 230 231 public final void init( DocumentProxy owner, String name, String value ) { 232 super.init( owner, owner instanceof HTMLDocument ? name.toLowerCase() : name, value, true ); 233 } 234 235 239 private boolean _specified; 240 241 } 242 | Popular Tags |