BrightSide Workbench Full Report + Source Code
org.turro.elephant.impl.util.Localizer Class Reference
Collaboration diagram for org.turro.elephant.impl.util.Localizer:

Public Member Functions

 Localizer (IConstructor constructor)
 
String parseString (String type, String inFormat, String outFormat, String value)
 
Object parseString (String type, String inFormat, String value)
 
String parseValue (String type, String outFormat, Object value)
 

Protected Attributes

IConstructor constructor
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 31 of file Localizer.java.

Constructor & Destructor Documentation

◆ Localizer()

org.turro.elephant.impl.util.Localizer.Localizer ( IConstructor  constructor)

Creates a new instance of Localizer

Definition at line 35 of file Localizer.java.

35  {
36  this.constructor = constructor;
37  }

Member Function Documentation

◆ parseString() [1/2]

String org.turro.elephant.impl.util.Localizer.parseString ( String  type,
String  inFormat,
String  outFormat,
String  value 
)

Definition at line 39 of file Localizer.java.

43  {
44  try {
45  String format = I_.compatibility().get("fmt." + inFormat);
46  if(format == null) format = inFormat;
47  if("date".equals(type)) {
48  SimpleDateFormat sdfi = new SimpleDateFormat(
49  (format == null ? ObjectString.DEFAULT_DATE : format)
50  );
51  return parseValue(type, outFormat, sdfi.parse(value));
52  }
53  else if("number".equals(type)) {
54  Number number = (Number)ObjectString.parseNativeString(value, Double.class, true);
55  return parseValue(type, outFormat, number);
56  }
57  else if("bytes".equals(type)) {
58  Long bytes = (Long)ObjectString.parseNativeString(value, Long.class, true);
59  return parseValue(type, outFormat, bytes);
60  }
61  else
62  return value;
63  } catch(Exception ex) {
64  return "";
65  }
66  }
String parseValue(String type, String outFormat, Object value)
Definition: Localizer.java:96
Here is the call graph for this function:

◆ parseString() [2/2]

Object org.turro.elephant.impl.util.Localizer.parseString ( String  type,
String  inFormat,
String  value 
)

Definition at line 68 of file Localizer.java.

71  {
72  try {
73  String format = I_.compatibility().get("fmt." + inFormat);
74  if(format == null) format = inFormat;
75  if("date".equals(type)) {
76  SimpleDateFormat sdfi = new SimpleDateFormat(
77  (format == null ? ObjectString.DEFAULT_DATE : format)
78  );
79  return sdfi.parse(value);
80  }
81  else if("number".equals(type)) {
82  Number number = (Number)ObjectString.parseNativeString(value, Double.class, true);
83  return number;
84  }
85  else if("bytes".equals(type)) {
86  Long bytes = (Long)ObjectString.parseNativeString(value, Long.class, true);
87  return bytes;
88  }
89  else
90  return value;
91  } catch(Exception ex) {
92  return null;
93  }
94  }
Here is the call graph for this function:

◆ parseValue()

String org.turro.elephant.impl.util.Localizer.parseValue ( String  type,
String  outFormat,
Object  value 
)

Definition at line 96 of file Localizer.java.

99  {
100  try {
101  if("date".equals(type)) {
102  outFormat = I_.compatibility().get("fmt." + outFormat);
103  SimpleDateFormat sdfo = new SimpleDateFormat(
104  (outFormat == null ? ObjectString.DATE_PATTERN : outFormat),
105  new java.util.Locale(I_.compatibility().get("fmt.locale"))
106  );
107  return sdfo.format(value);
108  }
109  else if("number".equals(type)) {
110  outFormat = I_.compatibility().get("fmt." + outFormat);
111  NumberFormat dfo = NumberFormat.getInstance(
112  new java.util.Locale(I_.compatibility().get("fmt.locale"))
113  );
114  if(dfo instanceof DecimalFormat) {
115  ((DecimalFormat)dfo).applyPattern(
116  (outFormat == null ? ObjectString.DEFAULT_NUMBER : outFormat)
117  );
118  }
119  return dfo.format(value);
120  }
121  else if("bytes".equals(type)) {
122  return new org.turro.formatter.BytesFormatter(((Long)value).longValue()).toString();
123  }
124  else
125  return value.toString();
126  } catch(Exception ex) {
127  return "";
128  }
129  }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ constructor

IConstructor org.turro.elephant.impl.util.Localizer.constructor
protected

Definition at line 32 of file Localizer.java.


The documentation for this class was generated from the following file: