1 19 package org.netbeans.modules.xml.catalog; 20 21 import org.xml.sax.*; 22 23 import org.netbeans.modules.xml.catalog.spi.CatalogReader; 24 25 32 public final class CatalogEntry extends Object { 33 34 private final String publicID; 35 private final CatalogReader catalog; 36 37 38 public CatalogEntry(String publicID, CatalogReader catalog) { 39 this.publicID = publicID; 40 this.catalog = catalog; 41 } 42 43 CatalogReader getCatalog() { 44 return catalog; 45 } 46 47 50 public String getSystemID() { 51 String sid = catalog.getSystemID(publicID); 52 if (sid == null) { 53 if (catalog instanceof EntityResolver) { 54 try { 55 InputSource in = ((EntityResolver) catalog).resolveEntity(publicID, null); 56 if (in != null) { 57 sid = in.getSystemId(); 58 } 59 } catch (Exception ex) { 60 } 62 } 63 } 64 65 String patchedSystemId = sid; 67 if (patchedSystemId != null) { 68 patchedSystemId = patchedSystemId.replaceAll("\\+", "%20"); patchedSystemId = patchedSystemId.replaceAll("\\ ", "%20"); return patchedSystemId; 71 } 72 73 return null; 74 } 75 76 public String getPublicID() { 77 return publicID; 78 } 79 80 public String getPublicIDValue() { 81 String id = getPublicID(); 82 if (id.startsWith("PUBLIC:")) return id.substring(7); if (id.startsWith("URI:")) return id.substring(4); if (id.startsWith("SYSTEM:")) return ""; if (id.startsWith("SCHEMA:")) return ""; return id; 87 } 88 89 public String getSystemIDValue() { 90 String id = getPublicID(); 91 if (id.startsWith("SYSTEM:")) return id.substring(7); if (id.startsWith("SCHEMA:")) return id.substring(7); return ""; 94 } 95 96 public String getUriValue() { 97 return getSystemID(); 98 } 99 100 public String getName() { 101 String id = getPublicID(); 102 if (id.startsWith("PUBLIC:")) return Util.THIS.getString("TXT_publicEntry",id.substring(7)); if (id.startsWith("SYSTEM:")) return Util.THIS.getString("TXT_systemEntry",id.substring(7)); if (id.startsWith("URI:")) return Util.THIS.getString("TXT_publicEntry",id.substring(4)); if (id.startsWith("SCHEMA:")) return Util.THIS.getString("TXT_systemEntry",id.substring(7)); return Util.THIS.getString("TXT_publicEntry",id); 107 } 108 109 public String toString() { 110 return publicID + " => " + getSystemID(); } 112 } 113 | Popular Tags |