jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java
changeset 33542 9f0eef87e8c1
child 38497 06b1977d0f4f
equal deleted inserted replaced
33390:d131f4b8433a 33542:9f0eef87e8c1
       
     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 an uriEntry entry.
       
    31  *
       
    32  * @since 9
       
    33  */
       
    34 final class UriEntry extends BaseEntry {
       
    35     String name;
       
    36     URL uri;
       
    37 
       
    38     /**
       
    39      * Construct a group entry.
       
    40      * @param name The name attribute.
       
    41      * @param uri The uri attribute.
       
    42      */
       
    43     public UriEntry(String base, String name, String uri) {
       
    44         super(CatalogEntryType.URI, base);
       
    45         setName(name);
       
    46         setURI(uri);
       
    47     }
       
    48 
       
    49     /**
       
    50      * Set the name attribute.
       
    51      * @param name The name attribute value.
       
    52      */
       
    53     public void setName(String name) {
       
    54         CatalogMessages.reportNPEOnNull("name", name);
       
    55         this.name = Normalizer.normalizeURI(name);
       
    56     }
       
    57 
       
    58     /**
       
    59      * Set the uri attribute. If the value of the uri attribute is relative, it
       
    60      * must be made absolute with respect to the base URI currently in effect.
       
    61      *
       
    62      * @param uri The uri attribute value.
       
    63      */
       
    64     public void setURI(String uri) {
       
    65         this.uri = verifyURI("setURI", baseURI, uri);
       
    66     }
       
    67 
       
    68     /**
       
    69      * Get the name attribute.
       
    70      * @return The name
       
    71      */
       
    72     public String getName() {
       
    73         return name;
       
    74     }
       
    75     /**
       
    76      * Get the uri attribute.
       
    77      * @return The uri attribute value.
       
    78      */
       
    79     public URL getURI() {
       
    80         return uri;
       
    81     }
       
    82 
       
    83     @Override
       
    84     public String match(String name) {
       
    85         if (this.name.equals(name)) {
       
    86             return uri.toString();
       
    87         }
       
    88         return null;
       
    89     }
       
    90 }