1 package com.ibm.webdav; 2 3 17 18 22 public class PropertyName { 23 24 protected String ns = null; 25 protected String local = null; 26 27 public static final PropertyName pnResourcetype = createPropertyNameQuietly( "DAV:resourcetype" ); 28 public static final PropertyName pnCreationdate = createPropertyNameQuietly( "DAV:creationdate" ); 29 public static final PropertyName pnSupportedlock = createPropertyNameQuietly( "DAV:supportedlock" ); 30 public static final PropertyName pnContenttype = createPropertyNameQuietly( "DAV:getcontenttype" ); 31 public static final PropertyName pnGetlastmodified = createPropertyNameQuietly( "DAV:getlastmodified" ); 32 public static final PropertyName pnGetcontentlength = createPropertyNameQuietly( "DAV:getcontentlength" ); 33 public static final PropertyName pnLockdiscovery = createPropertyNameQuietly( "DAV:lockdiscovery" ); 34 35 40 public PropertyName( org.w3c.dom.Element tag ) { 41 49 local = tag.getLocalName(); 50 ns = tag.getNamespaceURI(); 51 52 } 53 59 public PropertyName( String tag ) throws InvalidPropertyNameException { 60 if (!tag.startsWith("DAV:")) { 61 throw new InvalidPropertyNameException( "Invalid tag parameter: "+tag ); 62 } else { 63 tag = tag.substring( 4 ); 64 } 65 local = tag; 66 ns = "DAV:"; 67 } 68 73 public PropertyName( String namespace, String tag ) throws InvalidPropertyNameException { 74 ns = namespace; 75 local = tag; 76 if (local.indexOf(':') >= 0) { 77 throw new InvalidPropertyNameException( "local part is "+tag ); 78 } 79 } 80 84 public String asExpandedString() { 85 return ns+":"+local; 86 } 87 105 public static PropertyName createPropertyNameQuietly( String propname ) { 106 PropertyName res; 107 try { 108 res = new PropertyName( propname ); 109 } catch (InvalidPropertyNameException excc) { 110 throw new RuntimeException ( "internal error: bad property: "+propname ); 114 } 115 return res; 116 } 117 134 public boolean equals( Object obj) { 135 String s1 = ns+local; 136 if (obj instanceof PropertyName) { 137 PropertyName param1 = (PropertyName)obj; 138 String s2 = param1.ns + param1.local; 139 return s1.equals(s2); 140 } else if (obj instanceof String ) { 141 String param1 = (String )obj; 142 return s1.equals(param1); 143 } 144 return false; 145 } 146 153 public String getLocal() { 154 return local; 155 } 156 161 public String getNamespace() { 162 return ns; 163 } 164 171 public int hashCode() { 172 String join = ns + local; 176 return join.hashCode(); 177 } 178 182 public String toString() { 183 return asExpandedString(); 184 } 185 } 186 | Popular Tags |