| 1 | |
package uk.ac.ebi.xchars.palette; |
| 2 | |
|
| 3 | |
import java.util.*; |
| 4 | |
import java.io.Serializable; |
| 5 | |
|
| 6 | |
import uk.ac.ebi.xchars.SpecialCharacters; |
| 7 | |
import uk.ac.ebi.xchars.domain.Formatting; |
| 8 | |
import uk.ac.ebi.xchars.domain.XCharsClass; |
| 9 | |
import uk.ac.ebi.xchars.domain.Definition; |
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | 0 | public class XCharsPaletteClass implements Comparable<XCharsPaletteClass>, Serializable { |
| 15 | |
|
| 16 | |
private static final long serialVersionUID = 5070637959615601577L; |
| 17 | |
|
| 18 | |
private String classType; |
| 19 | |
private String definition; |
| 20 | 0 | private List<XCharsPaletteElement> elements = new ArrayList<XCharsPaletteElement>(); |
| 21 | 0 | private List<String> examples = new ArrayList<String>(); |
| 22 | |
|
| 23 | |
|
| 24 | 0 | public XCharsPaletteClass (SpecialCharacters sc, XCharsClass xcharsclass) { |
| 25 | 0 | classType = xcharsclass.getName(); |
| 26 | 0 | Definition def = xcharsclass.getDefinition(); |
| 27 | 0 | if( def!=null ){ |
| 28 | 0 | definition = def.getContent(); |
| 29 | |
} |
| 30 | 0 | examples.addAll(xcharsclass.getDefinition().getExamples()); |
| 31 | |
|
| 32 | 0 | Map characterAndEncodings = xcharsclass.getCharacterAndEncodings(); |
| 33 | 0 | for ( Iterator it = characterAndEncodings.keySet().iterator(); it.hasNext(); ) { |
| 34 | 0 | String character = (String) it.next(); |
| 35 | 0 | Object object = characterAndEncodings.get(character); |
| 36 | 0 | Class charclass = object.getClass(); |
| 37 | 0 | if ( charclass.equals(uk.ac.ebi.xchars.domain.Character.class) ){ |
| 38 | 0 | uk.ac.ebi.xchars.domain.Character domaincharacter = (uk.ac.ebi.xchars.domain.Character)object; |
| 39 | 0 | elements.add(new XCharsPaletteElement(sc, classType, domaincharacter.getContent())); |
| 40 | 0 | } else { |
| 41 | 0 | Formatting formatting = (Formatting)object; |
| 42 | 0 | elements.add(new XCharsPaletteElement(sc, classType, formatting.getCharacter().getContent())); |
| 43 | |
} |
| 44 | 0 | } |
| 45 | |
|
| 46 | 0 | Collections.sort(elements); |
| 47 | 0 | } |
| 48 | |
|
| 49 | |
public List<String> getExamples () { |
| 50 | 0 | return examples; |
| 51 | |
} |
| 52 | |
|
| 53 | |
public String getClassType() { |
| 54 | 0 | return classType; |
| 55 | |
} |
| 56 | |
|
| 57 | |
public String getDefinition() { |
| 58 | 0 | return definition; |
| 59 | |
} |
| 60 | |
|
| 61 | |
public List<XCharsPaletteElement> getElements() { |
| 62 | 0 | return elements; |
| 63 | |
} |
| 64 | |
|
| 65 | |
public int compareTo(XCharsPaletteClass o) { |
| 66 | 0 | return this.classType.compareTo(o.getClassType()); |
| 67 | |
} |
| 68 | |
} |