summaryrefslogtreecommitdiff
path: root/propertysheet/src/org/eclipse/wb/internal/core/nls/model/LocalePartInfo.java
blob: 92789796983b1e4eb475813434ac9805862a2a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*******************************************************************************
 * Copyright (c) 2011 Google, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Google, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.wb.internal.core.nls.model;

import org.eclipse.swt.graphics.Image;

/**
 * Information about part of Locale - language or country.
 * 
 * @author scheglov_ke
 * @coverage core.nls
 */
public final class LocalePartInfo implements Comparable<LocalePartInfo> {
  private final String m_name;
  private final String m_displayName;
  private final Image m_flagImage;

  ////////////////////////////////////////////////////////////////////////////
  //
  // Constructor
  //
  ////////////////////////////////////////////////////////////////////////////
  public LocalePartInfo(String name, String displayName, Image flagImage) {
    m_name = name;
    m_displayName = displayName;
    m_flagImage = flagImage;
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Access
  //
  ////////////////////////////////////////////////////////////////////////////
  public String getName() {
    return m_name;
  }

  public Image getFlagImage() {
    return m_flagImage;
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Object
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  public String toString() {
    if (m_name.length() == 0) {
      return m_displayName;
    }
    return m_name + " - " + m_displayName;
  }

  @Override
  public int hashCode() {
    return m_name.hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    return obj instanceof LocalePartInfo && m_name.equals(((LocalePartInfo) obj).m_name);
  }

  ////////////////////////////////////////////////////////////////////////////
  //
  // Comparable
  //
  ////////////////////////////////////////////////////////////////////////////
  public int compareTo(LocalePartInfo o) {
    return m_name.compareTo(o.m_name);
  }
}