|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| ExternalEntityDecl.java | 75% | 89,3% | 55,6% | 80% |
|
||||||||||||||
| 1 | /* | |
| 2 | * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. | |
| 3 | * | |
| 4 | * This software is open source. | |
| 5 | * See the bottom of this file for the licence. | |
| 6 | */ | |
| 7 | ||
| 8 | package org.dom4j.dtd; | |
| 9 | ||
| 10 | /** | |
| 11 | * <p> | |
| 12 | * <code>ExternalEntityDecl</code> represents an external entity declaration | |
| 13 | * in a DTD. | |
| 14 | * </p> | |
| 15 | * | |
| 16 | * @author <a href="mailto:james.strachan@metastuff.com">James Strachan </a> | |
| 17 | * @version $Revision: 1.9 $ | |
| 18 | */ | |
| 19 | public class ExternalEntityDecl { | |
| 20 | /** Holds value of property name. */ | |
| 21 | private String name; | |
| 22 | ||
| 23 | /** Holds value of property publicID. */ | |
| 24 | private String publicID; | |
| 25 | ||
| 26 | /** Holds value of property systemID. */ | |
| 27 | private String systemID; | |
| 28 | ||
| 29 | 0 | public ExternalEntityDecl() { |
| 30 | } | |
| 31 | ||
| 32 | 4 | public ExternalEntityDecl(String name, String publicID, String systemID) { |
| 33 | 4 | this.name = name; |
| 34 | 4 | this.publicID = publicID; |
| 35 | 4 | this.systemID = systemID; |
| 36 | } | |
| 37 | ||
| 38 | /** | |
| 39 | * Getter for property name. | |
| 40 | * | |
| 41 | * @return Value of property name. | |
| 42 | */ | |
| 43 | 2 | public String getName() { |
| 44 | 2 | return name; |
| 45 | } | |
| 46 | ||
| 47 | /** | |
| 48 | * Setter for property name. | |
| 49 | * | |
| 50 | * @param name | |
| 51 | * New value of property name. | |
| 52 | */ | |
| 53 | 0 | public void setName(String name) { |
| 54 | 0 | this.name = name; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * Getter for property publicID. | |
| 59 | * | |
| 60 | * @return Value of property publicID. | |
| 61 | */ | |
| 62 | 2 | public String getPublicID() { |
| 63 | 2 | return publicID; |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Setter for property publicID. | |
| 68 | * | |
| 69 | * @param publicID | |
| 70 | * New value of property publicID. | |
| 71 | */ | |
| 72 | 0 | public void setPublicID(String publicID) { |
| 73 | 0 | this.publicID = publicID; |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * Getter for property systemID. | |
| 78 | * | |
| 79 | * @return Value of property systemID. | |
| 80 | */ | |
| 81 | 2 | public String getSystemID() { |
| 82 | 2 | return systemID; |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * Setter for property systemID. | |
| 87 | * | |
| 88 | * @param systemID | |
| 89 | * New value of property systemID. | |
| 90 | */ | |
| 91 | 0 | public void setSystemID(String systemID) { |
| 92 | 0 | this.systemID = systemID; |
| 93 | } | |
| 94 | ||
| 95 | 4 | public String toString() { |
| 96 | 4 | StringBuffer buffer = new StringBuffer("<!ENTITY "); |
| 97 | ||
| 98 | 4 | if (name.startsWith("%")) { |
| 99 | 1 | buffer.append("% "); |
| 100 | 1 | buffer.append(name.substring(1)); |
| 101 | } else { | |
| 102 | 3 | buffer.append(name); |
| 103 | } | |
| 104 | ||
| 105 | 4 | if (publicID != null) { |
| 106 | 1 | buffer.append(" PUBLIC \""); |
| 107 | 1 | buffer.append(publicID); |
| 108 | 1 | buffer.append("\" "); |
| 109 | ||
| 110 | 1 | if (systemID != null) { |
| 111 | 1 | buffer.append("\""); |
| 112 | 1 | buffer.append(systemID); |
| 113 | 1 | buffer.append("\" "); |
| 114 | } | |
| 115 | 3 | } else if (systemID != null) { |
| 116 | 3 | buffer.append(" SYSTEM \""); |
| 117 | 3 | buffer.append(systemID); |
| 118 | 3 | buffer.append("\" "); |
| 119 | } | |
| 120 | ||
| 121 | 4 | buffer.append(">"); |
| 122 | ||
| 123 | 4 | return buffer.toString(); |
| 124 | } | |
| 125 | } | |
| 126 | ||
| 127 | /* | |
| 128 | * Redistribution and use of this software and associated documentation | |
| 129 | * ("Software"), with or without modification, are permitted provided that the | |
| 130 | * following conditions are met: | |
| 131 | * | |
| 132 | * 1. Redistributions of source code must retain copyright statements and | |
| 133 | * notices. Redistributions must also contain a copy of this document. | |
| 134 | * | |
| 135 | * 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 136 | * this list of conditions and the following disclaimer in the documentation | |
| 137 | * and/or other materials provided with the distribution. | |
| 138 | * | |
| 139 | * 3. The name "DOM4J" must not be used to endorse or promote products derived | |
| 140 | * from this Software without prior written permission of MetaStuff, Ltd. For | |
| 141 | * written permission, please contact dom4j-info@metastuff.com. | |
| 142 | * | |
| 143 | * 4. Products derived from this Software may not be called "DOM4J" nor may | |
| 144 | * "DOM4J" appear in their names without prior written permission of MetaStuff, | |
| 145 | * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd. | |
| 146 | * | |
| 147 | * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org | |
| 148 | * | |
| 149 | * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND | |
| 150 | * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 151 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 152 | * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE | |
| 153 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 154 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 155 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 156 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 157 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 158 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 159 | * POSSIBILITY OF SUCH DAMAGE. | |
| 160 | * | |
| 161 | * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. | |
| 162 | */ |
|
||||||||||