1 8 package org.apache.avalon.excalibur.catalog; 9 10 26 public class CatalogEntry 27 { 28 30 33 public final static int BASE = 1; 34 38 public final static int CATALOG = 2; 39 43 public final static int DOCUMENT = 3; 44 48 public final static int OVERRIDE = 4; 49 53 public final static int SGMLDECL = 5; 54 56 60 public final static int DELEGATE = 6; 61 65 public final static int DOCTYPE = 7; 66 70 public final static int DTDDECL = 8; 71 75 public final static int ENTITY = 9; 76 80 public final static int LINKTYPE = 10; 81 85 public final static int NOTATION = 11; 86 90 public final static int PUBLIC = 12; 91 95 public final static int SYSTEM = 13; 96 98 101 private int entryType = 0; 102 103 106 private String spec1 = ""; 107 108 111 private String spec2 = ""; 112 113 128 public CatalogEntry( int type, String spec ) 129 throws InvalidCatalogEntryTypeException, 130 InvalidCatalogEntryException 131 { 132 133 if( type < BASE || type > SYSTEM ) 134 { 135 throw new InvalidCatalogEntryTypeException(); 136 } 137 138 if( type > SGMLDECL ) 139 { 140 throw new InvalidCatalogEntryException(); 141 } 142 143 if( type == OVERRIDE 144 && !( spec.equalsIgnoreCase( "YES" ) 145 || spec.equalsIgnoreCase( "NO" ) ) ) 146 { 147 throw new InvalidCatalogEntryException(); 148 } 149 150 entryType = type; 151 spec1 = spec; 152 } 153 154 169 public CatalogEntry( int type, String spec, String fsispec ) 170 throws InvalidCatalogEntryTypeException, 171 InvalidCatalogEntryException 172 { 173 174 if( type < BASE || type > SYSTEM ) 175 { 176 throw new InvalidCatalogEntryTypeException(); 177 } 178 179 if( type < DELEGATE ) 180 { 181 throw new InvalidCatalogEntryException(); 182 } 183 184 entryType = type; 185 spec1 = spec; 186 spec2 = fsispec; 187 } 188 189 196 public int entryType() 197 { 198 return entryType; 199 } 200 201 208 public String formalSystemIdentifier() 209 { 210 if( entryType > SGMLDECL ) 211 { 212 return spec2; 213 } 214 else 215 { 216 if( entryType != OVERRIDE ) 217 { 218 return spec1; 219 } 220 else 221 { 222 return null; 223 } 224 } 225 } 226 227 234 public String yes_or_no() 235 { 236 if( entryType != OVERRIDE ) 237 { 238 return null; 239 } 240 else 241 { 242 return spec1; 243 } 244 } 245 246 254 public String partialPublicId() 255 { 256 if( entryType != DELEGATE ) 257 { 258 return null; 259 } 260 else 261 { 262 return spec1; 263 } 264 } 265 266 274 public String entityName() 275 { 276 if( entryType == DOCTYPE 277 || entryType == ENTITY 278 || entryType == LINKTYPE 279 || entryType == NOTATION ) 280 { 281 return spec1; 282 } 283 else 284 { 285 return null; 286 } 287 } 288 289 297 public String publicId() 298 { 299 if( entryType == DTDDECL 300 || entryType == PUBLIC ) 301 { 302 return spec1; 303 } 304 else 305 { 306 return null; 307 } 308 } 309 310 317 public String systemId() 318 { 319 if( entryType != SYSTEM ) 320 { 321 return null; 322 } 323 else 324 { 325 return spec1; 326 } 327 } 328 329 342 public void updateFormalSystemIdentifier( String newspec ) 343 { 344 if( entryType > SGMLDECL ) 345 { 346 spec2 = newspec; 347 } 348 else 349 { 350 spec1 = newspec; 351 } 352 } 353 } 354 | Popular Tags |