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