]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_4_2-src/tools/misc/src/com/ibm/icu/dev/tool/layout/TagUtilities.java
go
[Dictionary.git] / jars / icu4j-4_4_2-src / tools / misc / src / com / ibm / icu / dev / tool / layout / TagUtilities.java
1 /*\r
2  *******************************************************************************\r
3  * Copyright (C) 1998-2004, International Business Machines Corporation and    *\r
4  * others. All Rights Reserved.                                                *\r
5  *******************************************************************************\r
6  *\r
7  * Created on Apr 14, 2003\r
8  *\r
9  *******************************************************************************\r
10  */\r
11 package com.ibm.icu.dev.tool.layout;\r
12 \r
13 import com.ibm.icu.impl.Utility;\r
14 \r
15 /**\r
16  *  This class contains utility methods for dealing with\r
17  * four-letter tags.\r
18  * \r
19  * @author emader\r
20  *\r
21  */\r
22 public class TagUtilities\r
23 {\r
24     public static String makeTag(String tag)\r
25     {\r
26         if (tag == null || tag.length() == 0) {\r
27             return "0x00000000";\r
28         }\r
29         \r
30         int tagValue = 0;\r
31         \r
32         for (int i = 0; i < 4; i += 1) {\r
33             tagValue <<= 8;\r
34             tagValue += (int) ((i < tag.length()? tag.charAt(i) : ' ') & 0xFF);\r
35         }\r
36         \r
37         return "0x" + Utility.hex(tagValue, 8);\r
38     }\r
39     \r
40 //    public static String makeTagOld(String tag)\r
41 //    {\r
42 //        if (tag == null || tag.length() == 0) {\r
43 //            return "0x00000000";\r
44 //        }\r
45 //        \r
46 //        StringBuffer result = new StringBuffer("LE_MAKE_TAG(");\r
47 //        \r
48 //        for (int i = 0; i < 4; i += 1) {\r
49 //            if (i > 0) {\r
50 //                result.append(", ");\r
51 //            }\r
52 //            \r
53 //            result.append('\'');\r
54 //            result.append(i < tag.length()? tag.charAt(i) : ' ');\r
55 //            result.append('\'');\r
56 //        }\r
57 //        \r
58 //        result.append(")");\r
59 //        \r
60 //        return result.toString(); \r
61 //    }\r
62     \r
63     public static String tagLabel(String tag)\r
64     {\r
65         if (tag == null || tag.length() == 0) {\r
66             return "null";\r
67         } else {\r
68             return tag.toLowerCase();\r
69         }\r
70     }\r
71         \r
72 }\r
73 \r