1 17 18 19 20 package org.apache.fop.fonts; 21 22 import java.io.Serializable ; 23 24 27 public class FontTriplet implements Comparable , Serializable { 28 29 30 private static final long serialVersionUID = 1168991106658033508L; 31 32 private String name; 33 private String style; 34 private int weight; 35 36 private transient String key; 38 39 45 public FontTriplet(String name, String style, int weight) { 46 this.name = name; 47 this.style = style; 48 this.weight = weight; 49 } 50 51 52 public String getName() { 53 return name; 54 } 55 56 57 public String getStyle() { 58 return style; 59 } 60 61 62 public int getWeight() { 63 return weight; 64 } 65 66 private String getKey() { 67 if (this.key == null) { 68 this.key = getName() + "," + getStyle() + "," + getWeight(); 70 } 71 return this.key; 72 } 73 74 75 public int compareTo(Object o) { 76 return getKey().compareTo(((FontTriplet)o).getKey()); 77 } 78 79 80 public int hashCode() { 81 return toString().hashCode(); 82 } 83 84 85 public boolean equals(Object obj) { 86 if (obj == null) { 87 return false; 88 } else if (obj == this) { 89 return true; 90 } else { 91 if (obj instanceof FontTriplet) { 92 FontTriplet other = (FontTriplet)obj; 93 return (getName().equals(other.getName()) 94 && getStyle().equals(other.getStyle()) 95 && (getWeight() == other.getWeight())); 96 } 97 } 98 return false; 99 } 100 101 102 public String toString() { 103 return getKey(); 104 } 105 106 } 107 108 | Popular Tags |