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