1 /* 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package javax.xml.catalog; 26 27 import java.net.URL; 28 29 /** 30 * Represents a system entry. 31 * 32 * @since 9 33 */ 34 final class SystemEntry extends BaseEntry { 35 String systemId; 36 URL uri; 37 38 /** 39 * Construct a system entry. 40 * 41 * @param systemId The systemId attribute. 42 * @param uri The uri attribute. 43 */ 44 public SystemEntry(String base, String systemId, String uri) { 45 super(CatalogEntryType.SYSTEM, base); 46 setSystemId(systemId); 47 setURI(uri); 48 } 49 50 /** 51 * Set the systemId attribute. 52 * @param systemId The systemId attribute value. 53 */ 54 public void setSystemId(String systemId) { 55 CatalogMessages.reportNPEOnNull("systemId", systemId); 56 this.systemId = Normalizer.normalizeURI(systemId); 57 } 58 59 /** 60 * Set the uri attribute. If the value of the uri attribute is relative, it 61 * must be made absolute with respect to the base URI currently in effect. 62 * The URI reference should not include a fragment identifier. 63 * @param uri The uri attribute value. 64 */ 65 public void setURI(String uri) { 66 this.uri = verifyURI("setURI", baseURI, uri); 67 } 68 69 /** 70 * Get the systemId attribute. 71 * @return The systemId 72 */ 73 public String getSystemId() { 74 return systemId; 75 } 76 /** 77 * Get the uri attribute. 78 * @return The uri attribute value. 79 */ 80 public URL getURI() { 81 return uri; 82 } 83 84 /** 85 * Try to match the specified string with the entry 86 * 87 * @param systemId The systemId to be matched 88 * @return The replacement URI if the match is successful, null if not. 89 */ 90 @Override 91 public String match(String systemId) { 92 if (this.systemId.equals(systemId)) { 93 return uri.toString(); 94 } 95 return null; 96 } 97 }