1. /*
  2. * Copyright 2001-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. /*
  17. * $Id: QName.java,v 1.6 2004/02/16 22:24:29 minchau Exp $
  18. */
  19. package com.sun.org.apache.xalan.internal.xsltc.compiler;
  20. /**
  21. * @author Jacek Ambroziak
  22. * @author Santiago Pericas-Geertsen
  23. * @author Morten Jorgensen
  24. */
  25. final class QName {
  26. private final String _localname;
  27. private String _prefix;
  28. private String _namespace;
  29. private String _stringRep;
  30. private int _hashCode;
  31. public QName(String namespace, String prefix, String localname) {
  32. _namespace = namespace;
  33. _prefix = prefix;
  34. _localname = localname;
  35. _stringRep =
  36. (namespace != null && !namespace.equals(Constants.EMPTYSTRING)) ?
  37. (namespace + ':' + localname) : localname;
  38. _hashCode = _stringRep.hashCode() + 19; // cached for speed
  39. }
  40. public void clearNamespace() {
  41. _namespace = Constants.EMPTYSTRING;
  42. }
  43. public String toString() {
  44. return _stringRep;
  45. }
  46. public String getStringRep() {
  47. return _stringRep;
  48. }
  49. public boolean equals(Object other) {
  50. return (this == other);
  51. }
  52. public String getLocalPart() {
  53. return _localname;
  54. }
  55. public String getNamespace() {
  56. return _namespace;
  57. }
  58. public String getPrefix() {
  59. return _prefix;
  60. }
  61. public int hashCode() {
  62. return _hashCode;
  63. }
  64. public String dump() {
  65. return new String("QName: " + _namespace + "(" + _prefix + "):"
  66. + _localname);
  67. }
  68. }