1 package org.andromda.schema2xmi;
2
3 import org.apache.commons.lang.StringUtils;
4
5 /**
6 * Contains utilities for the Schema2XMI tool.
7 *
8 * @author Chad Brandon
9 * @author Joel Kozikowski
10 */
11 class Schema2XMIUtils
12 {
13 /**
14 * Constructs the entire type name from the
15 * given name and length.
16 *
17 * @param name the name of the type
18 * @param length the length of the type.
19 * @param decimalPlaces the number of decimal places specified for the type
20 * @return the type name with the length.
21 */
22 static String constructTypeName(
23 final String name,
24 final String length,
25 final String decimalPlaces)
26 {
27 final StringBuilder buffer = new StringBuilder();
28 if (name != null)
29 {
30 buffer.append(name);
31
32 if (!name.matches(".+\\(.+\\)"))
33 {
34 if (StringUtils.isNotBlank(length))
35 {
36 buffer.append('(').append(length);
37 if (StringUtils.isNotBlank(decimalPlaces))
38 {
39 buffer.append(',').append(decimalPlaces);
40 }
41 buffer.append(')');
42 }
43 }
44
45 }
46 return buffer.toString();
47 }
48 }