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