1. /*
  2. * Copyright 2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.sun.org.apache.xerces.internal.util;
  17. import com.sun.org.apache.xerces.internal.impl.XMLEntityDescription;
  18. /**
  19. * <p>This class is an implementation of the XMLEntityDescription
  20. * interface which describes the properties of an entity.</p>
  21. *
  22. * @author Michael Glavassevich, IBM
  23. *
  24. * @version $Id: XMLEntityDescriptionImpl.java,v 1.1.1.1 2004/05/04 10:22:35 vk112360 Exp $
  25. */
  26. public class XMLEntityDescriptionImpl
  27. extends XMLResourceIdentifierImpl
  28. implements XMLEntityDescription {
  29. //
  30. // Constructors
  31. //
  32. /** Constructs an empty entity description. */
  33. public XMLEntityDescriptionImpl() {} // <init>()
  34. /**
  35. * Constructs an entity description.
  36. *
  37. * @param entityName The name of the entity.
  38. * @param publicId The public identifier.
  39. * @param literalSystemId The literal system identifier.
  40. * @param baseSystemId The base system identifier.
  41. * @param expandedSystemId The expanded system identifier.
  42. */
  43. public XMLEntityDescriptionImpl(String entityName, String publicId, String literalSystemId,
  44. String baseSystemId, String expandedSystemId) {
  45. setDescription(entityName, publicId, literalSystemId, baseSystemId, expandedSystemId);
  46. } // <init>(String,String,String,String,String)
  47. /**
  48. * Constructs a resource identifier.
  49. *
  50. * @param entityName The name of the entity.
  51. * @param publicId The public identifier.
  52. * @param literalSystemId The literal system identifier.
  53. * @param baseSystemId The base system identifier.
  54. * @param expandedSystemId The expanded system identifier.
  55. * @param namespace The namespace.
  56. */
  57. public XMLEntityDescriptionImpl(String entityName, String publicId, String literalSystemId,
  58. String baseSystemId, String expandedSystemId, String namespace) {
  59. setDescription(entityName, publicId, literalSystemId, baseSystemId, expandedSystemId, namespace);
  60. } // <init>(String,String,String,String,String,String)
  61. //
  62. // Data
  63. //
  64. /** The name of the entity. */
  65. protected String fEntityName;
  66. //
  67. // Public methods
  68. //
  69. /**
  70. * Sets the name of the entity.
  71. *
  72. * @param name the name of the entity
  73. */
  74. public void setEntityName(String name) {
  75. fEntityName = name;
  76. } // setEntityName(String)
  77. /**
  78. * Returns the name of the entity.
  79. *
  80. * @return the name of the entity
  81. */
  82. public String getEntityName() {
  83. return fEntityName;
  84. } // getEntityName():String
  85. /**
  86. * <p>Sets the values of this entity description.</p>
  87. *
  88. * @param entityName The name of the entity.
  89. * @param publicId The public identifier.
  90. * @param literalSystemId The literal system identifier.
  91. * @param baseSystemId The base system identifier.
  92. * @param expandedSystemId The expanded system identifier.
  93. */
  94. public void setDescription(String entityName, String publicId, String literalSystemId,
  95. String baseSystemId, String expandedSystemId) {
  96. setDescription(entityName, publicId, literalSystemId, baseSystemId, expandedSystemId, null);
  97. } // setDescription(String,String,String,String,String)
  98. /**
  99. * <p>Sets the values of this entity description.</p>
  100. *
  101. * @param entityName The name of the entity.
  102. * @param publicId The public identifier.
  103. * @param literalSystemId The literal system identifier.
  104. * @param baseSystemId The base system identifier.
  105. * @param expandedSystemId The expanded system identifier.
  106. * @param namespace The namespace.
  107. */
  108. public void setDescription(String entityName, String publicId, String literalSystemId,
  109. String baseSystemId, String expandedSystemId, String namespace) {
  110. fEntityName = entityName;
  111. setValues(publicId, literalSystemId, baseSystemId, expandedSystemId, namespace);
  112. } // setDescription(String,String,String,String,String,String)
  113. /**
  114. * <p>Clears the values.</p>
  115. */
  116. public void clear() {
  117. super.clear();
  118. fEntityName = null;
  119. } // clear()
  120. //
  121. // Object methods
  122. //
  123. /** Returns a hash code for this object. */
  124. public int hashCode() {
  125. int code = super.hashCode();
  126. if (fEntityName != null) {
  127. code += fEntityName.hashCode();
  128. }
  129. return code;
  130. } // hashCode():int
  131. /** Returns a string representation of this object. */
  132. public String toString() {
  133. StringBuffer str = new StringBuffer();
  134. if (fEntityName != null) {
  135. str.append(fEntityName);
  136. }
  137. str.append(':');
  138. if (fPublicId != null) {
  139. str.append(fPublicId);
  140. }
  141. str.append(':');
  142. if (fLiteralSystemId != null) {
  143. str.append(fLiteralSystemId);
  144. }
  145. str.append(':');
  146. if (fBaseSystemId != null) {
  147. str.append(fBaseSystemId);
  148. }
  149. str.append(':');
  150. if (fExpandedSystemId != null) {
  151. str.append(fExpandedSystemId);
  152. }
  153. str.append(':');
  154. if (fNamespace != null) {
  155. str.append(fNamespace);
  156. }
  157. return str.toString();
  158. } // toString():String
  159. } // XMLEntityDescriptionImpl