1. /*
  2. * @(#)AttributeValue.java 1.4 00/02/02
  3. *
  4. * Copyright 1999, 2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.awt;
  11. import sun.awt.DebugHelper;
  12. abstract class AttributeValue {
  13. private final int value;
  14. private final String[] names;
  15. private static final DebugHelper dbg =
  16. DebugHelper.create(AttributeValue.class);
  17. protected AttributeValue(int value, String[] names) {
  18. if (dbg.on) {
  19. dbg.assert(value >= 0 && names != null && value < names.length);
  20. }
  21. this.value = value;
  22. this.names = names;
  23. }
  24. // This hashCode is used by the sun.awt implementation as an array
  25. // index.
  26. public int hashCode() {
  27. return value;
  28. }
  29. public String toString() {
  30. return names[value];
  31. }
  32. }